[FFmpeg-cvslog] r10322 - trunk/libavformat/matroskaenc.c

conrad subversion
Wed Sep 5 02:23:31 CEST 2007


Author: conrad
Date: Wed Sep  5 02:23:31 2007
New Revision: 10322

Log:
Write bit depth for PCM audio


Modified:
   trunk/libavformat/matroskaenc.c

Modified: trunk/libavformat/matroskaenc.c
==============================================================================
--- trunk/libavformat/matroskaenc.c	(original)
+++ trunk/libavformat/matroskaenc.c	Wed Sep  5 02:23:31 2007
@@ -366,6 +366,7 @@ static int mkv_write_tracks(AVFormatCont
         AVCodecContext *codec = st->codec;
         offset_t subinfo, track;
         int native_id = 0;
+        int bit_depth = 0;
 
         track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY);
         put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER     , i + 1);
@@ -384,6 +385,19 @@ static int mkv_write_tracks(AVFormatCont
             }
         }
 
+        switch (codec->codec_id) {
+            case CODEC_ID_PCM_S16LE:
+            case CODEC_ID_PCM_S16BE:
+            case CODEC_ID_PCM_U16LE:
+            case CODEC_ID_PCM_U16BE:
+                bit_depth = 16;
+                break;
+            case CODEC_ID_PCM_S8:
+            case CODEC_ID_PCM_U8:
+                bit_depth = 8;
+                break;
+        }
+
         // XXX: CodecPrivate for vorbis, theora, aac, native mpeg4, ...
         if (native_id) {
             if (codec->codec_id == CODEC_ID_VORBIS || codec->codec_id == CODEC_ID_THEORA) {
@@ -438,7 +452,9 @@ static int mkv_write_tracks(AVFormatCont
                 subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO);
                 put_ebml_uint  (pb, MATROSKA_ID_AUDIOCHANNELS    , codec->channels);
                 put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, codec->sample_rate);
-                // XXX: output sample freq (for sbr) and bitdepth (for pcm)
+                // XXX: output sample freq (for sbr)
+                if (bit_depth)
+                    put_ebml_uint(pb, MATROSKA_ID_AUDIOBITDEPTH, bit_depth);
                 end_ebml_master(pb, subinfo);
                 break;
 




More information about the ffmpeg-cvslog mailing list