File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -833,20 +833,23 @@ impl<'a> Iterator for SampleToChunkIterator<'a> {
833
833
let has_chunk = self . chunks . next ( )
834
834
. or_else ( || {
835
835
self . chunks = match ( self . stsc_peek_iter . next ( ) , self . stsc_peek_iter . peek ( ) ) {
836
- ( Some ( next) , Some ( peek) ) => {
836
+ ( Some ( next) , Some ( peek) ) if next . first_chunk > 0 && peek . first_chunk > 0 => {
837
837
self . sample_count = next. samples_per_chunk ;
838
838
( ( next. first_chunk - 1 ) .. ( peek. first_chunk - 1 ) )
839
839
} ,
840
- ( Some ( next) , None ) => {
840
+ ( Some ( next) , None ) if next . first_chunk > 0 => {
841
841
self . sample_count = next. samples_per_chunk ;
842
842
// Total chunk number in 'stsc' could be different to 'stco',
843
843
// there could be more chunks at the last 'stsc' record.
844
844
( ( next. first_chunk - 1 ) .. next. first_chunk + self . remain_chunk_count -1 )
845
845
} ,
846
846
_ => ( 0 .. 0 ) ,
847
847
} ;
848
- self . remain_chunk_count -= self . chunks . len ( ) as u32 ;
849
- self . chunks . next ( )
848
+
849
+ self . remain_chunk_count . checked_sub ( self . chunks . len ( ) as u32 ) . and_then ( |res| {
850
+ self . remain_chunk_count = res;
851
+ self . chunks . next ( )
852
+ } )
850
853
} ) ;
851
854
852
855
has_chunk. map_or ( None , |id| { Some ( ( id, self . sample_count ) ) } )
You can’t perform that action at this time.
0 commit comments