diff options
author | Aman Gupta <aman@tmm1.net> | 2017-06-05 16:22:58 -0400 |
---|---|---|
committer | Matthieu Bouron <matthieu.bouron@gmail.com> | 2017-06-08 19:16:09 +0200 |
commit | a32a6b4201dca46c54247194bd5249dfb7c64874 (patch) | |
tree | 15d3c387279dd0ca509fb87c083086c19ca0b335 /libavcodec/mediacodecdec.c | |
parent | a3b5b60bdf451faefeeec07c4e684a251968bf2d (diff) | |
download | ffmpeg-a32a6b4201dca46c54247194bd5249dfb7c64874.tar.gz |
lavc: add mpeg2 mediacodec decoder
Android TV and FireOS hardware supports mpeg2 hardware decoding via
MediaCodec.
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Diffstat (limited to 'libavcodec/mediacodecdec.c')
-rw-r--r-- | libavcodec/mediacodecdec.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index ccfcb4b9ce..5bdeb6c1d7 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -1,5 +1,5 @@ /* - * 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", |