In most cases, the channel ids will match the standard Ambisonic Order, saving us the need to use a custom order layout.
Unified · Split
| @@ -465,14 +465,16 @@ static int ambisonics_config(void *s, AVIOContext *pb, · 464 unmodified lines | ||
| 465 | 465 | return ret; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | − layer->ch_layout.order = AV_CHANNEL_ORDER_CUSTOM; | |
| 469 | − layer->ch_layout.nb_channels = output_channel_count; | |
| 470 | − layer->ch_layout.u.map = av_calloc(output_channel_count, sizeof(*layer->ch_layout.u.map)); | |
| 471 | − if (!layer->ch_layout.u.map) | |
| 472 | − return AVERROR(ENOMEM); | |
| 468 | + ret = av_channel_layout_custom_init(&layer->ch_layout, output_channel_count); | |
| 469 | + if (ret < 0) | |
| 470 | + return ret; | |
| 473 | 471 | |
| 474 | 472 | for (int i = 0; i < output_channel_count; i++) |
| 475 | 473 | layer->ch_layout.u.map[i].id = avio_r8(pb) + AV_CHAN_AMBISONIC_BASE; |
| 474 | + | |
| 475 | + ret = av_channel_layout_retype(&layer->ch_layout, AV_CHANNEL_ORDER_AMBISONIC, 0); | |
| 476 | + if (ret < 0 && ret != AVERROR(ENOSYS)) | |
| 477 | + return ret; | |
| 476 | 478 | } else { |
| 477 | 479 | int coupled_substream_count = avio_r8(pb); // M |
| 478 | 480 | int nb_demixing_matrix = substream_count + coupled_substream_count; |