Bug 1564643 - Update to latest mp4parse that fixes rust 1.37 deprecation errors. r!kinetik r=kinetik
authorEric Rahm <erahm@mozilla.com>
Wed, 10 Jul 2019 14:39:47 +0000
changeset 546224 2d91aeed09f88d75460a11db687fcf9fa8c5cb66
parent 546223 fa3246642d51d1f32702445747e86a8fc2ccc0e7
child 546225 78deb0f239034979f37df845acba79b5a267ebad
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1564643
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1564643 - Update to latest mp4parse that fixes rust 1.37 deprecation errors. r!kinetik r=kinetik Differential Revision: https://phabricator.services.mozilla.com/D37511
media/mp4parse-rust/mp4parse/src/lib.rs
media/mp4parse-rust/update-rust.sh
--- a/media/mp4parse-rust/mp4parse/src/lib.rs
+++ b/media/mp4parse-rust/mp4parse/src/lib.rs
@@ -37,47 +37,36 @@ mod tests;
 
 // Arbitrary buffer size limit used for raw read_bufs on a box.
 const BUF_SIZE_LIMIT: usize = 1024 * 1024;
 
 // Max table length. Calculating in worth case for one week long video, one
 // frame per table entry in 30 fps.
 const TABLE_SIZE_LIMIT: u32 = 30 * 60 * 60 * 24 * 7;
 
-// TODO: vec_push() and vec_reserve() needs to be replaced when Rust supports
-// fallible memory allocation in raw_vec.
+// TODO: vec_push() needs to be replaced when Rust supports fallible memory
+// allocation in raw_vec.
 #[allow(unreachable_code)]
 pub fn vec_push<T>(vec: &mut Vec<T>, val: T) -> std::result::Result<(), ()> {
     #[cfg(feature = "mp4parse_fallible")]
     {
         return FallibleVec::try_push(vec, val);
     }
 
     vec.push(val);
     Ok(())
 }
 
 #[allow(unreachable_code)]
-pub fn vec_reserve<T>(vec: &mut Vec<T>, size: usize) -> std::result::Result<(), ()> {
-    #[cfg(feature = "mp4parse_fallible")]
-    {
-        return FallibleVec::try_reserve(vec, size);
-    }
-
-    vec.reserve(size);
-    Ok(())
-}
-
-#[allow(unreachable_code)]
 fn allocate_read_buf(size: usize) -> std::result::Result<Vec<u8>, ()> {
     #[cfg(feature = "mp4parse_fallible")]
     {
         let mut buf: Vec<u8> = Vec::new();
         FallibleVec::try_reserve(&mut buf, size)?;
-        unsafe { buf.set_len(size); }
+        buf.extend(std::iter::repeat(0).take(size));
         return Ok(buf);
     }
 
     Ok(vec![0; size])
 }
 
 /// Describes parser failures.
 ///
