summaryrefslogtreecommitdiffstats
path: root/common/av_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/av_common.c')
-rw-r--r--common/av_common.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/av_common.c b/common/av_common.c
index e8a0e76ed2..aa1a1bfdf2 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -112,11 +112,19 @@ error:
// Set avctx codec headers for decoding. Returns <0 on failure.
int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c)
{
+ enum AVMediaType codec_type = avctx->codec_type;
+ enum AVCodecID codec_id = avctx->codec_id;
AVCodecParameters *avp = mp_codec_params_to_av(c);
if (!avp)
return -1;
+
int r = avcodec_parameters_to_context(avctx, avp) < 0 ? -1 : 0;
avcodec_parameters_free(&avp);
+
+ if (avctx->codec_type != AVMEDIA_TYPE_UNKNOWN)
+ avctx->codec_type = codec_type;
+ if (avctx->codec_id != AV_CODEC_ID_NONE)
+ avctx->codec_id = codec_id;
return r;
}