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

QDM2 and QDMC packets always decode to the same number of samples, but that 
number depends on the extradata, so only the decoder knows it. Setting 
`frame_size` lets the demuxer apply the MOV end trim.

`surge-2-16-B-QDM2.mov` now decodes to 565215 frames instead of 565248, which 
matches `afinfo` (565215 valid + 33 remainder).

This also lets the CAF muxer get the frames per packet from `frame_size` 
instead of its hard-coded table 
(https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25985).

FATE: `fate-qdm2` uses a new reference, 
`qt-surge-suite/surge-2-16-B-QDM2-trimmed.pcm` (2260860 bytes, md5 
6f50186b3220ef667b4bd8ddc91fd090). It is already uploaded to fate-suite. The 
old `.pcm` is unchanged, so older releases keep passing. No FATE sample covers 
QDMC.

🤖 Generated with [Claude Code](https://claude.com/claude-code)



From 3a5a97050e9d629b7ce79f7f455b4e8a094890a3 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Wed, 18 Nov 2026 13:01:42 -0800
Subject: [PATCH] avcodec/qdm2,qdmc: set frame_size

Lets the demuxer apply the MOV end trim; fate-qdm2 now matches afinfo's 565215 
frames.

Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavcodec/qdm2.c | 1 +
 libavcodec/qdmc.c | 1 +
 tests/fate/qt.mak | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index 796321f9d8e..df0a6622dc3 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -1789,6 +1789,7 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
 
     if (s->frame_size > QDM2_MAX_FRAME_SIZE)
         return AVERROR_INVALIDDATA;
+    avctx->frame_size = 16 * s->frame_size;
 
     s->sub_sampling = s->fft_order - 7;
     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index 474e5ef8faa..ebd70aecab2 100644
--- a/libavcodec/qdmc.c
+++ b/libavcodec/qdmc.c
@@ -280,6 +280,7 @@ static av_cold int qdmc_decode_init(AVCodecContext *avctx)
         s->frame_bits = 11;
     }
     s->frame_size = 1 << s->frame_bits;
+    avctx->frame_size = s->frame_size;
     s->subframe_size = s->frame_size >> 5;
 
     if (avctx->ch_layout.nb_channels == 2)
diff --git a/tests/fate/qt.mak b/tests/fate/qt.mak
index 436da172f1a..d9874b26ce2 100644
--- a/tests/fate/qt.mak
+++ b/tests/fate/qt.mak
@@ -4,7 +4,7 @@ fate-8bps: CMD = framecrc -i 
$(TARGET_SAMPLES)/8bps/full9iron-partial.mov -pix_f
 FATE_QT-$(call ENCDEC, PCM_S16LE QDM2, PCM_S16LE MOV, PIPE_PROTOCOL) += 
fate-qdm2
 fate-qdm2: CMD = pcm -i $(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.mov
 fate-qdm2: CMP = oneoff
-fate-qdm2: REF = $(SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.pcm
+fate-qdm2: REF = $(SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2-trimmed.pcm
 fate-qdm2: FUZZ = 2
 
 FATE_QT-$(call ENCDEC, PCM_S16LE PCM_ALAW, MOV PCM_S16LE) += fate-qt-alaw-mono
-- 
2.54.1

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

Reply via email to