avformat/sierravmd: Support for Shivers 2 stereo tracks
authorNicolas Roy-Renaud <nicolas.roy-renaud.1@ens.etsmtl.ca>
Sat, 18 Feb 2017 03:50:11 +0000 (22:50 -0500)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 21 Feb 2017 18:05:04 +0000 (19:05 +0100)
Signed-off-by: Nicolas Roy-Renaud <nicolas.roy-renaud.1@ens.etsmtl.ca>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/sierravmd.c

index 734a3f2..6960c28 100644 (file)
@@ -142,13 +142,6 @@ static int vmd_read_header(AVFormatContext *s)
         st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
         st->codecpar->codec_id   = AV_CODEC_ID_VMDAUDIO;
         st->codecpar->codec_tag  = 0;  /* no fourcc */
-        if (vmd->vmd_header[811] & 0x80) {
-            st->codecpar->channels       = 2;
-            st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
-        } else {
-            st->codecpar->channels       = 1;
-            st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
-        }
         st->codecpar->sample_rate = vmd->sample_rate;
         st->codecpar->block_align = AV_RL16(&vmd->vmd_header[806]);
         if (st->codecpar->block_align & 0x8000) {
@@ -157,6 +150,19 @@ static int vmd_read_header(AVFormatContext *s)
         } else {
             st->codecpar->bits_per_coded_sample = 8;
         }
+        if (vmd->vmd_header[811] & 0x80) {
+            st->codecpar->channels       = 2;
+            st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+        } else if (vmd->vmd_header[811] & 0x2) {
+            /* Shivers 2 stereo audio */
+            /* Frame length is for 1 channel */
+            st->codecpar->channels       = 2;
+            st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+            st->codecpar->block_align = st->codecpar->block_align << 1;
+        } else {
+            st->codecpar->channels       = 1;
+            st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+        }
         st->codecpar->bit_rate = st->codecpar->sample_rate *
             st->codecpar->bits_per_coded_sample * st->codecpar->channels;