From 7dc22358e4307d32b4a8d9ca8b074d33153902d5 Mon Sep 17 00:00:00 2001 From: Jon Bauman Date: Wed, 3 Nov 2021 20:06:58 +0000 Subject: [PATCH] Bug 1739032 - Update mp4parse-rust to a257137. r=kinetik Differential Revision: https://phabricator.services.mozilla.com/D130284 --- .cargo/config.in | 2 +- Cargo.lock | 8 +- image/decoders/nsAVIFDecoder.cpp | 21 +-- .../rust/mp4parse/.cargo-checksum.json | 2 +- third_party/rust/mp4parse/Cargo.toml | 2 +- third_party/rust/mp4parse/src/lib.rs | 127 ++++++++++-------- third_party/rust/mp4parse/src/tests.rs | 47 +++++++ .../rust/mp4parse_capi/.cargo-checksum.json | 2 +- third_party/rust/mp4parse_capi/Cargo.toml | 4 +- third_party/rust/mp4parse_capi/cbindgen.toml | 1 + .../rust/mp4parse_capi/examples/dump.rs | 4 +- third_party/rust/mp4parse_capi/src/lib.rs | 11 +- .../tests/test_chunk_out_of_range.rs | 4 +- .../mp4parse_capi/tests/test_encryption.rs | 4 +- .../rust/mp4parse_capi/tests/test_fragment.rs | 4 +- .../rust/mp4parse_capi/tests/test_rotation.rs | 4 +- .../mp4parse_capi/tests/test_sample_table.rs | 4 +- .../tests/test_workaround_stsc.rs | 4 +- toolkit/library/rust/shared/Cargo.toml | 2 +- 19 files changed, 158 insertions(+), 99 deletions(-) diff --git a/.cargo/config.in b/.cargo/config.in index 6e83d56c4d46e..6fa97a68463dc 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -15,7 +15,7 @@ tag = "v0.5.3" [source."https://github.com/mozilla/mp4parse-rust"] git = "https://github.com/mozilla/mp4parse-rust" replace-with = "vendored-sources" -rev = "72eb355ddeada541d7e57dbe5fb60eb5124dea0d" +rev = "a25713781eac774c531af43ba833ef86cb920889" [source."https://github.com/mozilla/l10nregistry-rs"] git = "https://github.com/mozilla/l10nregistry-rs" diff --git a/Cargo.lock b/Cargo.lock index cad50601bf5bc..de9d3e18b4878 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3185,8 +3185,8 @@ dependencies = [ [[package]] name = "mp4parse" -version = "0.11.5" -source = "git+https://github.com/mozilla/mp4parse-rust?rev=72eb355ddeada541d7e57dbe5fb60eb5124dea0d#72eb355ddeada541d7e57dbe5fb60eb5124dea0d" +version = "0.12.0" +source = "git+https://github.com/mozilla/mp4parse-rust?rev=a25713781eac774c531af43ba833ef86cb920889#a25713781eac774c531af43ba833ef86cb920889" dependencies = [ "bitreader", "byteorder", @@ -3203,8 +3203,8 @@ version = "0.1.0" [[package]] name = "mp4parse_capi" -version = "0.11.5" -source = "git+https://github.com/mozilla/mp4parse-rust?rev=72eb355ddeada541d7e57dbe5fb60eb5124dea0d#72eb355ddeada541d7e57dbe5fb60eb5124dea0d" +version = "0.12.0" +source = "git+https://github.com/mozilla/mp4parse-rust?rev=a25713781eac774c531af43ba833ef86cb920889#a25713781eac774c531af43ba833ef86cb920889" dependencies = [ "byteorder", "fallible_collections", diff --git a/image/decoders/nsAVIFDecoder.cpp b/image/decoders/nsAVIFDecoder.cpp index 3bb9e8f8d08a6..b99b9a8a06065 100644 --- a/image/decoders/nsAVIFDecoder.cpp +++ b/image/decoders/nsAVIFDecoder.cpp @@ -329,7 +329,7 @@ struct AVIFDecodedData : layers::PlanarYCbCrData { CICP::MatrixCoefficients mMatrixCoefficients = CICP::MC_UNSPECIFIED; void SetCicpValues( - const NclxColourInformation* aNclx, + const Mp4parseNclxColourInformation* aNclx, const CICP::ColourPrimaries aAv1ColourPrimaries, const CICP::TransferCharacteristics aAv1TransferCharacteristics, const CICP::MatrixCoefficients aAv1MatrixCoefficients); @@ -346,8 +346,8 @@ struct AVIFDecodedData : layers::PlanarYCbCrData { // that work unnecessarily because in addition to wasted effort, it would make // the logging more confusing. template -static gfx::YUVColorSpace GetAVIFColorSpace(const NclxColourInformation* aNclx, - F&& aBitstreamColorSpaceFunc) { +static gfx::YUVColorSpace GetAVIFColorSpace( + const Mp4parseNclxColourInformation* aNclx, F&& aBitstreamColorSpaceFunc) { return ToMaybe(aNclx) .map([=](const auto& nclx) { return gfxUtils::CicpToColorSpace( @@ -359,8 +359,9 @@ static gfx::YUVColorSpace GetAVIFColorSpace(const NclxColourInformation* aNclx, .valueOr(gfx::YUVColorSpace::BT601); } -static gfx::ColorRange GetAVIFColorRange(const NclxColourInformation* aNclx, - const gfx::ColorRange av1ColorRange) { +static gfx::ColorRange GetAVIFColorRange( + const Mp4parseNclxColourInformation* aNclx, + const gfx::ColorRange av1ColorRange) { return ToMaybe(aNclx) .map([=](const auto& nclx) { return aNclx->full_range_flag ? gfx::ColorRange::FULL @@ -370,7 +371,7 @@ static gfx::ColorRange GetAVIFColorRange(const NclxColourInformation* aNclx, } void AVIFDecodedData::SetCicpValues( - const NclxColourInformation* aNclx, + const Mp4parseNclxColourInformation* aNclx, const CICP::ColourPrimaries aAv1ColourPrimaries, const CICP::TransferCharacteristics aAv1TransferCharacteristics, const CICP::MatrixCoefficients aAv1MatrixCoefficients) { @@ -645,7 +646,7 @@ class Dav1dDecoder final : AVIFDecoderInterface { } static AVIFDecodedData Dav1dPictureToDecodedData( - const NclxColourInformation* aNclx, Dav1dPicture* aPicture, + const Mp4parseNclxColourInformation* aNclx, Dav1dPicture* aPicture, Dav1dPicture* aAlphaPlane, bool aPremultipliedAlpha); Dav1dContext* mContext = nullptr; @@ -926,7 +927,7 @@ class AOMDecoder final : AVIFDecoderInterface { }; static AVIFDecodedData AOMImageToToDecodedData( - const NclxColourInformation* aNclx, aom_image_t* aImage, + const Mp4parseNclxColourInformation* aNclx, aom_image_t* aImage, aom_image_t* aAlphaPlane, bool aPremultipliedAlpha); Maybe mContext; @@ -936,7 +937,7 @@ class AOMDecoder final : AVIFDecoderInterface { /* static */ AVIFDecodedData Dav1dDecoder::Dav1dPictureToDecodedData( - const NclxColourInformation* aNclx, Dav1dPicture* aPicture, + const Mp4parseNclxColourInformation* aNclx, Dav1dPicture* aPicture, Dav1dPicture* aAlphaPlane, bool aPremultipliedAlpha) { MOZ_ASSERT(aPicture); @@ -1026,7 +1027,7 @@ AVIFDecodedData Dav1dDecoder::Dav1dPictureToDecodedData( /* static */ AVIFDecodedData AOMDecoder::AOMImageToToDecodedData( - const NclxColourInformation* aNclx, aom_image_t* aImage, + const Mp4parseNclxColourInformation* aNclx, aom_image_t* aImage, aom_image_t* aAlphaPlane, bool aPremultipliedAlpha) { MOZ_ASSERT(aImage); MOZ_ASSERT(aImage->stride[AOM_PLANE_Y] == aImage->stride[AOM_PLANE_ALPHA]); diff --git a/third_party/rust/mp4parse/.cargo-checksum.json b/third_party/rust/mp4parse/.cargo-checksum.json index ec2fe7a4a1454..f5a15f61ad40f 100644 --- a/third_party/rust/mp4parse/.cargo-checksum.json +++ b/third_party/rust/mp4parse/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"3969c05e1a5ba7f937776863571b7af940d8a2915ba5a7853c5760a2d71b14b1","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"86cb40854b93f988e3a63ce6fe39d2ce95367f8ca301a5ba50676ff98a0ad791","benches/avif_benchmark.rs":"cd99c0dde025ab40d2cd860f53dc697a1587a48c164c3e5c8adfd40add29d772","src/boxes.rs":"496fd2961c55e798134680a9549ad8e8ba73f22f0330f68cfa6a414d49362f46","src/lib.rs":"a6376b0bdbf9e23cced5aa87fe12d954768c1927320ad6ce2a155237ddca7d92","src/macros.rs":"76c840f9299797527fe71aa5b378ffb01312767372b45cc62deddb19775400ae","src/tests.rs":"c48ff81f52925462eb283ff1706a7ac1cd6bbb7f2103a1354f6f84cfd3a6cf99","src/unstable.rs":"c2cef9a3b2b08a4da66fa0305fce7a117bd99c9b8d57b0a044e1d99dbda6faf5","tests/1x1-black-alpha-50pct-premultiplied.avif":"31a8c235bf2cf601a593a7bc33f7f2779f2d5b2e0cd145897b931fce94b0c0b8","tests/amr_nb_1f.3gp":"d1423e3414ad06b69f8b58d5c916ec353ba2d0402d99dec9f1c88acc33b6a127","tests/amr_wb_1f.3gp":"be635b24097e8757b0c04d70ab28e00417ca113e86108b6c269b79b64b89bcd5","tests/av1C-missing-essential.avif":"a1501254c4071847b2269fe40b81409c389ff14e91cf7c0005a47e6ea97a6803","tests/bad-ipma-flags.avif":"ecde7997b97db1910b9dcc7ca8e3c8957da0e83681ea9008c66dc9f12b78ad19","tests/bad-ipma-version.avif":"7f9a1a0b4ebbf8d800d22eaae5ff78970cc6b811317db6c1467c6883952b7c9b","tests/bbb_sunflower_QCIF_30fps_h263_noaudio_1f.3gp":"03e5b1264d0a188d77b9e676ba3ce23a801b17aaa11c0343dfd851d6ea4e3a40","tests/clap-basic-1_3x3-to-1x1.avif":"83af9c8196fa93b2475163585a23d0eb5a8f8015d0db8da7a5d6de61adfb1876","tests/clusterfuzz-testcase-minimized-mp4-6093954524250112":"af7044a470732d4e7e34ac7ab5ff038c58b66f09702cbcd774931d7766bbfd35","tests/corrupt/bug-1655846.avif":"e0a5a06225800fadf05f5352503a4cec11af73eef705c43b4acab5f4a99dea50","tests/corrupt/bug-1661347.avif":"31c26561e1d9eafb60f7c5968b82a0859d203d73f17f26b29276256acee12966","tests/corrupt/hdlr-not-first.avif":"2c29308af077209b9c984921b7e36f8fb7ca7cf379cf8eba4c7a91f65bc7a304","tests/corrupt/hdlr-not-pict.avif":"9fe37619606645a95725300a9e34fada9190d1e0b3919881db84353941ca9291","tests/corrupt/imir-before-clap.avif":"22d6b5dacf0ef0be59053beba7564b08037fed859ada2885e3476e0ff0d19c95","tests/corrupt/invalid-avif-colr-multiple-nclx.avif":"7990a995855120dc4f724a6098816595becc35077fcd9e0de8c68300b49c4f1f","tests/corrupt/invalid-avif-colr-multiple-prof.avif":"b077a6b58e3a13ad743ee3f19fbae53b521eab8727606e0dba9bf06384f3121c","tests/corrupt/invalid-avif-colr-multiple-rICC.avif":"88b24d4d588744b9f2cdc03944f28283e9315eb3de7d7d57773a0541137f6529","tests/corrupt/invalid-avif-colr-multiple.zip":"9abddcbc47fde6da20263a29b770c6a9e76c8ab8dc785ef8512f35d9cb3206ed","tests/corrupt/ipma-duplicate-item_id.avif":"ca8c5275b0b8b79c1068489a52d0a5c8f0b4453463971e72b694189f11c10745","tests/corrupt/ipma-duplicate-version-and-flags.avif":"cf8e15ec4b210235f3d68332a1adeb64e35c41b8d8e1e7586ae38b6d9cd8926c","tests/corrupt/ipma-invalid-property-index.avif":"2480e773fa716d22883032d05fd4cf2c6b00fba8796cf4ff286a5d1ba26adff6","tests/corrupt/no-alpha-av1C.avif":"ad3d34d6331db7d9bea0c5f37efb88923520e33e08e7c636a5df435a4575eae7","tests/corrupt/no-av1C.avif":"eeb4fc50930c91465999f787c4a2a3b12de20556da0857be72da5a1a9eaa3f01","tests/corrupt/no-hdlr.avif":"91a1eb70c7b6adf2104e471d7deeeb98084a591d64ce09ba106c27edfbc3a409","tests/corrupt/no-ispe.avif":"4b6edfd8c9b40c25dc40305a6057e32b5e65f40da4a9d810c58dbff53254113f","tests/corrupt/no-pixi-for-alpha.avif":"f8adc3573c79ee25bf6d4dd2693c61661469b28f86a5c7b1d9e41b0e8d2d53bb","tests/corrupt/no-pixi.avif":"4b1776def440dc8b913c170e4479772ee6bbb299b8679f7c564704bd03c9597e","tests/hdlr-nonzero-reserved.avif":"b872dcd7b4f49c6808d6da109cf4fedc26a237c42e8529c5aa8f7130abaf40a9","tests/imir-missing-essential.avif":"b1226e4b1358528befbd3f1126b5caf0c5051b4354777b87e71f6001f3829f87","tests/irot-missing-essential.avif":"b7da1fc1d1b45bb1b7ca3494476e052f711d794a6d010df6870872ed8b9da10e","tests/multiple-extents.avif":"b5549ac68793e155a726d754e565cea0da03fa17833d3545f45c79e13f4c9360","tests/no-mif1.avif":"1442aa6ffaeb9512724287768bfd1850d3aa29a651ef05abb33e5dec2b3ee5c2","tests/overflow.rs":"16b591d8def1a155b3b997622f6ea255536870d99c3d8f97c51755b77a50de3c","tests/public.rs":"5f18c3cd6a6ecf867489e95f9b5ba94335589b7c1c125e2171c1c0d1333a0328","tests/valid-alpha.avif":"9d417a35b9b62ad3ff66ffbc55f16552aacf821a092aa5ef4adff7e746bd4c2f","tests/valid-avif-colr-nclx-and-prof-and-rICC.avif":"ab6f5e786d26f8bcade5993f8b9cca3cd004a3d7fcec76e829f5d0f98cb18e7b","tests/valid-avif-colr-nclx-and-prof.avif":"0e982818de61869fcb85a2a4c2b7b8aeecb3053cbfdc6276987f91204998eefb","tests/valid-avif-colr-nclx-and-rICC.avif":"8530ef1305ff956a0c2912d0b3d1e0fc3a68cf3103e70b04cc2574530389b030","tests/valid-avif-colr-nclx.avif":"345ab58b7b1cb48aba2e21eb8dc5ab0a751a78a752ce1896c59b4bf361992f38","tests/valid-avif-colr-prof-and-rICC.avif":"1f0f085141106885bda78b0879c768818420d8196b39440a36578456a7d50a6c","tests/valid-avif-colr-prof.avif":"5d7aaefb5204ebe1cc296456866b8e46e023748b921a38ee56fd6c776a9733ff","tests/valid-avif-colr-rICC.avif":"e1c7b49bfad5904b484bd5118e6b33b78e2dc708a31a10fcbb0e4a373ed8dbb7","tests/valid.avif":"f0b33e09bf01232e0877df325f47986c0bee7764f2a81c9c908ae109e7dc63c4"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"edaee37d06f915338d729f67ade1aa28ac3e3904377e815c8515472f7573acbc","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"86cb40854b93f988e3a63ce6fe39d2ce95367f8ca301a5ba50676ff98a0ad791","benches/avif_benchmark.rs":"cd99c0dde025ab40d2cd860f53dc697a1587a48c164c3e5c8adfd40add29d772","src/boxes.rs":"496fd2961c55e798134680a9549ad8e8ba73f22f0330f68cfa6a414d49362f46","src/lib.rs":"85750da758dd3b65bcd7f777576fe049ff185bcee7968a1b2ec7cf2846e52abb","src/macros.rs":"76c840f9299797527fe71aa5b378ffb01312767372b45cc62deddb19775400ae","src/tests.rs":"75fe5467109242b2cc7991f8228e2e2ad1de5be2f29272a4a7f08c4e21ab5fa4","src/unstable.rs":"c2cef9a3b2b08a4da66fa0305fce7a117bd99c9b8d57b0a044e1d99dbda6faf5","tests/1x1-black-alpha-50pct-premultiplied.avif":"31a8c235bf2cf601a593a7bc33f7f2779f2d5b2e0cd145897b931fce94b0c0b8","tests/amr_nb_1f.3gp":"d1423e3414ad06b69f8b58d5c916ec353ba2d0402d99dec9f1c88acc33b6a127","tests/amr_wb_1f.3gp":"be635b24097e8757b0c04d70ab28e00417ca113e86108b6c269b79b64b89bcd5","tests/av1C-missing-essential.avif":"a1501254c4071847b2269fe40b81409c389ff14e91cf7c0005a47e6ea97a6803","tests/bad-ipma-flags.avif":"ecde7997b97db1910b9dcc7ca8e3c8957da0e83681ea9008c66dc9f12b78ad19","tests/bad-ipma-version.avif":"7f9a1a0b4ebbf8d800d22eaae5ff78970cc6b811317db6c1467c6883952b7c9b","tests/bbb_sunflower_QCIF_30fps_h263_noaudio_1f.3gp":"03e5b1264d0a188d77b9e676ba3ce23a801b17aaa11c0343dfd851d6ea4e3a40","tests/clap-basic-1_3x3-to-1x1.avif":"83af9c8196fa93b2475163585a23d0eb5a8f8015d0db8da7a5d6de61adfb1876","tests/clusterfuzz-testcase-minimized-mp4-6093954524250112":"af7044a470732d4e7e34ac7ab5ff038c58b66f09702cbcd774931d7766bbfd35","tests/corrupt/bug-1655846.avif":"e0a5a06225800fadf05f5352503a4cec11af73eef705c43b4acab5f4a99dea50","tests/corrupt/bug-1661347.avif":"31c26561e1d9eafb60f7c5968b82a0859d203d73f17f26b29276256acee12966","tests/corrupt/hdlr-not-first.avif":"2c29308af077209b9c984921b7e36f8fb7ca7cf379cf8eba4c7a91f65bc7a304","tests/corrupt/hdlr-not-pict.avif":"9fe37619606645a95725300a9e34fada9190d1e0b3919881db84353941ca9291","tests/corrupt/imir-before-clap.avif":"22d6b5dacf0ef0be59053beba7564b08037fed859ada2885e3476e0ff0d19c95","tests/corrupt/invalid-avif-colr-multiple-nclx.avif":"7990a995855120dc4f724a6098816595becc35077fcd9e0de8c68300b49c4f1f","tests/corrupt/invalid-avif-colr-multiple-prof.avif":"b077a6b58e3a13ad743ee3f19fbae53b521eab8727606e0dba9bf06384f3121c","tests/corrupt/invalid-avif-colr-multiple-rICC.avif":"88b24d4d588744b9f2cdc03944f28283e9315eb3de7d7d57773a0541137f6529","tests/corrupt/invalid-avif-colr-multiple.zip":"9abddcbc47fde6da20263a29b770c6a9e76c8ab8dc785ef8512f35d9cb3206ed","tests/corrupt/ipma-duplicate-item_id.avif":"ca8c5275b0b8b79c1068489a52d0a5c8f0b4453463971e72b694189f11c10745","tests/corrupt/ipma-duplicate-version-and-flags.avif":"cf8e15ec4b210235f3d68332a1adeb64e35c41b8d8e1e7586ae38b6d9cd8926c","tests/corrupt/ipma-invalid-property-index.avif":"2480e773fa716d22883032d05fd4cf2c6b00fba8796cf4ff286a5d1ba26adff6","tests/corrupt/no-alpha-av1C.avif":"ad3d34d6331db7d9bea0c5f37efb88923520e33e08e7c636a5df435a4575eae7","tests/corrupt/no-av1C.avif":"eeb4fc50930c91465999f787c4a2a3b12de20556da0857be72da5a1a9eaa3f01","tests/corrupt/no-hdlr.avif":"91a1eb70c7b6adf2104e471d7deeeb98084a591d64ce09ba106c27edfbc3a409","tests/corrupt/no-ispe.avif":"4b6edfd8c9b40c25dc40305a6057e32b5e65f40da4a9d810c58dbff53254113f","tests/corrupt/no-pixi-for-alpha.avif":"f8adc3573c79ee25bf6d4dd2693c61661469b28f86a5c7b1d9e41b0e8d2d53bb","tests/corrupt/no-pixi.avif":"4b1776def440dc8b913c170e4479772ee6bbb299b8679f7c564704bd03c9597e","tests/hdlr-nonzero-reserved.avif":"b872dcd7b4f49c6808d6da109cf4fedc26a237c42e8529c5aa8f7130abaf40a9","tests/imir-missing-essential.avif":"b1226e4b1358528befbd3f1126b5caf0c5051b4354777b87e71f6001f3829f87","tests/irot-missing-essential.avif":"b7da1fc1d1b45bb1b7ca3494476e052f711d794a6d010df6870872ed8b9da10e","tests/multiple-extents.avif":"b5549ac68793e155a726d754e565cea0da03fa17833d3545f45c79e13f4c9360","tests/no-mif1.avif":"1442aa6ffaeb9512724287768bfd1850d3aa29a651ef05abb33e5dec2b3ee5c2","tests/overflow.rs":"16b591d8def1a155b3b997622f6ea255536870d99c3d8f97c51755b77a50de3c","tests/public.rs":"5f18c3cd6a6ecf867489e95f9b5ba94335589b7c1c125e2171c1c0d1333a0328","tests/valid-alpha.avif":"9d417a35b9b62ad3ff66ffbc55f16552aacf821a092aa5ef4adff7e746bd4c2f","tests/valid-avif-colr-nclx-and-prof-and-rICC.avif":"ab6f5e786d26f8bcade5993f8b9cca3cd004a3d7fcec76e829f5d0f98cb18e7b","tests/valid-avif-colr-nclx-and-prof.avif":"0e982818de61869fcb85a2a4c2b7b8aeecb3053cbfdc6276987f91204998eefb","tests/valid-avif-colr-nclx-and-rICC.avif":"8530ef1305ff956a0c2912d0b3d1e0fc3a68cf3103e70b04cc2574530389b030","tests/valid-avif-colr-nclx.avif":"345ab58b7b1cb48aba2e21eb8dc5ab0a751a78a752ce1896c59b4bf361992f38","tests/valid-avif-colr-prof-and-rICC.avif":"1f0f085141106885bda78b0879c768818420d8196b39440a36578456a7d50a6c","tests/valid-avif-colr-prof.avif":"5d7aaefb5204ebe1cc296456866b8e46e023748b921a38ee56fd6c776a9733ff","tests/valid-avif-colr-rICC.avif":"e1c7b49bfad5904b484bd5118e6b33b78e2dc708a31a10fcbb0e4a373ed8dbb7","tests/valid.avif":"f0b33e09bf01232e0877df325f47986c0bee7764f2a81c9c908ae109e7dc63c4"},"package":null} \ No newline at end of file diff --git a/third_party/rust/mp4parse/Cargo.toml b/third_party/rust/mp4parse/Cargo.toml index a0f23ed8c24c4..1639eddb3defe 100644 --- a/third_party/rust/mp4parse/Cargo.toml +++ b/third_party/rust/mp4parse/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mp4parse" -version = "0.11.5" +version = "0.12.0" authors = [ "Ralph Giles ", "Matthew Gregan ", diff --git a/third_party/rust/mp4parse/src/lib.rs b/third_party/rust/mp4parse/src/lib.rs index 8d3525d35fd6b..3e16cac0bc11d 100644 --- a/third_party/rust/mp4parse/src/lib.rs +++ b/third_party/rust/mp4parse/src/lib.rs @@ -51,8 +51,6 @@ const MIF1_BRAND: FourCC = FourCC { value: *b"mif1" }; /// A trait to indicate a type can be infallibly converted to `u64`. /// This should only be implemented for infallible conversions, so only unsigned types are valid. trait ToU64 { - // Remove when https://github.com/rust-lang/rust-clippy/issues/6727 is resolved - #[allow(clippy::wrong_self_convention)] fn to_u64(self) -> u64; } @@ -227,6 +225,12 @@ impl From for Status { } } +impl From for Status { + fn from(_: std::io::Error) -> Self { + Status::Io + } +} + /// Describes parser failures. /// /// This enum wraps the standard `io::Error` type, unified with @@ -320,7 +324,7 @@ pub type Result = std::result::Result; /// four-byte box type which identifies the type of the box. Together these /// are enough to interpret the contents of that section of the file. /// -/// See ISOBMFF (ISO 14496-12:2015) § 4.2 +/// See ISOBMFF (ISO 14496-12:2020) § 4.2 #[derive(Debug, Clone, Copy)] struct BoxHeader { /// Box type. @@ -864,7 +868,7 @@ pub struct MetadataBox { pub xml: Option, } -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.2.1 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.2.1 #[cfg(feature = "meta-xml")] #[derive(Debug)] pub enum XmlBox { @@ -902,7 +906,7 @@ enum IsobmffItem { #[derive(Debug)] struct AvifItem { - /// The `item_ID` from ISOBMFF (ISO 14496-12:2015) + /// The `item_ID` from ISOBMFF (ISO 14496-12:2020) § 8.11.3 /// /// See [`read_iloc`] id: ItemId, @@ -933,7 +937,7 @@ pub struct AvifContext { strictness: ParseStrictness, /// Referred to by the `Location` variants of the `AvifItem`s in this struct item_storage: TryVec, - /// The item indicated by the `pitm` box, See ISOBMFF (ISO 14496-12:2015) § 8.11.4 + /// The item indicated by the `pitm` box, See ISOBMFF (ISO 14496-12:2020) § 8.11.4 primary_item: AvifItem, /// Associated alpha channel for the primary item, if any alpha_item: Option, @@ -1080,7 +1084,7 @@ struct AvifMeta { } /// A Media Data Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.1.1 +/// See ISOBMFF (ISO 14496-12:2020) § 8.1.1 struct MediaDataBox { /// Offset of `data` from the beginning of the "file". See ConstructionMethod::File. /// Note: the file may not be an actual file, read_avif supports any `&mut impl Read` @@ -1281,7 +1285,7 @@ impl ItemId { } /// Used for 'infe' boxes within 'iinf' boxes -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.6 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.6 /// Only versions {2, 3} are supported #[derive(Debug)] struct ItemInfoEntry { @@ -1289,7 +1293,7 @@ struct ItemInfoEntry { item_type: u32, } -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.12 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.12 #[derive(Debug)] struct SingleItemTypeReferenceBox { item_type: FourCC, @@ -1298,7 +1302,7 @@ struct SingleItemTypeReferenceBox { } /// Potential sizes (in bytes) of variable-sized fields of the 'iloc' box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.3 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.3 #[derive(Debug, Clone, Copy, PartialEq)] enum IlocFieldSize { Zero, @@ -1350,7 +1354,7 @@ impl TryFrom for IlocVersion { } /// Used for 'iloc' boxes -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.3 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.3 /// `base_offset` is omitted since it is integrated into the ranges in `extents` /// `data_reference_index` is omitted, since only 0 (i.e., this file) is supported #[derive(Debug)] @@ -1360,7 +1364,7 @@ struct ItemLocationBoxItem { extents: TryVec, } -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.3 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.3 /// /// Note: per MIAF (ISO 23000-22:2019) § 7.2.1.7:
/// > MIAF image items are constrained as follows:
@@ -1507,7 +1511,7 @@ impl Track { } } -/// See ISOBMFF (ISO 14496-12:2015) § 4.2 +/// See ISOBMFF (ISO 14496-12:2020) § 4.2 struct BMFFBox<'a, T: 'a> { head: BoxHeader, content: Take<&'a mut T>, @@ -1583,7 +1587,7 @@ impl<'a, T> Drop for BMFFBox<'a, T> { /// parsers for the internal content, or to get the length to /// skip unknown or uninteresting boxes. /// -/// See ISOBMFF (ISO 14496-12:2015) § 4.2 +/// See ISOBMFF (ISO 14496-12:2020) § 4.2 fn read_box_header(src: &mut T) -> Result { let size32 = be_u32(src)?; let name = BoxType::from(be_u32(src)?); @@ -1694,7 +1698,7 @@ pub fn read_avif(f: &mut T, strictness: ParseStrictness) -> Result(f: &mut T, strictness: ParseStrictness) -> Result { if meta.is_some() { return Err(Error::InvalidData( - "There should be zero or one meta boxes per ISOBMFF (ISO 14496-12:2015) § 8.11.1.1", + "There should be zero or one meta boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.1.1", )); } meta = Some(read_avif_meta(&mut b, strictness)?); @@ -1896,7 +1900,7 @@ pub fn read_avif(f: &mut T, strictness: ParseStrictness) -> Result( src: &mut BMFFBox, strictness: ParseStrictness, @@ -1930,7 +1934,7 @@ fn read_avif_meta( BoxType::HandlerBox => { if read_handler_box { return Err(Error::InvalidData( - "There shall be exactly one hdlr box per ISOBMFF (ISO 14496-12:2015) § 8.4.3.1", + "There shall be exactly one hdlr box per ISOBMFF (ISO 14496-12:2020) § 8.4.3.1", )); } let HandlerBox { handler_type } = read_hdlr(&mut b, strictness)?; @@ -1946,7 +1950,7 @@ fn read_avif_meta( BoxType::ItemInfoBox => { if item_infos.is_some() { return Err(Error::InvalidData( - "There shall be zero or one iinf boxes per ISOBMFF (ISO 14496-12:2015) § 8.11.6.1", + "There shall be zero or one iinf boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.6.1", )); } item_infos = Some(read_iinf(&mut b, strictness)?); @@ -1954,7 +1958,7 @@ fn read_avif_meta( BoxType::ItemLocationBox => { if iloc_items.is_some() { return Err(Error::InvalidData( - "There shall be zero or one iloc boxes per ISOBMFF (ISO 14496-12:2015) § 8.11.3.1", + "There shall be zero or one iloc boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.3.1", )); } iloc_items = Some(read_iloc(&mut b)?); @@ -1962,14 +1966,14 @@ fn read_avif_meta( BoxType::PrimaryItemBox => { if primary_item_id.is_some() { return Err(Error::InvalidData( - "There shall be zero or one pitm boxes per ISOBMFF (ISO 14496-12:2015) § 8.11.4.1", + "There shall be zero or one pitm boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.4.1", )); } primary_item_id = Some(read_pitm(&mut b)?); } BoxType::ItemReferenceBox => { if item_references.is_some() { - return Err(Error::InvalidData("There shall be zero or one iref boxes per ISOBMFF (ISO 14496-12:2015) § 8.11.12.1")); + return Err(Error::InvalidData("There shall be zero or one iref boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.12.1")); } item_references = Some(read_iref(&mut b)?); } @@ -2017,7 +2021,7 @@ fn read_avif_meta( } /// Parse a Primary Item Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.4 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.4 fn read_pitm(src: &mut BMFFBox) -> Result { let version = read_fullbox_version_no_flags(src)?; @@ -2031,7 +2035,7 @@ fn read_pitm(src: &mut BMFFBox) -> Result { } /// Parse an Item Information Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.6 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.6 fn read_iinf( src: &mut BMFFBox, strictness: ParseStrictness, @@ -2054,7 +2058,7 @@ fn read_iinf( while let Some(mut b) = iter.next_box()? { if b.head.name != BoxType::ItemInfoEntry { return Err(Error::InvalidData( - "iinf box shall contain only infe boxes per ISOBMFF (ISO 14496-12:2015) § 8.11.6.2", + "iinf box shall contain only infe boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.6.2", )); } @@ -2080,7 +2084,7 @@ impl std::fmt::Display for U32BE { } /// Parse an Item Info Entry -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.6.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.6.2 fn read_infe(src: &mut BMFFBox, strictness: ParseStrictness) -> Result { let (version, flags) = read_fullbox_extra(src)?; @@ -2091,7 +2095,7 @@ fn read_infe(src: &mut BMFFBox, strictness: ParseStrictness) -> Resu fail_if( strictness == ParseStrictness::Strict, "'infe' flags field shall be 0 \ - per ISOBMFF (ISO 14496-12:2015) § 8.11.6.2", + per ISOBMFF (ISO 14496-12:2020) § 8.11.6.2", )?; } @@ -2118,7 +2122,7 @@ fn read_infe(src: &mut BMFFBox, strictness: ParseStrictness) -> Resu } /// Parse an Item Reference Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.12 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.12 fn read_iref(src: &mut BMFFBox) -> Result> { let mut item_references = TryVec::new(); let version = read_fullbox_version_no_flags(src)?; @@ -3041,7 +3045,7 @@ fn read_auxc(src: &mut BMFFBox) -> Result { } /// Parse an item location box inside a meta box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.3 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.3 fn read_iloc(src: &mut BMFFBox) -> Result> { let version: IlocVersion = read_fullbox_version_no_flags(src)?.try_into()?; @@ -3086,7 +3090,7 @@ fn read_iloc(src: &mut BMFFBox) -> Result ConstructionMethod::File, 1 => ConstructionMethod::Idat, 2 => return Err(Error::Unsupported("construction_method 'item_offset' is not supported")), - _ => return Err(Error::InvalidData("construction_method is taken from the set 0, 1 or 2 per ISOBMFF (ISO 14496-12:2015) § 8.11.3.3")) + _ => return Err(Error::InvalidData("construction_method is taken from the set 0, 1 or 2 per ISOBMFF (ISO 14496-12:2020) § 8.11.3.3")) } } }; @@ -3104,7 +3108,7 @@ fn read_iloc(src: &mut BMFFBox) -> Result(src: &mut BMFFBox) -> Result(src: &mut BMFFBox) -> Result 0. @@ -3231,7 +3235,7 @@ pub fn read_mp4(f: &mut T) -> Result { } /// Parse a Movie Header Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.2.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.2.2 fn parse_mvhd(f: &mut BMFFBox) -> Result> { let mvhd = read_mvhd(f)?; debug!("{:?}", mvhd); @@ -3243,7 +3247,7 @@ fn parse_mvhd(f: &mut BMFFBox) -> Result> { } /// Parse a Movie Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.2.1 +/// See ISOBMFF (ISO 14496-12:2020) § 8.2.1 /// Note that despite the spec indicating "exactly one" moov box should exist at /// the file container level, we support reading and merging multiple moov boxes /// such as with tests/test_case_1185230.mp4. @@ -3342,7 +3346,7 @@ fn read_pssh(src: &mut BMFFBox) -> Result(src: &mut BMFFBox) -> Result { let mut iter = src.box_iter(); let mut fragment_duration = None; @@ -3369,7 +3373,7 @@ fn read_mehd(src: &mut BMFFBox) -> Result { } /// Parse a Track Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.3.1. +/// See ISOBMFF (ISO 14496-12:2020) § 8.3.1. fn read_trak(f: &mut BMFFBox, track: &mut Track) -> Result<()> { let mut iter = f.box_iter(); while let Some(mut b) = iter.next_box()? { @@ -3544,7 +3548,7 @@ fn read_stbl(f: &mut BMFFBox, track: &mut Track) -> Result<()> { } /// Parse an ftyp box. -/// See ISOBMFF (ISO 14496-12:2015) § 4.3 +/// See ISOBMFF (ISO 14496-12:2020) § 4.3 fn read_ftyp(src: &mut BMFFBox) -> Result { let major = be_u32(src)?; let minor = be_u32(src)?; @@ -3650,7 +3654,7 @@ fn read_tkhd(src: &mut BMFFBox) -> Result { } /// Parse a elst box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.6.6 +/// See ISOBMFF (ISO 14496-12:2020) § 8.6.6 fn read_elst(src: &mut BMFFBox) -> Result { let (version, _) = read_fullbox_extra(src)?; let edit_count = be_u32(src)?; @@ -3726,7 +3730,7 @@ fn read_mdhd(src: &mut BMFFBox) -> Result { } /// Parse a stco box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.7.5 +/// See ISOBMFF (ISO 14496-12:2020) § 8.7.5 fn read_stco(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let offset_count = be_u32(src)?; @@ -3742,7 +3746,7 @@ fn read_stco(src: &mut BMFFBox) -> Result { } /// Parse a co64 box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.7.5 +/// See ISOBMFF (ISO 14496-12:2020) § 8.7.5 fn read_co64(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let offset_count = be_u32(src)?; @@ -3758,7 +3762,7 @@ fn read_co64(src: &mut BMFFBox) -> Result { } /// Parse a stss box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.6.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.6.2 fn read_stss(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let sample_count = be_u32(src)?; @@ -3774,7 +3778,7 @@ fn read_stss(src: &mut BMFFBox) -> Result { } /// Parse a stsc box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.7.4 +/// See ISOBMFF (ISO 14496-12:2020) § 8.7.4 fn read_stsc(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let sample_count = be_u32(src)?; @@ -3797,7 +3801,7 @@ fn read_stsc(src: &mut BMFFBox) -> Result { } /// Parse a Composition Time to Sample Box -/// See ISOBMFF (ISO 14496-12:2015) § 8.6.1.3 +/// See ISOBMFF (ISO 14496-12:2020) § 8.6.1.3 fn read_ctts(src: &mut BMFFBox) -> Result { let (version, _) = read_fullbox_extra(src)?; @@ -3837,7 +3841,7 @@ fn read_ctts(src: &mut BMFFBox) -> Result { } /// Parse a stsz box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.7.3.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.7.3.2 fn read_stsz(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let sample_size = be_u32(src)?; @@ -3860,7 +3864,7 @@ fn read_stsz(src: &mut BMFFBox) -> Result { } /// Parse a stts box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.6.1.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.6.1.2 fn read_stts(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let sample_count = be_u32(src)?; @@ -4286,7 +4290,7 @@ fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> { } esds.audio_codec = match object_profile { - 0x40 | 0x41 => CodecType::AAC, + 0x40 | 0x66 | 0x67 => CodecType::AAC, 0x69 | 0x6B => CodecType::MP3, _ => CodecType::Unknown, }; @@ -4514,12 +4518,23 @@ fn read_hdlr(src: &mut BMFFBox, strictness: ParseStrictness) -> Resu match std::str::from_utf8(src.read_into_try_vec()?.as_slice()) { Ok(name) => { - if name.bytes().last() != Some(b'\0') { - fail_if( + match name.bytes().filter(|&b| b == b'\0').count() { + 0 => fail_if( strictness != ParseStrictness::Permissive, "The HandlerBox 'name' field shall be null-terminated \ per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2", - )? + )?, + 1 => (), + _ => + // See https://github.com/MPEGGroup/FileFormat/issues/35 + { + fail_if( + strictness == ParseStrictness::Strict, + "The HandlerBox 'name' field shall have a NUL byte \ + only in the final position \ + per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2", + )? + } } } Err(_) => fail_if( @@ -4693,7 +4708,7 @@ fn read_qt_wave_atom(src: &mut BMFFBox) -> Result { } /// Parse an audio description inside an stsd box. -/// See ISOBMFF (ISO 14496-12:2015) § 12.2.3 +/// See ISOBMFF (ISO 14496-12:2020) § 12.2.3 fn read_audio_sample_entry(src: &mut BMFFBox) -> Result { let name = src.get_header().name; @@ -4852,7 +4867,7 @@ fn read_audio_sample_entry(src: &mut BMFFBox) -> Result } /// Parse a stsd box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.5.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.5.2 /// See MP4 (ISO 14496-14:2020) § 6.7.2 fn read_stsd(src: &mut BMFFBox, track: &mut Track) -> Result { let (_, _) = read_fullbox_extra(src)?; @@ -4994,7 +5009,7 @@ fn read_schm(src: &mut BMFFBox) -> Result { } /// Parse a metadata box inside a moov, trak, or mdia box. -/// See ISOBMFF (ISO 14496-12:2015) § 8.10.1. +/// See ISOBMFF (ISO 14496-12:2020) § 8.10.1. fn read_udta(src: &mut BMFFBox) -> Result { let mut iter = src.box_iter(); let mut udta = UserdataBox { meta: None }; @@ -5013,7 +5028,7 @@ fn read_udta(src: &mut BMFFBox) -> Result { } /// Parse the meta box -/// See ISOBMFF (ISO 14496-12:2015) § 8.111. +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.1 fn read_meta(src: &mut BMFFBox) -> Result { let (_, _) = read_fullbox_extra(src)?; let mut iter = src.box_iter(); @@ -5033,7 +5048,7 @@ fn read_meta(src: &mut BMFFBox) -> Result { } /// Parse a XML box inside a meta box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.2 #[cfg(feature = "meta-xml")] fn read_xml_(src: &mut BMFFBox, meta: &mut MetadataBox) -> Result<()> { if read_fullbox_version_no_flags(src)? != 0 { @@ -5044,7 +5059,7 @@ fn read_xml_(src: &mut BMFFBox, meta: &mut MetadataBox) -> Result<() } /// Parse a Binary XML box inside a meta box -/// See ISOBMFF (ISO 14496-12:2015) § 8.11.2 +/// See ISOBMFF (ISO 14496-12:2020) § 8.11.2 #[cfg(feature = "meta-xml")] fn read_bxml(src: &mut BMFFBox, meta: &mut MetadataBox) -> Result<()> { if read_fullbox_version_no_flags(src)? != 0 { diff --git a/third_party/rust/mp4parse/src/tests.rs b/third_party/rust/mp4parse/src/tests.rs index 8f96ec5548d10..0f2276002019b 100644 --- a/third_party/rust/mp4parse/src/tests.rs +++ b/third_party/rust/mp4parse/src/tests.rs @@ -475,6 +475,24 @@ fn read_hdlr() { assert_eq!(parsed.handler_type, b"vide"); } +#[test] +fn read_hdlr_multiple_nul_in_name() { + let mut stream = make_fullbox(BoxSize::Short(45), b"hdlr", 0, |s| { + s.B32(0) + .append_bytes(b"vide") + .B32(0) + .B32(0) + .B32(0) + .append_bytes(b"Vide\0Handler") + .B8(0) // null-terminate string + }); + let mut iter = super::BoxIter::new(&mut stream); + let mut stream = iter.next_box().unwrap().unwrap(); + assert_eq!(stream.head.name, BoxType::HandlerBox); + assert_eq!(stream.head.size, 45); + assert!(super::read_hdlr(&mut stream, ParseStrictness::Strict).is_err()); +} + #[test] fn read_hdlr_short_name() { let mut stream = make_fullbox(BoxSize::Short(33), b"hdlr", 0, |s| { @@ -1060,6 +1078,35 @@ fn read_esds_aac_type5() { assert_eq!(es.decoder_specific_data, aac_dc_descriptor); } +#[test] +fn read_esds_mpeg2_aac_lc() { + // Recognize MPEG-2 AAC LC (ISO 13818-7) object type as AAC. + // Extracted from BMO #1722497 sdasdasdasd_001.mp4 using Bento4. + // "mp4extract --payload-only moov/trak[1]/mdia/minf/stbl/stsd/mp4a/esds sdasdasdasd_001.mp4 /dev/stdout | xxd -i -c 15" + let aac_esds = vec![ + 0x03, 0x19, 0x00, 0x00, 0x00, 0x04, 0x11, 0x67, 0x15, 0x00, 0x02, 0x38, 0x00, 0x01, 0x0f, + 0xd0, 0x00, 0x00, 0xf5, 0x48, 0x05, 0x02, 0x13, 0x90, 0x06, 0x01, 0x02, + ]; + let aac_dc_descriptor = &aac_esds[22..24]; + + let mut stream = make_box(BoxSize::Auto, b"esds", |s| { + s.B32(0) // reserved + .append_bytes(aac_esds.as_slice()) + }); + let mut iter = super::BoxIter::new(&mut stream); + let mut stream = iter.next_box().unwrap().unwrap(); + + let es = super::read_esds(&mut stream).unwrap(); + + assert_eq!(es.audio_codec, super::CodecType::AAC); + assert_eq!(es.audio_object_type, Some(2)); + assert_eq!(es.extended_audio_object_type, None); + assert_eq!(es.audio_sample_rate, Some(22050)); + assert_eq!(es.audio_channel_count, Some(2)); + assert_eq!(es.codec_esds, aac_esds); + assert_eq!(es.decoder_specific_data, aac_dc_descriptor); +} + #[test] fn read_stsd_mp4v() { let mp4v = vec![ diff --git a/third_party/rust/mp4parse_capi/.cargo-checksum.json b/third_party/rust/mp4parse_capi/.cargo-checksum.json index 0358591794ae5..f9bd2e1ca28b3 100644 --- a/third_party/rust/mp4parse_capi/.cargo-checksum.json +++ b/third_party/rust/mp4parse_capi/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"fa0e2b46e9547dba9134da4001b2cd803fac58f9252394aa62653fe99bd220fa","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"f776ed4bbb7b58a5684402a9c5c28dfe1fa02b6b184139b2c2c49384cc1e3723","cbindgen.toml":"f82065edc5be3d2e43db65ac67490194701b3800ce3d42976fc7ad351928a296","examples/dump.rs":"268093925d28d1636e106d93a2f2917fb1d7ddaf04ecd70880e1551fb578de1a","src/lib.rs":"9bec128eb9ac71a79e20a5e2c7125579baab921d285fb897ed04525df4ab9827","tests/test_chunk_out_of_range.rs":"b5da583218d98027ed973a29c67434a91a1306f2d2fb39ec4d640d4824c308ce","tests/test_encryption.rs":"b918f0f10e7708bff5fae4becf1d09a188db25d874d0919d509b90266504eed7","tests/test_fragment.rs":"e90eb5a4418d30002655466c0c4b3125c7fd70a74b6871471eaa172f1def9db8","tests/test_rotation.rs":"fb43c2f2dfa496d151c33bdd46c0fd3252387c23cc71e2cac9ed0234de715a81","tests/test_sample_table.rs":"19b8d0b0f7ed79a857329321b49f5a7f687901cadd4cd22bc6728febd919d3ce","tests/test_workaround_stsc.rs":"7dd419f3d55b9a3a039cac57e58a9240a9c8166bcd4356c24f69f731c3ced83b"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"a01dabf060b9e93415361370add87e1ab1170a4a94f93fd24c9f95fc4e004f48","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"f776ed4bbb7b58a5684402a9c5c28dfe1fa02b6b184139b2c2c49384cc1e3723","cbindgen.toml":"28c98f1dd0f4ec6ff0f4acbc86d4112d2a3569306b55baf84727f5e8c769b15d","examples/dump.rs":"a22630f5f1434d4832f9113dcb18161c0248465e8844d470da3c76bb9910677a","src/lib.rs":"dc0d0af89fceb7cce359fc581b00b211fdd8f70bc8e120157d1ef636d38cbcd1","tests/test_chunk_out_of_range.rs":"73ffb5b60e826f6136d22142c030d17d0f72b85c675ccbf1300c84f9deb73131","tests/test_encryption.rs":"196ba22efc3e693c940bcc1e45d29bec9cf290b81cf77a68c1d254f6b38e6ae3","tests/test_fragment.rs":"a4b275d7159c50b265db583a1cc8255bd0a141e3a44432355713b895a7970d37","tests/test_rotation.rs":"a5aa6cc88a327ec90d6898b2c4f5ac397667ce349d829deae1af46c230be9cb6","tests/test_sample_table.rs":"d191fe5836c58d4bdffd7390da029bb5371f8afb5b1a8d636e15ae0dd6b5f4c8","tests/test_workaround_stsc.rs":"85cd2546224b5c4891a60d86e2d302a56e0c0798c2636ad241603a00ebfa46b5"},"package":null} \ No newline at end of file diff --git a/third_party/rust/mp4parse_capi/Cargo.toml b/third_party/rust/mp4parse_capi/Cargo.toml index 894efc401eea1..202e03a897434 100644 --- a/third_party/rust/mp4parse_capi/Cargo.toml +++ b/third_party/rust/mp4parse_capi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mp4parse_capi" -version = "0.11.5" +version = "0.12.0" authors = [ "Ralph Giles ", "Matthew Gregan ", @@ -27,7 +27,7 @@ travis-ci = { repository = "https://github.com/mozilla/mp4parse-rust" } byteorder = "1.2.1" fallible_collections = { version = "0.4", features = ["std_io"] } log = "0.4" -mp4parse = { version = "0.11.5", path = "../mp4parse", features = ["unstable-api"] } +mp4parse = { version = "0.12.0", path = "../mp4parse", features = ["unstable-api"] } num-traits = "0.2.14" [dev-dependencies] diff --git a/third_party/rust/mp4parse_capi/cbindgen.toml b/third_party/rust/mp4parse_capi/cbindgen.toml index 73e8ce459ac4e..a65db2d7cfc9d 100644 --- a/third_party/rust/mp4parse_capi/cbindgen.toml +++ b/third_party/rust/mp4parse_capi/cbindgen.toml @@ -40,3 +40,4 @@ include = ["Status"] "ImageRotation" = "Mp4parseIrot" "ImageMirror" = "Mp4parseImir" "Indice" = "Mp4parseIndice" +"NclxColourInformation" = "Mp4parseNclxColourInformation" diff --git a/third_party/rust/mp4parse_capi/examples/dump.rs b/third_party/rust/mp4parse_capi/examples/dump.rs index dc145b9b4d753..1392b304f80b4 100644 --- a/third_party/rust/mp4parse_capi/examples/dump.rs +++ b/third_party/rust/mp4parse_capi/examples/dump.rs @@ -14,8 +14,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/src/lib.rs b/third_party/rust/mp4parse_capi/src/lib.rs index 2fe5de56af527..43e6e872cb5da 100644 --- a/third_party/rust/mp4parse_capi/src/lib.rs +++ b/third_party/rust/mp4parse_capi/src/lib.rs @@ -1287,12 +1287,7 @@ fn get_pssh_info( .try_into() .map_err(|_| Mp4parseStatus::Invalid)?; let mut data_len = TryVec::new(); - if data_len - .write_u32::(content_len) - .is_err() - { - return Err(Mp4parseStatus::Io); - } + data_len.write_u32::(content_len)?; pssh_data.extend_from_slice(pssh.system_id.as_slice())?; pssh_data.extend_from_slice(data_len.as_slice())?; pssh_data.extend_from_slice(pssh.box_content.as_slice())?; @@ -1312,8 +1307,8 @@ extern "C" fn error_read(_: *mut u8, _: usize, _: *mut std::os::raw::c_void) -> extern "C" fn valid_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/tests/test_chunk_out_of_range.rs b/third_party/rust/mp4parse_capi/tests/test_chunk_out_of_range.rs index 5529c92182548..b3a9543b4092a 100644 --- a/third_party/rust/mp4parse_capi/tests/test_chunk_out_of_range.rs +++ b/third_party/rust/mp4parse_capi/tests/test_chunk_out_of_range.rs @@ -4,8 +4,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/tests/test_encryption.rs b/third_party/rust/mp4parse_capi/tests/test_encryption.rs index 0634048a191f7..1a47e329fcd5c 100644 --- a/third_party/rust/mp4parse_capi/tests/test_encryption.rs +++ b/third_party/rust/mp4parse_capi/tests/test_encryption.rs @@ -4,8 +4,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/tests/test_fragment.rs b/third_party/rust/mp4parse_capi/tests/test_fragment.rs index 5ded45fd3dfb8..d6ebe1f177d50 100644 --- a/third_party/rust/mp4parse_capi/tests/test_fragment.rs +++ b/third_party/rust/mp4parse_capi/tests/test_fragment.rs @@ -4,8 +4,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/tests/test_rotation.rs b/third_party/rust/mp4parse_capi/tests/test_rotation.rs index 45991c6adaa61..918c9fbeaea78 100644 --- a/third_party/rust/mp4parse_capi/tests/test_rotation.rs +++ b/third_party/rust/mp4parse_capi/tests/test_rotation.rs @@ -4,8 +4,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/tests/test_sample_table.rs b/third_party/rust/mp4parse_capi/tests/test_sample_table.rs index eb88d4e504cf8..ad030a94c5452 100644 --- a/third_party/rust/mp4parse_capi/tests/test_sample_table.rs +++ b/third_party/rust/mp4parse_capi/tests/test_sample_table.rs @@ -6,8 +6,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/third_party/rust/mp4parse_capi/tests/test_workaround_stsc.rs b/third_party/rust/mp4parse_capi/tests/test_workaround_stsc.rs index b77da23b6db86..99c92a7fef994 100644 --- a/third_party/rust/mp4parse_capi/tests/test_workaround_stsc.rs +++ b/third_party/rust/mp4parse_capi/tests/test_workaround_stsc.rs @@ -4,8 +4,8 @@ use std::io::Read; extern "C" fn buf_read(buf: *mut u8, size: usize, userdata: *mut std::os::raw::c_void) -> isize { let input: &mut std::fs::File = unsafe { &mut *(userdata as *mut _) }; - let mut buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; - match input.read(&mut buf) { + let buf = unsafe { std::slice::from_raw_parts_mut(buf, size) }; + match input.read(buf) { Ok(n) => n as isize, Err(_) => -1, } diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 72ae8f22ffac5..8f92836cf2e0c 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -9,7 +9,7 @@ description = "Shared Rust code for libxul" geckoservo = { path = "../../../../servo/ports/geckolib" } kvstore = { path = "../../../components/kvstore" } lmdb-rkv-sys = { version = "0.11", features = ["mdb_idl_logn_9"] } -mp4parse_capi = { git = "https://github.com/mozilla/mp4parse-rust", rev = "72eb355ddeada541d7e57dbe5fb60eb5124dea0d", features = ["missing-pixi-permitted"] } +mp4parse_capi = { git = "https://github.com/mozilla/mp4parse-rust", rev = "a25713781eac774c531af43ba833ef86cb920889", features = ["missing-pixi-permitted"] } nserror = { path = "../../../../xpcom/rust/nserror" } nsstring = { path = "../../../../xpcom/rust/nsstring" } netwerk_helper = { path = "../../../../netwerk/base/rust-helper" }