[FFmpeg-devel] [PATCH 2/9] avformat/iamf_parse: try to retype the channel layout for ambisonics_mode == 0
James Almer
jamrial at gmail.com
Wed Jun 18 04:38:57 EEST 2025
In most cases, the channel ids will match the standard Ambisonic Order, saving us the
need to use a custom order layout.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/iamf_parse.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 71497876ac..f37edf5156 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -458,14 +458,16 @@ static int ambisonics_config(void *s, AVIOContext *pb,
return ret;
}
- layer->ch_layout.order = AV_CHANNEL_ORDER_CUSTOM;
- layer->ch_layout.nb_channels = output_channel_count;
- layer->ch_layout.u.map = av_calloc(output_channel_count, sizeof(*layer->ch_layout.u.map));
- if (!layer->ch_layout.u.map)
- return AVERROR(ENOMEM);
+ ret = av_channel_layout_custom_init(&layer->ch_layout, output_channel_count);
+ if (ret < 0)
+ return ret;
for (int i = 0; i < output_channel_count; i++)
layer->ch_layout.u.map[i].id = avio_r8(pb) + AV_CHAN_AMBISONIC_BASE;
+
+ ret = av_channel_layout_retype(&layer->ch_layout, AV_CHANNEL_ORDER_AMBISONIC, 0);
+ if (ret < 0 && ret != AVERROR(ENOSYS))
+ return ret;
} else {
int coupled_substream_count = avio_r8(pb); // M
int nb_demixing_matrix = substream_count + coupled_substream_count;
--
2.50.0
More information about the ffmpeg-devel
mailing list