PR #26192 opened by Baptiste Coudurier (bcoudurier)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26192
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26192.patch

QDMC stream copy currently writes its decompressor configuration in a `glbl` 
atom. Consumers expecting the configuration in `wave` can consequently produce 
silent audio.

Route QDMC through the MOV `wave` writer and copy its existing extradata as the 
complete payload. The MOV demuxer preserves the payload, including its `frma` 
and terminator atoms, so return before the generic writer adds either atom 
again.

The QuickTime File Format specification describes `wave` as the sound sample 
description extension carrying decompressor-specific configuration:
- 
https://developer.apple.com/documentation/quicktime-file-format/sidecompressionparam_atom
- 
https://developer.apple.com/documentation/quicktime-file-format/sound_sample_description_extensions

Validation with https://samples.ffmpeg.org/A-codecs/QDMC/rumcoke.mov:
- The fixed 72-byte `wave` atom is byte-identical to the original; a second 
remux preserves it without duplication.
- All 1,438 packet hashes, sizes, timestamps, and durations are unchanged.
- FFmpeg decodes the original and fixed remux to byte-identical PCM. A QDM2 
remux smoke test also preserves PCM.
- Independent extraction restores audio and matches all 11,780,066 original 
stereo sample frames byte-for-byte, followed by one zero frame. A control 
differing only in the four-byte atom type (`glbl` instead of `wave`) produces 
entirely zero PCM.
- Targeted build and `git diff --check` pass.

The remaining one-frame extraction delta at 44,100 Hz is separate from this 
configuration-only change. FFmpeg emits 11,780,096 frames from both original 
and fixed files. Decoder frame-size work is outside this PR.



>From 97e212b4de6536370ea36ca50ab4105b94b288ac Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Wed, 18 Nov 2026 16:04:47 -0800
Subject: [PATCH] avformat/movenc: write QDMC configuration in a wave atom

The QuickTime File Format specification defines wave as the sound sample
description extension for decompressor-specific configuration. QDMC
extradata read from MOV already contains the complete wave payload,
including the frma and terminator atoms.

Write that payload in wave instead of the generic glbl atom, without
adding another frma or terminator. This restores audio when the remuxed
stream is decoded by a consumer expecting the QDMC wave configuration.

Reference: 
https://developer.apple.com/documentation/quicktime-file-format/sidecompressionparam_atom
Reference: 
https://developer.apple.com/documentation/quicktime-file-format/sound_sample_description_extensions
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavformat/movenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 293a85633e5..3db29db2ac4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1150,6 +1150,12 @@ static int mov_write_wave_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
     avio_wb32(pb, 0);     /* size */
     ffio_wfourcc(pb, "wave");
 
+    if (track->par->codec_id == AV_CODEC_ID_QDMC) {
+        /* Extradata already contains the complete wave atom payload. */
+        mov_write_extradata_tag(pb, track);
+        return update_size(pb, pos);
+    }
+
     if (track->par->codec_id != AV_CODEC_ID_QDM2) {
         avio_wb32(pb, 12);    /* size */
         ffio_wfourcc(pb, "frma");
@@ -1581,6 +1587,7 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
          track->par->codec_id == AV_CODEC_ID_ADPCM_MS      ||
          track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
          track->par->codec_id == AV_CODEC_ID_QDM2          ||
+         track->par->codec_id == AV_CODEC_ID_QDMC          ||
          (mov_pcm_le_gt16(track->par->codec_id) && version==1) ||
          (mov_pcm_be_gt16(track->par->codec_id) && version==1)))
         ret = mov_write_wave_tag(s, pb, track);
-- 
2.54.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to