Defined in Immersive Audio Model and Formats 1.1.0, sections 3.6.2 and 3.7.3
Showing the changes to libavformat (1 of 1 file). Show all
Unified · Split
| @@ -240,8 +240,13 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const AVStreamGroup *stg, void · 239 unmodified lines | |||
| 240 | break; | 240 | break; |
| 241 | 241 | ||
| 242 | if (j >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)) { | 242 | if (j >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)) { |
| 243 | av_log(log_ctx, AV_LOG_ERROR, "Unsupported channel layout in stream group #%d\n", i); | 243 | for (j = 0; j < FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts); j++) |
| 244 | return AVERROR(EINVAL); | 244 | if (!av_channel_layout_compare(&layer->ch_layout, &ff_iamf_expanded_scalable_ch_layouts[j])) |
| 245 | break; | ||
| 246 | if (j >= FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts)) { | ||
| 247 | av_log(log_ctx, AV_LOG_ERROR, "Unsupported channel layout in stream group #%d\n", i); | ||
| 248 | return AVERROR(EINVAL); | ||
| 249 | } | ||
| 245 | } | 250 | } |
| 246 | } | 251 | } |
| 247 | 252 | ||
| @@ -539,13 +544,19 @@ static int scalable_channel_layout_config(const IAMFAudioElement *audio_element, · 291 unmodified lines | |||
| 539 | avio_write(dyn_bc, header, put_bytes_count(&pb, 1)); | 544 | avio_write(dyn_bc, header, put_bytes_count(&pb, 1)); |
| 540 | for (int i = 0; i < element->nb_layers; i++) { | 545 | for (int i = 0; i < element->nb_layers; i++) { |
| 541 | const AVIAMFLayer *layer = element->layers[i]; | 546 | const AVIAMFLayer *layer = element->layers[i]; |
| 542 | int layout; | 547 | int layout, expanded_layout = -1; |
| 543 | for (layout = 0; layout < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); layout++) { | 548 | for (layout = 0; layout < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); layout++) { |
| 544 | if (!av_channel_layout_compare(&layer->ch_layout, &ff_iamf_scalable_ch_layouts[layout])) | 549 | if (!av_channel_layout_compare(&layer->ch_layout, &ff_iamf_scalable_ch_layouts[layout])) |
| 545 | break; | 550 | break; |
| 546 | } | 551 | } |
| 552 | if (layout >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)) | ||
| 553 | for (expanded_layout = 0; expanded_layout < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); expanded_layout++) { | ||
| 554 | if (!av_channel_layout_compare(&layer->ch_layout, &ff_iamf_expanded_scalable_ch_layouts[expanded_layout])) | ||
| 555 | break; | ||
| 556 | } | ||
| 557 | av_assert0(expanded_layout > 0 || layout < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)); | ||
| 547 | init_put_bits(&pb, header, sizeof(header)); | 558 | init_put_bits(&pb, header, sizeof(header)); |
| 548 | put_bits(&pb, 4, layout); | 559 | put_bits(&pb, 4, expanded_layout >= 0 ? 15 : layout); |
| 549 | put_bits(&pb, 1, !!layer->output_gain_flags); | 560 | put_bits(&pb, 1, !!layer->output_gain_flags); |
| 550 | put_bits(&pb, 1, !!(layer->flags & AV_IAMF_LAYER_FLAG_RECON_GAIN)); | 561 | put_bits(&pb, 1, !!(layer->flags & AV_IAMF_LAYER_FLAG_RECON_GAIN)); |
| 551 | put_bits(&pb, 2, 0); // reserved | 562 | put_bits(&pb, 2, 0); // reserved |
| @@ -556,6 +567,8 @@ static int scalable_channel_layout_config(const IAMFAudioElement *audio_element, · 4 unmodified lines | |||
| 556 | put_bits(&pb, 2, 0); | 567 | put_bits(&pb, 2, 0); |
| 557 | put_bits(&pb, 16, rescale_rational(layer->output_gain, 1 << 8)); | 568 | put_bits(&pb, 16, rescale_rational(layer->output_gain, 1 << 8)); |
| 558 | } | 569 | } |
| 570 | if (expanded_layout >= 0) | ||
| 571 | put_bits(&pb, 8, expanded_layout); | ||
| 559 | flush_put_bits(&pb); | 572 | flush_put_bits(&pb); |
| 560 | avio_write(dyn_bc, header, put_bytes_count(&pb, 1)); | 573 | avio_write(dyn_bc, header, put_bytes_count(&pb, 1)); |
| 561 | } | 574 | } |