[FFmpeg-devel] [PATCH] lavf/mov: Fix PCM audio w/ bit depth > 16

John Stebbins jstebbins at jetheaddev.com
Mon Aug 27 22:59:28 EEST 2018


This type of audio is defined by the QT spec, but can be found in
non-QT branded files in the wild.

Fixes ticket #7376
---
 libavformat/mov.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8915e3b9e0..3d4f6bcb21 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2100,6 +2100,18 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
     }
 }
 
+static int mov_pcm_gt16(enum AVCodecID codec_id)
+{
+    return codec_id == AV_CODEC_ID_PCM_S24LE ||
+           codec_id == AV_CODEC_ID_PCM_S32LE ||
+           codec_id == AV_CODEC_ID_PCM_F32LE ||
+           codec_id == AV_CODEC_ID_PCM_F64LE ||
+           codec_id == AV_CODEC_ID_PCM_S24BE ||
+           codec_id == AV_CODEC_ID_PCM_S32BE ||
+           codec_id == AV_CODEC_ID_PCM_F32BE ||
+           codec_id == AV_CODEC_ID_PCM_F64BE;
+}
+
 static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
                                  AVStream *st, MOVStreamContext *sc)
 {
@@ -2120,8 +2132,10 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
     st->codecpar->sample_rate = ((avio_rb32(pb) >> 16));
 
     // Read QT version 1 fields. In version 0 these do not exist.
+    // PCM with bitdepth > 16 is only defined by QT version 1.
     av_log(c->fc, AV_LOG_TRACE, "version =%d, isom =%d\n", version, c->isom);
     if (!c->isom ||
+        mov_pcm_gt16(st->codecpar->codec_id) ||
         (compatible_brands && strstr(compatible_brands->value, "qt  "))) {
 
         if (version == 1) {
-- 
2.17.1



More information about the ffmpeg-devel mailing list