static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk ) { avi_chunk_t chk; if( !p_chk ) { if( AVI_ChunkReadCommon( s, &chk ) ) { return VLC_EGENERIC; } p_chk = &chk; } if( p_chk->common.p_father ) { if( p_chk->common.p_father->common.i_chunk_pos + __EVEN( p_chk->common.p_father->common.i_chunk_size ) + 8 < p_chk->common.i_chunk_pos + __EVEN( p_chk->common.i_chunk_size ) + 8 ) { return VLC_EGENERIC; } } return stream_Seek( s, p_chk->common.i_chunk_pos + __EVEN( p_chk->common.i_chunk_size ) + 8 ); }
int AVI_ChunkRead( stream_t *s, avi_chunk_t *p_chk, avi_chunk_t *p_father ) { int i_index; if( !p_chk ) { msg_Warn( (vlc_object_t*)s, "cannot read null chunk" ); return VLC_EGENERIC; } if( AVI_ChunkReadCommon( s, p_chk ) ) { msg_Warn( (vlc_object_t*)s, "cannot read one chunk" ); return VLC_EGENERIC; } if( p_chk->common.i_chunk_fourcc == VLC_FOURCC( 0, 0, 0, 0 ) ) { msg_Warn( (vlc_object_t*)s, "found null fourcc chunk (corrupted file?)" ); return AVI_ZERO_FOURCC; } p_chk->common.p_father = p_father; i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc ); if( AVI_Chunk_Function[i_index].AVI_ChunkRead_function ) { int i_return = AVI_Chunk_Function[i_index].AVI_ChunkRead_function( s, p_chk ); if ( i_return == AVI_STRD_ZERO_CHUNK || i_return == AVI_ZERO_FOURCC ) { if ( !p_father ) return VLC_EGENERIC; return AVI_NextChunk( s, p_father ); } return i_return; } else if( ( ((char*)&p_chk->common.i_chunk_fourcc)[0] == 'i' && ((char*)&p_chk->common.i_chunk_fourcc)[1] == 'x' ) || ( ((char*)&p_chk->common.i_chunk_fourcc)[2] == 'i' && ((char*)&p_chk->common.i_chunk_fourcc)[3] == 'x' ) ) { p_chk->common.i_chunk_fourcc = AVIFOURCC_indx; return AVI_ChunkRead_indx( s, p_chk ); } msg_Warn( (vlc_object_t*)s, "unknown chunk: %4.4s (not loaded)", (char*)&p_chk->common.i_chunk_fourcc ); return AVI_NextChunk( s, p_chk ); }
static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk ) { avi_chunk_t chk; if( !p_chk ) { if( AVI_ChunkReadCommon( s, &chk ) ) { return VLC_EGENERIC; } p_chk = &chk; } if( p_chk->common.p_father ) { if( p_chk->common.p_father->common.i_chunk_pos + __EVEN( p_chk->common.p_father->common.i_chunk_size ) + 8 < p_chk->common.i_chunk_pos + __EVEN( p_chk->common.i_chunk_size ) + 8 ) { return VLC_EGENERIC; } } bool b_seekable = false; uint64_t i_offset = p_chk->common.i_chunk_pos + __EVEN( p_chk->common.i_chunk_size ) + 8; if ( !vlc_stream_Control(s, STREAM_CAN_SEEK, &b_seekable) && b_seekable ) { return vlc_stream_Seek( s, i_offset ); } else { ssize_t i_read = i_offset - vlc_stream_Tell( s ); return (i_read >=0 && vlc_stream_Read( s, NULL, i_read ) == i_read) ? VLC_SUCCESS : VLC_EGENERIC; } }