From cd1b63f628a99d16183961056bb8177511a85888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 8 Jun 2024 23:17:53 +0200 Subject: [PATCH] ad_{lavc,spdif}: initialize channel layout It is not always available for the demuxer, so update it from decoder. --- audio/decode/ad_lavc.c | 2 ++ audio/decode/ad_spdif.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 8bab80901b..9eb308528d 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -215,6 +215,7 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out) return ret; mp_codec_info_from_av(avctx, priv->codec); + mp_chmap_from_av_layout(&priv->codec->channels, &avctx->ch_layout); double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase); @@ -311,6 +312,7 @@ static struct mp_decoder *create(struct mp_filter *parent, } codec->codec_desc = priv->avctx->codec_descriptor->long_name; + mp_chmap_from_av_layout(&priv->codec->channels, &priv->avctx->ch_layout); return &priv->public; } diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index c517cee8a8..6d9ce5e928 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -25,6 +25,7 @@ #include #include "audio/aframe.h" +#include "audio/chmap_avchannel.h" #include "audio/format.h" #include "common/av_common.h" #include "common/codecs.h" @@ -122,7 +123,7 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, av_parser_close(parser); } - if (profile != AV_PROFILE_UNKNOWN || spdif_ctx->codec_id == AV_CODEC_ID_AC3) + if (profile != AV_PROFILE_UNKNOWN) return; const AVCodec *codec = avcodec_find_decoder(spdif_ctx->codec_id); @@ -154,6 +155,7 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, 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; + mp_chmap_from_av_layout(&c->channels, &ctx->ch_layout); done: av_frame_free(&frame);