Commit f47a25fa38 for ffmpeg
commit f47a25fa3881f32f2677d40c151538f97f14f871
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Wed Nov 18 13:38:34 2026 -0800
avformat/mov: explain the QCELP frame size defaults
Every QCELP frame is 160 samples; version 0 sound descriptions store no byte size.
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6d31dc729a..f2fb4c77a2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3357,8 +3357,9 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
// force sample rate for qcelp when not stored in mov
if (st->codecpar->codec_tag != MKTAG('Q','c','l','p'))
st->codecpar->sample_rate = 8000;
- // FIXME: Why is the following needed for some files?
+ // Each QCELP frame decodes to 160 samples at every coding rate.
sc->samples_per_frame = 160;
+ // Assume a full-rate frame when the byte count is unset, as in version 0.
if (!sc->bytes_per_frame)
sc->bytes_per_frame = 35;
break;
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 3d571b184a..3af9918279 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -56,6 +56,11 @@ fate-mov-vpcc-reserved-color-tags: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -v erro
FATE_MOV-$(call DEMDEC, MOV, RAWVIDEO) += fate-mov-uncv-rgb24
fate-mov-uncv-rgb24: CMD = framecrc -i $(TARGET_SAMPLES)/mov/uncv-rgb24.mp4
+# Qclp with a version 0 sound description, no frame size stored;
+# 30 packets cross the first 25-packet chunk
+FATE_MOV-$(call DEMMUX, MOV, FRAMECRC, PIPE_PROTOCOL) += fate-mov-qclp-stsd-v0
+fate-mov-qclp-stsd-v0: CMD = framecrc -i $(TARGET_SAMPLES)/mov/clip43qt3-hi.mov -map 0:a -c copy -frames:a 30
+
FATE_MOV_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-ffprobe-stream-entries-tmcd \
fate-ffprobe-group-stream-entries-tmcd \
fate-ffprobe-show-groups-tmcd
diff --git a/tests/ref/fate/mov-qclp-stsd-v0 b/tests/ref/fate/mov-qclp-stsd-v0
new file mode 100644
index 0000000000..44a9c13030
--- /dev/null
+++ b/tests/ref/fate/mov-qclp-stsd-v0
@@ -0,0 +1,35 @@
+#tb 0: 1/8000
+#media_type 0: audio
+#codec_id 0: qcelp
+#sample_rate 0: 8000
+#channel_layout_name 0: mono
+0, 0, 0, 160, 35, 0xf0ba0d31
+0, 160, 160, 160, 35, 0x1a430f07
+0, 320, 320, 160, 35, 0x29f70f3f
+0, 480, 480, 160, 35, 0x3f3f1204
+0, 640, 640, 160, 35, 0xf6ee0e93
+0, 800, 800, 160, 35, 0x36a41050
+0, 960, 960, 160, 35, 0x1eb71035
+0, 1120, 1120, 160, 35, 0x1bec0f5c
+0, 1280, 1280, 160, 35, 0x3aa61183
+0, 1440, 1440, 160, 35, 0x2dac10ab
+0, 1600, 1600, 160, 35, 0x23dc0f9a
+0, 1760, 1760, 160, 35, 0x4d19126d
+0, 1920, 1920, 160, 35, 0xf4db0e57
+0, 2080, 2080, 160, 35, 0x13b70fe2
+0, 2240, 2240, 160, 35, 0x40d01181
+0, 2400, 2400, 160, 35, 0x086c0e99
+0, 2560, 2560, 160, 35, 0x2f881052
+0, 2720, 2720, 160, 35, 0x2a88110d
+0, 2880, 2880, 160, 35, 0x2ab9112f
+0, 3040, 3040, 160, 35, 0x108a1077
+0, 3200, 3200, 160, 35, 0x3e39118f
+0, 3360, 3360, 160, 35, 0x2a20116c
+0, 3520, 3520, 160, 35, 0x3bd31210
+0, 3680, 3680, 160, 35, 0x59961331
+0, 3840, 3840, 160, 35, 0x4e0611e8
+0, 4000, 4000, 160, 35, 0x49f0116a
+0, 4160, 4160, 160, 35, 0x163e10ea
+0, 4320, 4320, 160, 35, 0x4be11399
+0, 4480, 4480, 160, 35, 0x15dd1011
+0, 4640, 4640, 160, 35, 0x1a400f31