1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/iamf: use the new Binaural channel layout

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2024-10-27 15:22:00 -03:00
parent 20af68b63a
commit edc7b67508
7 changed files with 18 additions and 10 deletions

View File

@ -752,12 +752,12 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed,
for (int k = 0; k < sub_mix->nb_layouts; k++) {
const AVIAMFSubmixLayout *submix_layout = sub_mix->layouts[k];
av_log(NULL, AV_LOG_INFO, " Layout #%d:", k);
if (submix_layout->layout_type == 2) {
if (submix_layout->layout_type == 2 ||
submix_layout->layout_type == 3) {
ret = av_channel_layout_describe(&submix_layout->sound_system, buf, sizeof(buf));
if (ret >= 0)
av_log(NULL, AV_LOG_INFO, " %s", buf);
} else if (submix_layout->layout_type == 3)
av_log(NULL, AV_LOG_INFO, " Binaural");
}
av_log(NULL, AV_LOG_INFO, "\n");
}
}

View File

@ -42,7 +42,7 @@ const AVChannelLayout ff_iamf_scalable_ch_layouts[10] = {
// Front subset of "Loudspeaker configuration for Sound System J"
AV_CHANNEL_LAYOUT_3POINT1POINT2,
// Binaural
AV_CHANNEL_LAYOUT_STEREO,
AV_CHANNEL_LAYOUT_BINAURAL,
};
const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13] = {

View File

@ -956,7 +956,8 @@ static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int le
goto fail;
}
av_channel_layout_copy(&submix_layout->sound_system, &ff_iamf_sound_system_map[sound_system].layout);
}
} else
submix_layout->sound_system = (AVChannelLayout)AV_CHANNEL_LAYOUT_BINAURAL;
info_type = avio_r8(pbc);
submix_layout->integrated_loudness = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);

View File

@ -817,6 +817,9 @@ static int iamf_write_mixing_presentation(const IAMFContext *iamf,
av_log(log_ctx, AV_LOG_ERROR, "Invalid Sound System value in a submix\n");
return AVERROR(EINVAL);
}
} else if (submix_layout->layout_type != AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL) {
av_log(log_ctx, AV_LOG_ERROR, "Unsupported Layout Type value in a submix\n");
return AVERROR(EINVAL);
}
init_put_bits(&pbc, header, sizeof(header));
put_bits(&pbc, 2, submix_layout->layout_type); // layout_type

View File

@ -493,10 +493,14 @@ typedef struct AVIAMFSubmixElement {
enum AVIAMFSubmixLayoutType {
/**
* The layout follows the loudspeaker sound system convention of ITU-2051-3.
* @ref AVIAMFSubmixLayout.sound_system must be set.
*/
AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS = 2,
/**
* The layout is binaural.
*
* @note @ref AVIAMFSubmixLayout.sound_system may be set to
* AV_CHANNEL_LAYOUT_BINAURAL to simplify API usage, but it's not mandatory.
*/
AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL = 3,
};
@ -514,9 +518,9 @@ typedef struct AVIAMFSubmixLayout {
/**
* Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus
* 7.1.2ch and 3.1.2ch
* If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS, this field
* is undefined.
* 7.1.2ch, 3.1.2ch, and binaural.
* If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS or
* AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL, this field is undefined.
*/
AVChannelLayout sound_system;
/**

View File

@ -135,7 +135,7 @@ duration=0
constant_subblock_duration=0
[/PIECE]
[PIECE]
sound_system=0 channels
sound_system=binaural
integrated_loudness=0/256
digital_peak=0/256
true_peak=0/1

View File

@ -157,7 +157,7 @@ duration=0
constant_subblock_duration=0
[/PIECE]
[PIECE]
sound_system=0 channels
sound_system=binaural
integrated_loudness=0/256
digital_peak=0/256
true_peak=0/1