avformat/iamf_writer: ensure expanded_loudspeaker_layout is only written when using a single scalable layout layer

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-12-07 14:52:25 -03:00
parent 5cdc1cad77
commit 16050a1cef
+9 -1
View File
@@ -753,8 +753,16 @@ static int iamf_write_audio_element(const IAMFContext *iamf,
int layout = 0, expanded_layout = 0;
get_loudspeaker_layout(element->layers[0], &layout, &expanded_layout);
/* When the loudspeaker_layout = 15, the type PARAMETER_DEFINITION_DEMIXING SHALL NOT be present. */
if (layout == 15)
if (layout == 15) {
param_definition_types &= ~AV_IAMF_PARAMETER_DEFINITION_DEMIXING;
/* expanded_loudspeaker_layout SHALL only be present when num_layers = 1 and loudspeaker_layout is set to 15 */
if (element->nb_layers > 1) {
av_log(log_ctx, AV_LOG_ERROR, "expanded_loudspeaker_layout present when using more than one layer in "
"Stream Group #%u\n",
audio_element->audio_element_id);
return AVERROR(EINVAL);
}
}
/* When the loudspeaker_layout of the (non-)scalable channel audio (i.e., num_layers = 1) is less than or equal to 3.1.2ch,
* (i.e., Mono, Stereo, or 3.1.2ch), the type PARAMETER_DEFINITION_DEMIXING SHALL NOT be present. */
else if (element->nb_layers == 1 && (layout == 0 || layout == 1 || layout == 8))