Since mkvmerge doesn't set the bit depth for A_QUICKTIME audio (as far as I know), the track->audio.bitdepth variable will be zero, and its value needs to be retrieved from the sound sample description. Also, confine the 0x00000000 to 'raw '/'twos' fourcc mapping to old version 0 sound sample descriptions, since they are the only valid sample descriptions for this type of mapping.

Mats
>From 5c0635522f888ec208588215dc3d4a13dabe1018 Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Wed, 13 Jan 2016 00:06:52 +0100
Subject: [PATCH] lavf/matroskadec: Set A_QUICKTIME bit depth

Since mkvmerge doesn't set the bit depth for A_QUICKTIME audio (as far
as I know), the track->audio.bitdepth variable will be zero, and its
value needs to be retrieved from the sound sample description. Also,
confine the 0x00000000 to 'raw '/'twos' fourcc mapping to old version 0
sound sample descriptions, since they are the only valid sample
descriptions for this type of mapping.

---
 libavformat/matroskadec.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index cc5ec19..89bc68e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1891,16 +1891,23 @@ static int matroska_parse_tracks(AVFormatContext *s)
                    /* Normally 36, but allow noncompliant private data */
                    && (track->codec_priv.size >= 32)
                    && (track->codec_priv.data)) {
+            uint16_t stsd_version;
             int ret = get_qt_codec(track, &fourcc, &codec_id);
             if (ret < 0)
                 return ret;
-            if (fourcc == 0) {
-                if (track->audio.bitdepth == 8) {
-                    fourcc = MKTAG('r','a','w',' ');
-                    codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
-                } else if (track->audio.bitdepth == 16) {
-                    fourcc = MKTAG('t','w','o','s');
-                    codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
+            stsd_version = AV_RB16(track->codec_priv.data + 16);
+            if (stsd_version == 0) {
+                /* Currently not set by mkvmerge, so get the bit depth
+                 * from the sample description. */
+                track->audio.bitdepth = AV_RB16(track->codec_priv.data + 26);
+                if (fourcc == 0) {
+                    if (track->audio.bitdepth == 8) {
+                        fourcc = MKTAG('r','a','w',' ');
+                        codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
+                    } else if (track->audio.bitdepth == 16) {
+                        fourcc = MKTAG('t','w','o','s');
+                        codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
+                    }
                 }
             }
         } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to