Commit 19c66b86 authored by Filip Roséen's avatar Filip Roséen Committed by Jean-Baptiste Kempf

mkv: `MKV_CHECKED_PTR_DECL` introduced to `matroska_segment.cpp`

See previous commit for information regarding the macro.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent d8b179e2
...@@ -135,18 +135,17 @@ void matroska_segment_c::LoadCues( KaxCues *cues ) ...@@ -135,18 +135,17 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
ep->Down(); ep->Down();
while( ( el = ep->Get() ) != NULL ) while( ( el = ep->Get() ) != NULL )
{ {
if( MKV_IS_ID( el, KaxCueTime ) ) if ( MKV_CHECKED_PTR_DECL( kct_ptr, KaxCueTime, el ) )
{ {
KaxCueTime &ctime = *static_cast<KaxCueTime*>( el );
try try
{ {
if( unlikely( !ctime.ValidateSize() ) ) if( unlikely( !kct_ptr->ValidateSize() ) )
{ {
msg_Err( &sys.demuxer, "CueTime size too big"); msg_Err( &sys.demuxer, "CueTime size too big");
b_invalid_cue = true; b_invalid_cue = true;
break; break;
} }
ctime.ReadData( es.I_O() ); kct_ptr->ReadData( es.I_O() );
} }
catch(...) catch(...)
{ {
...@@ -154,7 +153,7 @@ void matroska_segment_c::LoadCues( KaxCues *cues ) ...@@ -154,7 +153,7 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
b_invalid_cue = true; b_invalid_cue = true;
break; break;
} }
last_idx.i_mk_time = static_cast<uint64>( ctime ) * i_timescale / INT64_C(1000); last_idx.i_mk_time = static_cast<uint64>( *kct_ptr ) * i_timescale / INT64_C(1000);
} }
else if( MKV_IS_ID( el, KaxCueTrackPositions ) ) else if( MKV_IS_ID( el, KaxCueTrackPositions ) )
{ {
...@@ -171,25 +170,20 @@ void matroska_segment_c::LoadCues( KaxCues *cues ) ...@@ -171,25 +170,20 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
break; break;
} }
if( MKV_IS_ID( el, KaxCueTrack ) ) if( MKV_CHECKED_PTR_DECL ( kct_ptr, KaxCueTrack, el ) )
{ {
KaxCueTrack &ctrack = *static_cast<KaxCueTrack*>( el ); kct_ptr->ReadData( es.I_O() );
ctrack.ReadData( es.I_O() ); last_idx.i_track = static_cast<uint16>( *kct_ptr );
last_idx.i_track = static_cast<uint16>( ctrack );
} }
else if( MKV_IS_ID( el, KaxCueClusterPosition ) ) else if( MKV_CHECKED_PTR_DECL ( kccp_ptr, KaxCueClusterPosition, el ) )
{ {
KaxCueClusterPosition &ccpos = *static_cast<KaxCueClusterPosition*>( el ); kccp_ptr->ReadData( es.I_O() );
last_idx.i_position = segment->GetGlobalPosition( static_cast<uint64> ( *kccp_ptr ) );
ccpos.ReadData( es.I_O() );
last_idx.i_position = segment->GetGlobalPosition( static_cast<uint64>( ccpos ) );
} }
else if( MKV_IS_ID( el, KaxCueBlockNumber ) ) else if( MKV_CHECKED_PTR_DECL ( kcbn_ptr, KaxCueBlockNumber, el ) )
{ {
KaxCueBlockNumber &cbnum = *static_cast<KaxCueBlockNumber*>( el ); kcbn_ptr->ReadData( es.I_O() );
last_idx.i_block_number = static_cast<uint32>( *kcbn_ptr );
cbnum.ReadData( es.I_O() );
last_idx.i_block_number = static_cast<uint32>( cbnum );
} }
#if LIBMATROSKA_VERSION >= 0x010401 #if LIBMATROSKA_VERSION >= 0x010401
else if( MKV_IS_ID( el, KaxCueRelativePosition ) ) else if( MKV_IS_ID( el, KaxCueRelativePosition ) )
...@@ -296,34 +290,30 @@ SimpleTag * matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag, int target_t ...@@ -296,34 +290,30 @@ SimpleTag * matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag, int target_t
delete p_simple; delete p_simple;
return NULL; return NULL;
} }
if( MKV_IS_ID( el, KaxTagName ) ) if( MKV_CHECKED_PTR_DECL ( ktn_ptr, KaxTagName, el ) )
{ {
KaxTagName &key = *static_cast<KaxTagName*>( el ); ktn_ptr->ReadData( es.I_O(), SCOPE_ALL_DATA );
key.ReadData( es.I_O(), SCOPE_ALL_DATA ); p_simple->psz_tag_name = strdup( UTFstring( *ktn_ptr ).GetUTF8().c_str() );
p_simple->psz_tag_name = strdup( UTFstring( key ).GetUTF8().c_str() );
} }
else if( MKV_IS_ID( el, KaxTagString ) ) else if( MKV_CHECKED_PTR_DECL ( kts_ptr, KaxTagString, el ) )
{ {
KaxTagString &value = *static_cast<KaxTagString*>( el ); kts_ptr->ReadData( es.I_O(), SCOPE_ALL_DATA );
value.ReadData( es.I_O(), SCOPE_ALL_DATA ); p_simple->p_value = strdup( UTFstring( *kts_ptr ).GetUTF8().c_str() );
p_simple->p_value = strdup( UTFstring( value ).GetUTF8().c_str() );
} }
else if( MKV_IS_ID( el, KaxTagLangue ) ) else if( MKV_CHECKED_PTR_DECL ( ktl_ptr, KaxTagLangue, el ) )
{ {
KaxTagLangue &language = *static_cast<KaxTagLangue*>( el ); ktl_ptr->ReadData( es.I_O(), SCOPE_ALL_DATA );
language.ReadData( es.I_O(), SCOPE_ALL_DATA ); p_simple->psz_lang = strdup( std::string( *ktl_ptr ).c_str());
p_simple->psz_lang = strdup( std::string( language ).c_str());
} }
else if( MKV_IS_ID( el, KaxTagDefault ) ) else if( MKV_CHECKED_PTR_DECL ( ktd_ptr, KaxTagDefault, el ) )
{ {
KaxTagDefault & dft = *static_cast<KaxTagDefault*>( el ); ktd_ptr->ReadData( es.I_O(), SCOPE_ALL_DATA );
dft.ReadData( es.I_O(), SCOPE_ALL_DATA ); p_simple->b_default = (bool) uint8( *ktd_ptr );
p_simple->b_default = static_cast<bool>( static_cast<uint8>( dft ) );
} }
/*Tags can be nested*/ /*Tags can be nested*/
else if( MKV_IS_ID( el, KaxTagSimple) ) else if( MKV_CHECKED_PTR_DECL ( kts_ptr, KaxTagSimple, el) )
{ {
SimpleTag * p_st = ParseSimpleTags( static_cast<KaxTagSimple*>( el ), target_type ); SimpleTag * p_st = ParseSimpleTags( kts_ptr, target_type );
if( p_st ) if( p_st )
p_simple->sub_tags.push_back( p_st ); p_simple->sub_tags.push_back( p_st );
} }
...@@ -407,45 +397,40 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -407,45 +397,40 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
msg_Err( &sys.demuxer, "Invalid size while reading tag"); msg_Err( &sys.demuxer, "Invalid size while reading tag");
break; break;
} }
if( MKV_IS_ID( el, KaxTagTargetTypeValue ) ) if( MKV_CHECKED_PTR_DECL ( ktttv_ptr, KaxTagTargetTypeValue, el ) )
{ {
KaxTagTargetTypeValue &value = *static_cast<KaxTagTargetTypeValue*>( el ); ktttv_ptr->ReadData( es.I_O() );
value.ReadData( es.I_O() );
msg_Dbg( &sys.demuxer, "| | + TargetTypeValue: %u", static_cast<uint32>(value)); msg_Dbg( &sys.demuxer, "| | + TargetTypeValue: %u", uint32(*ktttv_ptr));
target_type = static_cast<uint32>(value); target_type = static_cast<uint32>( *ktttv_ptr );
} }
else if( MKV_IS_ID( el, KaxTagTrackUID ) ) else if( MKV_CHECKED_PTR_DECL ( kttu_ptr, KaxTagTrackUID, el ) )
{ {
p_tag->i_tag_type = TRACK_UID; p_tag->i_tag_type = TRACK_UID;
KaxTagTrackUID &uid = *static_cast<KaxTagTrackUID*>( el ); kttu_ptr->ReadData( es.I_O() );
uid.ReadData( es.I_O() ); p_tag->i_uid = static_cast<uint64>( *kttu_ptr );
p_tag->i_uid = static_cast<uint64>( uid );
msg_Dbg( &sys.demuxer, "| | + TrackUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + TrackUID: %" PRIu64, p_tag->i_uid);
} }
else if( MKV_IS_ID( el, KaxTagEditionUID ) ) else if( MKV_CHECKED_PTR_DECL ( kteu_ptr, KaxTagEditionUID, el ) )
{ {
p_tag->i_tag_type = EDITION_UID; p_tag->i_tag_type = EDITION_UID;
KaxTagEditionUID &uid = *static_cast<KaxTagEditionUID*>( el ); kteu_ptr->ReadData( es.I_O() );
uid.ReadData( es.I_O() ); p_tag->i_uid = static_cast<uint64>( *kteu_ptr );
p_tag->i_uid = static_cast<uint64>( uid );
msg_Dbg( &sys.demuxer, "| | + EditionUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + EditionUID: %" PRIu64, p_tag->i_uid);
} }
else if( MKV_IS_ID( el, KaxTagChapterUID ) ) else if( MKV_CHECKED_PTR_DECL ( ktcu_ptr, KaxTagChapterUID, el ) )
{ {
p_tag->i_tag_type = CHAPTER_UID; p_tag->i_tag_type = CHAPTER_UID;
KaxTagChapterUID &uid = *static_cast<KaxTagChapterUID*>( el ); ktcu_ptr->ReadData( es.I_O() );
uid.ReadData( es.I_O() ); p_tag->i_uid = static_cast<uint64>( *ktcu_ptr );
p_tag->i_uid = static_cast<uint64>( uid );
msg_Dbg( &sys.demuxer, "| | + ChapterUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + ChapterUID: %" PRIu64, p_tag->i_uid);
} }
else if( MKV_IS_ID( el, KaxTagAttachmentUID ) ) else if( MKV_CHECKED_PTR_DECL ( ktau_ptr, KaxTagAttachmentUID, el ) )
{ {
p_tag->i_tag_type = ATTACHMENT_UID; p_tag->i_tag_type = ATTACHMENT_UID;
KaxTagAttachmentUID &uid = *static_cast<KaxTagAttachmentUID*>( el ); ktau_ptr->ReadData( es.I_O() );
uid.ReadData( es.I_O() ); p_tag->i_uid = static_cast<uint64>( *ktau_ptr );
p_tag->i_uid = static_cast<uint64>( uid );
msg_Dbg( &sys.demuxer, "| | + AttachmentUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + AttachmentUID: %" PRIu64, p_tag->i_uid);
} }
else else
...@@ -461,11 +446,9 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -461,11 +446,9 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
} }
ep->Up(); ep->Up();
} }
else if( MKV_IS_ID( el, KaxTagSimple ) ) else if( MKV_CHECKED_PTR_DECL ( kts_ptr, KaxTagSimple, el ) )
{ {
SimpleTag * p_simple = SimpleTag * p_simple = ParseSimpleTags( kts_ptr, target_type );
ParseSimpleTags( static_cast<KaxTagSimple*>( el ),
target_type );
if( p_simple ) if( p_simple )
p_tag->simple_tags.push_back( p_simple ); p_tag->simple_tags.push_back( p_simple );
} }
...@@ -672,13 +655,13 @@ bool matroska_segment_c::Preload( ) ...@@ -672,13 +655,13 @@ bool matroska_segment_c::Preload( )
i_info_position = el->GetElementPosition(); i_info_position = el->GetElementPosition();
} }
} }
else if( MKV_IS_ID( el, KaxTracks ) ) else if( MKV_CHECKED_PTR_DECL ( kt_ptr, KaxTracks, el ) )
{ {
/* Multiple allowed */ /* Multiple allowed */
msg_Dbg( &sys.demuxer, "| + Tracks" ); msg_Dbg( &sys.demuxer, "| + Tracks" );
if( i_tracks_position < 0 ) if( i_tracks_position < 0 )
{ {
ParseTracks( static_cast<KaxTracks*>( el ) ); ParseTracks( kt_ptr );
} }
if ( tracks.size() == 0 ) if ( tracks.size() == 0 )
{ {
...@@ -687,20 +670,20 @@ bool matroska_segment_c::Preload( ) ...@@ -687,20 +670,20 @@ bool matroska_segment_c::Preload( )
} }
i_tracks_position = el->GetElementPosition(); i_tracks_position = el->GetElementPosition();
} }
else if( MKV_IS_ID( el, KaxCues ) ) else if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxCues, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Cues" ); msg_Dbg( &sys.demuxer, "| + Cues" );
if( i_cues_position < 0 ) if( i_cues_position < 0 )
{ {
LoadCues( static_cast<KaxCues*>( el ) ); LoadCues( kc_ptr );
i_cues_position = el->GetElementPosition(); i_cues_position = el->GetElementPosition();
} }
} }
else if( MKV_IS_ID( el, KaxCluster ) ) else if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxCluster, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Cluster" ); msg_Dbg( &sys.demuxer, "| + Cluster" );
cluster = static_cast<KaxCluster*>( el ); cluster = kc_ptr;
i_cluster_pos = i_start_pos = cluster->GetElementPosition(); i_cluster_pos = i_start_pos = cluster->GetElementPosition();
ParseCluster( cluster ); ParseCluster( cluster );
...@@ -709,34 +692,34 @@ bool matroska_segment_c::Preload( ) ...@@ -709,34 +692,34 @@ bool matroska_segment_c::Preload( )
/* stop pre-parsing the stream */ /* stop pre-parsing the stream */
break; break;
} }
else if( MKV_IS_ID( el, KaxAttachments ) ) else if( MKV_CHECKED_PTR_DECL ( ka_ptr, KaxAttachments, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Attachments" ); msg_Dbg( &sys.demuxer, "| + Attachments" );
if( i_attachments_position < 0 ) if( i_attachments_position < 0 )
{ {
ParseAttachments( static_cast<KaxAttachments*>( el ) ); ParseAttachments( ka_ptr );
i_attachments_position = el->GetElementPosition(); i_attachments_position = el->GetElementPosition();
} }
} }
else if( MKV_IS_ID( el, KaxChapters ) ) else if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxChapters, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Chapters" ); msg_Dbg( &sys.demuxer, "| + Chapters" );
if( i_chapters_position < 0 ) if( i_chapters_position < 0 )
{ {
ParseChapters( static_cast<KaxChapters*>( el ) ); ParseChapters( kc_ptr );
i_chapters_position = el->GetElementPosition(); i_chapters_position = el->GetElementPosition();
} }
} }
else if( MKV_IS_ID( el, KaxTags ) ) else if( MKV_CHECKED_PTR_DECL ( kt_ptr, KaxTags, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Tags" ); msg_Dbg( &sys.demuxer, "| + Tags" );
if( i_tags_position < 0) if( i_tags_position < 0)
{ {
LoadTags( static_cast<KaxTags*>( el ) ); LoadTags( kt_ptr );
i_tags_position = el->GetElementPosition(); i_tags_position = el->GetElementPosition();
} }
} }
else if( MKV_IS_ID( el, EbmlVoid ) ) else if( MKV_IS_ID ( el, EbmlVoid ) )
msg_Dbg( &sys.demuxer, "| + Void" ); msg_Dbg( &sys.demuxer, "| + Void" );
else else
msg_Dbg( &sys.demuxer, "| + Preload Unknown (%s)", typeid(*el).name() ); msg_Dbg( &sys.demuxer, "| + Preload Unknown (%s)", typeid(*el).name() );
...@@ -767,7 +750,7 @@ bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int ...@@ -767,7 +750,7 @@ bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int
return false; return false;
} }
if( MKV_IS_ID( el, KaxSeekHead ) ) if( MKV_CHECKED_PTR_DECL ( ksh_ptr, KaxSeekHead, el ) )
{ {
/* Multiple allowed */ /* Multiple allowed */
msg_Dbg( &sys.demuxer, "| + Seek head" ); msg_Dbg( &sys.demuxer, "| + Seek head" );
...@@ -776,26 +759,26 @@ bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int ...@@ -776,26 +759,26 @@ bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int
if ( i_seekhead_position != i_element_position ) if ( i_seekhead_position != i_element_position )
{ {
i_seekhead_position = i_element_position; i_seekhead_position = i_element_position;
ParseSeekHead( static_cast<KaxSeekHead*>( el ) ); ParseSeekHead( ksh_ptr );
} }
} }
} }
else if( MKV_IS_ID( el, KaxInfo ) ) // FIXME else if( MKV_CHECKED_PTR_DECL ( ki_ptr, KaxInfo, el ) ) // FIXME
{ {
/* Multiple allowed, mandatory */ /* Multiple allowed, mandatory */
msg_Dbg( &sys.demuxer, "| + Information" ); msg_Dbg( &sys.demuxer, "| + Information" );
if( i_info_position < 0 ) if( i_info_position < 0 )
{ {
ParseInfo( static_cast<KaxInfo*>( el ) ); ParseInfo( ki_ptr );
i_info_position = i_element_position; i_info_position = i_element_position;
} }
} }
else if( MKV_IS_ID( el, KaxTracks ) ) // FIXME else if( MKV_CHECKED_PTR_DECL ( kt_ptr, KaxTracks, el ) ) // FIXME
{ {
/* Multiple allowed */ /* Multiple allowed */
msg_Dbg( &sys.demuxer, "| + Tracks" ); msg_Dbg( &sys.demuxer, "| + Tracks" );
if( i_tracks_position < 0 ) if( i_tracks_position < 0 )
ParseTracks( static_cast<KaxTracks*>( el ) ); ParseTracks( kt_ptr );
if ( tracks.size() == 0 ) if ( tracks.size() == 0 )
{ {
msg_Err( &sys.demuxer, "No tracks supported" ); msg_Err( &sys.demuxer, "No tracks supported" );
...@@ -805,39 +788,39 @@ bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int ...@@ -805,39 +788,39 @@ bool matroska_segment_c::LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int
} }
i_tracks_position = i_element_position; i_tracks_position = i_element_position;
} }
else if( MKV_IS_ID( el, KaxCues ) ) else if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxCues, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Cues" ); msg_Dbg( &sys.demuxer, "| + Cues" );
if( i_cues_position < 0 ) if( i_cues_position < 0 )
{ {
LoadCues( static_cast<KaxCues*>( el ) ); LoadCues( kc_ptr );
i_cues_position = i_element_position; i_cues_position = i_element_position;
} }
} }
else if( MKV_IS_ID( el, KaxAttachments ) ) else if( MKV_CHECKED_PTR_DECL ( ka_ptr, KaxAttachments, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Attachments" ); msg_Dbg( &sys.demuxer, "| + Attachments" );
if( i_attachments_position < 0 ) if( i_attachments_position < 0 )
{ {
ParseAttachments( static_cast<KaxAttachments*>( el ) ); ParseAttachments( ka_ptr );
i_attachments_position = i_element_position; i_attachments_position = i_element_position;
} }
} }
else if( MKV_IS_ID( el, KaxChapters ) ) else if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxChapters, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Chapters" ); msg_Dbg( &sys.demuxer, "| + Chapters" );
if( i_chapters_position < 0 ) if( i_chapters_position < 0 )
{ {
ParseChapters( static_cast<KaxChapters*>( el ) ); ParseChapters( kc_ptr );
i_chapters_position = i_element_position; i_chapters_position = i_element_position;
} }
} }
else if( MKV_IS_ID( el, KaxTags ) ) else if( MKV_CHECKED_PTR_DECL ( kt_ptr, KaxTags, el ) )
{ {
msg_Dbg( &sys.demuxer, "| + Tags" ); msg_Dbg( &sys.demuxer, "| + Tags" );
if( i_tags_position < 0 ) if( i_tags_position < 0 )
{ {
LoadTags( static_cast<KaxTags*>( el ) ); LoadTags( kt_ptr );
i_tags_position = i_element_position; i_tags_position = i_element_position;
} }
} }
...@@ -898,9 +881,9 @@ void matroska_segment_c::Seek( mtime_t i_mk_date, mtime_t i_mk_time_offset, int6 ...@@ -898,9 +881,9 @@ void matroska_segment_c::Seek( mtime_t i_mk_date, mtime_t i_mk_time_offset, int6
while( ( el = ep->Get() ) != NULL ) while( ( el = ep->Get() ) != NULL )
{ {
if( MKV_IS_ID( el, KaxCluster ) ) if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxCluster, el ) )
{ {
cluster = static_cast<KaxCluster *>( el ); cluster = kc_ptr;
i_cluster_pos = cluster->GetElementPosition(); i_cluster_pos = cluster->GetElementPosition();
if( index_idx() == 0 || if( index_idx() == 0 ||
( prev_index().i_position < (int64_t)cluster->GetElementPosition() ) ) ( prev_index().i_position < (int64_t)cluster->GetElementPosition() ) )
...@@ -1254,30 +1237,26 @@ void matroska_segment_c::EnsureDuration() ...@@ -1254,30 +1237,26 @@ void matroska_segment_c::EnsureDuration()
{ {
EbmlElement *l = (*p_last_cluster)[i]; EbmlElement *l = (*p_last_cluster)[i];
if( MKV_IS_ID( l, KaxSimpleBlock ) ) if( MKV_CHECKED_PTR_DECL ( block, KaxSimpleBlock, l ) )
{ {
KaxSimpleBlock *block = static_cast<KaxSimpleBlock*>( l );
block->SetParent( *p_last_cluster ); block->SetParent( *p_last_cluster );
i_last_timecode = std::max(i_last_timecode, block->GlobalTimecode()); i_last_timecode = std::max(i_last_timecode, block->GlobalTimecode());
} }
else if( MKV_IS_ID( l, KaxBlockGroup ) ) else if( MKV_CHECKED_PTR_DECL ( group, KaxBlockGroup, l ) )
{ {
KaxBlockGroup *group = static_cast<KaxBlockGroup*>( l );
uint64 i_group_timecode = 0; uint64 i_group_timecode = 0;
for( unsigned int j = 0; j < group->ListSize(); j++ ) for( unsigned int j = 0; j < group->ListSize(); j++ )
{ {
EbmlElement *l = (*group)[j]; EbmlElement *l = (*group)[j];
if( MKV_IS_ID( l, KaxBlock ) ) if( MKV_CHECKED_PTR_DECL ( block, KaxBlock, l ) )
{ {
KaxBlock *block = static_cast<KaxBlock*>( l );
block->SetParent( *p_last_cluster ); block->SetParent( *p_last_cluster );
i_group_timecode += block->GlobalTimecode(); i_group_timecode += block->GlobalTimecode();
} }
else if( MKV_IS_ID( l, KaxBlockDuration ) ) else if( MKV_CHECKED_PTR_DECL ( kbd_ptr, KaxBlockDuration, l ) )
{ {
KaxBlockDuration & dur = *static_cast<KaxBlockDuration*>( l ); i_group_timecode += static_cast<uint64>( *kbd_ptr );
i_group_timecode += static_cast<uint64>( dur );
} }
} }
i_last_timecode = std::max(i_last_timecode, i_group_timecode); i_last_timecode = std::max(i_last_timecode, i_group_timecode);
...@@ -1461,9 +1440,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s ...@@ -1461,9 +1440,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
switch ( i_level ) switch ( i_level )
{ {
case 1: case 1:
if( MKV_IS_ID( el, KaxCluster ) ) if( MKV_CHECKED_PTR_DECL ( kc_ptr, KaxCluster, el ) )
{ {
cluster = static_cast<KaxCluster*>( el ); cluster = kc_ptr;
i_cluster_pos = cluster->GetElementPosition(); i_cluster_pos = cluster->GetElementPosition();
// reset silent tracks // reset silent tracks
...@@ -1492,12 +1471,10 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s ...@@ -1492,12 +1471,10 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
ep->Up(); ep->Up();