summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2023-02-20 23:11:47 +0200
committerJan Ekström <jeebjp@gmail.com>2023-03-14 23:59:47 +0200
commite20b6456110e3f30417764b69f28dd3798d1ca9a (patch)
treee198a2b5aff39c581a32efe2ee0ae096467e9acb
parentef7b711bede143615b9ecd04f8df1d4b780cd7bc (diff)
downloadmpv-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.
-rw-r--r--sub/lavc_conv.c11
-rw-r--r--sub/sd.h4
-rw-r--r--sub/sd_ass.c4
3 files changed, 9 insertions, 10 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;
diff --git a/sub/sd.h b/sub/sd.h
index 6801a383b7..87270c6c4f 100644
--- a/sub/sd.h
+++ b/sub/sd.h
@@ -46,8 +46,8 @@ struct sd_functions {
// lavc_conv.c
struct lavc_conv;
-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);
char *lavc_conv_get_extradata(struct lavc_conv *priv);
char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet,
double *sub_pts, double *sub_duration);
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 0ea696eeab..34dc567e54 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -261,9 +261,7 @@ static int init(struct sd *sd)
strcmp(sd->codec->codec, "null") != 0)
{
ctx->is_converted = true;
- ctx->converter = lavc_conv_create(sd->log, sd->codec->codec,
- sd->codec->extradata,
- sd->codec->extradata_size);
+ ctx->converter = lavc_conv_create(sd->log, sd->codec);
if (!ctx->converter)
return -1;