ad_{lavc,spdif}: initialize channel layout

It is not always available for the demuxer, so update it from decoder.
This commit is contained in:
Kacper Michajłow 2024-06-08 23:17:53 +02:00
parent f7ed8c42d2
commit cd1b63f628
2 changed files with 5 additions and 1 deletions

View File

@ -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;
}

View File

@ -25,6 +25,7 @@
#include <libavutil/opt.h>
#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);