]> git.sesse.net Git - ffmpeg/commitdiff
matroskaenc: set the actual PCM bitdepth in the header
authorHendrik Leppkes <h.leppkes@gmail.com>
Wed, 16 Mar 2016 11:39:19 +0000 (12:39 +0100)
committerHendrik Leppkes <h.leppkes@gmail.com>
Wed, 16 Mar 2016 11:52:35 +0000 (12:52 +0100)
The actual bitdepth can be different to the storage format (ie. sample format).
Fixes the stored bitdepth for 24-bit formats like FLAC.

libavformat/matroskaenc.c

index 05b1b94f64c0db368cfdc0523d9fed8c87b83c15..6ad9aed538bb134eaf32e8a344792e6f677e7a32 100644 (file)
@@ -850,8 +850,12 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
         return 0;
     }
 
-    if (!bit_depth && codec->codec_id != AV_CODEC_ID_ADPCM_G726)
-        bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
+    if (!bit_depth && codec->codec_id != AV_CODEC_ID_ADPCM_G726) {
+        if (codec->bits_per_raw_sample)
+            bit_depth = codec->bits_per_raw_sample;
+        else
+            bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
+    }
     if (!bit_depth)
         bit_depth = codec->bits_per_coded_sample;