diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c index 2cd1119409..db65c09f11 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -147,12 +147,6 @@ static int aiff_write_header(AVFormatContext *s) avio_wb32(pb, 0xA2805140); } - if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && par->ch_layout.nb_channels > 2) { - ffio_wfourcc(pb, "CHAN"); - avio_wb32(pb, 12); - ff_mov_write_chan(pb, par->ch_layout.u.mask); - } - put_meta(s, "title", MKBETAG('N', 'A', 'M', 'E')); put_meta(s, "author", MKBETAG('A', 'U', 'T', 'H')); put_meta(s, "copyright", MKBETAG('(', 'c', ')', ' ')); @@ -193,6 +187,14 @@ static int aiff_write_header(AVFormatContext *s) avio_write(pb, par->extradata, par->extradata_size); } + /* CHAN chunk; a decoder may use the channel count when parsing this chunk, + * so let's write it after the COMM chunk which indicates said channel count. */ + if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && par->ch_layout.nb_channels > 2) { + ffio_wfourcc(pb, "CHAN"); + avio_wb32(pb, 12); + ff_mov_write_chan(pb, par->ch_layout.u.mask); + } + /* Sound data chunk */ ffio_wfourcc(pb, "SSND"); aiff->ssnd = avio_tell(pb); /* Sound chunk size */ diff --git a/tests/ref/fate/id3v2-utf16-bom b/tests/ref/fate/id3v2-utf16-bom index 99d1bd064d..99e54deef6 100644 --- a/tests/ref/fate/id3v2-utf16-bom +++ b/tests/ref/fate/id3v2-utf16-bom @@ -1,4 +1,4 @@ -9b8bfdf87a8d3d089819ef9f6f264ec4 *tests/data/fate/id3v2-utf16-bom.aiff +8e292c72670bc4b09b05b2eb11edfa70 *tests/data/fate/id3v2-utf16-bom.aiff 885482 tests/data/fate/id3v2-utf16-bom.aiff #tb 0: 1/90000 #media_type 0: video