@@ -568,31 +568,25 @@ pub unsafe extern fn mp4parse_get_track_audio_info(parser: *mut mp4parse_parser,
568
568
Ok ( _) => {
569
569
let header = ( * parser) . opus_header_mut ( ) ;
570
570
header. insert ( track_index, v) ;
571
- match header. get ( & track_index) {
572
- None => { }
573
- Some ( v) => {
574
- if v. len ( ) > std:: u32:: MAX as usize {
575
- return MP4PARSE_ERROR_INVALID ;
576
- }
577
- ( * info) . codec_specific_config . length = v. len ( ) as u32 ;
578
- ( * info) . codec_specific_config . data = v. as_ptr ( ) ;
571
+ if let Some ( v) = header. get ( & track_index) {
572
+ if v. len ( ) > std:: u32:: MAX as usize {
573
+ return MP4PARSE_ERROR_INVALID ;
579
574
}
575
+ ( * info) . codec_specific_config . length = v. len ( ) as u32 ;
576
+ ( * info) . codec_specific_config . data = v. as_ptr ( ) ;
580
577
}
581
578
}
582
579
}
583
580
}
584
581
AudioCodecSpecific :: MP3 => ( ) ,
585
582
}
586
583
587
- match audio. protection_info . iter ( ) . find ( |sinf| sinf. tenc . is_some ( ) ) {
588
- Some ( p) => {
589
- if let Some ( ref tenc) = p. tenc {
590
- ( * info) . protected_data . is_encrypted = tenc. is_encrypted ;
591
- ( * info) . protected_data . iv_size = tenc. iv_size ;
592
- ( * info) . protected_data . kid . set_data ( & ( tenc. kid ) ) ;
593
- }
594
- } ,
595
- _ => { } ,
584
+ if let Some ( p) = audio. protection_info . iter ( ) . find ( |sinf| sinf. tenc . is_some ( ) ) {
585
+ if let Some ( ref tenc) = p. tenc {
586
+ ( * info) . protected_data . is_encrypted = tenc. is_encrypted ;
587
+ ( * info) . protected_data . iv_size = tenc. iv_size ;
588
+ ( * info) . protected_data . kid . set_data ( & ( tenc. kid ) ) ;
589
+ }
596
590
}
597
591
598
592
MP4PARSE_OK
@@ -648,22 +642,16 @@ pub unsafe extern fn mp4parse_get_track_video_info(parser: *mut mp4parse_parser,
648
642
( * info) . image_width = video. width ;
649
643
( * info) . image_height = video. height ;
650
644
651
- match video. codec_specific {
652
- VideoCodecSpecific :: AVCConfig ( ref avc) => {
653
- ( * info) . extra_data . set_data ( avc) ;
654
- } ,
655
- _ => { } ,
645
+ if let VideoCodecSpecific :: AVCConfig ( ref avc) = video. codec_specific {
646
+ ( * info) . extra_data . set_data ( avc) ;
656
647
}
657
648
658
- match video. protection_info . iter ( ) . find ( |sinf| sinf. tenc . is_some ( ) ) {
659
- Some ( p) => {
660
- if let Some ( ref tenc) = p. tenc {
661
- ( * info) . protected_data . is_encrypted = tenc. is_encrypted ;
662
- ( * info) . protected_data . iv_size = tenc. iv_size ;
663
- ( * info) . protected_data . kid . set_data ( & ( tenc. kid ) ) ;
664
- }
665
- } ,
666
- _ => { } ,
649
+ if let Some ( p) = video. protection_info . iter ( ) . find ( |sinf| sinf. tenc . is_some ( ) ) {
650
+ if let Some ( ref tenc) = p. tenc {
651
+ ( * info) . protected_data . is_encrypted = tenc. is_encrypted ;
652
+ ( * info) . protected_data . iv_size = tenc. iv_size ;
653
+ ( * info) . protected_data . kid . set_data ( & ( tenc. kid ) ) ;
654
+ }
667
655
}
668
656
669
657
MP4PARSE_OK
@@ -686,12 +674,9 @@ pub unsafe extern fn mp4parse_get_indice_table(parser: *mut mp4parse_parser, tra
686
674
} ;
687
675
688
676
let index_table = ( * parser) . sample_table_mut ( ) ;
689
- match index_table. get ( & track_id) {
690
- Some ( v) => {
691
- ( * indices) . set_indices ( v) ;
692
- return MP4PARSE_OK ;
693
- } ,
694
- _ => { } ,
677
+ if let Some ( v) = index_table. get ( & track_id) {
678
+ ( * indices) . set_indices ( v) ;
679
+ return MP4PARSE_OK ;
695
680
}
696
681
697
682
let media_time = match ( & track. media_time , & track. timescale ) {
@@ -718,13 +703,10 @@ pub unsafe extern fn mp4parse_get_indice_table(parser: *mut mp4parse_parser, tra
718
703
_ => 0 ,
719
704
} ;
720
705
721
- match create_sample_table ( track, offset_time) {
722
- Some ( v) => {
723
- ( * indices) . set_indices ( & v) ;
724
- index_table. insert ( track_id, v) ;
725
- return MP4PARSE_OK ;
726
- } ,
727
- _ => { } ,
706
+ if let Some ( v) = create_sample_table ( track, offset_time) {
707
+ ( * indices) . set_indices ( & v) ;
708
+ index_table. insert ( track_id, v) ;
709
+ return MP4PARSE_OK ;
728
710
}
729
711
730
712
MP4PARSE_ERROR_INVALID
@@ -934,13 +916,10 @@ fn create_sample_table(track: &Track, track_offset_time: i64) -> Option<Vec<mp4p
934
916
}
935
917
936
918
// Mark the sync sample in sample_table according to 'stss'.
937
- match track. stss {
938
- Some ( ref v) => {
939
- for iter in & v. samples {
940
- sample_table[ ( iter - 1 ) as usize ] . sync = true ;
941
- }
942
- } ,
943
- _ => { }
919
+ if let Some ( ref v) = track. stss {
920
+ for iter in & v. samples {
921
+ sample_table[ ( iter - 1 ) as usize ] . sync = true ;
922
+ }
944
923
}
945
924
946
925
let ctts_iter = match track. ctts {
@@ -1114,12 +1093,13 @@ pub unsafe extern fn mp4parse_get_pssh_info(parser: *mut mp4parse_parser, info:
1114
1093
1115
1094
pssh_data. clear ( ) ;
1116
1095
for pssh in & context. psshs {
1096
+ let content_len = pssh. box_content . len ( ) ;
1097
+ if content_len > std:: u32:: MAX as usize {
1098
+ return MP4PARSE_ERROR_INVALID ;
1099
+ }
1117
1100
let mut data_len = Vec :: new ( ) ;
1118
- match data_len. write_u32 :: < byteorder:: NativeEndian > ( pssh. box_content . len ( ) as u32 ) {
1119
- Err ( _) => {
1120
- return MP4PARSE_ERROR_IO ;
1121
- } ,
1122
- _ => ( ) ,
1101
+ if data_len. write_u32 :: < byteorder:: NativeEndian > ( content_len as u32 ) . is_err ( ) {
1102
+ return MP4PARSE_ERROR_IO ;
1123
1103
}
1124
1104
pssh_data. extend_from_slice ( pssh. system_id . as_slice ( ) ) ;
1125
1105
pssh_data. extend_from_slice ( data_len. as_slice ( ) ) ;
0 commit comments