Commit af167d97 authored by Matthieu Bouron's avatar Matthieu Bouron

avcodec/mediacodecdec: factorize common extradata functions

parent 535e0202
...@@ -264,34 +264,11 @@ done: ...@@ -264,34 +264,11 @@ done:
} }
#endif #endif
#if CONFIG_MPEG2_MEDIACODEC_DECODER #if CONFIG_MPEG2_MEDIACODEC_DECODER || \
static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format) CONFIG_MPEG4_MEDIACODEC_DECODER || \
{ CONFIG_VP8_MEDIACODEC_DECODER || \
int ret = 0; CONFIG_VP9_MEDIACODEC_DECODER
static int common_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
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)
{
int ret = 0;
if (avctx->extradata) {
ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
}
return ret;
}
#endif
#if CONFIG_VP8_MEDIACODEC_DECODER || CONFIG_VP9_MEDIACODEC_DECODER
static int vpx_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
{ {
int ret = 0; int ret = 0;
...@@ -342,7 +319,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx) ...@@ -342,7 +319,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
codec_mime = "video/mpeg2"; codec_mime = "video/mpeg2";
ret = mpeg2_set_extradata(avctx, format); ret = common_set_extradata(avctx, format);
if (ret < 0) if (ret < 0)
goto done; goto done;
break; break;
...@@ -351,7 +328,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx) ...@@ -351,7 +328,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
case AV_CODEC_ID_MPEG4: case AV_CODEC_ID_MPEG4:
codec_mime = "video/mp4v-es", codec_mime = "video/mp4v-es",
ret = mpeg4_set_extradata(avctx, format); ret = common_set_extradata(avctx, format);
if (ret < 0) if (ret < 0)
goto done; goto done;
break; break;
...@@ -360,7 +337,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx) ...@@ -360,7 +337,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
case AV_CODEC_ID_VP8: case AV_CODEC_ID_VP8:
codec_mime = "video/x-vnd.on2.vp8"; codec_mime = "video/x-vnd.on2.vp8";
ret = vpx_set_extradata(avctx, format); ret = common_set_extradata(avctx, format);
if (ret < 0) if (ret < 0)
goto done; goto done;
break; break;
...@@ -369,7 +346,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx) ...@@ -369,7 +346,7 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
case AV_CODEC_ID_VP9: case AV_CODEC_ID_VP9:
codec_mime = "video/x-vnd.on2.vp9"; codec_mime = "video/x-vnd.on2.vp9";
ret = vpx_set_extradata(avctx, format); ret = common_set_extradata(avctx, format);
if (ret < 0) if (ret < 0)
goto done; goto done;
break; break;
......
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