From c178f4e8ec3bd1b1269d5a22f02aa04c11d30fcc Mon Sep 17 00:00:00 2001 From: "Alfredo.Yang" Date: Tue, 7 Mar 2017 09:30:48 +0800 Subject: [PATCH] Bug 1343793 - update rust mp4parser. r=kinetik MozReview-Commit-ID: GGfv911o5Rb --HG-- rename : third_party/rust/bitreader/LICENSE => third_party/rust/bitreader/LICENSE-APACHE extra : rebase_source : a60a623af8465fe2220c5294f60f43f75a8513ec --- .../libstagefright/binding/include/mp4parse.h | 6 +-- .../binding/mp4parse-cargo.patch | 6 +-- .../binding/mp4parse/Cargo.toml | 4 +- .../binding/mp4parse/src/lib.rs | 6 +-- .../binding/mp4parse_capi/Cargo.toml | 4 +- .../binding/mp4parse_capi/src/lib.rs | 48 +++++++++++-------- media/libstagefright/binding/update-rust.sh | 2 +- .../rust/bitreader/.cargo-checksum.json | 2 +- third_party/rust/bitreader/Cargo.toml | 4 +- .../bitreader/{LICENSE => LICENSE-APACHE} | 0 third_party/rust/bitreader/LICENSE-MIT | 25 ++++++++++ third_party/rust/bitreader/README.md | 6 ++- third_party/rust/bitreader/src/lib.rs | 16 ++----- third_party/rust/bitreader/src/tests.rs | 16 ++----- toolkit/library/gtest/rust/Cargo.lock | 14 +++--- toolkit/library/rust/Cargo.lock | 14 +++--- 16 files changed, 100 insertions(+), 73 deletions(-) rename third_party/rust/bitreader/{LICENSE => LICENSE-APACHE} (100%) create mode 100644 third_party/rust/bitreader/LICENSE-MIT diff --git a/media/libstagefright/binding/include/mp4parse.h b/media/libstagefright/binding/include/mp4parse.h index 1f10293bce07..e3c75839c178 100644 --- a/media/libstagefright/binding/include/mp4parse.h +++ b/media/libstagefright/binding/include/mp4parse.h @@ -51,9 +51,9 @@ typedef struct mp4parse_track_info { typedef struct mp4parse_indice { uint64_t start_offset; uint64_t end_offset; - uint64_t start_composition; - uint64_t end_composition; - uint64_t start_decode; + int64_t start_composition; + int64_t end_composition; + int64_t start_decode; bool sync; } mp4parse_indice; diff --git a/media/libstagefright/binding/mp4parse-cargo.patch b/media/libstagefright/binding/mp4parse-cargo.patch index dc7f23283de7..015a4e9d7423 100644 --- a/media/libstagefright/binding/mp4parse-cargo.patch +++ b/media/libstagefright/binding/mp4parse-cargo.patch @@ -10,9 +10,9 @@ index ff9422c..814c4c6 100644 -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.2.0" } +-bitreader = { version = "0.3.0" } +byteorder = "1.0.0" -+bitreader = { version = "0.2.0" } ++bitreader = { version = "0.3.0" } [dev-dependencies] test-assembler = "0.1.2" @@ -39,7 +39,7 @@ index aeeebc65..5c0836a 100644 [dependencies] byteorder = "1.0.0" - mp4parse = {version = "0.7.0", path = "../mp4parse"} + mp4parse = {version = "0.7.1", path = "../mp4parse"} -[build-dependencies] -rusty-cheddar = "0.3.2" diff --git a/media/libstagefright/binding/mp4parse/Cargo.toml b/media/libstagefright/binding/mp4parse/Cargo.toml index f243c7e87ae2..6e2493abcd09 100644 --- a/media/libstagefright/binding/mp4parse/Cargo.toml +++ b/media/libstagefright/binding/mp4parse/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mp4parse" -version = "0.7.0" +version = "0.7.1" authors = [ "Ralph Giles ", "Matthew Gregan ", @@ -24,7 +24,7 @@ travis-ci = { repository = "https://github.com/mozilla/mp4parse-rust" } [dependencies] byteorder = "1.0.0" -bitreader = { version = "0.2.0" } +bitreader = { version = "0.3.0" } [dev-dependencies] test-assembler = "0.1.2" diff --git a/media/libstagefright/binding/mp4parse/src/lib.rs b/media/libstagefright/binding/mp4parse/src/lib.rs index 2a7aacb122b4..0d26309b89b6 100644 --- a/media/libstagefright/binding/mp4parse/src/lib.rs +++ b/media/libstagefright/binding/mp4parse/src/lib.rs @@ -416,9 +416,9 @@ pub struct TrackScaledTime(pub u64, pub usize); #[derive(Debug, Default)] pub struct EmptySampleTableBoxes { // TODO: Track has stts, stsc and stco, this structure can be discarded. - pub empty_stts : bool, - pub empty_stsc : bool, - pub empty_stco : bool, + pub empty_stts: bool, + pub empty_stsc: bool, + pub empty_stco: bool, } /// Check boxes contain data. diff --git a/media/libstagefright/binding/mp4parse_capi/Cargo.toml b/media/libstagefright/binding/mp4parse_capi/Cargo.toml index c3de7622dbaf..cae07ea8ea2e 100644 --- a/media/libstagefright/binding/mp4parse_capi/Cargo.toml +++ b/media/libstagefright/binding/mp4parse_capi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mp4parse_capi" -version = "0.7.0" +version = "0.7.1" authors = [ "Ralph Giles ", "Matthew Gregan ", @@ -22,7 +22,7 @@ build = false [dependencies] byteorder = "1.0.0" -mp4parse = {version = "0.7.0", path = "../mp4parse"} +mp4parse = {version = "0.7.1", path = "../mp4parse"} # Somewhat heavy-handed, but we want at least -Z force-overflow-checks=on. [profile.release] diff --git a/media/libstagefright/binding/mp4parse_capi/src/lib.rs b/media/libstagefright/binding/mp4parse_capi/src/lib.rs index 95a72aefc2db..c672bc60aafe 100644 --- a/media/libstagefright/binding/mp4parse_capi/src/lib.rs +++ b/media/libstagefright/binding/mp4parse_capi/src/lib.rs @@ -65,6 +65,7 @@ use mp4parse::Track; use mp4parse_error::*; use mp4parse_track_type::*; +#[allow(non_camel_case_types)] #[repr(C)] #[derive(PartialEq, Debug)] pub enum mp4parse_error { @@ -76,6 +77,7 @@ pub enum mp4parse_error { MP4PARSE_ERROR_IO = 5, } +#[allow(non_camel_case_types)] #[repr(C)] #[derive(PartialEq, Debug)] pub enum mp4parse_track_type { @@ -87,6 +89,7 @@ impl Default for mp4parse_track_type { fn default() -> Self { mp4parse_track_type::MP4PARSE_TRACK_TYPE_VIDEO } } +#[allow(non_camel_case_types)] #[repr(C)] #[derive(PartialEq, Debug)] pub enum mp4parse_codec { @@ -119,9 +122,9 @@ pub struct mp4parse_track_info { pub struct mp4parse_indice { pub start_offset: u64, pub end_offset: u64, - pub start_composition: u64, - pub end_composition: u64, - pub start_decode: u64, + pub start_composition: i64, + pub end_composition: i64, + pub start_decode: i64, pub sync: bool, } @@ -668,22 +671,29 @@ pub unsafe extern fn mp4parse_get_indice_table(parser: *mut mp4parse_parser, tra _ => {}, } + let media_time = match (&track.media_time, &track.timescale) { + (&Some(t), &Some(s)) => { + track_time_to_us(t, s).map(|v| v as i64) + }, + _ => None, + }; + + let empty_duration = match (&track.empty_duration, &context.timescale) { + (&Some(e), &Some(s)) => { + media_time_to_us(e, s).map(|v| v as i64) + }, + _ => None + }; + // Find the track start offset time from 'elst'. // 'media_time' maps start time onward, 'empty_duration' adds time offset // before first frame is displayed. - let offset_time = - match (&track.empty_duration, &track.media_time, &context.timescale) { - (&Some(empty_duration), &Some(media_time), &Some(scale)) => { - (empty_duration.0 as i64 - media_time.0 as i64) * scale.0 as i64 - }, - (&Some(empty_duration), _, &Some(scale)) => { - empty_duration.0 as i64 * scale.0 as i64 - }, - (_, &Some(media_time), &Some(scale)) => { - (0 - media_time.0 as i64) * scale.0 as i64 - }, - _ => 0, - }; + let offset_time = match (empty_duration, media_time) { + (Some(e), Some(m)) => e - m, + (Some(e), None) => e, + (None, Some(m)) => m, + _ => 0, + }; match create_sample_table(track, offset_time) { Some(v) => { @@ -962,10 +972,10 @@ fn create_sample_table(track: &Track, track_offset_time: i64) -> Option"] description = """ @@ -16,4 +16,4 @@ repository = "https://github.com/irauta/bitreader" keywords = ["bit", "bits", "bitstream"] -license = "Apache-2.0" +license = "MIT OR Apache-2.0" diff --git a/third_party/rust/bitreader/LICENSE b/third_party/rust/bitreader/LICENSE-APACHE similarity index 100% rename from third_party/rust/bitreader/LICENSE rename to third_party/rust/bitreader/LICENSE-APACHE diff --git a/third_party/rust/bitreader/LICENSE-MIT b/third_party/rust/bitreader/LICENSE-MIT new file mode 100644 index 000000000000..f8bbc4db180a --- /dev/null +++ b/third_party/rust/bitreader/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 Ilkka Rauta + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/rust/bitreader/README.md b/third_party/rust/bitreader/README.md index 4c45711d805f..ef1debbb9155 100644 --- a/third_party/rust/bitreader/README.md +++ b/third_party/rust/bitreader/README.md @@ -4,7 +4,7 @@ BitReader is a helper type to extract strings of bits from a slice of bytes. [![Published Package](https://img.shields.io/crates/v/bitreader.svg)](https://crates.io/crates/bitreader) [![Documentation](https://docs.rs/bitreader/badge.svg)](https://docs.rs/bitreader) -[![Build Status](https://travis-ci.org/irauta/bitreader.svg)](https://travis-ci.org/irauta/bitreader) +[![Build Status](https://travis-ci.org/irauta/bitreader.svg?branch=master)](https://travis-ci.org/irauta/bitreader) Here is how you read first a single bit, then three bits and finally four bits from a byte buffer: @@ -21,3 +21,7 @@ Here is how you read first a single bit, then three bits and finally four bits f You can naturally read bits from longer buffer of data than just a single byte. As you read bits, the internal cursor of BitReader moves on along the stream of bits. Little endian format is assumed when reading the multi-byte values. BitReader supports reading maximum of 64 bits at a time (with read_u64). + +## License + +Licensed under the Apache License, Version 2.0 or the MIT license, at your option. diff --git a/third_party/rust/bitreader/src/lib.rs b/third_party/rust/bitreader/src/lib.rs index 60bc474f67a8..3d04dc4fadfe 100644 --- a/third_party/rust/bitreader/src/lib.rs +++ b/third_party/rust/bitreader/src/lib.rs @@ -1,16 +1,10 @@ // Copyright 2015 Ilkka Rauta // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. //! BitReader is a helper type to extract strings of bits from a slice of bytes. //! diff --git a/third_party/rust/bitreader/src/tests.rs b/third_party/rust/bitreader/src/tests.rs index 52d461b62977..f62be1f0c70b 100644 --- a/third_party/rust/bitreader/src/tests.rs +++ b/third_party/rust/bitreader/src/tests.rs @@ -1,16 +1,10 @@ // Copyright 2015 Ilkka Rauta // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. use super::*; diff --git a/toolkit/library/gtest/rust/Cargo.lock b/toolkit/library/gtest/rust/Cargo.lock index 2561f3856303..406a4678a2d0 100644 --- a/toolkit/library/gtest/rust/Cargo.lock +++ b/toolkit/library/gtest/rust/Cargo.lock @@ -94,7 +94,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitreader" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -369,7 +369,7 @@ name = "gkrust-shared" version = "0.1.0" dependencies = [ "geckoservo 0.0.1", - "mp4parse_capi 0.7.0", + "mp4parse_capi 0.7.1", "nsstring 0.1.0", "rust_url_capi 0.0.1", "webrender_bindings 0.1.0", @@ -487,9 +487,9 @@ dependencies = [ [[package]] name = "mp4parse" -version = "0.7.0" +version = "0.7.1" dependencies = [ - "bitreader 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -499,10 +499,10 @@ version = "0.1.0" [[package]] name = "mp4parse_capi" -version = "0.7.0" +version = "0.7.1" dependencies = [ "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mp4parse 0.7.0", + "mp4parse 0.7.1", ] [[package]] @@ -1251,7 +1251,7 @@ dependencies = [ "checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c" "checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitreader 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8319aa6588c40cce19a135009ec70dc730a34ed9d27bab2409298b948546da7a" +"checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707" "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" "checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" diff --git a/toolkit/library/rust/Cargo.lock b/toolkit/library/rust/Cargo.lock index d69359a9a640..611ecfec1690 100644 --- a/toolkit/library/rust/Cargo.lock +++ b/toolkit/library/rust/Cargo.lock @@ -92,7 +92,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitreader" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -367,7 +367,7 @@ name = "gkrust-shared" version = "0.1.0" dependencies = [ "geckoservo 0.0.1", - "mp4parse_capi 0.7.0", + "mp4parse_capi 0.7.1", "nsstring 0.1.0", "rust_url_capi 0.0.1", "webrender_bindings 0.1.0", @@ -485,18 +485,18 @@ dependencies = [ [[package]] name = "mp4parse" -version = "0.7.0" +version = "0.7.1" dependencies = [ - "bitreader 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "mp4parse_capi" -version = "0.7.0" +version = "0.7.1" dependencies = [ "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mp4parse 0.7.0", + "mp4parse 0.7.1", ] [[package]] @@ -1238,7 +1238,7 @@ dependencies = [ "checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c" "checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitreader 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8319aa6588c40cce19a135009ec70dc730a34ed9d27bab2409298b948546da7a" +"checksum bitreader 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "80b13e2ab064ff3aa0bdbf1eff533f9822dc37899821f5f98c67f263eab51707" "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" "checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c"