1 /*****************************************************************************
2 * mkv.cpp : matroska demuxer
3 *****************************************************************************
4 * Copyright (C) 2003-2004 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Steve Lhomme <steve.lhomme@free.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include "matroska_segment.hpp"
27 #include "chapters.hpp"
32 #include "../vobsub.h"
35 #include <vlc_codecs.h>
37 /* GetFourCC helper */
38 #define GetFOURCC( p ) __GetFOURCC( (uint8_t*)p )
39 static vlc_fourcc_t __GetFOURCC( uint8_t *p )
41 return VLC_FOURCC( p[0], p[1], p[2], p[3] );
45 matroska_segment_c::~matroska_segment_c()
47 for( size_t i_track = 0; i_track < tracks.size(); i_track++ )
49 delete tracks[i_track]->p_compression_data;
50 es_format_Clean( &tracks[i_track]->fmt );
51 free( tracks[i_track]->p_extra_data );
52 free( tracks[i_track]->psz_codec );
53 delete tracks[i_track];
56 free( psz_writing_application );
57 free( psz_muxing_application );
58 free( psz_segment_filename );
66 delete p_prev_segment_uid;
67 delete p_next_segment_uid;
69 std::vector<chapter_edition_c*>::iterator index = stored_editions.begin();
70 while ( index != stored_editions.end() )
75 std::vector<chapter_translation_c*>::iterator indext = translations.begin();
76 while ( indext != translations.end() )
81 std::vector<KaxSegmentFamily*>::iterator indexf = families.begin();
82 while ( indexf != families.end() )
90 /*****************************************************************************
92 * * LoadCues : load the cues element and update index
94 * * LoadTags : load ... the tags element
96 * * InformationCreate : create all information, load tags if present
98 *****************************************************************************/
99 void matroska_segment_c::LoadCues( KaxCues *cues )
106 msg_Err( &sys.demuxer, "There can be only 1 Cues per section." );
110 ep = new EbmlParser( &es, cues, &sys.demuxer );
111 while( ( el = ep->Get() ) != NULL )
113 if( MKV_IS_ID( el, KaxCuePoint ) )
115 #define idx p_indexes[i_index]
118 idx.i_block_number= -1;
124 while( ( el = ep->Get() ) != NULL )
126 if( MKV_IS_ID( el, KaxCueTime ) )
128 KaxCueTime &ctime = *(KaxCueTime*)el;
130 ctime.ReadData( es.I_O() );
132 idx.i_time = uint64( ctime ) * i_timescale / (mtime_t)1000;
134 else if( MKV_IS_ID( el, KaxCueTrackPositions ) )
137 while( ( el = ep->Get() ) != NULL )
139 if( MKV_IS_ID( el, KaxCueTrack ) )
141 KaxCueTrack &ctrack = *(KaxCueTrack*)el;
143 ctrack.ReadData( es.I_O() );
144 idx.i_track = uint16( ctrack );
146 else if( MKV_IS_ID( el, KaxCueClusterPosition ) )
148 KaxCueClusterPosition &ccpos = *(KaxCueClusterPosition*)el;
150 ccpos.ReadData( es.I_O() );
151 idx.i_position = segment->GetGlobalPosition( uint64( ccpos ) );
153 else if( MKV_IS_ID( el, KaxCueBlockNumber ) )
155 KaxCueBlockNumber &cbnum = *(KaxCueBlockNumber*)el;
157 cbnum.ReadData( es.I_O() );
158 idx.i_block_number = uint32( cbnum );
162 msg_Dbg( &sys.demuxer, " * Unknown (%s)", typeid(*el).name() );
169 msg_Dbg( &sys.demuxer, " * Unknown (%s)", typeid(*el).name() );
175 msg_Dbg( &sys.demuxer, " * added time=%"PRId64" pos=%"PRId64
176 " track=%d bnum=%d", idx.i_time, idx.i_position,
177 idx.i_track, idx.i_block_number );
181 if( i_index >= i_index_max )
184 p_indexes = (mkv_index_t*)xrealloc( p_indexes,
185 sizeof( mkv_index_t ) * i_index_max );
191 msg_Dbg( &sys.demuxer, " * Unknown (%s)", typeid(*el).name() );
196 msg_Dbg( &sys.demuxer, "| - loading cues done." );
199 void matroska_segment_c::LoadTags( KaxTags *tags )
204 /* Master elements */
205 ep = new EbmlParser( &es, tags, &sys.demuxer );
207 while( ( el = ep->Get() ) != NULL )
209 if( MKV_IS_ID( el, KaxTag ) )
211 msg_Dbg( &sys.demuxer, "+ Tag" );
213 while( ( el = ep->Get() ) != NULL )
215 if( MKV_IS_ID( el, KaxTagTargets ) )
217 msg_Dbg( &sys.demuxer, "| + Targets" );
219 while( ( el = ep->Get() ) != NULL )
221 msg_Dbg( &sys.demuxer, "| | + Unknown (%s)", typeid( *el ).name() );
225 else if( MKV_IS_ID( el, KaxTagGeneral ) )
227 msg_Dbg( &sys.demuxer, "| + General" );
229 while( ( el = ep->Get() ) != NULL )
231 msg_Dbg( &sys.demuxer, "| | + Unknown (%s)", typeid( *el ).name() );
235 else if( MKV_IS_ID( el, KaxTagGenres ) )
237 msg_Dbg( &sys.demuxer, "| + Genres" );
239 while( ( el = ep->Get() ) != NULL )
241 msg_Dbg( &sys.demuxer, "| | + Unknown (%s)", typeid( *el ).name() );
245 else if( MKV_IS_ID( el, KaxTagAudioSpecific ) )
247 msg_Dbg( &sys.demuxer, "| + Audio Specific" );
249 while( ( el = ep->Get() ) != NULL )
251 msg_Dbg( &sys.demuxer, "| | + Unknown (%s)", typeid( *el ).name() );
255 else if( MKV_IS_ID( el, KaxTagImageSpecific ) )
257 msg_Dbg( &sys.demuxer, "| + Images Specific" );
259 while( ( el = ep->Get() ) != NULL )
261 msg_Dbg( &sys.demuxer, "| | + Unknown (%s)", typeid( *el ).name() );
265 else if( MKV_IS_ID( el, KaxTagMultiComment ) )
267 msg_Dbg( &sys.demuxer, "| + Multi Comment" );
269 else if( MKV_IS_ID( el, KaxTagMultiCommercial ) )
271 msg_Dbg( &sys.demuxer, "| + Multi Commercial" );
273 else if( MKV_IS_ID( el, KaxTagMultiDate ) )
275 msg_Dbg( &sys.demuxer, "| + Multi Date" );
277 else if( MKV_IS_ID( el, KaxTagMultiEntity ) )
279 msg_Dbg( &sys.demuxer, "| + Multi Entity" );
281 else if( MKV_IS_ID( el, KaxTagMultiIdentifier ) )
283 msg_Dbg( &sys.demuxer, "| + Multi Identifier" );
285 else if( MKV_IS_ID( el, KaxTagMultiLegal ) )
287 msg_Dbg( &sys.demuxer, "| + Multi Legal" );
289 else if( MKV_IS_ID( el, KaxTagMultiTitle ) )
291 msg_Dbg( &sys.demuxer, "| + Multi Title" );
295 msg_Dbg( &sys.demuxer, "| + LoadTag Unknown (%s)", typeid( *el ).name() );
302 msg_Dbg( &sys.demuxer, "+ Unknown (%s)", typeid( *el ).name() );
307 msg_Dbg( &sys.demuxer, "loading tags done." );
310 /*****************************************************************************
312 *****************************************************************************/
313 void matroska_segment_c::InformationCreate( )
315 sys.meta = vlc_meta_New();
319 vlc_meta_SetTitle( sys.meta, psz_title );
323 vlc_meta_SetDate( sys.meta, psz_date_utc );
326 if( psz_segment_filename )
328 fprintf( stderr, "***** WARNING: Unhandled meta - Use custom\n" );
330 if( psz_muxing_application )
332 fprintf( stderr, "***** WARNING: Unhandled meta - Use custom\n" );
334 if( psz_writing_application )
336 fprintf( stderr, "***** WARNING: Unhandled meta - Use custom\n" );
339 for( size_t i_track = 0; i_track < tracks.size(); i_track++ )
341 // mkv_track_t *tk = tracks[i_track];
342 // vlc_meta_t *mtk = vlc_meta_New();
343 fprintf( stderr, "***** WARNING: Unhandled child meta\n");
347 if( i_tags_position >= 0 )
351 stream_Control( sys.demuxer.s, STREAM_CAN_FASTSEEK, &b_seekable );
361 /*****************************************************************************
363 *****************************************************************************/
365 void matroska_segment_c::IndexAppendCluster( KaxCluster *cluster )
367 #define idx p_indexes[i_index]
369 idx.i_block_number= -1;
370 idx.i_position = cluster->GetElementPosition();
375 if( i_index >= i_index_max )
378 p_indexes = (mkv_index_t*)xrealloc( p_indexes,
379 sizeof( mkv_index_t ) * i_index_max );
385 bool matroska_segment_c::PreloadFamily( const matroska_segment_c & of_segment )
390 for (size_t i=0; i<families.size(); i++)
392 for (size_t j=0; j<of_segment.families.size(); j++)
394 if ( *(families[i]) == *(of_segment.families[j]) )
402 bool matroska_segment_c::CompareSegmentUIDs( const matroska_segment_c * p_item_a, const matroska_segment_c * p_item_b )
406 if ( p_item_a == NULL || p_item_b == NULL )
409 p_tmp = (EbmlBinary *)p_item_a->p_segment_uid;
410 if ( p_item_b->p_prev_segment_uid != NULL
411 && *p_tmp == *p_item_b->p_prev_segment_uid )
414 p_tmp = (EbmlBinary *)p_item_a->p_next_segment_uid;
418 if ( p_item_b->p_segment_uid != NULL
419 && *p_tmp == *p_item_b->p_segment_uid )
422 if ( p_item_b->p_prev_segment_uid != NULL
423 && *p_tmp == *p_item_b->p_prev_segment_uid )
429 bool matroska_segment_c::Preload( )
434 EbmlElement *el = NULL;
436 ep->Reset( &sys.demuxer );
438 while( ( el = ep->Get() ) != NULL )
440 if( MKV_IS_ID( el, KaxSeekHead ) )
442 /* Multiple allowed */
443 /* We bail at 10, to prevent possible recursion */
444 msg_Dbg( &sys.demuxer, "| + Seek head" );
445 if( i_seekhead_count < 10 )
447 i_seekhead_position = (int64_t) es.I_O().getFilePointer();
448 ParseSeekHead( static_cast<KaxSeekHead*>( el ) );
451 else if( MKV_IS_ID( el, KaxInfo ) )
453 /* Multiple allowed, mandatory */
454 msg_Dbg( &sys.demuxer, "| + Information" );
455 if( i_info_position < 0 ) // FIXME
456 ParseInfo( static_cast<KaxInfo*>( el ) );
457 i_info_position = (int64_t) es.I_O().getFilePointer();
459 else if( MKV_IS_ID( el, KaxTracks ) )
461 /* Multiple allowed */
462 msg_Dbg( &sys.demuxer, "| + Tracks" );
463 if( i_tracks_position < 0 ) // FIXME
464 ParseTracks( static_cast<KaxTracks*>( el ) );
465 if ( tracks.size() == 0 )
467 msg_Err( &sys.demuxer, "No tracks supported" );
470 i_tracks_position = (int64_t) es.I_O().getFilePointer();
472 else if( MKV_IS_ID( el, KaxCues ) )
474 msg_Dbg( &sys.demuxer, "| + Cues" );
475 if( i_cues_position < 0 )
476 LoadCues( static_cast<KaxCues*>( el ) );
477 i_cues_position = (int64_t) es.I_O().getFilePointer();
479 else if( MKV_IS_ID( el, KaxCluster ) )
481 msg_Dbg( &sys.demuxer, "| + Cluster" );
483 cluster = (KaxCluster*)el;
485 i_cluster_pos = i_start_pos = cluster->GetElementPosition();
489 /* stop pre-parsing the stream */
492 else if( MKV_IS_ID( el, KaxAttachments ) )
494 msg_Dbg( &sys.demuxer, "| + Attachments" );
495 if( i_attachments_position < 0 )
496 ParseAttachments( static_cast<KaxAttachments*>( el ) );
497 i_attachments_position = (int64_t) es.I_O().getFilePointer();
499 else if( MKV_IS_ID( el, KaxChapters ) )
501 msg_Dbg( &sys.demuxer, "| + Chapters" );
502 if( i_chapters_position < 0 )
503 ParseChapters( static_cast<KaxChapters*>( el ) );
504 i_chapters_position = (int64_t) es.I_O().getFilePointer();
506 else if( MKV_IS_ID( el, KaxTag ) )
508 msg_Dbg( &sys.demuxer, "| + Tags" );
509 if( i_tags_position < 0) // FIXME
510 ;//LoadTags( static_cast<KaxTags*>( el ) );
511 i_tags_position = (int64_t) es.I_O().getFilePointer();
514 msg_Dbg( &sys.demuxer, "| + Preload Unknown (%s)", typeid(*el).name() );
522 /* Here we try to load elements that were found in Seek Heads, but not yet parsed */
523 bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int64_t i_element_position )
525 int64_t i_sav_position = (int64_t)es.I_O().getFilePointer();
528 es.I_O().setFilePointer( i_element_position, seek_beginning );
529 el = es.FindNextID( ClassInfos, 0xFFFFFFFFL);
533 msg_Err( &sys.demuxer, "cannot load some cues/chapters/tags etc. (broken seekhead or file)" );
534 es.I_O().setFilePointer( i_sav_position, seek_beginning );
538 if( MKV_IS_ID( el, KaxSeekHead ) )
540 /* Multiple allowed */
541 msg_Dbg( &sys.demuxer, "| + Seek head" );
542 if( i_seekhead_count < 10 )
544 i_seekhead_position = i_element_position;
545 ParseSeekHead( static_cast<KaxSeekHead*>( el ) );
548 else if( MKV_IS_ID( el, KaxInfo ) ) // FIXME
550 /* Multiple allowed, mandatory */
551 msg_Dbg( &sys.demuxer, "| + Information" );
552 if( i_info_position < 0 )
553 ParseInfo( static_cast<KaxInfo*>( el ) );
554 i_info_position = i_element_position;
556 else if( MKV_IS_ID( el, KaxTracks ) ) // FIXME
558 /* Multiple allowed */
559 msg_Dbg( &sys.demuxer, "| + Tracks" );
560 if( i_tracks_position < 0 )
561 ParseTracks( static_cast<KaxTracks*>( el ) );
562 if ( tracks.size() == 0 )
564 msg_Err( &sys.demuxer, "No tracks supported" );
566 es.I_O().setFilePointer( i_sav_position, seek_beginning );
569 i_tracks_position = i_element_position;
571 else if( MKV_IS_ID( el, KaxCues ) )
573 msg_Dbg( &sys.demuxer, "| + Cues" );
574 if( i_cues_position < 0 )
575 LoadCues( static_cast<KaxCues*>( el ) );
576 i_cues_position = i_element_position;
578 else if( MKV_IS_ID( el, KaxAttachments ) )
580 msg_Dbg( &sys.demuxer, "| + Attachments" );
581 if( i_attachments_position < 0 )
582 ParseAttachments( static_cast<KaxAttachments*>( el ) );
583 i_attachments_position = i_element_position;
585 else if( MKV_IS_ID( el, KaxChapters ) )
587 msg_Dbg( &sys.demuxer, "| + Chapters" );
588 if( i_chapters_position < 0 )
589 ParseChapters( static_cast<KaxChapters*>( el ) );
590 i_chapters_position = i_element_position;
592 else if( MKV_IS_ID( el, KaxTag ) ) // FIXME
594 msg_Dbg( &sys.demuxer, "| + Tags" );
595 if( i_tags_position < 0 )
596 ;//LoadTags( static_cast<KaxTags*>( el ) );
597 i_tags_position = i_element_position;
601 msg_Dbg( &sys.demuxer, "| + LoadSeekHeadItem Unknown (%s)", typeid(*el).name() );
605 es.I_O().setFilePointer( i_sav_position, seek_beginning );
609 void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_global_position )
612 KaxSimpleBlock *simpleblock;
613 int i_track_skipping;
614 int64_t i_block_duration;
615 int64_t i_block_ref1;
616 int64_t i_block_ref2;
618 int64_t i_seek_position = i_start_pos;
619 int64_t i_seek_time = i_start_time;
621 if( i_global_position >= 0 )
623 /* Special case for seeking in files with no cues */
624 EbmlElement *el = NULL;
625 es.I_O().setFilePointer( i_start_pos, seek_beginning );
627 ep = new EbmlParser( &es, segment, &sys.demuxer );
630 while( ( el = ep->Get() ) != NULL )
632 if( MKV_IS_ID( el, KaxCluster ) )
634 cluster = (KaxCluster *)el;
635 i_cluster_pos = cluster->GetElementPosition();
637 ( i_index > 0 && p_indexes[i_index - 1].i_position < (int64_t)cluster->GetElementPosition() ) )
639 IndexAppendCluster( cluster );
641 if( es.I_O().getFilePointer() >= i_global_position )
644 msg_Dbg( &sys.demuxer, "we found a cluster that is in the neighbourhood" );
649 msg_Err( &sys.demuxer, "This file has no cues, and we were unable to seek to the requested position by parsing." );
657 for( ; i_idx < i_index; i_idx++ )
659 if( p_indexes[i_idx].i_time + i_time_offset > i_date )
670 i_seek_position = p_indexes[i_idx].i_position;
671 i_seek_time = p_indexes[i_idx].i_time;
674 msg_Dbg( &sys.demuxer, "seek got %"PRId64" (%d%%)",
675 i_seek_time, (int)( 100 * i_seek_position / stream_Size( sys.demuxer.s ) ) );
677 es.I_O().setFilePointer( i_seek_position, seek_beginning );
680 ep = new EbmlParser( &es, segment, &sys.demuxer );
683 sys.i_start_pts = i_date;
685 /* now parse until key frame */
686 i_track_skipping = 0;
687 for( i_track = 0; i_track < tracks.size(); i_track++ )
689 if( tracks[i_track]->fmt.i_cat == VIDEO_ES )
691 tracks[i_track]->b_search_keyframe = true;
695 es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date );
697 while( i_track_skipping > 0 )
699 if( BlockGet( block, simpleblock, &i_block_ref1, &i_block_ref2, &i_block_duration ) )
701 msg_Warn( &sys.demuxer, "cannot get block EOF?" );
706 for( i_track = 0; i_track < tracks.size(); i_track++ )
708 if( (simpleblock && tracks[i_track]->i_number == simpleblock->TrackNum()) ||
709 (block && tracks[i_track]->i_number == block->TrackNum()) )
716 sys.i_pts = (sys.i_chapter_time + simpleblock->GlobalTimecode()) / (mtime_t) 1000;
718 sys.i_pts = (sys.i_chapter_time + block->GlobalTimecode()) / (mtime_t) 1000;
720 if( i_track < tracks.size() )
722 if( sys.i_pts > sys.i_start_pts )
724 cluster = static_cast<KaxCluster*>(ep->UnGet( i_block_pos, i_cluster_pos ));
725 i_track_skipping = 0;
727 else if( tracks[i_track]->fmt.i_cat == VIDEO_ES )
729 if( i_block_ref1 == 0 && tracks[i_track]->b_search_keyframe )
731 tracks[i_track]->b_search_keyframe = false;
734 if( !tracks[i_track]->b_search_keyframe )
736 BlockDecode( &sys.demuxer, block, simpleblock, sys.i_pts, 0, i_block_ref1 >= 0 || i_block_ref2 > 0 );
744 /* FIXME current ES_OUT_SET_NEXT_DISPLAY_TIME does not work that well if
745 * the delay is too high. */
746 if( sys.i_pts + 500*1000 < sys.i_start_pts )
748 sys.i_start_pts = sys.i_pts;
750 es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, sys.i_start_pts );
755 int matroska_segment_c::BlockFindTrackIndex( size_t *pi_track,
756 const KaxBlock *p_block, const KaxSimpleBlock *p_simpleblock )
760 for( i_track = 0; i_track < tracks.size(); i_track++ )
762 const mkv_track_t *tk = tracks[i_track];
764 if( ( p_block != NULL && tk->i_number == p_block->TrackNum() ) ||
765 ( p_simpleblock != NULL && tk->i_number == p_simpleblock->TrackNum() ) )
771 if( i_track >= tracks.size() )
779 bool matroska_segment_c::Select( mtime_t i_start_time )
784 msg_Dbg( &sys.demuxer, "found %d es", (int)tracks.size() );
785 sys.b_pci_packet_set = false;
787 for( i_track = 0; i_track < tracks.size(); i_track++ )
789 mkv_track_t *p_tk = tracks[i_track];
790 es_format_t *p_fmt = &p_tk->fmt;
792 if( p_fmt->i_cat == UNKNOWN_ES || !p_tk->psz_codec )
794 msg_Warn( &sys.demuxer, "invalid track[%d, n=%d]", (int)i_track, tracks[i_track]->i_number );
795 tracks[i_track]->p_es = NULL;
799 if( !strcmp( tracks[i_track]->psz_codec, "V_MS/VFW/FOURCC" ) )
801 if( tracks[i_track]->i_extra_data < (int)sizeof( BITMAPINFOHEADER ) )
803 msg_Err( &sys.demuxer, "missing/invalid BITMAPINFOHEADER" );
804 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 'u', 'n', 'd', 'f' );
808 BITMAPINFOHEADER *p_bih = (BITMAPINFOHEADER*)tracks[i_track]->p_extra_data;
810 tracks[i_track]->fmt.video.i_width = GetDWLE( &p_bih->biWidth );
811 tracks[i_track]->fmt.video.i_height= GetDWLE( &p_bih->biHeight );
812 tracks[i_track]->fmt.i_codec = GetFOURCC( &p_bih->biCompression );
814 tracks[i_track]->fmt.i_extra = GetDWLE( &p_bih->biSize ) - sizeof( BITMAPINFOHEADER );
815 if( tracks[i_track]->fmt.i_extra > 0 )
817 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra );
818 memcpy( tracks[i_track]->fmt.p_extra, &p_bih[1], tracks[i_track]->fmt.i_extra );
821 p_tk->b_dts_only = true;
823 else if( !strcmp( tracks[i_track]->psz_codec, "V_MPEG1" ) ||
824 !strcmp( tracks[i_track]->psz_codec, "V_MPEG2" ) )
826 tracks[i_track]->fmt.i_codec = VLC_CODEC_MPGV;
828 else if( !strncmp( tracks[i_track]->psz_codec, "V_THEORA", 8 ) )
830 tracks[i_track]->fmt.i_codec = VLC_CODEC_THEORA;
831 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
832 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
833 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
835 else if( !strncmp( tracks[i_track]->psz_codec, "V_REAL/RV", 9 ) )
837 if( !strcmp( p_tk->psz_codec, "V_REAL/RV10" ) )
838 p_fmt->i_codec = VLC_CODEC_RV10;
839 else if( !strcmp( p_tk->psz_codec, "V_REAL/RV20" ) )
840 p_fmt->i_codec = VLC_CODEC_RV20;
841 else if( !strcmp( p_tk->psz_codec, "V_REAL/RV30" ) )
842 p_fmt->i_codec = VLC_CODEC_RV30;
843 else if( !strcmp( p_tk->psz_codec, "V_REAL/RV40" ) )
844 p_fmt->i_codec = VLC_CODEC_RV40;
846 if( p_tk->i_extra_data > 26 )
848 p_fmt->p_extra = malloc( p_tk->i_extra_data - 26 );
851 p_fmt->i_extra = p_tk->i_extra_data - 26;
852 memcpy( p_fmt->p_extra, &p_tk->p_extra_data[26], p_fmt->i_extra );
855 p_tk->b_dts_only = true;
857 else if( !strncmp( tracks[i_track]->psz_codec, "V_DIRAC", 7 ) )
859 tracks[i_track]->fmt.i_codec = VLC_CODEC_DIRAC;
861 else if( !strncmp( tracks[i_track]->psz_codec, "V_MPEG4", 7 ) )
863 if( !strcmp( tracks[i_track]->psz_codec, "V_MPEG4/MS/V3" ) )
865 tracks[i_track]->fmt.i_codec = VLC_CODEC_DIV3;
867 else if( !strncmp( tracks[i_track]->psz_codec, "V_MPEG4/ISO", 11 ) )
869 /* A MPEG 4 codec, SP, ASP, AP or AVC */
870 if( !strcmp( tracks[i_track]->psz_codec, "V_MPEG4/ISO/AVC" ) )
871 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 'a', 'v', 'c', '1' );
873 tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4V;
874 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
875 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
876 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
879 else if( !strcmp( tracks[i_track]->psz_codec, "V_QUICKTIME" ) )
881 MP4_Box_t *p_box = (MP4_Box_t*)xmalloc( sizeof( MP4_Box_t ) );
882 stream_t *p_mp4_stream = stream_MemoryNew( VLC_OBJECT(&sys.demuxer),
883 tracks[i_track]->p_extra_data,
884 tracks[i_track]->i_extra_data,
886 if( MP4_ReadBoxCommon( p_mp4_stream, p_box ) &&
887 MP4_ReadBox_sample_vide( p_mp4_stream, p_box ) )
889 tracks[i_track]->fmt.i_codec = p_box->i_type;
890 tracks[i_track]->fmt.video.i_width = p_box->data.p_sample_vide->i_width;
891 tracks[i_track]->fmt.video.i_height = p_box->data.p_sample_vide->i_height;
892 tracks[i_track]->fmt.i_extra = p_box->data.p_sample_vide->i_qt_image_description;
893 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra );
894 memcpy( tracks[i_track]->fmt.p_extra, p_box->data.p_sample_vide->p_qt_image_description, tracks[i_track]->fmt.i_extra );
895 MP4_FreeBox_sample_vide( p_box );
901 stream_Delete( p_mp4_stream );
903 else if( !strcmp( tracks[i_track]->psz_codec, "A_MS/ACM" ) )
905 if( tracks[i_track]->i_extra_data < (int)sizeof( WAVEFORMATEX ) )
907 msg_Err( &sys.demuxer, "missing/invalid WAVEFORMATEX" );
908 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 'u', 'n', 'd', 'f' );
912 WAVEFORMATEX *p_wf = (WAVEFORMATEX*)tracks[i_track]->p_extra_data;
914 wf_tag_to_fourcc( GetWLE( &p_wf->wFormatTag ), &tracks[i_track]->fmt.i_codec, NULL );
916 tracks[i_track]->fmt.audio.i_channels = GetWLE( &p_wf->nChannels );
917 tracks[i_track]->fmt.audio.i_rate = GetDWLE( &p_wf->nSamplesPerSec );
918 tracks[i_track]->fmt.i_bitrate = GetDWLE( &p_wf->nAvgBytesPerSec ) * 8;
919 tracks[i_track]->fmt.audio.i_blockalign = GetWLE( &p_wf->nBlockAlign );;
920 tracks[i_track]->fmt.audio.i_bitspersample = GetWLE( &p_wf->wBitsPerSample );
922 tracks[i_track]->fmt.i_extra = GetWLE( &p_wf->cbSize );
923 if( tracks[i_track]->fmt.i_extra > 0 )
925 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra );
926 memcpy( tracks[i_track]->fmt.p_extra, &p_wf[1], tracks[i_track]->fmt.i_extra );
930 else if( !strcmp( tracks[i_track]->psz_codec, "A_MPEG/L3" ) ||
931 !strcmp( tracks[i_track]->psz_codec, "A_MPEG/L2" ) ||
932 !strcmp( tracks[i_track]->psz_codec, "A_MPEG/L1" ) )
934 tracks[i_track]->fmt.i_codec = VLC_CODEC_MPGA;
936 else if( !strcmp( tracks[i_track]->psz_codec, "A_AC3" ) )
938 tracks[i_track]->fmt.i_codec = VLC_CODEC_A52;
940 else if( !strcmp( tracks[i_track]->psz_codec, "A_EAC3" ) )
942 tracks[i_track]->fmt.i_codec = VLC_CODEC_EAC3;
944 else if( !strcmp( tracks[i_track]->psz_codec, "A_DTS" ) )
946 tracks[i_track]->fmt.i_codec = VLC_CODEC_DTS;
948 else if( !strcmp( tracks[i_track]->psz_codec, "A_MLP" ) )
950 tracks[i_track]->fmt.i_codec = VLC_CODEC_MLP;
952 else if( !strcmp( tracks[i_track]->psz_codec, "A_TRUEHD" ) )
954 /* FIXME when more samples arrive */
955 tracks[i_track]->fmt.i_codec = VLC_CODEC_TRUEHD;
956 p_fmt->b_packetized = false;
958 else if( !strcmp( tracks[i_track]->psz_codec, "A_FLAC" ) )
960 tracks[i_track]->fmt.i_codec = VLC_CODEC_FLAC;
961 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
962 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
963 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
965 else if( !strcmp( tracks[i_track]->psz_codec, "A_VORBIS" ) )
967 tracks[i_track]->fmt.i_codec = VLC_CODEC_VORBIS;
968 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
969 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
970 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
972 else if( !strncmp( tracks[i_track]->psz_codec, "A_AAC/MPEG2/", strlen( "A_AAC/MPEG2/" ) ) ||
973 !strncmp( tracks[i_track]->psz_codec, "A_AAC/MPEG4/", strlen( "A_AAC/MPEG4/" ) ) )
975 int i_profile, i_srate, sbr = 0;
976 static const unsigned int i_sample_rates[] =
978 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
979 16000, 12000, 11025, 8000, 7350, 0, 0, 0
982 tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4A;
983 /* create data for faad (MP4DecSpecificDescrTag)*/
985 if( !strcmp( &tracks[i_track]->psz_codec[12], "MAIN" ) )
989 else if( !strcmp( &tracks[i_track]->psz_codec[12], "LC" ) )
993 else if( !strcmp( &tracks[i_track]->psz_codec[12], "SSR" ) )
997 else if( !strcmp( &tracks[i_track]->psz_codec[12], "LC/SBR" ) )
1007 for( i_srate = 0; i_srate < 13; i_srate++ )
1009 if( i_sample_rates[i_srate] == tracks[i_track]->i_original_rate )
1014 msg_Dbg( &sys.demuxer, "profile=%d srate=%d", i_profile, i_srate );
1016 tracks[i_track]->fmt.i_extra = sbr ? 5 : 2;
1017 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->fmt.i_extra );
1018 ((uint8_t*)tracks[i_track]->fmt.p_extra)[0] = ((i_profile + 1) << 3) | ((i_srate&0xe) >> 1);
1019 ((uint8_t*)tracks[i_track]->fmt.p_extra)[1] = ((i_srate & 0x1) << 7) | (tracks[i_track]->fmt.audio.i_channels << 3);
1022 int syncExtensionType = 0x2B7;
1024 for (iDSRI=0; iDSRI<13; iDSRI++)
1025 if( i_sample_rates[iDSRI] == tracks[i_track]->fmt.audio.i_rate )
1027 ((uint8_t*)tracks[i_track]->fmt.p_extra)[2] = (syncExtensionType >> 3) & 0xFF;
1028 ((uint8_t*)tracks[i_track]->fmt.p_extra)[3] = ((syncExtensionType & 0x7) << 5) | 5;
1029 ((uint8_t*)tracks[i_track]->fmt.p_extra)[4] = ((1 & 0x1) << 7) | (iDSRI << 3);
1032 else if( !strcmp( tracks[i_track]->psz_codec, "A_AAC" ) )
1034 tracks[i_track]->fmt.i_codec = VLC_CODEC_MP4A;
1035 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
1036 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
1037 memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
1039 else if( !strcmp( tracks[i_track]->psz_codec, "A_WAVPACK4" ) )
1041 tracks[i_track]->fmt.i_codec = VLC_CODEC_WAVPACK;
1042 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
1043 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
1044 memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
1046 else if( !strcmp( tracks[i_track]->psz_codec, "A_TTA1" ) )
1048 p_fmt->i_codec = VLC_CODEC_TTA;
1049 p_fmt->i_extra = p_tk->i_extra_data;
1050 if( p_fmt->i_extra > 0 )
1052 p_fmt->p_extra = xmalloc( p_tk->i_extra_data );
1053 memcpy( p_fmt->p_extra, p_tk->p_extra_data, p_tk->i_extra_data );
1057 p_fmt->i_extra = 30;
1058 p_fmt->p_extra = xmalloc( p_fmt->i_extra );
1059 uint8_t *p_extra = (uint8_t*)p_fmt->p_extra;
1060 memcpy( &p_extra[ 0], "TTA1", 4 );
1061 SetWLE( &p_extra[ 4], 1 );
1062 SetWLE( &p_extra[ 6], p_fmt->audio.i_channels );
1063 SetWLE( &p_extra[ 8], p_fmt->audio.i_bitspersample );
1064 SetDWLE( &p_extra[10], p_fmt->audio.i_rate );
1065 SetDWLE( &p_extra[14], 0xffffffff );
1066 memset( &p_extra[18], 0, 30 - 18 );
1069 else if( !strcmp( tracks[i_track]->psz_codec, "A_PCM/INT/BIG" ) ||
1070 !strcmp( tracks[i_track]->psz_codec, "A_PCM/INT/LIT" ) ||
1071 !strcmp( tracks[i_track]->psz_codec, "A_PCM/FLOAT/IEEE" ) )
1073 if( !strcmp( tracks[i_track]->psz_codec, "A_PCM/INT/BIG" ) )
1075 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 't', 'w', 'o', 's' );
1079 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 'a', 'r', 'a', 'w' );
1081 tracks[i_track]->fmt.audio.i_blockalign = ( tracks[i_track]->fmt.audio.i_bitspersample + 7 ) / 8 * tracks[i_track]->fmt.audio.i_channels;
1083 else if( !strncmp( tracks[i_track]->psz_codec, "A_REAL/", 7 ) )
1085 if( !strcmp( tracks[i_track]->psz_codec, "A_REAL/COOK" ) )
1086 tracks[i_track]->fmt.i_codec = VLC_CODEC_COOK;
1087 else if( !strcmp( tracks[i_track]->psz_codec, "A_REAL/ATRC" ) )
1088 tracks[i_track]->fmt.i_codec = VLC_CODEC_ATRAC3;
1089 else if( !strcmp( tracks[i_track]->psz_codec, "A_REAL/28_8" ) )
1090 tracks[i_track]->fmt.i_codec = VLC_CODEC_RA_288;
1091 /* FIXME 14_4, RALF and SIPR */
1092 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
1093 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
1094 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
1096 /* disabled due to the potential "S_KATE" namespace issue */
1097 else if( !strcmp( tracks[i_track]->psz_codec, "S_KATE" ) )
1099 int i, i_offset = 1, i_extra, num_headers, size_so_far;
1102 tracks[i_track]->fmt.i_codec = VLC_CODEC_KATE;
1103 tracks[i_track]->fmt.subs.psz_encoding = strdup( "UTF-8" );
1105 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
1106 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
1107 memcpy( tracks[i_track]->fmt.p_extra,tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
1109 else if( !strcmp( tracks[i_track]->psz_codec, "S_TEXT/ASCII" ) )
1111 p_fmt->i_codec = VLC_CODEC_SUBT;
1112 p_fmt->subs.psz_encoding = NULL; /* Is there a place where it is stored ? */
1114 else if( !strcmp( tracks[i_track]->psz_codec, "S_TEXT/UTF8" ) )
1116 tracks[i_track]->fmt.i_codec = VLC_CODEC_SUBT;
1117 tracks[i_track]->fmt.subs.psz_encoding = strdup( "UTF-8" );
1119 else if( !strcmp( tracks[i_track]->psz_codec, "S_TEXT/USF" ) )
1121 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 'u', 's', 'f', ' ' );
1122 tracks[i_track]->fmt.subs.psz_encoding = strdup( "UTF-8" );
1123 if( tracks[i_track]->i_extra_data )
1125 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
1126 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
1127 memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
1130 else if( !strcmp( tracks[i_track]->psz_codec, "S_TEXT/SSA" ) ||
1131 !strcmp( tracks[i_track]->psz_codec, "S_TEXT/ASS" ) ||
1132 !strcmp( tracks[i_track]->psz_codec, "S_SSA" ) ||
1133 !strcmp( tracks[i_track]->psz_codec, "S_ASS" ))
1135 tracks[i_track]->fmt.i_codec = VLC_CODEC_SSA;
1136 tracks[i_track]->fmt.subs.psz_encoding = strdup( "UTF-8" );
1137 if( tracks[i_track]->i_extra_data )
1139 tracks[i_track]->fmt.i_extra = tracks[i_track]->i_extra_data;
1140 tracks[i_track]->fmt.p_extra = xmalloc( tracks[i_track]->i_extra_data );
1141 memcpy( tracks[i_track]->fmt.p_extra, tracks[i_track]->p_extra_data, tracks[i_track]->i_extra_data );
1144 else if( !strcmp( tracks[i_track]->psz_codec, "S_VOBSUB" ) )
1146 tracks[i_track]->fmt.i_codec = VLC_CODEC_SPU;
1147 if( tracks[i_track]->i_extra_data )
1150 char *psz_buf = (char *)malloc( tracks[i_track]->i_extra_data + 1);
1151 if( psz_buf != NULL )
1153 memcpy( psz_buf, tracks[i_track]->p_extra_data , tracks[i_track]->i_extra_data );
1154 psz_buf[tracks[i_track]->i_extra_data] = '\0';
1156 psz_start = strstr( psz_buf, "size:" );
1158 vobsub_size_parse( psz_start,
1159 &tracks[i_track]->fmt.subs.spu.i_original_frame_width,
1160 &tracks[i_track]->fmt.subs.spu.i_original_frame_height ) == VLC_SUCCESS )
1162 msg_Dbg( &sys.demuxer, "original frame size vobsubs: %dx%d",
1163 tracks[i_track]->fmt.subs.spu.i_original_frame_width,
1164 tracks[i_track]->fmt.subs.spu.i_original_frame_height );
1168 msg_Warn( &sys.demuxer, "reading original frame size for vobsub failed" );
1171 psz_start = strstr( psz_buf, "palette:" );
1173 vobsub_palette_parse( psz_start, &tracks[i_track]->fmt.subs.spu.palette[1] ) == VLC_SUCCESS )
1175 tracks[i_track]->fmt.subs.spu.palette[0] = 0xBeef;
1176 msg_Dbg( &sys.demuxer, "vobsub palette read" );
1180 msg_Warn( &sys.demuxer, "reading original palette failed" );
1186 else if( !strcmp( tracks[i_track]->psz_codec, "S_HDMV/PGS" ) )
1188 tracks[i_track]->fmt.i_codec = VLC_CODEC_BD_PG;
1190 else if( !strcmp( tracks[i_track]->psz_codec, "B_VOBBTN" ) )
1192 tracks[i_track]->fmt.i_cat = NAV_ES;
1195 else if( !strcmp( p_tk->psz_codec, "A_REAL/14_4" ) )
1197 p_fmt->i_codec = VLC_CODEC_RA_144;
1198 p_fmt->audio.i_channels = 1;
1199 p_fmt->audio.i_rate = 8000;
1200 p_fmt->audio.i_blockalign = 0x14;
1204 msg_Err( &sys.demuxer, "unknown codec id=`%s'", tracks[i_track]->psz_codec );
1205 tracks[i_track]->fmt.i_codec = VLC_FOURCC( 'u', 'n', 'd', 'f' );
1207 if( tracks[i_track]->b_default )
1209 tracks[i_track]->fmt.i_priority = 1000;
1212 tracks[i_track]->p_es = es_out_Add( sys.demuxer.out, &tracks[i_track]->fmt );
1214 /* Turn on a subtitles track if it has been flagged as default -
1215 * but only do this if no subtitles track has already been engaged,
1216 * either by an earlier 'default track' (??) or by default
1217 * language choice behaviour.
1219 if( tracks[i_track]->b_default )
1221 es_out_Control( sys.demuxer.out,
1222 ES_OUT_SET_ES_DEFAULT,
1223 tracks[i_track]->p_es );
1226 es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_start_time );
1228 sys.i_start_pts = i_start_time;
1229 // reset the stream reading to the first cluster of the segment used
1230 es.I_O().setFilePointer( i_start_pos );
1233 ep = new EbmlParser( &es, segment, &sys.demuxer );
1238 void matroska_segment_c::UnSelect( )
1242 for( i_track = 0; i_track < tracks.size(); i_track++ )
1244 if ( tracks[i_track]->p_es != NULL )
1246 // es_format_Clean( &tracks[i_track]->fmt );
1247 es_out_Del( sys.demuxer.out, tracks[i_track]->p_es );
1248 tracks[i_track]->p_es = NULL;
1255 int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_simpleblock, int64_t *pi_ref1, int64_t *pi_ref2, int64_t *pi_duration )
1257 pp_simpleblock = NULL;
1264 EbmlElement *el = NULL;
1268 return VLC_EGENERIC;
1270 if( pp_simpleblock != NULL || ((el = ep->Get()) == NULL && pp_block != NULL) )
1272 /* Check blocks validity to protect againts broken files */
1273 if( BlockFindTrackIndex( NULL, pp_block , pp_simpleblock ) )
1276 pp_simpleblock = NULL;
1281 /* update the index */
1282 #define idx p_indexes[i_index - 1]
1283 if( i_index > 0 && idx.i_time == -1 )
1285 if ( pp_simpleblock != NULL )
1286 idx.i_time = pp_simpleblock->GlobalTimecode() / (mtime_t)1000;
1288 idx.i_time = (*pp_block).GlobalTimecode() / (mtime_t)1000;
1289 idx.b_key = *pi_ref1 == 0 ? true : false;
1295 i_level = ep->GetLevel();
1304 msg_Warn( &sys.demuxer, "EOF" );
1305 return VLC_EGENERIC;
1308 /* Verify that we are still inside our cluster
1309 * It can happens whith broken files and when seeking
1313 if( cluster && !ep->IsTopPresent( cluster ) )
1315 msg_Warn( &sys.demuxer, "Unexpected escape from current cluster" );
1326 if( MKV_IS_ID( el, KaxCluster ) )
1328 cluster = (KaxCluster*)el;
1329 i_cluster_pos = cluster->GetElementPosition();
1331 /* add it to the index */
1333 ( i_index > 0 && p_indexes[i_index - 1].i_position < (int64_t)cluster->GetElementPosition() ) )
1335 IndexAppendCluster( cluster );
1338 // reset silent tracks
1339 for (size_t i=0; i<tracks.size(); i++)
1341 tracks[i]->b_silent = false;
1346 else if( MKV_IS_ID( el, KaxCues ) )
1348 msg_Warn( &sys.demuxer, "find KaxCues FIXME" );
1349 return VLC_EGENERIC;
1353 msg_Dbg( &sys.demuxer, "unknown (%s)", typeid( el ).name() );
1357 if( MKV_IS_ID( el, KaxClusterTimecode ) )
1359 KaxClusterTimecode &ctc = *(KaxClusterTimecode*)el;
1361 ctc.ReadData( es.I_O(), SCOPE_ALL_DATA );
1362 cluster->InitTimecode( uint64( ctc ), i_timescale );
1364 else if( MKV_IS_ID( el, KaxClusterSilentTracks ) )
1368 else if( MKV_IS_ID( el, KaxBlockGroup ) )
1370 i_block_pos = el->GetElementPosition();
1373 else if( MKV_IS_ID( el, KaxSimpleBlock ) )
1375 pp_simpleblock = (KaxSimpleBlock*)el;
1377 pp_simpleblock->ReadData( es.I_O() );
1378 pp_simpleblock->SetParent( *cluster );
1382 if( MKV_IS_ID( el, KaxBlock ) )
1384 pp_block = (KaxBlock*)el;
1386 pp_block->ReadData( es.I_O() );
1387 pp_block->SetParent( *cluster );
1391 else if( MKV_IS_ID( el, KaxBlockDuration ) )
1393 KaxBlockDuration &dur = *(KaxBlockDuration*)el;
1395 dur.ReadData( es.I_O() );
1396 *pi_duration = uint64( dur );
1398 else if( MKV_IS_ID( el, KaxReferenceBlock ) )
1400 KaxReferenceBlock &ref = *(KaxReferenceBlock*)el;
1402 ref.ReadData( es.I_O() );
1405 *pi_ref1 = int64( ref ) * cluster->GlobalTimecodeScale();
1407 else if( *pi_ref2 == 0 )
1409 *pi_ref2 = int64( ref ) * cluster->GlobalTimecodeScale();
1412 else if( MKV_IS_ID( el, KaxClusterSilentTrackNumber ) )
1414 KaxClusterSilentTrackNumber &track_num = *(KaxClusterSilentTrackNumber*)el;
1415 track_num.ReadData( es.I_O() );
1417 for (size_t i=0; i<tracks.size(); i++)
1419 if ( tracks[i]->i_number == uint32(track_num))
1421 tracks[i]->b_silent = true;
1428 msg_Err( &sys.demuxer, "invalid level = %d", i_level );
1429 return VLC_EGENERIC;