diff options
author | Jan Ekström <jeebjp@gmail.com> | 2023-02-20 23:11:47 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2023-03-14 23:59:47 +0200 |
commit | e20b6456110e3f30417764b69f28dd3798d1ca9a (patch) | |
tree | e198a2b5aff39c581a32efe2ee0ae096467e9acb /sub/lavc_conv.c | |
parent | ef7b711bede143615b9ecd04f8df1d4b780cd7bc (diff) | |
download | mpv-e20b6456110e3f30417764b69f28dd3798d1ca9a.tar.bz2 mpv-e20b6456110e3f30417764b69f28dd3798d1ca9a.tar.xz |
sub/lavc_conv: properly fill avctx with codecpar values at init
This way we receive such minor details as the profile (necessary for
ARIB captions, among others) during init. This enables decoders
to switch between ARIB caption profile A and profile C streams.
Diffstat (limited to 'sub/lavc_conv.c')
-rw-r--r-- | sub/lavc_conv.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c index 2a7347bee8..532e91d508 100644 --- a/sub/lavc_conv.c +++ b/sub/lavc_conv.c @@ -26,6 +26,7 @@ #include "mpv_talloc.h" #include "common/msg.h" #include "common/av_common.h" +#include "demux/stheader.h" #include "misc/bstr.h" #include "sd.h" @@ -65,13 +66,13 @@ static void disable_styles(bstr header) } } -struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name, - char *extradata, int extradata_len) +struct lavc_conv *lavc_conv_create(struct mp_log *log, + const struct mp_codec_params *mp_codec) { struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv); priv->log = log; priv->cur_list = talloc_array(priv, char*, 0); - priv->codec = talloc_strdup(priv, codec_name); + priv->codec = talloc_strdup(priv, mp_codec->codec); AVCodecContext *avctx = NULL; AVDictionary *opts = NULL; const char *fmt = get_lavc_format(priv->codec); @@ -81,7 +82,7 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name, avctx = avcodec_alloc_context3(codec); if (!avctx) goto error; - if (mp_lavc_set_extradata(avctx, extradata, extradata_len) < 0) + if (mp_set_avctx_codec_headers(avctx, mp_codec) < 0) goto error; priv->avpkt = av_packet_alloc(); @@ -93,7 +94,7 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name, av_dict_set(&opts, "sub_text_format", "ass", 0); #endif av_dict_set(&opts, "flags2", "+ass_ro_flush_noop", 0); - if (strcmp(codec_name, "eia_608") == 0) + if (strcmp(priv->codec, "eia_608") == 0) av_dict_set(&opts, "real_time", "1", 0); if (avcodec_open2(avctx, codec, &opts) < 0) goto error; |