]> git.sesse.net Git - vlc/blobdiff - modules/demux/mkv.cpp
* modules/codec/dvbsub.c: disabled translation of some internal error messages
[vlc] / modules / demux / mkv.cpp
index a11c5b926863222c84d9e01841502f667cc95042..d0d4374b95f428e6244c05f6de6fa0ca4a89b19a 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * mkv.cpp : matroska demuxer
  *****************************************************************************
- * Copyright (C) 2001 VideoLAN
- * $Id: mkv.cpp,v 1.40 2003/11/16 21:07:31 gbazin Exp $
+ * Copyright (C) 2003-2004 VideoLAN
+ * $Id: mkv.cpp,v 1.58 2004/03/02 13:53:14 kuehne Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -91,14 +91,14 @@ static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
 vlc_module_begin();
-    add_category_hint( N_("mkv-demuxer"), NULL, VLC_TRUE );
-        add_bool( "mkv-seek-percent", 1, NULL,
-                  N_("Seek based on percent not time"),
-                  N_("Seek based on percent not time"), VLC_TRUE );
-
-    set_description( _("mka/mkv stream demuxer" ) );
+    set_description( _("Matroska stream demuxer" ) );
     set_capability( "demux", 50 );
     set_callbacks( Open, Close );
+    
+    add_bool( "mkv-seek-percent", 1, NULL,
+            N_("Seek based on percent not time"),
+            N_("Seek based on percent not time"), VLC_TRUE );
+
     add_shortcut( "mka" );
     add_shortcut( "mkv" );
 vlc_module_end();
@@ -197,7 +197,6 @@ typedef struct
     vlc_bool_t      b_search_keyframe;
 
     /* informative */
-    char         *psz_name;
     char         *psz_codec_name;
     char         *psz_codec_settings;
     char         *psz_codec_info_url;
@@ -263,8 +262,6 @@ static char *UTF8ToStr          ( const UTFstring &u );
 static void LoadCues            ( input_thread_t *);
 static void InformationsCreate  ( input_thread_t *p_input );
 
-static char *LanguageGetName    ( const char *psz_code );
-
 /*****************************************************************************
  * Open: initializes matroska demux structures
  *****************************************************************************/
@@ -475,6 +472,7 @@ static int Open( vlc_object_t * p_this )
 
                     es_format_Init( &tk.fmt, UNKNOWN_ES, 0 );
                     tk.fmt.psz_language = strdup("English");
+                    tk.fmt.psz_description = NULL;
 
                     tk.b_default = VLC_TRUE;
                     tk.b_enabled = VLC_TRUE;
@@ -489,7 +487,6 @@ static int Open( vlc_object_t * p_this )
                     tk.i_data_init = 0;
                     tk.p_data_init = NULL;
 
-                    tk.psz_name = NULL;
                     tk.psz_codec_name = NULL;
                     tk.psz_codec_settings = NULL;
                     tk.psz_codec_info_url = NULL;
@@ -544,15 +541,15 @@ static int Open( vlc_object_t * p_this )
                             msg_Dbg( p_input, "|   |   |   + Track Type=%s",
                                      psz_type );
                         }
