sub/lavc_conv: take sd context as a parameter for lavc_conv_create

Will be useful for future commits.
This commit is contained in:
Kacper Michajłow 2024-03-23 09:43:30 +01:00
parent 1586ccc0c8
commit 73779a8c70
3 changed files with 6 additions and 8 deletions

View File

@ -66,13 +66,12 @@ static void disable_styles(bstr header)
}
}
struct lavc_conv *lavc_conv_create(struct mp_log *log,
const struct mp_codec_params *mp_codec)
struct lavc_conv *lavc_conv_create(struct sd *sd)
{
struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv);
priv->log = log;
priv->log = sd->log;
priv->cur_list = talloc_array(priv, char*, 0);
priv->codec = talloc_strdup(priv, mp_codec->codec);
priv->codec = talloc_strdup(priv, sd->codec->codec);
AVCodecContext *avctx = NULL;
AVDictionary *opts = NULL;
const char *fmt = get_lavc_format(priv->codec);
@ -82,7 +81,7 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log,
avctx = avcodec_alloc_context3(codec);
if (!avctx)
goto error;
if (mp_set_avctx_codec_headers(avctx, mp_codec) < 0)
if (mp_set_avctx_codec_headers(avctx, sd->codec) < 0)
goto error;
priv->avpkt = av_packet_alloc();

View File

@ -51,8 +51,7 @@ struct sd_functions {
// lavc_conv.c
struct lavc_conv;
struct lavc_conv *lavc_conv_create(struct mp_log *log,
const struct mp_codec_params *mp_codec);
struct lavc_conv *lavc_conv_create(struct sd *sd);
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);

View File

@ -271,7 +271,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);
ctx->converter = lavc_conv_create(sd);
if (!ctx->converter)
return -1;