Commit a32a6b42 authored by Aman Gupta's avatar Aman Gupta Committed by Matthieu Bouron

lavc: add mpeg2 mediacodec decoder

Android TV and FireOS hardware supports mpeg2 hardware decoding via
MediaCodec.
Signed-off-by: 's avatarMatthieu Bouron <matthieu.bouron@gmail.com>
parent a3b5b60b
......@@ -2656,6 +2656,7 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va"
mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
mpeg2_dxva2_hwaccel_deps="dxva2"
mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
mpeg2_mediacodec_hwaccel_deps="mediacodec"
mpeg2_mmal_hwaccel_deps="mmal"
mpeg2_qsv_hwaccel_deps="libmfx"
mpeg2_qsv_hwaccel_select="qsvdec_mpeg2"
......@@ -2762,6 +2763,7 @@ mpeg1_vdpau_decoder_select="mpeg1video_decoder"
mpeg2_crystalhd_decoder_select="crystalhd"
mpeg2_cuvid_decoder_deps="cuda cuvid"
mpeg2_mmal_decoder_deps="mmal"
mpeg2_mediacodec_decoder_deps="mediacodec"
mpeg2_qsv_decoder_deps="libmfx"
mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel"
mpeg2_qsv_encoder_deps="libmfx"
......
......@@ -423,6 +423,7 @@ OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec_other.o
OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o
OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
......
......@@ -96,6 +96,7 @@ static void register_all(void)
REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau);
REGISTER_HWACCEL(MPEG2_VIDEOTOOLBOX, mpeg2_videotoolbox);
REGISTER_HWACCEL(MPEG2_MEDIACODEC, mpeg2_mediacodec);
REGISTER_HWACCEL(MPEG4_CUVID, mpeg4_cuvid);
REGISTER_HWACCEL(MPEG4_MEDIACODEC, mpeg4_mediacodec);
REGISTER_HWACCEL(MPEG4_MMAL, mpeg4_mmal);
......@@ -257,6 +258,7 @@ static void register_all(void)
REGISTER_DECODER(MPEG2_MMAL, mpeg2_mmal);
REGISTER_DECODER(MPEG2_CRYSTALHD, mpeg2_crystalhd);
REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
REGISTER_DECODER(MPEG2_MEDIACODEC, mpeg2_mediacodec);
REGISTER_DECODER(MSA1, msa1);
REGISTER_DECODER(MSCC, mscc);
REGISTER_DECODER(MSMPEG4V1, msmpeg4v1);
......
/*
* Android MediaCodec H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
* Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
*
* Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
*
......@@ -267,6 +267,19 @@ done:
}
#endif
#if CONFIG_MPEG2_MEDIACODEC_DECODER
static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
{
int ret = 0;
if (avctx->extradata) {
ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
}
return ret;
}
#endif
#if CONFIG_MPEG4_MEDIACODEC_DECODER
static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
{
......@@ -333,6 +346,15 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
goto done;
break;
#endif
#if CONFIG_MPEG2_MEDIACODEC_DECODER
case AV_CODEC_ID_MPEG2VIDEO:
codec_mime = "video/mpeg2";
ret = mpeg2_set_extradata(avctx, format);
if (ret < 0)
goto done;
break;
#endif
#if CONFIG_MPEG4_MEDIACODEC_DECODER
case AV_CODEC_ID_MPEG4:
codec_mime = "video/mp4v-es",
......@@ -575,6 +597,22 @@ AVCodec ff_hevc_mediacodec_decoder = {
};
#endif
#if CONFIG_MPEG2_MEDIACODEC_DECODER
AVCodec ff_mpeg2_mediacodec_decoder = {
.name = "mpeg2_mediacodec",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MPEG2VIDEO,
.priv_data_size = sizeof(MediaCodecH264DecContext),
.init = mediacodec_decode_init,
.decode = mediacodec_decode_frame,
.flush = mediacodec_decode_flush,
.close = mediacodec_decode_close,
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING,
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
};
#endif
#if CONFIG_MPEG4_MEDIACODEC_DECODER
AVCodec ff_mpeg4_mediacodec_decoder = {
.name = "mpeg4_mediacodec",
......
......@@ -766,6 +766,13 @@ AVHWAccel ff_hevc_mediacodec_hwaccel = {
.pix_fmt = AV_PIX_FMT_MEDIACODEC,
};
AVHWAccel ff_mpeg2_mediacodec_hwaccel = {
.name = "mediacodec",
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MPEG2VIDEO,
.pix_fmt = AV_PIX_FMT_MEDIACODEC,
};
AVHWAccel ff_mpeg4_mediacodec_hwaccel = {
.name = "mediacodec",
.type = AVMEDIA_TYPE_VIDEO,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment