Bug 1380468 - update rust parser. r?kinetik draft
authorAlfredo Yang <ayang@mozilla.com>
Fri, 14 Jul 2017 10:36:11 +0800
changeset 609687 f2f4b282869dd0fa9f716a4216bc3ebaa4d837b6
parent 609686 2b05993d207c54630ee5d9af272ac446449a0351
child 637622 37a0749d68a53ca41cbe9e169c5de816e5ac7a5f
push id68634
push userayang@mozilla.com
push dateMon, 17 Jul 2017 07:45:34 +0000
reviewerskinetik
bugs1380468
milestone56.0a1
Bug 1380468 - update rust parser. r?kinetik MozReview-Commit-ID: CerH4JHFIP
media/libstagefright/binding/include/mp4parse.h
media/libstagefright/binding/mp4parse-cargo.patch
media/libstagefright/binding/mp4parse/Cargo.toml
media/libstagefright/binding/mp4parse/src/boxes.rs
media/libstagefright/binding/mp4parse/src/lib.rs
media/libstagefright/binding/mp4parse/src/tests.rs
media/libstagefright/binding/mp4parse/tests/public.rs
media/libstagefright/binding/mp4parse_capi/Cargo.toml
media/libstagefright/binding/mp4parse_capi/src/lib.rs
media/libstagefright/binding/update-rust.sh
--- a/media/libstagefright/binding/include/mp4parse.h
+++ b/media/libstagefright/binding/include/mp4parse.h
@@ -18,16 +18,17 @@ extern "C" {
 
 typedef enum mp4parse_status {
 	mp4parse_status_OK = 0,
 	mp4parse_status_BAD_ARG = 1,
 	mp4parse_status_INVALID = 2,
 	mp4parse_status_UNSUPPORTED = 3,
 	mp4parse_status_EOF = 4,
 	mp4parse_status_IO = 5,
+	mp4parse_status_TABLE_TOO_LARGE = 6,
 } mp4parse_status;
 
 typedef enum mp4parse_track_type {
 	mp4parse_track_type_VIDEO = 0,
 	mp4parse_track_type_AUDIO = 1,
 } mp4parse_track_type;
 
 typedef enum mp4parse_codec {
--- a/media/libstagefright/binding/mp4parse-cargo.patch
+++ b/media/libstagefright/binding/mp4parse-cargo.patch
@@ -1,55 +1,55 @@
 diff --git a/media/libstagefright/binding/mp4parse/Cargo.toml b/media/libstagefright/binding/mp4parse/Cargo.toml
 index ff9422c..814c4c6 100644
 --- a/media/libstagefright/binding/mp4parse/Cargo.toml
 +++ b/media/libstagefright/binding/mp4parse/Cargo.toml
-@@ -18,19 +18,13 @@ exclude = [
+@@ -20,19 +20,11 @@ exclude = [
  ]
  
+-[badges]
+-travis-ci = { repository = "https://github.com/mozilla/mp4parse-rust" }
+ 
  [dependencies]
 -byteorder = "1.0.0"
 -afl = { version = "0.1.1", optional = true }
 -afl-plugin = { version = "0.1.1", optional = true }
 -abort_on_panic = { version = "1.0.0", optional = true }
 -bitreader = { version = "0.3.0" }
 -num-traits = "0.1.37"
 +byteorder = "1.0.0"
 +bitreader = { version = "0.3.0" }
 +num-traits = "0.1.37"
-
+ 
  [dev-dependencies]
  test-assembler = "0.1.2"
  
 -[features]
 -fuzz = ["afl", "afl-plugin", "abort_on_panic"]
 -
  # Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on.
  [profile.release]
  debug-assertions = true
 diff --git a/media/libstagefright/binding/mp4parse_capi/Cargo.toml b/media/libstagefright/binding/mp4parse_capi/Cargo.toml
 index a30e045..a965f06 100644
 --- a/media/libstagefright/binding/mp4parse_capi/Cargo.toml
 +++ b/media/libstagefright/binding/mp4parse_capi/Cargo.toml
-@@ -18,22 +18,13 @@ exclude = [
+@@ -18,19 +18,10 @@ exclude = [
    "*.mp4",
  ]
- 
+
 -build = "build.rs"
 -
 -[badges]
 -travis-ci = { repository = "https://github.com/mozilla/mp4parse-rust" }
 +build = false
- 
+
  [dependencies]
  byteorder = "1.0.0"
  mp4parse = {version = "0.8.0", path = "../mp4parse"}
  num-traits = "0.1.37"
- 
+
 -[build-dependencies]
 -moz-cheddar = "0.4.0"
 -
 -[features]
 -fuzz = ["mp4parse/fuzz"]
 -
- # Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on.
- [profile.release]
- debug-assertions = true
--- a/media/libstagefright/binding/mp4parse/Cargo.toml
+++ b/media/libstagefright/binding/mp4parse/Cargo.toml
@@ -3,33 +3,28 @@ name = "mp4parse"
 version = "0.8.0"
 authors = [
   "Ralph Giles <giles@mozilla.com>",
   "Matthew Gregan <kinetik@flim.org>",
   "Alfredo Yang <ayang@mozilla.com>",
 ]
 
 description = "Parser for ISO base media file format (mp4)"
-documentation = "https://mp4parse-docs.surge.sh/mp4parse/"
+documentation = "https://docs.rs/mp4parse/"
 license = "MPL-2.0"
 categories = ["multimedia::video"]
 
 repository = "https://github.com/mozilla/mp4parse-rust"
 
 # Avoid complaints about trying to package test files.
 exclude = [
   "*.mp4",
 ]
 
-[badges]
-travis-ci = { repository = "https://github.com/mozilla/mp4parse-rust" }
 
 [dependencies]
 byteorder = "1.0.0"
 bitreader = { version = "0.3.0" }
 num-traits = "0.1.37"
 
 [dev-dependencies]
 test-assembler = "0.1.2"
 
-# Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on.
-[profile.release]
-debug-assertions = true
--- a/media/libstagefright/binding/mp4parse/src/boxes.rs
+++ b/media/libstagefright/binding/mp4parse/src/boxes.rs
@@ -132,14 +132,9 @@ box_database!(
     QTWaveAtom                        0x77617665, // "wave" - quicktime atom
     ProtectionSystemSpecificHeaderBox 0x70737368, // "pssh"
     SchemeInformationBox              0x73636869, // "schi"
     TrackEncryptionBox                0x74656e63, // "tenc"
     ProtectionSchemeInformationBox    0x73696e66, // "sinf"
     OriginalFormatBox                 0x66726d61, // "frma"
     MP3AudioSampleEntry               0x2e6d7033, // ".mp3" - from F4V.
     CompositionOffsetBox              0x63747473, // "ctts"
-    JPEGAtom                          0x6a706567, // "jpeg" - QT JPEG
-    AC3SampleEntry                    0x61632d33, // "ac-3"
-    EC3SampleEntry                    0x65632d33, // "ec-3"
-    AC3SpecificBox                    0x64616333, // "dac3"
-    EC3SpecificBox                    0x64656333, // "dec3"
 );
--- a/media/libstagefright/binding/mp4parse/src/lib.rs
+++ b/media/libstagefright/binding/mp4parse/src/lib.rs
@@ -62,16 +62,18 @@ pub enum Error {
     /// Parse error caused by limited parser support rather than invalid data.
     Unsupported(&'static str),
     /// Reflect `std::io::ErrorKind::UnexpectedEof` for short data.
     UnexpectedEOF,
     /// Propagate underlying errors from `std::io`.
     Io(std::io::Error),
     /// read_mp4 terminated without detecting a moov box.
     NoMoov,
+    /// Parse error caused by table size is over limitation.
+    TableTooLarge,
 }
 
 impl From<bitreader::BitReaderError> for Error {
     fn from(_: bitreader::BitReaderError) -> Error {
         Error::InvalidData("invalid data")
     }
 }
 
@@ -262,18 +264,16 @@ pub struct ES_Descriptor {
 }
 
 #[allow(non_camel_case_types)]
 #[derive(Debug, Clone)]
 pub enum AudioCodecSpecific {
     ES_Descriptor(ES_Descriptor),
     FLACSpecificBox(FLACSpecificBox),
     OpusSpecificBox(OpusSpecificBox),
-    AC3SpecificBox,
-    EC3SpecificBox,
     MP3,
 }
 
 #[derive(Debug, Clone)]
 pub struct AudioSampleEntry {
     data_reference_index: u16,
     pub channelcount: u16,
     pub samplesize: u16,
@@ -282,17 +282,16 @@ pub struct AudioSampleEntry {
     pub protection_info: Vec<ProtectionSchemeInfoBox>,
 }
 
 #[derive(Debug, Clone)]
 pub enum VideoCodecSpecific {
     AVCConfig(Vec<u8>),
     VPxConfig(VPxConfigBox),
     ESDSConfig(Vec<u8>),
-    JPEG,
 }
 
 #[derive(Debug, Clone)]
 pub struct VideoSampleEntry {
     data_reference_index: u16,
     pub width: u16,
     pub height: u16,
     pub codec_specific: VideoCodecSpecific,
@@ -411,19 +410,16 @@ pub enum CodecType {
     Opus,
     H264,   // 14496-10
     MP4V,   // 14496-2
     VP10,
     VP9,
     VP8,
     EncryptedVideo,
     EncryptedAudio,
-    JPEG,   // QT JPEG atom
-    AC3,    // Digital Audio Compression (AC-3, Enhanced AC-3) Standard, ETSI TS 102 366.
-    EC3,    // Digital Audio Compression (AC-3, Enhanced AC-3) Standard, ETSI TS 102 366.
 }
 
 impl Default for CodecType {
     fn default() -> Self { CodecType::Unknown }
 }
 
 /// The media's global (mvhd) timescale in units per second.
 #[derive(Debug, Copy, Clone, PartialEq)]
@@ -1157,17 +1153,17 @@ fn read_stss<T: Read>(src: &mut BMFFBox<
 
 /// Parse a stsc box.
 fn read_stsc<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleToChunkBox> {
     let (_, _) = read_fullbox_extra(src)?;
     let sample_count = be_u32_with_limit(src)?;
     let mut samples = Vec::new();
     for _ in 0..sample_count {
         let first_chunk = be_u32(src)?;
-        let samples_per_chunk = be_u32(src)?;
+        let samples_per_chunk = be_u32_with_limit(src)?;
         let sample_description_index = be_u32(src)?;
         samples.push(SampleToChunk {
             first_chunk: first_chunk,
             samples_per_chunk: samples_per_chunk,
             sample_description_index: sample_description_index,
         });
     }
 
@@ -1190,17 +1186,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 => {
-                let count = be_u32(src)?;
+                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"));
             }
         };
         offsets.push(TimeOffset {
@@ -1238,17 +1234,17 @@ fn read_stsz<T: Read>(src: &mut BMFFBox<
 }
 
 /// Parse a stts box.
 fn read_stts<T: Read>(src: &mut BMFFBox<T>) -> Result<TimeToSampleBox> {
     let (_, _) = read_fullbox_extra(src)?;
     let sample_count = be_u32_with_limit(src)?;
     let mut samples = Vec::new();
     for _ in 0..sample_count {
-        let sample_count = be_u32(src)?;
+        let sample_count = be_u32_with_limit(src)?;
         let sample_delta = be_u32(src)?;
         samples.push(Sample {
             sample_count: sample_count,
             sample_delta: sample_delta,
         });
     }
 
     // Padding could be added in some contents.
@@ -1669,17 +1665,16 @@ fn read_hdlr<T: Read>(src: &mut BMFFBox<
 fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType, SampleEntry)> {
     let name = src.get_header().name;
     let codec_type = match name {
         BoxType::AVCSampleEntry | BoxType::AVC3SampleEntry => CodecType::H264,
         BoxType::MP4VideoSampleEntry => CodecType::MP4V,
         BoxType::VP8SampleEntry => CodecType::VP8,
         BoxType::VP9SampleEntry => CodecType::VP9,
         BoxType::ProtectedVisualSampleEntry => CodecType::EncryptedVideo,
-        BoxType::JPEGAtom => CodecType::JPEG,
         _ => {
             log!("Unsupported video codec, box {:?} found", name);
             CodecType::Unknown
         }
     };
 
     // Skip uninteresting fields.
     skip(src, 6)?;
@@ -1691,21 +1686,17 @@ fn read_video_sample_entry<T: Read>(src:
 
     let width = be_u16(src)?;
     let height = be_u16(src)?;
 
     // Skip uninteresting fields.
     skip(src, 50)?;
 
     // Skip clap/pasp/etc. for now.
-    let mut codec_specific = if name == BoxType::JPEGAtom {
-        Some(VideoCodecSpecific::JPEG)
-    } else {
-        None
-    };
+    let mut codec_specific = None;
     let mut protection_info = Vec::new();
     let mut iter = src.box_iter();
     while let Some(mut b) = iter.next_box()? {
         match b.head.name {
             BoxType::AVCConfigurationBox => {
                 if (name != BoxType::AVCSampleEntry &&
                     name != BoxType::AVC3SampleEntry &&
                     name != BoxType::ProtectedVisualSampleEntry) ||
@@ -1732,21 +1723,16 @@ fn read_video_sample_entry<T: Read>(src:
                 if name != BoxType::MP4VideoSampleEntry || codec_specific.is_some() {
                     return Err(Error::InvalidData("malformed video sample entry"));
                 }
                 let (_, _) = read_fullbox_extra(&mut b.content)?;
                 let esds_size = b.head.size - b.head.offset - 4;
                 let esds = read_buf(&mut b.content, esds_size as usize)?;
                 codec_specific = Some(VideoCodecSpecific::ESDSConfig(esds));
             }
-            BoxType::JPEGAtom => {
-                if name != BoxType::JPEGAtom || codec_specific.is_some() {
-                    return Err(Error::InvalidData("malformed video sample entry"));
-                }
-            }
             BoxType::ProtectionSchemeInformationBox => {
                 if name != BoxType::ProtectedVisualSampleEntry {
                     return Err(Error::InvalidData("malformed video sample entry"));
                 }
                 let sinf = read_sinf(&mut b)?;
                 log!("{:?} (sinf)", sinf);
                 protection_info.push(sinf);
             }
@@ -1870,36 +1856,16 @@ fn read_audio_sample_entry<T: Read>(src:
                 if name != BoxType::ProtectedAudioSampleEntry {
                     return Err(Error::InvalidData("malformed audio sample entry"));
                 }
                 let sinf = read_sinf(&mut b)?;
                 log!("{:?} (sinf)", sinf);
                 codec_type = CodecType::EncryptedAudio;
                 protection_info.push(sinf);
             }
-            BoxType::AC3SpecificBox => {
-                if name != BoxType::AC3SampleEntry {
-                    return Err(Error::InvalidData("malformed AC3 sample entry"));
-                }
-                // TODO: AC3SpecificBox needs to be parsed for detail information.
-                skip_box_remain(&mut b)?;
-                log!("(ac3)");
-                codec_type = CodecType::AC3;
-                codec_specific = Some(AudioCodecSpecific::AC3SpecificBox);
-            }
-            BoxType::EC3SpecificBox => {
-                if name != BoxType::EC3SpecificBox {
-                    return Err(Error::InvalidData("malformed EC3 sample entry"));
-                }
-                // TODO: EC3SpecificBox needs to be parsed for detail information.
-                skip_box_remain(&mut b)?;
-                log!("(ec3)");
-                codec_type = CodecType::EC3;
-                codec_specific = Some(AudioCodecSpecific::EC3SpecificBox);
-            }
             _ => {
                 log!("Unsupported audio codec, box {:?} found", b.head.name);
                 skip_box_content(&mut b)?;
             }
         }
         check_parser_state!(b.content);
     }
 
@@ -2079,17 +2045,17 @@ fn be_u24<T: ReadBytesExt>(src: &mut T) 
 fn be_u32<T: ReadBytesExt>(src: &mut T) -> Result<u32> {
     src.read_u32::<byteorder::BigEndian>().map_err(From::from)
 }
 
 /// Using in reading table size and return error if it exceeds limitation.
 fn be_u32_with_limit<T: ReadBytesExt>(src: &mut T) -> Result<u32> {
     be_u32(src).and_then(|v| {
         if v > TABLE_SIZE_LIMIT {
-            return Err(Error::Unsupported("Over limited value"));
+            return Err(Error::TableTooLarge);
         }
         Ok(v)
     })
 }
 
 fn be_u64<T: ReadBytesExt>(src: &mut T) -> Result<u64> {
     src.read_u64::<byteorder::BigEndian>().map_err(From::from)
 }
--- a/media/libstagefright/binding/mp4parse/src/tests.rs
+++ b/media/libstagefright/binding/mp4parse/src/tests.rs
@@ -896,41 +896,16 @@ fn read_esds() {
     assert_eq!(es.audio_object_type, Some(2));
     assert_eq!(es.audio_sample_rate, Some(24000));
     assert_eq!(es.audio_channel_count, Some(6));
     assert_eq!(es.codec_esds, aac_esds);
     assert_eq!(es.decoder_specific_data, aac_dc_descriptor);
 }
 
 #[test]
-fn read_ac3_sample_entry() {
-    let ac3 =
-        vec![
-            0x00, 0x00, 0x00, 0x0b, 0x64, 0x61, 0x63, 0x33, 0x10, 0x11, 0x60
-        ];
-
-    let mut stream = make_box(BoxSize::Auto, b"ac-3", |s| {
-        s.append_repeated(0, 6)
-         .B16(1)    // data_reference_count
-         .B16(0)
-         .append_repeated(0, 6)
-         .B16(2)
-         .B16(16)
-         .append_repeated(0, 4)
-         .B32(48000 << 16)
-         .append_bytes(ac3.as_slice())
-    });
-
-    let mut iter = super::BoxIter::new(&mut stream);
-    let mut stream = iter.next_box().unwrap().unwrap();
-    let (codec_type, _) = super::read_audio_sample_entry(&mut stream)
-          .expect("fail to read ac3 atom");
-    assert_eq!(codec_type, super::CodecType::AC3);
-}
-#[test]
 fn read_stsd_mp4v() {
     let mp4v =
         vec![
                                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd0, 0x01, 0xe0, 0x00, 0x48,
             0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
             0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
@@ -1026,58 +1001,23 @@ fn max_table_limit() {
     }).into_inner();
     let mut stream = make_box(BoxSize::Auto, b"edts", |s| {
         s.append_bytes(elst.as_slice())
     });
     let mut iter = super::BoxIter::new(&mut stream);
     let mut stream = iter.next_box().unwrap().unwrap();
     let mut track = super::Track::new(0);
     match super::read_edts(&mut stream, &mut track) {
-        Err(Error::Unsupported(s)) => assert_eq!(s, "Over limited value"),
+        Err(Error::TableTooLarge) => (),
         Ok(_) => panic!("expected an error result"),
         _ => panic!("expected a different error result"),
     }
 }
 
 #[test]
-fn jpeg_video_sample_entry() {
-    let jpeg = make_box(BoxSize::Auto, b"jpeg", |s| {
-        s.append_repeated(0, 6)
-         .B16(1)
-         .append_repeated(0, 16)
-         .B16(1024)
-         .B16(1024)
-         .append_repeated(0, 14)
-         .append_repeated(0, 32)
-         .append_repeated(0, 4)
-    }).into_inner();
-    let mut stream = make_fullbox(BoxSize::Auto, b"stsd", 0, |s| {
-        s.B32(1)
-         .append_bytes(jpeg.as_slice())
-    });
-
-    let mut iter = super::BoxIter::new(&mut stream);
-    let mut stream = iter.next_box().unwrap().unwrap();
-    let mut track = super::Track::new(0);
-    match super::read_stsd(&mut stream, &mut track) {
-        Ok(sample_description) => {
-            match sample_description.descriptions[0] {
-                super::SampleEntry::Video(ref jpeg) => {
-                    assert_eq!(track.codec_type, super::CodecType::JPEG);
-                    assert_eq!(jpeg.height, 1024);
-                    assert_eq!(jpeg.width, 1024);
-                } ,
-                _ => {},
-            }
-        },
-        _ => panic!("failed to parse a jpeg atom"),
-    }
-}
-
-#[test]
 fn unknown_video_sample_entry() {
     let unknown_codec = make_box(BoxSize::Auto, b"yyyy", |s| {
         s.append_repeated(0, 16)
     }).into_inner();
     let mut stream = make_box(BoxSize::Auto, b"xxxx", |s| {
         s.append_repeated(0, 6)
          .B16(1)
          .append_repeated(0, 16)
--- a/media/libstagefright/binding/mp4parse/tests/public.rs
+++ b/media/libstagefright/binding/mp4parse/tests/public.rs
@@ -55,19 +55,16 @@ fn public_api() {
                         assert!(vpx.chroma_subsampling > 0);
                         assert!(!vpx.codec_init.is_empty());
                         "VPx"
                     }
                     mp4::VideoCodecSpecific::ESDSConfig(mp4v) => {
                         assert!(!mp4v.is_empty());
                         "MP4V"
                     }
-                    mp4::VideoCodecSpecific::JPEG => {
-                        "JPEG"
-                    }
                 }, "AVC");
             }
             Some(mp4::SampleEntry::Audio(a)) => {
                 // track part
                 assert_eq!(track.duration, Some(mp4::TrackScaledTime(2944, 1)));
                 assert_eq!(track.empty_duration, Some(mp4::MediaScaledTime(0)));
                 assert_eq!(track.media_time, Some(mp4::TrackScaledTime(1024, 1)));
                 assert_eq!(track.timescale, Some(mp4::TrackTimeScale(48000, 1)));
@@ -97,22 +94,16 @@ fn public_api() {
                     mp4::AudioCodecSpecific::OpusSpecificBox(opus) => {
                         // We don't enter in here, we just check if fields are public.
                         assert!(opus.version > 0);
                         "Opus"
                     }
                     mp4::AudioCodecSpecific::MP3 => {
                         "MP3"
                     }
-                    mp4::AudioCodecSpecific::AC3SpecificBox => {
-                        "AC3"
-                    }
-                    mp4::AudioCodecSpecific::EC3SpecificBox => {
-                        "EC3"
-                    }
                 }, "ES");
                 assert!(a.samplesize > 0);
                 assert!(a.samplerate > 0);
             }
             Some(mp4::SampleEntry::Unknown) | None => {}
         }
     }
 }
--- a/media/libstagefright/binding/mp4parse_capi/Cargo.toml
+++ b/media/libstagefright/binding/mp4parse_capi/Cargo.toml
@@ -3,28 +3,25 @@ name = "mp4parse_capi"
 version = "0.8.0"
 authors = [
   "Ralph Giles <giles@mozilla.com>",
   "Matthew Gregan <kinetik@flim.org>",
   "Alfredo Yang <ayang@mozilla.com>",
 ]
 
 description = "Parser for ISO base media file format (mp4)"
-documentation = "https://mp4parse-docs.surge.sh/mp4parse/"
+documentation = "https://docs.rs/mp4parse_capi/"
 license = "MPL-2.0"
 
 repository = "https://github.com/mozilla/mp4parse-rust"
 
 # Avoid complaints about trying to package test files.
 exclude = [
   "*.mp4",
 ]
 
 build = false
 
 [dependencies]
 byteorder = "1.0.0"
 mp4parse = {version = "0.8.0", path = "../mp4parse"}
 num-traits = "0.1.37"
 
-# Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on.
-[profile.release]
-debug-assertions = true
--- a/media/libstagefright/binding/mp4parse_capi/src/lib.rs
+++ b/media/libstagefright/binding/mp4parse_capi/src/lib.rs
@@ -64,16 +64,17 @@ use mp4parse::Track;
 #[derive(PartialEq, Debug)]
 pub enum mp4parse_status {
     OK = 0,
     BAD_ARG = 1,
     INVALID = 2,
     UNSUPPORTED = 3,
     EOF = 4,
     IO = 5,
+    TABLE_TOO_LARGE = 6,
 }
 
 #[allow(non_camel_case_types)]
 #[repr(C)]
 #[derive(PartialEq, Debug)]
 pub enum mp4parse_track_type {
     VIDEO = 0,
     AUDIO = 1,
@@ -330,17 +331,18 @@ pub unsafe extern fn mp4parse_read(parse
         Err(Error::UnexpectedEOF) => mp4parse_status::EOF,
         Err(Error::Io(_)) => {
             // Block further calls after a read failure.
             // Getting std::io::ErrorKind::UnexpectedEof is normal
             // but our From trait implementation should have converted
             // those to our Error::UnexpectedEOF variant.
             (*parser).set_poisoned(true);
             mp4parse_status::IO
-        }
+        },
+        Err(Error::TableTooLarge) => mp4parse_status::TABLE_TOO_LARGE,
     }
 }
 
 /// Return the number of tracks parsed by previous `mp4parse_read()` call.
 #[no_mangle]
 pub unsafe extern fn mp4parse_get_track_count(parser: *const mp4parse_parser, count: *mut u32) -> mp4parse_status {
     // Validate arguments from C.
     if parser.is_null() || count.is_null() || (*parser).poisoned() {
@@ -412,44 +414,39 @@ pub unsafe extern fn mp4parse_get_track_
     }
 
     info.track_type = match context.tracks[track_index].track_type {
         TrackType::Video => mp4parse_track_type::VIDEO,
         TrackType::Audio => mp4parse_track_type::AUDIO,
         TrackType::Unknown => return mp4parse_status::UNSUPPORTED,
     };
 
+    // Return UNKNOWN for unsupported format.
     info.codec = match context.tracks[track_index].data {
         Some(SampleEntry::Audio(ref audio)) => match audio.codec_specific {
             AudioCodecSpecific::OpusSpecificBox(_) =>
                 mp4parse_codec::OPUS,
             AudioCodecSpecific::FLACSpecificBox(_) =>
                 mp4parse_codec::FLAC,
             AudioCodecSpecific::ES_Descriptor(ref esds) if esds.audio_codec == CodecType::AAC =>
                 mp4parse_codec::AAC,
             AudioCodecSpecific::ES_Descriptor(ref esds) if esds.audio_codec == CodecType::MP3 =>
                 mp4parse_codec::MP3,
             AudioCodecSpecific::ES_Descriptor(_) =>
                 mp4parse_codec::UNKNOWN,
             AudioCodecSpecific::MP3 =>
                 mp4parse_codec::MP3,
-            AudioCodecSpecific::AC3SpecificBox =>
-                mp4parse_codec::AC3,
-            AudioCodecSpecific::EC3SpecificBox =>
-                mp4parse_codec::EC3,
         },
         Some(SampleEntry::Video(ref video)) => match video.codec_specific {
             VideoCodecSpecific::VPxConfig(_) =>
                 mp4parse_codec::VP9,
             VideoCodecSpecific::AVCConfig(_) =>
                 mp4parse_codec::AVC,
-            VideoCodecSpecific::ESDSConfig(_) =>
-                mp4parse_codec::MP4V,
-            VideoCodecSpecific::JPEG =>
-                mp4parse_codec::JPEG,
+            VideoCodecSpecific::ESDSConfig(_) => // MP4V (14496-2) video is unsupported.
+                mp4parse_codec::UNKNOWN,
         },
         _ => mp4parse_codec::UNKNOWN,
     };
 
     let track = &context.tracks[track_index];
 
     if let (Some(track_timescale),
             Some(context_timescale)) = (track.timescale,
@@ -568,18 +565,16 @@ pub unsafe extern fn mp4parse_get_track_
                             return mp4parse_status::INVALID;
                         }
                         (*info).extra_data.length = v.len() as u32;
                         (*info).extra_data.data = v.as_ptr();
                     }
                 }
             }
         }
-        AudioCodecSpecific::AC3SpecificBox => (),
-        AudioCodecSpecific::EC3SpecificBox => (),
         AudioCodecSpecific::MP3 => (),
     }
 
     if let Some(p) = audio.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
         if let Some(ref tenc) = p.tenc {
             (*info).protected_data.is_encrypted = tenc.is_encrypted;
             (*info).protected_data.iv_size = tenc.iv_size;
             (*info).protected_data.kid.set_data(&(tenc.kid));
--- a/media/libstagefright/binding/update-rust.sh
+++ b/media/libstagefright/binding/update-rust.sh
@@ -1,13 +1,13 @@
 #!/bin/sh -e
 # Script to update mp4parse-rust sources to latest upstream
 
 # Default version.
-VER=ce7e2e66613009d56aea2588c4d11a23d4dd8056
+VER=33e7ea77aaf06939b4aaf284f487cdd13d3db671
 
 # Accept version or commit from the command line.
 if test -n "$1"; then
   VER=$1
 fi
 
 echo "Fetching sources..."
 rm -rf _upstream