Forged a TTA1 header in matroska if not present.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 28 Jun 2009 21:07:03 +0000 (23:07 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 28 Jun 2009 21:07:54 +0000 (23:07 +0200)
modules/demux/mkv/matroska_segment.cpp

index 0884678..1a60e83 100644 (file)
@@ -989,10 +989,30 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
         }
         else if( !strcmp( tracks[i_track]->psz_codec, "A_TTA1" ) )
         {
-            tracks[i_track]->fmt.i_codec = VLC_CODEC_TTA;
-            tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
-            tracks[i_track]->fmt.p_extra = malloc( tracks[i_track]->i_extra_data );
-            memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
+            p_fmt->i_codec = VLC_CODEC_TTA;
+            p_fmt->i_extra = p_tk->i_extra_data;
+            if( p_fmt->i_extra > 0 )
+            {
+                p_fmt->p_extra = malloc( p_tk->i_extra_data );
+                if( !p_fmt->p_extra )
+                    abort();
+                memcpy( p_fmt->p_extra, p_tk->p_extra_data, p_tk->i_extra_data );
+            }
+            else
+            {
+                p_fmt->i_extra = 30;
+                p_fmt->p_extra = malloc( p_fmt->i_extra );
+                if( !p_fmt->p_extra )
+                    abort();
+                uint8_t *p_extra = (uint8_t*)p_fmt->p_extra;
+                memcpy( &p_extra[ 0], "TTA1", 4 );
+                SetWLE( &p_extra[ 4], 1 );
+                SetWLE( &p_extra[ 6], p_fmt->audio.i_channels );
+                SetWLE( &p_extra[ 8], p_fmt->audio.i_bitspersample );
+                SetDWLE( &p_extra[10], p_fmt->audio.i_rate );
+                SetDWLE( &p_extra[14], 0xffffffff );
+                memset( &p_extra[18], 0, 30  - 18 );
+            }
         }
         else if( !strcmp( tracks[i_track]->psz_codec, "A_PCM/INT/BIG" ) ||
                  !strcmp( tracks[i_track]->psz_codec, "A_PCM/INT/LIT" ) ||