ad_spdif: set codec params

It seems that we decode small portion of the audio to determine codec
params. We can remember that information.

Fixes: #14178
This commit is contained in:
Kacper Michajłow 2024-05-20 16:33:21 +02:00
parent 7b77672794
commit 6eb0f4b27f
1 changed files with 9 additions and 0 deletions

View File

@ -45,6 +45,7 @@
struct spdifContext {
struct mp_log *log;
struct mp_codec_params *codec;
enum AVCodecID codec_id;
AVFormatContext *lavf_ctx;
AVPacket *avpkt;
@ -151,6 +152,13 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
*out_profile = profile = ctx->profile;
*out_rate = ctx->sample_rate;
struct mp_codec_params *c = spdif_ctx->codec;
c->codec_profile = av_get_profile_name(ctx->codec, ctx->profile);
if (!c->codec_profile)
c->codec_profile = avcodec_profile_name(ctx->codec_id, ctx->profile);
c->codec = ctx->codec_descriptor->name;
c->codec_desc = ctx->codec_descriptor->long_name;
done:
av_frame_free(&frame);
avcodec_free_context(&ctx);
@ -432,6 +440,7 @@ static struct mp_decoder *create(struct mp_filter *parent,
struct spdifContext *spdif_ctx = da->priv;
spdif_ctx->log = da->log;
spdif_ctx->codec = codec;
spdif_ctx->pool = mp_aframe_pool_create(spdif_ctx);
spdif_ctx->public.f = da;