@@ -621,17 +610,17 @@ fn read_box_header<T: ReadBytesExt>(src:
         0 => return Err(Error::Unsupported("unknown sized box")),
         1 => {
             let size64 = be_u64(src)?;
             if size64 < 16 {
                 return Err(Error::InvalidData("malformed wide size"));
             }
             size64
         }
-        2...7 => return Err(Error::InvalidData("malformed size")),
+        2 ..= 7 => return Err(Error::InvalidData("malformed size")),
         _ => size32 as u64,
     };
     let mut offset = match size32 {
         1 => 4 + 4 + 8,
         _ => 4 + 4,
     };
     let uuid = if name == BoxType::UuidBox {
         if size >= offset + 16 {
@@ -1280,17 +1269,17 @@ fn read_ctts<T: Read>(src: &mut BMFFBox<
     }
 
     let mut offsets = Vec::new();
     for _ in 0..counts {
         let (sample_count, time_offset) = match version {
             // According to spec, Version0 shoule be used when version == 0;
             // however, some buggy contents have negative value when version == 0.
             // So we always use Version1 here.
-            0...1 => {
+            0 ..= 1 => {
                 let count = be_u32_with_limit(src)?;
                 let offset = TimeOffsetVersion::Version1(be_i32(src)?);
                 (count, offset)
             },
             _ => {
                 return Err(Error::InvalidData("unsupported version in 'ctts' box"));
             }
         };
@@ -1575,44 +1564,44 @@ fn read_ds_descriptor(data: &[u8], esds:
         audio_object_type = get_audio_object_type(bit_reader)?;
         let _extended_channel_configuration = match audio_object_type {
             22 => ReadInto::read(bit_reader, 4)?,
             _ => channel_configuration
         };
     };
 
     match audio_object_type {
-        1 ... 4 | 6 | 7 | 17 | 19 ... 23 => {
+        1 ..= 4 | 6 | 7 | 17 | 19 ..= 23 => {
             if sample_frequency.is_none() {
                 return Err(Error::Unsupported("unknown frequency"));
             }
 
             // parsing GASpecificConfig
 
             // If the sampling rate is not one of the rates listed in the right
             // column in Table 4.82, the sampling frequency dependent tables
             // (code tables, scale factor band tables etc.) must be deduced in
             // order for the bitstream payload to be parsed. Since a given
             // sampling frequency is associated with only one sampling frequency
             // table, and since maximum flexibility is desired in the range of
             // possible sampling frequencies, the following table shall be used
             // to associate an implied sampling frequency with the desired
             // sampling frequency dependent tables.
             let sample_frequency_value = match sample_frequency.unwrap() {
-                0 ... 9390 => 8000,
-                9391 ... 11501 => 11025,
-                11502 ... 13855 => 12000,
-                13856 ... 18782 => 16000,
-                18783 ... 23003 => 22050,
-                23004 ... 27712 => 24000,
-                27713 ... 37565 => 32000,
-                37566 ... 46008 => 44100,
-                46009 ... 55425 => 48000,
-                55426 ... 75131 => 64000,
-                75132 ... 92016 => 88200,
+                0 ..= 9390 => 8000,
+                9391 ..= 11501 => 11025,
+                11502 ..= 13855 => 12000,
+                13856 ..= 18782 => 16000,
+                18783 ..= 23003 => 22050,
+                23004 ..= 27712 => 24000,
+                27713 ..= 37565 => 32000,
+                37566 ..= 46008 => 44100,
+                46009 ..= 55425 => 48000,
+                55426 ..= 75131 => 64000,
+                75132 ..= 92016 => 88200,
                 _ => 96000
             };
 
             bit_reader.skip(1)?;        // frameLengthFlag
             let depend_on_core_order: u8 = ReadInto::read(bit_reader, 1)?;
             if depend_on_core_order > 0 {
                 bit_reader.skip(14)?;   // codeCoderDelay
             }
@@ -1649,17 +1638,17 @@ fn read_ds_descriptor(data: &[u8], esds:
                     }
                     let mut _channel_counts = 0;
                     _channel_counts += read_surround_channel_count(bit_reader, num_front_channel)?;
                     _channel_counts += read_surround_channel_count(bit_reader, num_side_channel)?;
                     _channel_counts += read_surround_channel_count(bit_reader, num_back_channel)?;
                     _channel_counts += read_surround_channel_count(bit_reader, num_lfe_channel)?;
                     _channel_counts
                 },
-                1 ... 7 => channel_configuration,
+                1 ..= 7 => channel_configuration,
                 // Amendment 4 of the AAC standard in 2013 below
                 11 => 7, // 6.1 Amendment 4 of the AAC standard in 2013
                 12 | 14 => 8, // 7.1 (a/d) of ITU BS.2159
                 _ => {
                     return Err(Error::Unsupported("invalid channel configuration"));
                 }
             };
 
--- a/media/mp4parse-rust/update-rust.sh
+++ b/media/mp4parse-rust/update-rust.sh
@@ -1,15 +1,15 @@
-#!/bin/sh
+#!/bin/bash
 # Script to update mp4parse-rust sources to latest upstream
 
 set -e
 
 # Default version.
-VER="26e614bbcb4d7322dc2e4b7e15391bdb30b9f7be"
+VER="b10bc03bc279b2312f6a4ddfc96230577dcffe56"
 
 # Accept version or commit from the command line.
 if test -n "$1"; then
   VER=$1
 fi
 
 echo "Fetching sources..."
 rm -rf _upstream