diff mbox series

[FFmpeg-devel,1/4] avformat/movenc: fix channel count and samplerate fields for IAMF tracks

Message ID 20240717014925.16517-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/4] avformat/movenc: fix channel count and samplerate fields for IAMF tracks | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer July 17, 2024, 1:49 a.m. UTC
From: Felicia Lim <flim@google.com>

Clause 6.2.3 of IAMF[1] states both of these shall be set to 0.

[1]https://aomediacodec.github.io/iamf/v1.0.0-errata.html#iasampleentry-section
---
 libavformat/movenc.c                    | 15 +++++++++++++++
 tests/ref/fate/mov-mp4-iamf-5_1_4       |  2 +-
 tests/ref/fate/mov-mp4-iamf-7_1_4       |  2 +-
 tests/ref/fate/mov-mp4-iamf-ambisonic_1 |  2 +-
 tests/ref/fate/mov-mp4-iamf-stereo      |  2 +-
 5 files changed, 19 insertions(+), 4 deletions(-)

Comments

Anton Khirnov July 17, 2024, 6:18 a.m. UTC | #1
Quoting James Almer (2024-07-17 03:49:22)
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 2bea55e33d..5de188f4cf 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1399,6 +1399,11 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
>                  avio_wb16(pb, 16);
>              avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
>          } else { /* reserved for mp4/3gp */
> +#if CONFIG_IAMFENC
> +            if (track->tag == MKTAG('i','a','m','f'))
> +                avio_wb16(pb, 0); /* channelcount must be 0 for IAMF */
> +            else
> +#endif
>              avio_wb16(pb, track->par->ch_layout.nb_channels);

avio_wb16(pb, track->tag == MKTAG('i', 'a', 'm', 'f') ?
              0 : track->par->ch_layout.nb_channels);

looks more readable to me
James Almer July 17, 2024, 11:29 a.m. UTC | #2
On 7/17/2024 3:18 AM, Anton Khirnov wrote:
> Quoting James Almer (2024-07-17 03:49:22)
>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> index 2bea55e33d..5de188f4cf 100644
>> --- a/libavformat/movenc.c
>> +++ b/libavformat/movenc.c
>> @@ -1399,6 +1399,11 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
>>                   avio_wb16(pb, 16);
>>               avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
>>           } else { /* reserved for mp4/3gp */
>> +#if CONFIG_IAMFENC
>> +            if (track->tag == MKTAG('i','a','m','f'))
>> +                avio_wb16(pb, 0); /* channelcount must be 0 for IAMF */
>> +            else
>> +#endif
>>               avio_wb16(pb, track->par->ch_layout.nb_channels);
> 
> avio_wb16(pb, track->tag == MKTAG('i', 'a', 'm', 'f') ?
>                0 : track->par->ch_layout.nb_channels);
> 
> looks more readable to me

Ok, changed locally.
diff mbox series

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 2bea55e33d..5de188f4cf 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1399,6 +1399,11 @@  static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
                 avio_wb16(pb, 16);
             avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
         } else { /* reserved for mp4/3gp */
+#if CONFIG_IAMFENC
+            if (track->tag == MKTAG('i','a','m','f'))
+                avio_wb16(pb, 0); /* channelcount must be 0 for IAMF */
+            else
+#endif
             avio_wb16(pb, track->par->ch_layout.nb_channels);
             if (track->par->codec_id == AV_CODEC_ID_FLAC ||
                 track->par->codec_id == AV_CODEC_ID_ALAC) {
@@ -1410,6 +1415,11 @@  static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
         }
 
         avio_wb16(pb, 0); /* packet size (= 0) */
+#if CONFIG_IAMFENC
+        if (track->tag == MKTAG('i','a','m','f'))
+            avio_wb16(pb, 0); /* samplerate must be 0 for IAMF */
+        else
+#endif
         if (track->par->codec_id == AV_CODEC_ID_OPUS)
             avio_wb16(pb, 48000);
         else if (track->par->codec_id == AV_CODEC_ID_TRUEHD)
@@ -5158,6 +5168,11 @@  static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat
             param_write_int(pb, "AudioTag", ff_codec_get_tag(ff_codec_wav_tags,
                                                              track->par->codec_id));
             param_write_int(pb, "Channels", track->par->ch_layout.nb_channels);
+#if CONFIG_IAMFENC
+            if (track->tag == MKTAG('i','a','m','f'))
+                param_write_int(pb, "SamplingRate", 0);
+            else
+#endif
             param_write_int(pb, "SamplingRate", track->par->sample_rate);
             param_write_int(pb, "BitsPerSample", 16);
             param_write_int(pb, "PacketSize", track->par->block_align ?
diff --git a/tests/ref/fate/mov-mp4-iamf-5_1_4 b/tests/ref/fate/mov-mp4-iamf-5_1_4
index afaa620621..36106528ab 100644
--- a/tests/ref/fate/mov-mp4-iamf-5_1_4
+++ b/tests/ref/fate/mov-mp4-iamf-5_1_4
@@ -1,4 +1,4 @@ 
-5585ed23481b6f28437b3707a1ed632d *tests/data/fate/mov-mp4-iamf-5_1_4.mp4
+0316d0a483480ccd582fd20f06c77420 *tests/data/fate/mov-mp4-iamf-5_1_4.mp4
 86340 tests/data/fate/mov-mp4-iamf-5_1_4.mp4
 #extradata 0:       34, 0xafa70d5e
 #extradata 1:       34, 0xafa70d5e
diff --git a/tests/ref/fate/mov-mp4-iamf-7_1_4 b/tests/ref/fate/mov-mp4-iamf-7_1_4
index e8b859121d..51494222fc 100644
--- a/tests/ref/fate/mov-mp4-iamf-7_1_4
+++ b/tests/ref/fate/mov-mp4-iamf-7_1_4
@@ -1,4 +1,4 @@ 
-690d2b7a15b5489c59a9148fcd7975be *tests/data/fate/mov-mp4-iamf-7_1_4.mp4
+d9ef5d14bbd37c5a06c1494cacdb8f29 *tests/data/fate/mov-mp4-iamf-7_1_4.mp4
 100588 tests/data/fate/mov-mp4-iamf-7_1_4.mp4
 #extradata 0:       34, 0xafa70d5e
 #extradata 1:       34, 0xafa70d5e
diff --git a/tests/ref/fate/mov-mp4-iamf-ambisonic_1 b/tests/ref/fate/mov-mp4-iamf-ambisonic_1
index 8de90c868f..d0877f73c7 100644
--- a/tests/ref/fate/mov-mp4-iamf-ambisonic_1
+++ b/tests/ref/fate/mov-mp4-iamf-ambisonic_1
@@ -1,4 +1,4 @@ 
-2b3517591f7bf20e0f74f3ec1381af1e *tests/data/fate/mov-mp4-iamf-ambisonic_1.mp4
+b0f4accdb8f1f3dfe594a6cbd6c00603 *tests/data/fate/mov-mp4-iamf-ambisonic_1.mp4
 57743 tests/data/fate/mov-mp4-iamf-ambisonic_1.mp4
 #extradata 0:       34, 0xad120cfe
 #extradata 1:       34, 0xad120cfe
diff --git a/tests/ref/fate/mov-mp4-iamf-stereo b/tests/ref/fate/mov-mp4-iamf-stereo
index 32027e6daf..e40d164fc4 100644
--- a/tests/ref/fate/mov-mp4-iamf-stereo
+++ b/tests/ref/fate/mov-mp4-iamf-stereo
@@ -1,4 +1,4 @@ 
-88c2b547f069f2d4a11d24f7f922251a *tests/data/fate/mov-mp4-iamf-stereo.mp4
+87c17d1a9fd07e16c369d386d39c3249 *tests/data/fate/mov-mp4-iamf-stereo.mp4
 15163 tests/data/fate/mov-mp4-iamf-stereo.mp4
 #extradata 0:       34, 0xafa70d5e
 #tb 0: 1/44100