-                        else  if( EbmlId( *el3 ) == KaxTrackFlagEnabled::ClassInfos.GlobalId )
-                        {
-                            KaxTrackFlagEnabled &fenb = *(KaxTrackFlagEnabled*)el3;
-                            fenb.ReadData( p_sys->es->I_O() );
-
-                            tk.b_enabled = uint32( fenb );
-                            msg_Dbg( p_input, "|   |   |   + Track Enabled=%u",
-                                     uint32( fenb )  );
-                        }
+//                         else  if( EbmlId( *el3 ) == KaxTrackFlagEnabled::ClassInfos.GlobalId )
+//                         {
+//                             KaxTrackFlagEnabled &fenb = *(KaxTrackFlagEnabled*)el3;
+//                             fenb.ReadData( p_sys->es->I_O() );
+
+//                             tk.b_enabled = uint32( fenb );
+//                             msg_Dbg( p_input, "|   |   |   + Track Enabled=%u",
+//                                      uint32( fenb )  );
+//                         }
                         else  if( EbmlId( *el3 ) == KaxTrackFlagDefault::ClassInfos.GlobalId )
                         {
                             KaxTrackFlagDefault &fdef = *(KaxTrackFlagDefault*)el3;
@@ -607,20 +604,19 @@ static int Open( vlc_object_t * p_this )
                             KaxTrackName &tname = *(KaxTrackName*)el3;
                             tname.ReadData( p_sys->es->I_O() );
 
-                            tk.psz_name = UTF8ToStr( UTFstring( tname ) );
+                            tk.fmt.psz_description = UTF8ToStr( UTFstring( tname ) );
                             msg_Dbg( p_input, "|   |   |   + Track Name=%s",
-                                     tk.psz_name );
+                                     tk.fmt.psz_description );
                         }
                         else  if( EbmlId( *el3 ) == KaxTrackLanguage::ClassInfos.GlobalId )
                         {
                             KaxTrackLanguage &lang = *(KaxTrackLanguage*)el3;
                             lang.ReadData( p_sys->es->I_O() );
 
-                            tk.fmt.psz_language =
-                                LanguageGetName( string( lang ).c_str() );
+                            tk.fmt.psz_language = strdup( string( lang ).c_str() );
                             msg_Dbg( p_input,
-                                     "|   |   |   + Track Language=`%s'(%s) ",
-                                     tk.fmt.psz_language, string( lang ).c_str() );
+                                     "|   |   |   + Track Language=`%s'",
+                                     tk.fmt.psz_language );
                         }
                         else  if( EbmlId( *el3 ) == KaxCodecID::ClassInfos.GlobalId )
                         {
@@ -634,7 +630,7 @@ static int Open( vlc_object_t * p_this )
                         else  if( EbmlId( *el3 ) == KaxCodecPrivate::ClassInfos.GlobalId )
                         {
                             KaxCodecPrivate &cpriv = *(KaxCodecPrivate*)el3;
-                            cpriv.ReadData( p_sys->es->I_O() );
+                            cpriv.ReadData( p_sys->es->I_O(), SCOPE_ALL_DATA );
 
                             tk.i_extra_data = cpriv.GetSize();
                             if( tk.i_extra_data > 0 )
@@ -652,44 +648,44 @@ static int Open( vlc_object_t * p_this )
                             tk.psz_codec_name = UTF8ToStr( UTFstring( cname ) );
                             msg_Dbg( p_input, "|   |   |   + Track Codec Name=%s", tk.psz_codec_name );
                         }
-                        else if( EbmlId( *el3 ) == KaxCodecSettings::ClassInfos.GlobalId )
-                        {
-                            KaxCodecSettings &cset = *(KaxCodecSettings*)el3;
-                            cset.ReadData( p_sys->es->I_O() );
-
-                            tk.psz_codec_settings = UTF8ToStr( UTFstring( cset ) );
-                            msg_Dbg( p_input, "|   |   |   + Track Codec Settings=%s", tk.psz_codec_settings );
-                        }
-                        else if( EbmlId( *el3 ) == KaxCodecInfoURL::ClassInfos.GlobalId )
-                        {
-                            KaxCodecInfoURL &ciurl = *(KaxCodecInfoURL*)el3;
-                            ciurl.ReadData( p_sys->es->I_O() );
-
-                            tk.psz_codec_info_url = strdup( string( ciurl ).c_str() );
-                            msg_Dbg( p_input, "|   |   |   + Track Codec Info URL=%s", tk.psz_codec_info_url );
-                        }
-                        else if( EbmlId( *el3 ) == KaxCodecDownloadURL::ClassInfos.GlobalId )
-                        {
-                            KaxCodecDownloadURL &cdurl = *(KaxCodecDownloadURL*)el3;
-                            cdurl.ReadData( p_sys->es->I_O() );
-
-                            tk.psz_codec_download_url = strdup( string( cdurl ).c_str() );
-                            msg_Dbg( p_input, "|   |   |   + Track Codec Info URL=%s", tk.psz_codec_download_url );
-                        }
-                        else if( EbmlId( *el3 ) == KaxCodecDecodeAll::ClassInfos.GlobalId )
-                        {
-                            KaxCodecDecodeAll &cdall = *(KaxCodecDecodeAll*)el3;
-                            cdall.ReadData( p_sys->es->I_O() );
-
-                            msg_Dbg( p_input, "|   |   |   + Track Codec Decode All=%u <== UNUSED", uint8( cdall ) );
-                        }
-                        else if( EbmlId( *el3 ) == KaxTrackOverlay::ClassInfos.GlobalId )
-                        {
-                            KaxTrackOverlay &tovr = *(KaxTrackOverlay*)el3;
-                            tovr.ReadData( p_sys->es->I_O() );
-
-                            msg_Dbg( p_input, "|   |   |   + Track Overlay=%u <== UNUSED", uint32( tovr ) );
-                        }
+//                         else if( EbmlId( *el3 ) == KaxCodecSettings::ClassInfos.GlobalId )
+//                         {
+//                             KaxCodecSettings &cset = *(KaxCodecSettings*)el3;
+//                             cset.ReadData( p_sys->es->I_O() );
+
+//                             tk.psz_codec_settings = UTF8ToStr( UTFstring( cset ) );
+//                             msg_Dbg( p_input, "|   |   |   + Track Codec Settings=%s", tk.psz_codec_settings );
+//                         }
+//                         else if( EbmlId( *el3 ) == KaxCodecInfoURL::ClassInfos.GlobalId )
+//                         {
+//                             KaxCodecInfoURL &ciurl = *(KaxCodecInfoURL*)el3;
+//                             ciurl.ReadData( p_sys->es->I_O() );
+
+//                             tk.psz_codec_info_url = strdup( string( ciurl ).c_str() );
+//                             msg_Dbg( p_input, "|   |   |   + Track Codec Info URL=%s", tk.psz_codec_info_url );
+//                         }
+//                         else if( EbmlId( *el3 ) == KaxCodecDownloadURL::ClassInfos.GlobalId )
+//                         {
+//                             KaxCodecDownloadURL &cdurl = *(KaxCodecDownloadURL*)el3;
+//                             cdurl.ReadData( p_sys->es->I_O() );
+
+//                             tk.psz_codec_download_url = strdup( string( cdurl ).c_str() );
+//                             msg_Dbg( p_input, "|   |   |   + Track Codec Info URL=%s", tk.psz_codec_download_url );
+//                         }
+//                         else if( EbmlId( *el3 ) == KaxCodecDecodeAll::ClassInfos.GlobalId )
+//                         {
+//                             KaxCodecDecodeAll &cdall = *(KaxCodecDecodeAll*)el3;
+//                             cdall.ReadData( p_sys->es->I_O() );
+
+//                             msg_Dbg( p_input, "|   |   |   + Track Codec Decode All=%u <== UNUSED", uint8( cdall ) );
+//                         }
+//                         else if( EbmlId( *el3 ) == KaxTrackOverlay::ClassInfos.GlobalId )
+//                         {
+//                             KaxTrackOverlay &tovr = *(KaxTrackOverlay*)el3;
+//                             tovr.ReadData( p_sys->es->I_O() );
+
+//                             msg_Dbg( p_input, "|   |   |   + Track Overlay=%u <== UNUSED", uint32( tovr ) );
+//                         }
                         else  if( EbmlId( *el3 ) == KaxTrackVideo::ClassInfos.GlobalId )
                         {
                             msg_Dbg( p_input, "|   |   |   + Track Video" );
@@ -699,21 +695,22 @@ static int Open( vlc_object_t * p_this )
 
                             while( ( el4 = p_sys->ep->Get() ) != NULL )
                             {
-                                if( EbmlId( *el4 ) == KaxVideoFlagInterlaced::ClassInfos.GlobalId )
-                                {
-                                    KaxVideoFlagInterlaced &fint = *(KaxVideoFlagInterlaced*)el4;
-                                    fint.ReadData( p_sys->es->I_O() );
-
-                                    msg_Dbg( p_input, "|   |   |   |   + Track Video Interlaced=%u", uint8( fint ) );
-                                }
-                                else if( EbmlId( *el4 ) == KaxVideoStereoMode::ClassInfos.GlobalId )
-                                {
-                                    KaxVideoStereoMode &stereo = *(KaxVideoStereoMode*)el4;
-                                    stereo.ReadData( p_sys->es->I_O() );
-
-                                    msg_Dbg( p_input, "|   |   |   |   + Track Video Stereo Mode=%u", uint8( stereo ) );
-                                }
-                                else if( EbmlId( *el4 ) == KaxVideoPixelWidth::ClassInfos.GlobalId )
+//                                 if( EbmlId( *el4 ) == KaxVideoFlagInterlaced::ClassInfos.GlobalId )
+//                                 {
+//                                     KaxVideoFlagInterlaced &fint = *(KaxVideoFlagInterlaced*)el4;
+//                                     fint.ReadData( p_sys->es->I_O() );
+
+//                                     msg_Dbg( p_input, "|   |   |   |   + Track Video Interlaced=%u", uint8( fint ) );
+//                                 }
+//                                 else if( EbmlId( *el4 ) == KaxVideoStereoMode::ClassInfos.GlobalId )
+//                                 {
+//                                     KaxVideoStereoMode &stereo = *(KaxVideoStereoMode*)el4;
+//                                     stereo.ReadData( p_sys->es->I_O() );
+
+//                                     msg_Dbg( p_input, "|   |   |   |   + Track Video Stereo Mode=%u", uint8( stereo ) );
+//                                 }
+//                                 else 
+                              if( EbmlId( *el4 ) == KaxVideoPixelWidth::ClassInfos.GlobalId )
                                 {
                                     KaxVideoPixelWidth &vwidth = *(KaxVideoPixelWidth*)el4;
                                     vwidth.ReadData( p_sys->es->I_O() );
@@ -753,28 +750,28 @@ static int Open( vlc_object_t * p_this )
                                     tk.f_fps = float( vfps );
                                     msg_Dbg( p_input, "   |   |   |   + fps=%f", float( vfps ) );
                                 }
-                                else if( EbmlId( *el4 ) == KaxVideoDisplayUnit::ClassInfos.GlobalId )
-                                {
-                                     KaxVideoDisplayUnit &vdmode = *(KaxVideoDisplayUnit*)el4;
-                                    vdmode.ReadData( p_sys->es->I_O() );
-
-                                    msg_Dbg( p_input, "|   |   |   |   + Track Video Display Unit=%s",
-                                             uint8( vdmode ) == 0 ? "pixels" : ( uint8( vdmode ) == 1 ? "centimeters": "inches" ) );
-                                }
-                                else if( EbmlId( *el4 ) == KaxVideoAspectRatio::ClassInfos.GlobalId )
-                                {
-                                    KaxVideoAspectRatio &ratio = *(KaxVideoAspectRatio*)el4;
-                                    ratio.ReadData( p_sys->es->I_O() );
-
-                                    msg_Dbg( p_input, "   |   |   |   + Track Video Aspect Ratio Type=%u", uint8( ratio ) );
-                                }
-                                else if( EbmlId( *el4 ) == KaxVideoGamma::ClassInfos.GlobalId )
-                                {
-                                    KaxVideoGamma &gamma = *(KaxVideoGamma*)el4;
-                                    gamma.ReadData( p_sys->es->I_O() );
-
-                                    msg_Dbg( p_input, "   |   |   |   + fps=%f", float( gamma ) );
-                                }
+//                                 else if( EbmlId( *el4 ) == KaxVideoDisplayUnit::ClassInfos.GlobalId )
+//                                 {
+//                                      KaxVideoDisplayUnit &vdmode = *(KaxVideoDisplayUnit*)el4;
+//                                     vdmode.ReadData( p_sys->es->I_O() );
+
+//                                     msg_Dbg( p_input, "|   |   |   |   + Track Video Display Unit=%s",
+//                                              uint8( vdmode ) == 0 ? "pixels" : ( uint8( vdmode ) == 1 ? "centimeters": "inches" ) );
+//                                 }
+//                                 else if( EbmlId( *el4 ) == KaxVideoAspectRatio::ClassInfos.GlobalId )
+//                                 {
+//                                     KaxVideoAspectRatio &ratio = *(KaxVideoAspectRatio*)el4;
+//                                     ratio.ReadData( p_sys->es->I_O() );
+
+//                                     msg_Dbg( p_input, "   |   |   |   + Track Video Aspect Ratio Type=%u", uint8( ratio ) );
+//                                 }
+//                                 else if( EbmlId( *el4 ) == KaxVideoGamma::ClassInfos.GlobalId )
+//                                 {
+//                                     KaxVideoGamma &gamma = *(KaxVideoGamma*)el4;
+//                                     gamma.ReadData( p_sys->es->I_O() );
+
+//                                     msg_Dbg( p_input, "   |   |   |   + fps=%f", float( gamma ) );
+//                                 }
                                 else
                                 {
                                     msg_Dbg( p_input, "|   |   |   |   + Unknown (%s)", typeid(*el4).name() );
@@ -857,7 +854,7 @@ static int Open( vlc_object_t * p_this )
                         {
                             KaxSeekID &sid = *(KaxSeekID*)el;
 
-                            sid.ReadData( p_sys->es->I_O() );
+                            sid.ReadData( p_sys->es->I_O(), SCOPE_ALL_DATA );
 
                             id = EbmlId( sid.GetBuffer(), sid.GetSize() );
                         }
@@ -865,7 +862,7 @@ static int Open( vlc_object_t * p_this )
                         {
                             KaxSeekPosition &spos = *(KaxSeekPosition*)el;
 
-                            spos.ReadData( p_sys->es->I_O() );
+                            spos.ReadData( p_sys->es->I_O(), SCOPE_ALL_DATA );
 
                             i_pos = uint64( spos );
                         }
@@ -1029,7 +1026,6 @@ static int Open( vlc_object_t * p_this )
                 tk.fmt.video.i_height= GetDWLE( &p_bih->biHeight );
                 tk.fmt.i_codec       = GetFOURCC( &p_bih->biCompression );
 
-                tk.fmt.i_extra_type  = ES_EXTRA_TYPE_BITMAPINFOHEADER;
                 tk.fmt.i_extra       = GetDWLE( &p_bih->biSize ) - sizeof( BITMAPINFOHEADER );
                 if( tk.fmt.i_extra > 0 )
                 {
@@ -1069,7 +1065,7 @@ static int Open( vlc_object_t * p_this )
 
                 tk.fmt.audio.i_channels   = GetWLE( &p_wf->nChannels );
                 tk.fmt.audio.i_rate = GetDWLE( &p_wf->nSamplesPerSec );
-                tk.fmt.audio.i_bitrate    = GetDWLE( &p_wf->nAvgBytesPerSec ) * 8;
+                tk.fmt.i_bitrate    = GetDWLE( &p_wf->nAvgBytesPerSec ) * 8;
                 tk.fmt.audio.i_blockalign = GetWLE( &p_wf->nBlockAlign );;
                 tk.fmt.audio.i_bitspersample = GetWLE( &p_wf->wBitsPerSample );
 
@@ -1095,6 +1091,13 @@ static int Open( vlc_object_t * p_this )
         {
             tk.fmt.i_codec = VLC_FOURCC( 'd', 't', 's', ' ' );
         }
+        else if( !strcmp( tk.psz_codec, "A_FLAC" ) )
+        {
+            tk.fmt.i_codec = VLC_FOURCC( 'f', 'l', 'a', 'c' );
+            tk.fmt.i_extra = tk.i_extra_data;
+            tk.fmt.p_extra = malloc( tk.i_extra_data );
+            memcpy( tk.fmt.p_extra,tk.p_extra_data, tk.i_extra_data );
+        }
         else if( !strcmp( tk.psz_codec, "A_VORBIS" ) )
         {
             tk.fmt.i_codec = VLC_FOURCC( 'v', 'o', 'r', 'b' );
@@ -1105,7 +1108,7 @@ static int Open( vlc_object_t * p_this )
                  !strncmp( tk.psz_codec, "A_AAC/MPEG4/", strlen( "A_AAC/MPEG4/" ) ) )
         {
             int i_profile, i_srate;
-            static int i_sample_rates[] =
+            static unsigned int i_sample_rates[] =
             {
                     96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
                         16000, 12000, 11025, 8000,  7350,  0,     0,     0
@@ -1214,6 +1217,10 @@ static void Close( vlc_object_t *p_this )
     for( i_track = 0; i_track < p_sys->i_track; i_track++ )
     {
 #define tk  p_sys->track[i_track]
+        if( tk.fmt.psz_description )
+        {
+            free( tk.fmt.psz_description );
+        }
         if( tk.psz_codec )
         {
             free( tk.psz_codec );
@@ -1321,7 +1328,7 @@ static int BlockGet( input_thread_t *p_input, KaxBlock **pp_block, int64_t *pi_r
             {
                 KaxClusterTimecode &ctc = *(KaxClusterTimecode*)el;
 
-                ctc.ReadData( p_sys->es->I_O() );
+                ctc.ReadData( p_sys->es->I_O(), SCOPE_ALL_DATA );
                 p_sys->cluster->InitTimecode( uint64( ctc ), p_sys->i_timescale );
             }
             else if( EbmlId( *el ) == KaxBlockGroup::ClassInfos.GlobalId )
@@ -1370,27 +1377,13 @@ static int BlockGet( input_thread_t *p_input, KaxBlock **pp_block, int64_t *pi_r
     }
 }
 
-static pes_packet_t *MemToPES( input_thread_t *p_input, uint8_t *p_mem, int i_mem )
+static block_t *MemToBlock( input_thread_t *p_input, uint8_t *p_mem, int i_mem)
 {
-    pes_packet_t *p_pes;
-    data_packet_t *p_data;
-
-    if( ( p_pes = input_NewPES( p_input->p_method_data ) ) == NULL )
-    {
-        return NULL;
-    }
-
-    p_data = input_NewPacket( p_input->p_method_data, i_mem);
-
-    memcpy( p_data->p_payload_start, p_mem, i_mem );
-    p_data->p_payload_end = p_data->p_payload_start + i_mem;
-
-    p_pes->p_first = p_pes->p_last = p_data;
-    p_pes->i_nb_data = 1;
-    p_pes->i_pes_size = i_mem;
-    p_pes->i_rate = p_input->stream.control.i_rate;
-    
-    return p_pes;
+    block_t *p_block;
+    if( !(p_block = block_New( p_input, i_mem ) ) ) return NULL;
+    memcpy( p_block->p_buffer, p_mem, i_mem );
+    //p_block->i_rate = p_input->stream.control.i_rate;
+    return p_block;
 }
 
 static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts, mtime_t i_duration )
@@ -1416,7 +1409,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
         return;
     }
 
-    es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, tk.p_es, &b );
+    es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk.p_es, &b );
     if( !b )
     {
         tk.b_inited = VLC_FALSE;
@@ -1431,7 +1424,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
     /* First send init data */
     if( !tk.b_inited && tk.i_data_init > 0 )
     {
-        pes_packet_t *p_init;
+        block_t *p_init;
 
         msg_Dbg( p_input, "sending header (%d bytes)", tk.i_data_init );
 
@@ -1463,17 +1456,17 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
             i_size[1] = __MIN( i_size[1], tk.i_data_init - i_offset - i_size[0] );
             i_size[2] = tk.i_data_init - i_offset - i_size[0] - i_size[1];
 
-            p_init = MemToPES( p_input, &tk.p_data_init[i_offset], i_size[0] );
+            p_init = MemToBlock( p_input, &tk.p_data_init[i_offset], i_size[0] );
             if( p_init )
             {
                 es_out_Send( p_input->p_es_out, tk.p_es, p_init );
             }
-            p_init = MemToPES( p_input, &tk.p_data_init[i_offset+i_size[0]], i_size[1] );
+            p_init = MemToBlock( p_input, &tk.p_data_init[i_offset+i_size[0]], i_size[1] );
             if( p_init )
             {
                 es_out_Send( p_input->p_es_out, tk.p_es, p_init );
             }
-            p_init = MemToPES( p_input, &tk.p_data_init[i_offset+i_size[0]+i_size[1]], i_size[2] );
+            p_init = MemToBlock( p_input, &tk.p_data_init[i_offset+i_size[0]+i_size[1]], i_size[2] );
             if( p_init )
             {
                 es_out_Send( p_input->p_es_out, tk.p_es, p_init );
@@ -1481,7 +1474,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
         }
         else
         {
-            p_init = MemToPES( p_input, tk.p_data_init, tk.i_data_init );
+            p_init = MemToBlock( p_input, tk.p_data_init, tk.i_data_init );
             if( p_init )
             {
                 es_out_Send( p_input->p_es_out, tk.p_es, p_init );
@@ -1493,35 +1486,35 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
 
     for( i = 0; i < block->NumberFrames(); i++ )
     {
-        pes_packet_t *p_pes;
+        block_t *p_block;
         DataBuffer &data = block->GetBuffer(i);
 
-        p_pes = MemToPES( p_input, data.Buffer(), data.Size() );
-        if( p_pes == NULL )
+        p_block = MemToBlock( p_input, data.Buffer(), data.Size() );
+        if( p_block == NULL )
         {
             break;
         }
 
-        p_pes->i_pts = i_pts;
-        p_pes->i_dts = i_pts;
+        if( tk.fmt.i_cat != VIDEO_ES )
+            p_block->i_dts = p_block->i_pts = i_pts;
+        else
+        {
+            p_block->i_dts = i_pts;
+            p_block->i_pts = 0;
+        }
 
         if( tk.fmt.i_cat == SPU_ES && strcmp( tk.psz_codec, "S_VOBSUB" ) )
         {
             if( i_duration > 0 )
             {
-                p_pes->i_dts += i_duration * 1000;
+                p_block->i_dts += i_duration * 1000;
             }
             else
             {
-                p_pes->i_dts = 0;
-            }
-
-            if( p_pes->p_first && p_pes->i_pes_size > 0 )
-            {
-                p_pes->p_first->p_payload_end[0] = '\0';
+                p_block->i_dts = 0;
             }
         }
-        es_out_Send( p_input->p_es_out, tk.p_es, p_pes );
+        es_out_Send( p_input->p_es_out, tk.p_es, p_block );
 
         /* use time stamp only for first block */
         i_pts = 0;
@@ -1558,7 +1551,7 @@ static void Seek( input_thread_t *p_input, mtime_t i_date, int i_percent)
     {
         int64_t i_pos = i_percent * stream_Size( p_input->s ) / 100;
 
-        msg_Dbg( p_input, "imprecise way of seeking" );
+        msg_Dbg( p_input, "inacurate way of seeking" );
         for( i_index = 0; i_index < p_sys->i_index; i_index++ )
         {
             if( p_sys->index[i_index].i_position >= i_pos)
@@ -2024,9 +2017,11 @@ static void LoadCues( input_thread_t *p_input )
             }
             ep->Up();
 
+#if 0
             msg_Dbg( p_input, " * added time="I64Fd" pos="I64Fd
                      " track=%d bnum=%d", idx.i_time, idx.i_position,
                      idx.i_track, idx.i_block_number );
+#endif
 
             p_sys->i_index++;
             if( p_sys->i_index >= p_sys->i_index_max )
@@ -2178,19 +2173,15 @@ static void InformationsCreate( input_thread_t *p_input )
 {
     demux_sys_t           *p_sys = p_input->p_demux_data;
     input_info_category_t *p_cat;
+    playlist_t            *p_playlist;
     int                   i_track;
 
     p_cat = input_InfoCategory( p_input, "Matroska" );
     if( p_sys->f_duration > 1000.1 )
     {
-        int64_t i_sec = (int64_t)p_sys->f_duration / 1000;
-        int h,m,s;
-
-        h = i_sec / 3600;
-        m = ( i_sec / 60 ) % 60;
-        s = i_sec % 60;
-
-        input_AddInfo( p_cat, _("Duration"), "%d:%2.2d:%2.2d" , h, m, s );
+        char psz_buffer[MSTRTIME_MAX_SIZE];
+        input_AddInfo( p_cat, _("Duration"),
+                       msecstotimestr( psz_buffer, (int)p_sys->f_duration ) );
     }
 
     if( p_sys->psz_title )
@@ -2199,19 +2190,19 @@ static void InformationsCreate( input_thread_t *p_input )
     }
     if( p_sys->psz_date_utc )
     {
-        input_AddInfo( p_cat, _("Date UTC"), "%s" ,p_sys->psz_date_utc );
+        input_AddInfo( p_cat, _("UTC date"), "%s" ,p_sys->psz_date_utc );
     }
     if( p_sys->psz_segment_filename )
     {
-        input_AddInfo( p_cat, _("Segment Filename"), "%s" ,p_sys->psz_segment_filename );
+        input_AddInfo( p_cat, _("Segment filename"), "%s" ,p_sys->psz_segment_filename );
     }
     if( p_sys->psz_muxing_application )
     {
-        input_AddInfo( p_cat, _("Muxing Application"), "%s" ,p_sys->psz_muxing_application );
+        input_AddInfo( p_cat, _("Muxing application"), "%s" ,p_sys->psz_muxing_application );
     }
     if( p_sys->psz_writing_application )
     {
-        input_AddInfo( p_cat, _("Writing Application"), "%s" ,p_sys->psz_writing_application );
+        input_AddInfo( p_cat, _("Writing application"), "%s" ,p_sys->psz_writing_application );
     }
     input_AddInfo( p_cat, _("Number of streams"), "%d" , p_sys->i_track );
 
@@ -2222,25 +2213,29 @@ static void InformationsCreate( input_thread_t *p_input )
 
         sprintf( psz_cat, "Stream %d", i_track );
         p_cat = input_InfoCategory( p_input, psz_cat);
-        if( tk.psz_name )
+        if( tk.fmt.psz_description )
         {
-            input_AddInfo( p_cat, _("Name"), "%s", tk.psz_name );
+            input_AddInfo( p_cat, _("Name"), "%s", tk.fmt.psz_description );
+        }
+        if( tk.fmt.psz_language )
+        {
+            input_AddInfo( p_cat, _("Language"), "%s", tk.fmt.psz_language );
         }
         if( tk.psz_codec_name )
         {
-            input_AddInfo( p_cat, _("Codec Name"), "%s", tk.psz_codec_name );
+            input_AddInfo( p_cat, _("Codec name"), "%s", tk.psz_codec_name );
         }
         if( tk.psz_codec_settings )
         {
-            input_AddInfo( p_cat, _("Codec Setting"), "%s", tk.psz_codec_settings );
+            input_AddInfo( p_cat, _("Codec setting"), "%s", tk.psz_codec_settings );
         }
         if( tk.psz_codec_info_url )
         {
-            input_AddInfo( p_cat, _("Codec Info"), "%s", tk.psz_codec_info_url );
+            input_AddInfo( p_cat, _("Codec info"), "%s", tk.psz_codec_info_url );
         }
         if( tk.psz_codec_download_url )
         {
-            input_AddInfo( p_cat, _("Codec Download"), "%s", tk.psz_codec_download_url );
+            input_AddInfo( p_cat, _("Codec download"), "%s", tk.psz_codec_download_url );
         }
 #undef  tk
     }
@@ -2310,38 +2305,3 @@ static char * UTF8ToStr( const UTFstring &u )
     return dst;
 }
 
-static char *LanguageGetName    ( const char *psz_code )
-{
-    const iso639_lang_t *pl;
-
-    if( strlen( psz_code ) == 2 )
-    {
-        pl = GetLang_1( psz_code );
-    }
-    else if( strlen( psz_code ) == 3 )
-    {
-        pl = GetLang_2B( psz_code );
-        if( !strcmp( pl->psz_iso639_1, "??" ) )
-        {
-            pl = GetLang_2T( psz_code );
-        }
-    }
-    else
-    {
-        return strdup( psz_code );
-    }
-
-    if( !strcmp( pl->psz_iso639_1, "??" ) )
-    {
-       return strdup( psz_code );
-    }
-    else
-    {
-        if( *pl->psz_native_name )
-        {
-            return strdup( pl->psz_native_name );
-        }
-        return strdup( pl->psz_eng_name );
-    }
-}
-