PR #26094 opened by Baptiste Coudurier (bcoudurier) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26094 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26094.patch
# Summary of changes Fix AMR-WB configuration in MOV/3GP and recognize AMR-WB streams in CAF. The MOV/3GP muxer accepts AMR-WB but only writes decoder configuration for AMR-NB. Extend the existing configuration paths to AMR-WB, including the MOV wave configuration. 3GPP TS 26.244 section 6.7 requires an AMRSpecificBox for both codecs and specifies 0x83ff as the AMR-WB mode set. Add the sawb format identifier to the shared CAF codec tag table so the demuxer recognizes existing AMR-WB streams and the muxer can write them using its existing packet table support. Add MOV, 3GP and CAF remux regression tests using the existing amrwb/seed-23k85.awb sample. Output checksums cover configuration bytes, and packet checksums cover coded data and timing. No new FATE samples are required. Validation: - Passed fate-amrwb-mov-remux, fate-amrwb-3gp-remux, fate-amrwb-remux, fate-caf-amr_wb-remux and fate-caf-amr_nb-remux. - Remuxed a 250-frame, 16 kHz mono AMR-WB stream through MOV, 3GP and CAF with identical elementary-frame hashes and 80,000 decoded samples. - Verified a CAF-to-raw round trip preserves the compressed stream byte for byte. - Verified seeking to 2 seconds preserves the remaining 150 coded frames in MOV. - git diff --check passes. >From cf73f9b9b7293282c7413052bdea6d03a201f1c3 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier <[email protected]> Date: Sun, 15 Nov 2026 23:34:43 -0800 Subject: [PATCH 1/2] avformat/movenc: write AMR-WB decoder configuration 3GPP TS 26.244 section 6.7 requires an AMRSpecificBox for both AMR and AMR-WB sample entries. Extend the existing AMR configuration writer to AMR-WB and use its specified 0x83ff mode set. Write the corresponding wave configuration for MOV as well. Add MOV and 3GP remux tests covering the configuration bytes and preserved packet data. --- libavformat/movenc.c | 10 ++++-- tests/fate/amrwb.mak | 8 +++++ tests/ref/fate/amrwb-3gp-remux | 57 ++++++++++++++++++++++++++++++++++ tests/ref/fate/amrwb-mov-remux | 57 ++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 tests/ref/fate/amrwb-3gp-remux create mode 100644 tests/ref/fate/amrwb-mov-remux diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c3fa66d816c..0e9afbb362f 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -375,7 +375,8 @@ static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track) ffio_wfourcc(pb, "FFMP"); avio_w8(pb, 0); /* decoder version */ - avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */ + /* All modes and comfort noise frames, per 3GPP TS 26.244, 6.7. */ + avio_wb16(pb, track->par->codec_id == AV_CODEC_ID_AMR_WB ? 0x83FF : 0x81FF); avio_w8(pb, 0x00); /* Mode change period (no restriction) */ avio_w8(pb, 0x01); /* Frames per sample */ return 0x11; @@ -1166,7 +1167,8 @@ static int mov_write_wave_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra mov_write_enda_tag(pb); } else if (mov_pcm_be_gt16(track->par->codec_id)) { mov_write_enda_tag_be(pb); - } else if (track->par->codec_id == AV_CODEC_ID_AMR_NB) { + } else if (track->par->codec_id == AV_CODEC_ID_AMR_NB || + track->par->codec_id == AV_CODEC_ID_AMR_WB) { mov_write_amr_tag(pb, track); } else if (track->par->codec_id == AV_CODEC_ID_AC3) { mov_write_ac3_tag(s, pb, track); @@ -1577,6 +1579,7 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex track->par->codec_id == AV_CODEC_ID_AC3 || track->par->codec_id == AV_CODEC_ID_EAC3 || track->par->codec_id == AV_CODEC_ID_AMR_NB || + track->par->codec_id == AV_CODEC_ID_AMR_WB || track->par->codec_id == AV_CODEC_ID_ALAC || track->par->codec_id == AV_CODEC_ID_ADPCM_MS || track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || @@ -1590,7 +1593,8 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex else if (track->tag == MKTAG('i','a','m','f')) ret = mov_write_iacb_tag(mov->fc, pb, track); #endif - else if (track->par->codec_id == AV_CODEC_ID_AMR_NB) + else if (track->par->codec_id == AV_CODEC_ID_AMR_NB || + track->par->codec_id == AV_CODEC_ID_AMR_WB) ret = mov_write_amr_tag(pb, track); else if (track->par->codec_id == AV_CODEC_ID_AC3) ret = mov_write_ac3_tag(s, pb, track); diff --git a/tests/fate/amrwb.mak b/tests/fate/amrwb.mak index 3ffb9349981..b68d6c1976c 100644 --- a/tests/fate/amrwb.mak +++ b/tests/fate/amrwb.mak @@ -44,6 +44,14 @@ fate-amrwb-23k85-2: REF = $(SAMPLES)/amrwb/deus-23k85.pcm FATE_AMRWB_REMUX-$(call REMUX, AMR, MOV_DEMUXER AMR_PARSER) += fate-amrwb-remux fate-amrwb-remux: CMD = transcode mov $(TARGET_SAMPLES)/amrwb/seed-23k85.awb amr "-c copy" "-c copy -t 1" +# Exercise both the MOV wave configuration and the 3GP damr box, including +# the AMR-WB mode set. The output file checksum covers the configuration. +FATE_AMRWB_REMUX-$(call REMUX, MOV, AMR_PARSER) += fate-amrwb-mov-remux +fate-amrwb-mov-remux: CMD = transcode mov $(TARGET_SAMPLES)/amrwb/seed-23k85.awb mov "-c copy -t 1" "-c copy" + +FATE_AMRWB_REMUX-$(call REMUX, TGP MOV, AMR_PARSER) += fate-amrwb-3gp-remux +fate-amrwb-3gp-remux: CMD = transcode mov $(TARGET_SAMPLES)/amrwb/seed-23k85.awb 3gp "-c copy -t 1" "-c copy" + $(FATE_AMRWB): CMP = stddev # Check that SID frames are decoded to comfort noise instead of being dropped, diff --git a/tests/ref/fate/amrwb-3gp-remux b/tests/ref/fate/amrwb-3gp-remux new file mode 100644 index 00000000000..1aeefd1590c --- /dev/null +++ b/tests/ref/fate/amrwb-3gp-remux @@ -0,0 +1,57 @@ +11064b8b71aa9bc47113655f82fecf31 *tests/data/fate/amrwb-3gp-remux.3gp +3661 tests/data/fate/amrwb-3gp-remux.3gp +#tb 0: 1/16000 +#media_type 0: audio +#codec_id 0: amr_wb +#sample_rate 0: 16000 +#channel_layout_name 0: mono +0, 0, 0, 320, 61, 0xc8891fe9 +0, 320, 320, 320, 61, 0xc2562027 +0, 640, 640, 320, 61, 0xe46e207f +0, 960, 960, 320, 61, 0xa27a1c46 +0, 1280, 1280, 320, 61, 0xf1d42007 +0, 1600, 1600, 320, 61, 0x50d61af4 +0, 1920, 1920, 320, 61, 0xbacf1eef +0, 2240, 2240, 320, 61, 0xbd691d7b +0, 2560, 2560, 320, 61, 0xfd1323a2 +0, 2880, 2880, 320, 61, 0x7ca01f0e +0, 3200, 3200, 320, 61, 0x2f812276 +0, 3520, 3520, 320, 61, 0xaef41ca8 +0, 3840, 3840, 320, 61, 0x2560211f +0, 4160, 4160, 320, 61, 0xd6ad1fd4 +0, 4480, 4480, 320, 61, 0x87d81d18 +0, 4800, 4800, 320, 61, 0x11531a44 +0, 5120, 5120, 320, 61, 0x83011d4f +0, 5440, 5440, 320, 61, 0xca39211f +0, 5760, 5760, 320, 61, 0xa0031e8d +0, 6080, 6080, 320, 61, 0x0b8a1980 +0, 6400, 6400, 320, 61, 0xd2931e62 +0, 6720, 6720, 320, 61, 0x0f7820fd +0, 7040, 7040, 320, 61, 0xcc8c2149 +0, 7360, 7360, 320, 61, 0x29f82236 +0, 7680, 7680, 320, 61, 0xf7a71f9c +0, 8000, 8000, 320, 61, 0xa64f1cba +0, 8320, 8320, 320, 61, 0x685321c1 +0, 8640, 8640, 320, 61, 0x48002221 +0, 8960, 8960, 320, 61, 0xef0a1f53 +0, 9280, 9280, 320, 61, 0x31e321a0 +0, 9600, 9600, 320, 61, 0xb49f1ead +0, 9920, 9920, 320, 61, 0xe5bb1f9d +0, 10240, 10240, 320, 61, 0xc5971d19 +0, 10560, 10560, 320, 61, 0x33182328 +0, 10880, 10880, 320, 61, 0xb791204e +0, 11200, 11200, 320, 61, 0x5db81bd8 +0, 11520, 11520, 320, 61, 0x9f171da7 +0, 11840, 11840, 320, 61, 0xec4a1974 +0, 12160, 12160, 320, 61, 0x980620e1 +0, 12480, 12480, 320, 61, 0x74cf1d0c +0, 12800, 12800, 320, 61, 0xea761ef7 +0, 13120, 13120, 320, 61, 0xa1da1cc7 +0, 13440, 13440, 320, 61, 0x68741b28 +0, 13760, 13760, 320, 61, 0x87991cee +0, 14080, 14080, 320, 61, 0x955f1d0f +0, 14400, 14400, 320, 61, 0x8eea1e69 +0, 14720, 14720, 320, 61, 0xadb21ede +0, 15040, 15040, 320, 61, 0xace61e29 +0, 15360, 15360, 320, 61, 0x67441c17 +0, 15680, 15680, 320, 61, 0x7f1b1e7c diff --git a/tests/ref/fate/amrwb-mov-remux b/tests/ref/fate/amrwb-mov-remux new file mode 100644 index 00000000000..c44a3fb116a --- /dev/null +++ b/tests/ref/fate/amrwb-mov-remux @@ -0,0 +1,57 @@ +f5da07b4ffdd239203759472f23db352 *tests/data/fate/amrwb-mov-remux.mov +3741 tests/data/fate/amrwb-mov-remux.mov +#tb 0: 1/16000 +#media_type 0: audio +#codec_id 0: amr_wb +#sample_rate 0: 16000 +#channel_layout_name 0: mono +0, 0, 0, 320, 61, 0xc8891fe9 +0, 320, 320, 320, 61, 0xc2562027 +0, 640, 640, 320, 61, 0xe46e207f +0, 960, 960, 320, 61, 0xa27a1c46 +0, 1280, 1280, 320, 61, 0xf1d42007 +0, 1600, 1600, 320, 61, 0x50d61af4 +0, 1920, 1920, 320, 61, 0xbacf1eef +0, 2240, 2240, 320, 61, 0xbd691d7b +0, 2560, 2560, 320, 61, 0xfd1323a2 +0, 2880, 2880, 320, 61, 0x7ca01f0e +0, 3200, 3200, 320, 61, 0x2f812276 +0, 3520, 3520, 320, 61, 0xaef41ca8 +0, 3840, 3840, 320, 61, 0x2560211f +0, 4160, 4160, 320, 61, 0xd6ad1fd4 +0, 4480, 4480, 320, 61, 0x87d81d18 +0, 4800, 4800, 320, 61, 0x11531a44 +0, 5120, 5120, 320, 61, 0x83011d4f +0, 5440, 5440, 320, 61, 0xca39211f +0, 5760, 5760, 320, 61, 0xa0031e8d +0, 6080, 6080, 320, 61, 0x0b8a1980 +0, 6400, 6400, 320, 61, 0xd2931e62 +0, 6720, 6720, 320, 61, 0x0f7820fd +0, 7040, 7040, 320, 61, 0xcc8c2149 +0, 7360, 7360, 320, 61, 0x29f82236 +0, 7680, 7680, 320, 61, 0xf7a71f9c +0, 8000, 8000, 320, 61, 0xa64f1cba +0, 8320, 8320, 320, 61, 0x685321c1 +0, 8640, 8640, 320, 61, 0x48002221 +0, 8960, 8960, 320, 61, 0xef0a1f53 +0, 9280, 9280, 320, 61, 0x31e321a0 +0, 9600, 9600, 320, 61, 0xb49f1ead +0, 9920, 9920, 320, 61, 0xe5bb1f9d +0, 10240, 10240, 320, 61, 0xc5971d19 +0, 10560, 10560, 320, 61, 0x33182328 +0, 10880, 10880, 320, 61, 0xb791204e +0, 11200, 11200, 320, 61, 0x5db81bd8 +0, 11520, 11520, 320, 61, 0x9f171da7 +0, 11840, 11840, 320, 61, 0xec4a1974 +0, 12160, 12160, 320, 61, 0x980620e1 +0, 12480, 12480, 320, 61, 0x74cf1d0c +0, 12800, 12800, 320, 61, 0xea761ef7 +0, 13120, 13120, 320, 61, 0xa1da1cc7 +0, 13440, 13440, 320, 61, 0x68741b28 +0, 13760, 13760, 320, 61, 0x87991cee +0, 14080, 14080, 320, 61, 0x955f1d0f +0, 14400, 14400, 320, 61, 0x8eea1e69 +0, 14720, 14720, 320, 61, 0xadb21ede +0, 15040, 15040, 320, 61, 0xace61e29 +0, 15360, 15360, 320, 61, 0x67441c17 +0, 15680, 15680, 320, 61, 0x7f1b1e7c -- 2.54.0 >From 955227b74c67b638bff233b1a0d6202064261b92 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier <[email protected]> Date: Sun, 15 Nov 2026 23:37:07 -0800 Subject: [PATCH 2/2] avformat/caf: recognize the AMR-WB format identifier Map the CAF audio description format identifier sawb to AMR-WB, allowing the demuxer to recognize existing streams and the muxer to write them using its packet table support. Add a remux regression test covering the audio description, packet timing and compressed data. --- libavformat/caf.c | 1 + tests/fate/caf.mak | 3 ++ tests/ref/fate/caf-amr_wb-remux | 57 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 tests/ref/fate/caf-amr_wb-remux diff --git a/libavformat/caf.c b/libavformat/caf.c index a61c39fae52..1c8f6cbfd18 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -40,6 +40,7 @@ const AVCodecTag ff_codec_caf_tags[] = { { AV_CODEC_ID_ADPCM_MS, MKTAG('m','s', 0, 2 ) }, { AV_CODEC_ID_ALAC, MKTAG('a','l','a','c') }, { AV_CODEC_ID_AMR_NB, MKTAG('s','a','m','r') }, + { AV_CODEC_ID_AMR_WB, MKTAG('s','a','w','b') }, /* FIXME: use DV demuxer, as done in MOV */ /*{ AV_CODEC_ID_DVAUDIO, MKTAG('v','d','v','a') },*/ /*{ AV_CODEC_ID_DVAUDIO, MKTAG('d','v','c','a') },*/ diff --git a/tests/fate/caf.mak b/tests/fate/caf.mak index 4ee9c95a5c8..5d35fc07e4e 100644 --- a/tests/fate/caf.mak +++ b/tests/fate/caf.mak @@ -7,6 +7,9 @@ fate-caf-alac-remux: CMD = transcode m4a $(TARGET_SAMPLES)/lossless-audio/inside FATE_CAF_FFMPEG-$(call REMUX, CAF, AMR_DEMUXER) += fate-caf-amr_nb-remux fate-caf-amr_nb-remux: CMD = transcode amr $(TARGET_SAMPLES)/amrnb/4.75k.amr caf "-c copy" "-c copy -t 0.2" +FATE_CAF_FFMPEG-$(call REMUX, CAF, MOV_DEMUXER) += fate-caf-amr_wb-remux +fate-caf-amr_wb-remux: CMD = transcode mov $(TARGET_SAMPLES)/amrwb/seed-23k85.awb caf "-c copy -t 1" "-c copy" + FATE_CAF_FFMPEG-$(call REMUX, CAF, MOV_DEMUXER) += fate-caf-qdm2-remux fate-caf-qdm2-remux: CMD = transcode mov $(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.mov caf "-c copy" "-c copy -t 0.2" diff --git a/tests/ref/fate/caf-amr_wb-remux b/tests/ref/fate/caf-amr_wb-remux new file mode 100644 index 00000000000..937d17f3fa9 --- /dev/null +++ b/tests/ref/fate/caf-amr_wb-remux @@ -0,0 +1,57 @@ +6b510cbdc01182c55ba5662eca3444a8 *tests/data/fate/caf-amr_wb-remux.caf +3328 tests/data/fate/caf-amr_wb-remux.caf +#tb 0: 1/16000 +#media_type 0: audio +#codec_id 0: amr_wb +#sample_rate 0: 16000 +#channel_layout_name 0: mono +0, 0, 0, 320, 61, 0xc8891fe9 +0, 320, 320, 320, 61, 0xc2562027 +0, 640, 640, 320, 61, 0xe46e207f +0, 960, 960, 320, 61, 0xa27a1c46 +0, 1280, 1280, 320, 61, 0xf1d42007 +0, 1600, 1600, 320, 61, 0x50d61af4 +0, 1920, 1920, 320, 61, 0xbacf1eef +0, 2240, 2240, 320, 61, 0xbd691d7b +0, 2560, 2560, 320, 61, 0xfd1323a2 +0, 2880, 2880, 320, 61, 0x7ca01f0e +0, 3200, 3200, 320, 61, 0x2f812276 +0, 3520, 3520, 320, 61, 0xaef41ca8 +0, 3840, 3840, 320, 61, 0x2560211f +0, 4160, 4160, 320, 61, 0xd6ad1fd4 +0, 4480, 4480, 320, 61, 0x87d81d18 +0, 4800, 4800, 320, 61, 0x11531a44 +0, 5120, 5120, 320, 61, 0x83011d4f +0, 5440, 5440, 320, 61, 0xca39211f +0, 5760, 5760, 320, 61, 0xa0031e8d +0, 6080, 6080, 320, 61, 0x0b8a1980 +0, 6400, 6400, 320, 61, 0xd2931e62 +0, 6720, 6720, 320, 61, 0x0f7820fd +0, 7040, 7040, 320, 61, 0xcc8c2149 +0, 7360, 7360, 320, 61, 0x29f82236 +0, 7680, 7680, 320, 61, 0xf7a71f9c +0, 8000, 8000, 320, 61, 0xa64f1cba +0, 8320, 8320, 320, 61, 0x685321c1 +0, 8640, 8640, 320, 61, 0x48002221 +0, 8960, 8960, 320, 61, 0xef0a1f53 +0, 9280, 9280, 320, 61, 0x31e321a0 +0, 9600, 9600, 320, 61, 0xb49f1ead +0, 9920, 9920, 320, 61, 0xe5bb1f9d +0, 10240, 10240, 320, 61, 0xc5971d19 +0, 10560, 10560, 320, 61, 0x33182328 +0, 10880, 10880, 320, 61, 0xb791204e +0, 11200, 11200, 320, 61, 0x5db81bd8 +0, 11520, 11520, 320, 61, 0x9f171da7 +0, 11840, 11840, 320, 61, 0xec4a1974 +0, 12160, 12160, 320, 61, 0x980620e1 +0, 12480, 12480, 320, 61, 0x74cf1d0c +0, 12800, 12800, 320, 61, 0xea761ef7 +0, 13120, 13120, 320, 61, 0xa1da1cc7 +0, 13440, 13440, 320, 61, 0x68741b28 +0, 13760, 13760, 320, 61, 0x87991cee +0, 14080, 14080, 320, 61, 0x955f1d0f +0, 14400, 14400, 320, 61, 0x8eea1e69 +0, 14720, 14720, 320, 61, 0xadb21ede +0, 15040, 15040, 320, 61, 0xace61e29 +0, 15360, 15360, 320, 61, 0x67441c17 +0, 15680, 15680, 320, 61, 0x7f1b1e7c -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
