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 | return ret; | 465 | return ret; |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | layer->ch_layout.order = AV_CHANNEL_ORDER_CUSTOM; | 468 | ret = av_channel_layout_custom_init(&layer->ch_layout, output_channel_count); |
| 469 | layer->ch_layout.nb_channels = output_channel_count; | 469 | if (ret < 0) |
| 470 | layer->ch_layout.u.map = av_calloc(output_channel_count, sizeof(*layer->ch_layout.u.map)); | 470 | return ret; |
| 471 | if (!layer->ch_layout.u.map) | ||
| 472 | return AVERROR(ENOMEM); | ||
| 473 | 471 | ||
| 474 | for (int i = 0; i < output_channel_count; i++) | 472 | for (int i = 0; i < output_channel_count; i++) |
| 475 | layer->ch_layout.u.map[i].id = avio_r8(pb) + AV_CHAN_AMBISONIC_BASE; | 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 | } else { | 478 | } else { |
| 477 | int coupled_substream_count = avio_r8(pb); // M | 479 | int coupled_substream_count = avio_r8(pb); // M |
| 478 | int nb_demixing_matrix = substream_count + coupled_substream_count; | 480 | int nb_demixing_matrix = substream_count + coupled_substream_count; |