@@ -1645,8 +1645,8 @@ fn read_hdlr<T: Read>(src: &mut BMFFBox<T>) -> Result<HandlerBox> {
1645
1645
// Skip uninteresting fields.
1646
1646
skip ( src, 12 ) ?;
1647
1647
1648
- let bytes_left = src . bytes_left ( ) ;
1649
- let _name = read_null_terminated_string ( src, bytes_left ) ?;
1648
+ // Skip name.
1649
+ skip_box_remain ( src) ?;
1650
1650
1651
1651
Ok ( HandlerBox {
1652
1652
handler_type : handler_type,
@@ -1676,12 +1676,7 @@ fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
1676
1676
let height = be_u16 ( src) ?;
1677
1677
1678
1678
// Skip uninteresting fields.
1679
- skip ( src, 14 ) ?;
1680
-
1681
- let _compressorname = read_fixed_length_pascal_string ( src, 32 ) ?;
1682
-
1683
- // Skip uninteresting fields.
1684
- skip ( src, 4 ) ?;
1679
+ skip ( src, 50 ) ?;
1685
1680
1686
1681
// Skip clap/pasp/etc. for now.
1687
1682
let mut codec_specific = None ;
@@ -1998,43 +1993,6 @@ fn read_buf<T: ReadBytesExt>(src: &mut T, size: usize) -> Result<Vec<u8>> {
1998
1993
Ok ( buf)
1999
1994
}
2000
1995
2001
- // TODO(kinetik): Find a copy of ISO/IEC 14496-1 to confirm various string encodings.
2002
- // XXX(kinetik): definition of "null-terminated" string is fuzzy, we have:
2003
- // - zero or more byte strings, with a single null terminating the string.
2004
- // - zero byte strings with no null terminator (i.e. zero space in the box for the string)
2005
- // - length-prefixed strings with no null terminator (e.g. bear_rotate_0.mp4)
2006
- // - multiple byte strings where more than one byte is a null.
2007
- fn read_null_terminated_string < T : ReadBytesExt > ( src : & mut T , mut size : usize ) -> Result < String > {
2008
- let mut buf = Vec :: new ( ) ;
2009
- while size > 0 {
2010
- let c = src. read_u8 ( ) ?;
2011
- size -= 1 ;
2012
- if c == 0 {
2013
- break ;
2014
- }
2015
- buf. push ( c) ;
2016
- }
2017
- skip ( src, size) ?;
2018
- String :: from_utf8 ( buf) . map_err ( From :: from)
2019
- }
2020
-
2021
- #[ allow( dead_code) ]
2022
- fn read_pascal_string < T : ReadBytesExt > ( src : & mut T ) -> Result < String > {
2023
- let len = src. read_u8 ( ) ?;
2024
- let buf = read_buf ( src, len as usize ) ?;
2025
- String :: from_utf8 ( buf) . map_err ( From :: from)
2026
- }
2027
-
2028
- // Weird string encoding with a length prefix and a fixed sized buffer which
2029
- // contains padding if the string doesn't fill the buffer.
2030
- fn read_fixed_length_pascal_string < T : Read > ( src : & mut T , size : usize ) -> Result < String > {
2031
- assert ! ( size > 0 ) ;
2032
- let len = cmp:: min ( src. read_u8 ( ) ? as usize , size - 1 ) ;
2033
- let buf = read_buf ( src, len) ?;
2034
- skip ( src, size - 1 - buf. len ( ) ) ?;
2035
- String :: from_utf8 ( buf) . map_err ( From :: from)
2036
- }
2037
-
2038
1996
fn be_i16 < T : ReadBytesExt > ( src : & mut T ) -> Result < i16 > {
2039
1997
src. read_i16 :: < byteorder:: BigEndian > ( ) . map_err ( From :: from)
2040
1998
}
0 commit comments