mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1723247
- Update mp4parse-rust to 5326af6 r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D121449
This commit is contained in:
parent
f56e6314c0
commit
2e5d433f82
@ -20,7 +20,7 @@ tag = "v0.4.28"
|
||||
[source."https://github.com/mozilla/mp4parse-rust"]
|
||||
git = "https://github.com/mozilla/mp4parse-rust"
|
||||
replace-with = "vendored-sources"
|
||||
rev = "1bb484e96ae724309e3346968e8ffd4c25e61616"
|
||||
rev = "5326af6b54cec885cdb9e7be282a6db6e757b964"
|
||||
|
||||
[source."https://github.com/mozilla/l10nregistry-rs"]
|
||||
git = "https://github.com/mozilla/l10nregistry-rs"
|
||||
|
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -3278,13 +3278,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "mp4parse"
|
||||
version = "0.11.5"
|
||||
source = "git+https://github.com/mozilla/mp4parse-rust?rev=1bb484e96ae724309e3346968e8ffd4c25e61616#1bb484e96ae724309e3346968e8ffd4c25e61616"
|
||||
source = "git+https://github.com/mozilla/mp4parse-rust?rev=5326af6b54cec885cdb9e7be282a6db6e757b964#5326af6b54cec885cdb9e7be282a6db6e757b964"
|
||||
dependencies = [
|
||||
"bitreader",
|
||||
"byteorder",
|
||||
"env_logger",
|
||||
"fallible_collections",
|
||||
"hashbrown",
|
||||
"log",
|
||||
"num-traits",
|
||||
"static_assertions",
|
||||
@ -3297,7 +3296,7 @@ version = "0.1.0"
|
||||
[[package]]
|
||||
name = "mp4parse_capi"
|
||||
version = "0.11.5"
|
||||
source = "git+https://github.com/mozilla/mp4parse-rust?rev=1bb484e96ae724309e3346968e8ffd4c25e61616#1bb484e96ae724309e3346968e8ffd4c25e61616"
|
||||
source = "git+https://github.com/mozilla/mp4parse-rust?rev=5326af6b54cec885cdb9e7be282a6db6e757b964#5326af6b54cec885cdb9e7be282a6db6e757b964"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"fallible_collections",
|
||||
|
@ -233,8 +233,6 @@ static const TestFileData testFiles[] = {
|
||||
0, false, 2},
|
||||
{"test_case_1388991.mp4", true, 0, false, -1, 0, 0, 1, 30000181, false, 0,
|
||||
false, 2},
|
||||
{"test_case_1380468.mp4", false, 0, false, 0, 0, 0, 0, 0, false, 0, false,
|
||||
0},
|
||||
{"test_case_1410565.mp4", false, 0, false, 0, 0, 0, 0, 0, false, 955100,
|
||||
true, 2}, // negative 'timescale'
|
||||
{"test_case_1513651-2-sample-description-entries.mp4", true, 1, true,
|
||||
|
@ -39,7 +39,6 @@ TEST_HARNESS_FILES.gtest += [
|
||||
"test_case_1301065.mp4",
|
||||
"test_case_1329061.mov",
|
||||
"test_case_1351094.mp4",
|
||||
"test_case_1380468.mp4",
|
||||
"test_case_1388991.mp4",
|
||||
"test_case_1389299.mp4",
|
||||
"test_case_1389527.mp4",
|
||||
|
Binary file not shown.
@ -5,6 +5,7 @@
|
||||
#ifndef mp4parse_rust_mp4parse_h
|
||||
#define mp4parse_rust_mp4parse_h
|
||||
|
||||
#define MP4PARSE_UNSTABLE_API 1
|
||||
#include "mp4parse_ffi_generated.h" // prepend mozilla/media when we namespace this
|
||||
|
||||
// Add any non-generated support code here
|
||||
|
@ -1 +1 @@
|
||||
{"files":{"Cargo.toml":"21a2ada4f794296fd07b2b6f4ff781a7ac256d0d6c0b707621a4c84d142b2cf7","benches/avif_benchmark.rs":"cd99c0dde025ab40d2cd860f53dc697a1587a48c164c3e5c8adfd40add29d772","src/boxes.rs":"2bae06b89cd6f4a8bf6d58fc055b9900c9fe89697a5776c19a2e587b6b20b803","src/lib.rs":"ea3d90a541bd01cbb9f8e25599e77600f2ab011535b23334a433e5bd0d8ac7df","src/macros.rs":"76c840f9299797527fe71aa5b378ffb01312767372b45cc62deddb19775400ae","src/tests.rs":"0662320d5600a51370d3df7b8848814f4e779f10f8ad37edffe9541565dc67be","src/unstable.rs":"5a0edd7f803fdc355a46bc8142f29aca976d5bbb24cc5d94a3d7c61d0cf4634a","tests/1x1-black-alpha-50pct-premultiplied.avif":"31a8c235bf2cf601a593a7bc33f7f2779f2d5b2e0cd145897b931fce94b0c0b8","tests/amr_nb_1f.3gp":"d1423e3414ad06b69f8b58d5c916ec353ba2d0402d99dec9f1c88acc33b6a127","tests/amr_wb_1f.3gp":"be635b24097e8757b0c04d70ab28e00417ca113e86108b6c269b79b64b89bcd5","tests/bbb_sunflower_QCIF_30fps_h263_noaudio_1f.3gp":"03e5b1264d0a188d77b9e676ba3ce23a801b17aaa11c0343dfd851d6ea4e3a40","tests/clap-basic-1_3x3-to-1x1.avif":"83af9c8196fa93b2475163585a23d0eb5a8f8015d0db8da7a5d6de61adfb1876","tests/corrupt/av1C-missing-essential.avif":"a1501254c4071847b2269fe40b81409c389ff14e91cf7c0005a47e6ea97a6803","tests/corrupt/bad-ipma-flags.avif":"ecde7997b97db1910b9dcc7ca8e3c8957da0e83681ea9008c66dc9f12b78ad19","tests/corrupt/bad-ipma-version.avif":"7f9a1a0b4ebbf8d800d22eaae5ff78970cc6b811317db6c1467c6883952b7c9b","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/imir-missing-essential.avif":"b1226e4b1358528befbd3f1126b5caf0c5051b4354777b87e71f6001f3829f87","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/irot-missing-essential.avif":"b7da1fc1d1b45bb1b7ca3494476e052f711d794a6d010df6870872ed8b9da10e","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-mif1.avif":"1442aa6ffaeb9512724287768bfd1850d3aa29a651ef05abb33e5dec2b3ee5c2","tests/corrupt/no-pixi-for-alpha.avif":"f8adc3573c79ee25bf6d4dd2693c61661469b28f86a5c7b1d9e41b0e8d2d53bb","tests/corrupt/no-pixi.avif":"4b1776def440dc8b913c170e4479772ee6bbb299b8679f7c564704bd03c9597e","tests/multiple-extents.avif":"b5549ac68793e155a726d754e565cea0da03fa17833d3545f45c79e13f4c9360","tests/overflow.rs":"16b591d8def1a155b3b997622f6ea255536870d99c3d8f97c51755b77a50de3c","tests/public.rs":"dd2464ef83e861833f7ef9f8a1055254f1453665fd4b5ec32a2a1f6362ce535b","tests/valid-alpha.avif":"9d417a35b9b62ad3ff66ffbc55f16552aacf821a092aa5ef4adff7e746bd4c2f","tests/valid.avif":"f0b33e09bf01232e0877df325f47986c0bee7764f2a81c9c908ae109e7dc63c4"},"package":null}
|
||||
{"files":{"Cargo.toml":"c06a8bf810a588465e8d26852c29ebb1fdf7e7adc1ee3cbac8a487ae92c38000","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"86cb40854b93f988e3a63ce6fe39d2ce95367f8ca301a5ba50676ff98a0ad791","benches/avif_benchmark.rs":"cd99c0dde025ab40d2cd860f53dc697a1587a48c164c3e5c8adfd40add29d772","src/boxes.rs":"50eed905feb775a1e696a6faa33233e8f8803591bfa9c5ad15ea02cbd17732d6","src/lib.rs":"d24a97ca6dfb25d672b28ba2e9da31923136b4f1783ceca4b96c745a7bc1be51","src/macros.rs":"76c840f9299797527fe71aa5b378ffb01312767372b45cc62deddb19775400ae","src/tests.rs":"87a391c2383f601439bf1ebebb3b24d998252e2574dde75c7c578fae9bfc27bb","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/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/av1C-missing-essential.avif":"a1501254c4071847b2269fe40b81409c389ff14e91cf7c0005a47e6ea97a6803","tests/corrupt/bad-ipma-flags.avif":"ecde7997b97db1910b9dcc7ca8e3c8957da0e83681ea9008c66dc9f12b78ad19","tests/corrupt/bad-ipma-version.avif":"7f9a1a0b4ebbf8d800d22eaae5ff78970cc6b811317db6c1467c6883952b7c9b","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/imir-missing-essential.avif":"b1226e4b1358528befbd3f1126b5caf0c5051b4354777b87e71f6001f3829f87","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/irot-missing-essential.avif":"b7da1fc1d1b45bb1b7ca3494476e052f711d794a6d010df6870872ed8b9da10e","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-mif1.avif":"1442aa6ffaeb9512724287768bfd1850d3aa29a651ef05abb33e5dec2b3ee5c2","tests/corrupt/no-pixi-for-alpha.avif":"f8adc3573c79ee25bf6d4dd2693c61661469b28f86a5c7b1d9e41b0e8d2d53bb","tests/corrupt/no-pixi.avif":"4b1776def440dc8b913c170e4479772ee6bbb299b8679f7c564704bd03c9597e","tests/multiple-extents.avif":"b5549ac68793e155a726d754e565cea0da03fa17833d3545f45c79e13f4c9360","tests/overflow.rs":"16b591d8def1a155b3b997622f6ea255536870d99c3d8f97c51755b77a50de3c","tests/public.rs":"38f046cebbfcb7e34a816b585282887acafe68dc5143dad1841fae6328677cc3","tests/valid-alpha.avif":"9d417a35b9b62ad3ff66ffbc55f16552aacf821a092aa5ef4adff7e746bd4c2f","tests/valid.avif":"f0b33e09bf01232e0877df325f47986c0bee7764f2a81c9c908ae109e7dc63c4"},"package":null}
|
1
third_party/rust/mp4parse/Cargo.toml
vendored
1
third_party/rust/mp4parse/Cargo.toml
vendored
@ -30,7 +30,6 @@ byteorder = "1.2.1"
|
||||
bitreader = { version = "0.3.2" }
|
||||
env_logger = "0.8"
|
||||
fallible_collections = { version = "0.4", features = ["std_io"] }
|
||||
hashbrown = "0.9"
|
||||
num-traits = "0.2.14"
|
||||
log = "0.4"
|
||||
static_assertions = "1.1.0"
|
||||
|
373
third_party/rust/mp4parse/LICENSE
vendored
Normal file
373
third_party/rust/mp4parse/LICENSE
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
2
third_party/rust/mp4parse/README.md
vendored
Normal file
2
third_party/rust/mp4parse/README.md
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
`mp4parse` is a parser for ISO base media file format (mp4) written in rust.
|
||||
See [the README in the mp4parse-rust repo](https://github.com/mozilla/mp4parse-rust/blob/master/README.md) for more details.
|
3
third_party/rust/mp4parse/src/boxes.rs
vendored
3
third_party/rust/mp4parse/src/boxes.rs
vendored
@ -98,7 +98,6 @@ impl PartialEq<&[u8; 4]> for FourCC {
|
||||
}
|
||||
}
|
||||
|
||||
#[deny(unreachable_patterns)]
|
||||
box_database!(
|
||||
FileTypeBox 0x6674_7970, // "ftyp"
|
||||
MediaDataBox 0x6d64_6174, // "mdat"
|
||||
@ -120,7 +119,7 @@ box_database!(
|
||||
ItemPropertiesBox 0x6970_7270, // "iprp"
|
||||
ItemPropertyContainerBox 0x6970_636f, // "ipco"
|
||||
ItemPropertyAssociationBox 0x6970_6d61, // "ipma"
|
||||
ColorInformationBox 0x636f_6c72, // "colr"
|
||||
ColourInformationBox 0x636f_6c72, // "colr"
|
||||
ImageSpatialExtentsProperty 0x6973_7065, // "ispe"
|
||||
PixelInformationBox 0x7069_7869, // "pixi"
|
||||
AuxiliaryTypeProperty 0x6175_7843, // "auxC"
|
||||
|
355
third_party/rust/mp4parse/src/lib.rs
vendored
355
third_party/rust/mp4parse/src/lib.rs
vendored
@ -44,13 +44,6 @@ mod tests;
|
||||
#[cfg(feature = "unstable-api")]
|
||||
pub mod unstable;
|
||||
|
||||
// Arbitrary buffer size limit used for raw read_bufs on a box.
|
||||
const BUF_SIZE_LIMIT: u64 = 10 * 1024 * 1024;
|
||||
|
||||
// Max table length. Calculating in worst case for one week long video, one
|
||||
// frame per table entry in 30 fps.
|
||||
const TABLE_SIZE_LIMIT: u32 = 30 * 60 * 60 * 24 * 7;
|
||||
|
||||
/// The 'mif1' brand indicates structural requirements on files
|
||||
/// See HEIF (ISO 23008-12:2017) § 10.2.1
|
||||
const MIF1_BRAND: FourCC = FourCC { value: *b"mif1" };
|
||||
@ -204,6 +197,12 @@ impl From<std::string::FromUtf8Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::str::Utf8Error> for Error {
|
||||
fn from(_: std::str::Utf8Error) -> Error {
|
||||
Error::InvalidData("invalid utf8")
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::num::TryFromIntError> for Error {
|
||||
fn from(_: std::num::TryFromIntError) -> Error {
|
||||
Error::Unsupported("integer conversion failed")
|
||||
@ -816,18 +815,18 @@ struct AvifItem {
|
||||
}
|
||||
|
||||
impl AvifItem {
|
||||
fn with_data_location(id: ItemId, extent: Extent) -> Result<Self> {
|
||||
Ok(Self {
|
||||
fn with_data_location(id: ItemId, extent: Extent) -> Self {
|
||||
Self {
|
||||
id,
|
||||
image_data: IsobmffItem::Location(extent),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn with_inline_data(id: ItemId) -> Result<Self> {
|
||||
Ok(Self {
|
||||
fn with_inline_data(id: ItemId) -> Self {
|
||||
Self {
|
||||
id,
|
||||
image_data: IsobmffItem::Data(TryVec::new()),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -859,42 +858,64 @@ impl AvifContext {
|
||||
.map(|item| self.item_as_slice(item))
|
||||
}
|
||||
|
||||
pub fn spatial_extents_ptr(&self) -> *const ImageSpatialExtentsProperty {
|
||||
pub fn spatial_extents_ptr(&self) -> Result<*const ImageSpatialExtentsProperty> {
|
||||
match self
|
||||
.item_properties
|
||||
.get(self.primary_item.id, BoxType::ImageSpatialExtentsProperty)
|
||||
.get(self.primary_item.id, BoxType::ImageSpatialExtentsProperty)?
|
||||
{
|
||||
Some(ItemProperty::ImageSpatialExtents(ispe)) => ispe,
|
||||
Some(ItemProperty::ImageSpatialExtents(ispe)) => Ok(ispe),
|
||||
Some(other_property) => panic!("property key mismatch: {:?}", other_property),
|
||||
None => {
|
||||
assert!(
|
||||
fail_if(
|
||||
self.strictness == ParseStrictness::Permissive,
|
||||
"ispe is a mandatory property",
|
||||
);
|
||||
std::ptr::null()
|
||||
)?;
|
||||
Ok(std::ptr::null())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn image_rotation(&self) -> ImageRotation {
|
||||
pub fn nclx_colour_information_ptr(&self) -> Result<*const NclxColourInformation> {
|
||||
match self
|
||||
.item_properties
|
||||
.get(self.primary_item.id, BoxType::ImageRotation)
|
||||
.get(self.primary_item.id, BoxType::ColourInformationBox)?
|
||||
{
|
||||
Some(ItemProperty::Rotation(irot)) => *irot,
|
||||
Some(ItemProperty::Colour(ColourInformation::Nclx(nclx))) => Ok(nclx),
|
||||
None | Some(ItemProperty::Colour(ColourInformation::Icc(_))) => Ok(std::ptr::null()),
|
||||
Some(other_property) => panic!("property key mismatch: {:?}", other_property),
|
||||
None => ImageRotation::D0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn image_mirror_ptr(&self) -> *const ImageMirror {
|
||||
pub fn icc_colour_information(&self) -> Result<&[u8]> {
|
||||
match self
|
||||
.item_properties
|
||||
.get(self.primary_item.id, BoxType::ImageMirror)
|
||||
.get(self.primary_item.id, BoxType::ColourInformationBox)?
|
||||
{
|
||||
Some(ItemProperty::Mirroring(imir)) => imir,
|
||||
Some(ItemProperty::Colour(ColourInformation::Icc(icc))) => Ok(icc.bytes.as_slice()),
|
||||
None | Some(ItemProperty::Colour(ColourInformation::Nclx(_))) => Ok(&[]),
|
||||
Some(other_property) => panic!("property key mismatch: {:?}", other_property),
|
||||
None => std::ptr::null(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn image_rotation(&self) -> Result<ImageRotation> {
|
||||
match self
|
||||
.item_properties
|
||||
.get(self.primary_item.id, BoxType::ImageRotation)?
|
||||
{
|
||||
Some(ItemProperty::Rotation(irot)) => Ok(*irot),
|
||||
Some(other_property) => panic!("property key mismatch: {:?}", other_property),
|
||||
None => Ok(ImageRotation::D0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn image_mirror_ptr(&self) -> Result<*const ImageMirror> {
|
||||
match self
|
||||
.item_properties
|
||||
.get(self.primary_item.id, BoxType::ImageMirror)?
|
||||
{
|
||||
Some(ItemProperty::Mirroring(imir)) => Ok(imir),
|
||||
Some(other_property) => panic!("property key mismatch: {:?}", other_property),
|
||||
None => Ok(std::ptr::null()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1603,11 +1624,7 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
|
||||
})
|
||||
.map(|iref| iref.from_item_id)
|
||||
// which has the alpha property
|
||||
.filter(|&item_id| {
|
||||
item_properties.get_auxc(item_id).map_or(false, |urn| {
|
||||
urn.aux_type.as_slice() == "urn:mpeg:mpegB:cicp:systems:auxiliary:alpha".as_bytes()
|
||||
})
|
||||
});
|
||||
.filter(|&item_id| item_properties.is_alpha(item_id));
|
||||
let alpha_item_id = alpha_item_ids.next();
|
||||
if alpha_item_ids.next().is_some() {
|
||||
return Err(Error::InvalidData("multiple alpha planes"));
|
||||
@ -1644,7 +1661,7 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
|
||||
// into a contiguous buffer. Otherwise, we can just store the extent
|
||||
// and return a pointer into the mdat later to avoid the copy.
|
||||
if loc.extents.len() > 1 {
|
||||
*item = Some(AvifItem::with_inline_data(item_id)?)
|
||||
*item = Some(AvifItem::with_inline_data(item_id))
|
||||
}
|
||||
|
||||
for extent in loc.extents {
|
||||
@ -1655,7 +1672,7 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
|
||||
match item {
|
||||
None => {
|
||||
trace!("Using IsobmffItem::Location");
|
||||
*item = Some(AvifItem::with_data_location(item_id, extent)?);
|
||||
*item = Some(AvifItem::with_data_location(item_id, extent));
|
||||
}
|
||||
Some(AvifItem {
|
||||
image_data: IsobmffItem::Data(item_data),
|
||||
@ -1691,7 +1708,7 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
|
||||
let has_pixi = |item_id| {
|
||||
item_properties
|
||||
.get(item_id, BoxType::PixelInformationBox)
|
||||
.is_some()
|
||||
.map_or(false, |opt| opt.is_some())
|
||||
};
|
||||
if !has_pixi(primary_item_id) || !alpha_item_id.map_or(true, has_pixi) {
|
||||
fail_if(
|
||||
@ -1705,7 +1722,7 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
|
||||
let has_av1c = |item_id| {
|
||||
item_properties
|
||||
.get(item_id, BoxType::AV1CodecConfigurationBox)
|
||||
.is_some()
|
||||
.map_or(false, |opt| opt.is_some())
|
||||
};
|
||||
if !has_av1c(primary_item_id) || !alpha_item_id.map_or(true, has_av1c) {
|
||||
fail_if(
|
||||
@ -1716,7 +1733,7 @@ pub fn read_avif<T: Read>(f: &mut T, strictness: ParseStrictness) -> Result<Avif
|
||||
)?;
|
||||
}
|
||||
|
||||
if item_properties.get_ispe(primary_item_id).is_none() {
|
||||
if item_properties.get_ispe(primary_item_id)?.is_none() {
|
||||
fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
"Missing 'ispe' property for primary item, required \
|
||||
@ -1774,7 +1791,7 @@ fn read_avif_meta<T: Read + Offset>(
|
||||
"There shall be exactly one hdlr box per ISOBMFF (ISO 14496-12:2015) § 8.4.3.1",
|
||||
));
|
||||
}
|
||||
let HandlerBox { handler_type } = read_hdlr(&mut b)?;
|
||||
let HandlerBox { handler_type } = read_hdlr(&mut b, strictness)?;
|
||||
if handler_type != b"pict" {
|
||||
fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
@ -1816,7 +1833,7 @@ fn read_avif_meta<T: Read + Offset>(
|
||||
}
|
||||
BoxType::ItemPropertiesBox => {
|
||||
if item_properties.is_some() {
|
||||
return Err(Error::InvalidData("There shall be zero or one iprp boxes per ISOBMFF (ISO 14496-12:2020 § 8.11.14.1"));
|
||||
return Err(Error::InvalidData("There shall be zero or one iprp boxes per ISOBMFF (ISO 14496-12:2020) § 8.11.14.1"));
|
||||
}
|
||||
item_properties = Some(read_iprp(&mut b, MIF1_BRAND, strictness)?);
|
||||
}
|
||||
@ -2001,7 +2018,9 @@ fn read_iprp<T: Read>(
|
||||
let mut iter = src.box_iter();
|
||||
|
||||
let properties = match iter.next_box()? {
|
||||
Some(mut b) if b.head.name == BoxType::ItemPropertyContainerBox => read_ipco(&mut b),
|
||||
Some(mut b) if b.head.name == BoxType::ItemPropertyContainerBox => {
|
||||
read_ipco(&mut b, strictness)
|
||||
}
|
||||
Some(_) => Err(Error::InvalidData("unexpected iprp child")),
|
||||
None => Err(Error::UnexpectedEOF),
|
||||
}?;
|
||||
@ -2141,6 +2160,7 @@ pub enum ItemProperty {
|
||||
AuxiliaryType(AuxiliaryTypeProperty),
|
||||
AV1Config(AV1ConfigBox),
|
||||
Channels(TryVec<u8>),
|
||||
Colour(ColourInformation),
|
||||
ImageSpatialExtents(ImageSpatialExtentsProperty),
|
||||
Mirroring(ImageMirror),
|
||||
Rotation(ImageRotation),
|
||||
@ -2153,6 +2173,7 @@ impl ItemProperty {
|
||||
match self {
|
||||
ItemProperty::AuxiliaryType(_) => BoxType::AuxiliaryTypeProperty,
|
||||
ItemProperty::AV1Config(_) => BoxType::AV1CodecConfigurationBox,
|
||||
ItemProperty::Colour(_) => BoxType::ColourInformationBox,
|
||||
ItemProperty::Mirroring(_) => BoxType::ImageMirror,
|
||||
ItemProperty::Rotation(_) => BoxType::ImageRotation,
|
||||
ItemProperty::ImageSpatialExtents(_) => BoxType::ImageSpatialExtentsProperty,
|
||||
@ -2196,41 +2217,69 @@ impl ItemPropertiesBox {
|
||||
/// is typically included too, so we might as well use an even power of 2.
|
||||
const MIN_PROPERTIES: usize = 4;
|
||||
|
||||
fn get_auxc(&self, item_id: ItemId) -> Option<&AuxiliaryTypeProperty> {
|
||||
if let Some(ItemProperty::AuxiliaryType(urn)) =
|
||||
self.get(item_id, BoxType::AuxiliaryTypeProperty)
|
||||
{
|
||||
Some(urn)
|
||||
} else {
|
||||
None
|
||||
fn is_alpha(&self, item_id: ItemId) -> bool {
|
||||
match self.get(item_id, BoxType::AuxiliaryTypeProperty) {
|
||||
Ok(Some(ItemProperty::AuxiliaryType(urn))) => {
|
||||
urn.aux_type.as_slice() == "urn:mpeg:mpegB:cicp:systems:auxiliary:alpha".as_bytes()
|
||||
}
|
||||
Ok(Some(other_property)) => panic!("property key mismatch: {:?}", other_property),
|
||||
Ok(None) => false,
|
||||
Err(e) => {
|
||||
error!(
|
||||
"is_alpha: Error checking AuxiliaryTypeProperty ({}), returning false",
|
||||
e
|
||||
);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_ispe(&self, item_id: ItemId) -> Option<&ImageSpatialExtentsProperty> {
|
||||
fn get_ispe(&self, item_id: ItemId) -> Result<Option<&ImageSpatialExtentsProperty>> {
|
||||
if let Some(ItemProperty::ImageSpatialExtents(ispe)) =
|
||||
self.get(item_id, BoxType::ImageSpatialExtentsProperty)
|
||||
self.get(item_id, BoxType::ImageSpatialExtentsProperty)?
|
||||
{
|
||||
Some(ispe)
|
||||
Ok(Some(ispe))
|
||||
} else {
|
||||
None
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn get(&self, item_id: ItemId, property_type: BoxType) -> Option<&ItemProperty> {
|
||||
fn get(&self, item_id: ItemId, property_type: BoxType) -> Result<Option<&ItemProperty>> {
|
||||
match self.get_multiple(item_id, property_type)?.as_slice() {
|
||||
&[] => Ok(None),
|
||||
&[single_value] => Ok(Some(single_value)),
|
||||
multiple_values => {
|
||||
error!(
|
||||
"Multiple values for {:?}: {:?}",
|
||||
property_type, multiple_values
|
||||
);
|
||||
// TODO: add test
|
||||
Err(Error::InvalidData("conflicting item property values"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_multiple(
|
||||
&self,
|
||||
item_id: ItemId,
|
||||
property_type: BoxType,
|
||||
) -> Result<TryVec<&ItemProperty>> {
|
||||
let mut values = TryVec::new();
|
||||
for entry in &self.association_entries {
|
||||
for a in &entry.associations {
|
||||
if entry.item_id == item_id {
|
||||
match self.properties.get(&a.property_index) {
|
||||
Some(ItemProperty::Unsupported(_)) => {}
|
||||
Some(property) if property.box_type() == property_type => {
|
||||
return Some(property)
|
||||
values.push(property)?
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
|
||||
Ok(values)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2477,7 +2526,10 @@ fn read_ipma<T: Read>(
|
||||
/// Parse an ItemPropertyContainerBox
|
||||
///
|
||||
/// See ISOBMFF (ISO 14496-12:2020 § 8.11.14.1
|
||||
fn read_ipco<T: Read>(src: &mut BMFFBox<T>) -> Result<TryHashMap<PropertyIndex, ItemProperty>> {
|
||||
fn read_ipco<T: Read>(
|
||||
src: &mut BMFFBox<T>,
|
||||
strictness: ParseStrictness,
|
||||
) -> Result<TryHashMap<PropertyIndex, ItemProperty>> {
|
||||
let mut properties = TryHashMap::with_capacity(ItemPropertiesBox::MIN_PROPERTIES)?;
|
||||
|
||||
let mut index = PropertyIndex(1); // ipma uses 1-based indexing
|
||||
@ -2486,6 +2538,9 @@ fn read_ipco<T: Read>(src: &mut BMFFBox<T>) -> Result<TryHashMap<PropertyIndex,
|
||||
if let Some(property) = match b.head.name {
|
||||
BoxType::AuxiliaryTypeProperty => Some(ItemProperty::AuxiliaryType(read_auxc(&mut b)?)),
|
||||
BoxType::AV1CodecConfigurationBox => Some(ItemProperty::AV1Config(read_av1c(&mut b)?)),
|
||||
BoxType::ColourInformationBox => {
|
||||
Some(ItemProperty::Colour(read_colr(&mut b, strictness)?))
|
||||
}
|
||||
BoxType::ImageMirror => Some(ItemProperty::Mirroring(read_imir(&mut b)?)),
|
||||
BoxType::ImageRotation => Some(ItemProperty::Rotation(read_irot(&mut b)?)),
|
||||
BoxType::ImageSpatialExtentsProperty => {
|
||||
@ -2561,6 +2616,96 @@ fn read_pixi<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<u8>> {
|
||||
Ok(channels)
|
||||
}
|
||||
|
||||
/// Despite [Rec. ITU-T H.273] (12/2016) defining the CICP fields as having a
|
||||
/// range of 0-255, and only a small fraction of those values being used,
|
||||
/// ISOBMFF (ISO 14496-12:2020) § 12.1.5 defines them as 16-bit values in the
|
||||
/// `colr` box. Since we have no use for the additional range, and it would
|
||||
/// complicate matters later, we fallibly convert before storing the input.
|
||||
///
|
||||
/// [Rec. ITU-T H.273]: https://www.itu.int/rec/T-REC-H.273-201612-I/en
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct NclxColourInformation {
|
||||
colour_primaries: u8,
|
||||
transfer_characteristics: u8,
|
||||
matrix_coefficients: u8,
|
||||
full_range_flag: bool,
|
||||
}
|
||||
|
||||
/// The raw bytes of the ICC profile
|
||||
#[repr(C)]
|
||||
pub struct IccColourInformation {
|
||||
bytes: TryVec<u8>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for IccColourInformation {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("IccColourInformation")
|
||||
.field("data", &format_args!("{} bytes", self.bytes.len()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub enum ColourInformation {
|
||||
Nclx(NclxColourInformation),
|
||||
Icc(IccColourInformation),
|
||||
}
|
||||
|
||||
/// Parse colour information
|
||||
/// See ISOBMFF (ISO 14496-12:2020) § 12.1.5
|
||||
fn read_colr<T: Read>(
|
||||
src: &mut BMFFBox<T>,
|
||||
strictness: ParseStrictness,
|
||||
) -> Result<ColourInformation> {
|
||||
let colour_type = be_u32(src)?.to_be_bytes();
|
||||
|
||||
match &colour_type {
|
||||
b"nclx" => {
|
||||
const NUM_RESERVED_BITS: u8 = 7;
|
||||
let colour_primaries = be_u16(src)?.try_into()?;
|
||||
let transfer_characteristics = be_u16(src)?.try_into()?;
|
||||
let matrix_coefficients = be_u16(src)?.try_into()?;
|
||||
let bytes = src.read_into_try_vec()?;
|
||||
let mut bit_reader = BitReader::new(&bytes);
|
||||
let full_range_flag = bit_reader.read_bool()?;
|
||||
if bit_reader.remaining() != NUM_RESERVED_BITS.into() {
|
||||
error!(
|
||||
"read_colr expected {} reserved bits, found {}",
|
||||
NUM_RESERVED_BITS,
|
||||
bit_reader.remaining()
|
||||
);
|
||||
return Err(Error::InvalidData("Unexpected size for colr box"));
|
||||
}
|
||||
if bit_reader.read_u8(NUM_RESERVED_BITS)? != 0 {
|
||||
fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
"The 7 reserved bits at the end of the ColourInformationBox \
|
||||
for colour_type == 'nclx' must be 0 \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 12.1.5.2",
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(ColourInformation::Nclx(NclxColourInformation {
|
||||
colour_primaries,
|
||||
transfer_characteristics,
|
||||
matrix_coefficients,
|
||||
full_range_flag,
|
||||
}))
|
||||
}
|
||||
b"rICC" | b"prof" => Ok(ColourInformation::Icc(IccColourInformation {
|
||||
bytes: src.read_into_try_vec()?,
|
||||
})),
|
||||
_ => {
|
||||
error!("read_colr colour_type: {:?}", colour_type);
|
||||
Err(Error::InvalidData(
|
||||
"Unsupported colour_type for ColourInformationBox",
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
/// Rotation in the positive (that is, anticlockwise) direction
|
||||
@ -2952,14 +3097,14 @@ fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHe
|
||||
|
||||
let mut kid = TryVec::<ByteData>::new();
|
||||
if version > 0 {
|
||||
let count = be_u32_with_limit(pssh)?;
|
||||
let count = be_u32(pssh)?;
|
||||
for _ in 0..count {
|
||||
let item = read_buf(pssh, 16)?;
|
||||
kid.push(item)?;
|
||||
}
|
||||
}
|
||||
|
||||
let data_size = be_u32_with_limit(pssh)?;
|
||||
let data_size = be_u32(pssh)?;
|
||||
let data = read_buf(pssh, data_size.into())?;
|
||||
|
||||
(system_id, kid, data)
|
||||
@ -3099,7 +3244,7 @@ fn read_mdia<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
||||
debug!("{:?}", mdhd);
|
||||
}
|
||||
BoxType::HandlerBox => {
|
||||
let hdlr = read_hdlr(&mut b)?;
|
||||
let hdlr = read_hdlr(&mut b, ParseStrictness::Permissive)?;
|
||||
|
||||
match hdlr.handler_type.value.as_ref() {
|
||||
b"vide" => track.track_type = TrackType::Video,
|
||||
@ -3290,7 +3435,7 @@ fn read_tkhd<T: Read>(src: &mut BMFFBox<T>) -> Result<TrackHeaderBox> {
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.6.6
|
||||
fn read_elst<T: Read>(src: &mut BMFFBox<T>) -> Result<EditListBox> {
|
||||
let (version, _) = read_fullbox_extra(src)?;
|
||||
let edit_count = be_u32_with_limit(src)?;
|
||||
let edit_count = be_u32(src)?;
|
||||
let mut edits = TryVec::with_capacity(edit_count.to_usize())?;
|
||||
for _ in 0..edit_count {
|
||||
let (segment_duration, media_time) = match version {
|
||||
@ -3366,7 +3511,7 @@ fn read_mdhd<T: Read>(src: &mut BMFFBox<T>) -> Result<MediaHeaderBox> {
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.7.5
|
||||
fn read_stco<T: Read>(src: &mut BMFFBox<T>) -> Result<ChunkOffsetBox> {
|
||||
let (_, _) = read_fullbox_extra(src)?;
|
||||
let offset_count = be_u32_with_limit(src)?;
|
||||
let offset_count = be_u32(src)?;
|
||||
let mut offsets = TryVec::with_capacity(offset_count.to_usize())?;
|
||||
for _ in 0..offset_count {
|
||||
offsets.push(be_u32(src)?.into())?;
|
||||
@ -3382,7 +3527,7 @@ fn read_stco<T: Read>(src: &mut BMFFBox<T>) -> Result<ChunkOffsetBox> {
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.7.5
|
||||
fn read_co64<T: Read>(src: &mut BMFFBox<T>) -> Result<ChunkOffsetBox> {
|
||||
let (_, _) = read_fullbox_extra(src)?;
|
||||
let offset_count = be_u32_with_limit(src)?;
|
||||
let offset_count = be_u32(src)?;
|
||||
let mut offsets = TryVec::with_capacity(offset_count.to_usize())?;
|
||||
for _ in 0..offset_count {
|
||||
offsets.push(be_u64(src)?)?;
|
||||
@ -3398,7 +3543,7 @@ fn read_co64<T: Read>(src: &mut BMFFBox<T>) -> Result<ChunkOffsetBox> {
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.6.2
|
||||
fn read_stss<T: Read>(src: &mut BMFFBox<T>) -> Result<SyncSampleBox> {
|
||||
let (_, _) = read_fullbox_extra(src)?;
|
||||
let sample_count = be_u32_with_limit(src)?;
|
||||
let sample_count = be_u32(src)?;
|
||||
let mut samples = TryVec::with_capacity(sample_count.to_usize())?;
|
||||
for _ in 0..sample_count {
|
||||
samples.push(be_u32(src)?)?;
|
||||
@ -3414,11 +3559,11 @@ fn read_stss<T: Read>(src: &mut BMFFBox<T>) -> Result<SyncSampleBox> {
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.7.4
|
||||
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 sample_count = be_u32(src)?;
|
||||
let mut samples = TryVec::with_capacity(sample_count.to_usize())?;
|
||||
for _ in 0..sample_count {
|
||||
let first_chunk = be_u32(src)?;
|
||||
let samples_per_chunk = be_u32_with_limit(src)?;
|
||||
let samples_per_chunk = be_u32(src)?;
|
||||
let sample_description_index = be_u32(src)?;
|
||||
samples.push(SampleToChunk {
|
||||
first_chunk,
|
||||
@ -3438,13 +3583,11 @@ fn read_stsc<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleToChunkBox> {
|
||||
fn read_ctts<T: Read>(src: &mut BMFFBox<T>) -> Result<CompositionOffsetBox> {
|
||||
let (version, _) = read_fullbox_extra(src)?;
|
||||
|
||||
let counts = be_u32_with_limit(src)?;
|
||||
let counts = be_u32(src)?;
|
||||
|
||||
if src.bytes_left()
|
||||
< counts
|
||||
.checked_mul(8)
|
||||
.expect("counts -> bytes overflow")
|
||||
.into()
|
||||
if counts
|
||||
.checked_mul(8)
|
||||
.map_or(true, |bytes| u64::from(bytes) > src.bytes_left())
|
||||
{
|
||||
return Err(Error::InvalidData("insufficient data in 'ctts' box"));
|
||||
}
|
||||
@ -3456,7 +3599,7 @@ fn read_ctts<T: Read>(src: &mut BMFFBox<T>) -> Result<CompositionOffsetBox> {
|
||||
// however, some buggy contents have negative value when version == 0.
|
||||
// So we always use Version1 here.
|
||||
0..=1 => {
|
||||
let count = be_u32_with_limit(src)?;
|
||||
let count = be_u32(src)?;
|
||||
let offset = TimeOffsetVersion::Version1(be_i32(src)?);
|
||||
(count, offset)
|
||||
}
|
||||
@ -3470,7 +3613,7 @@ fn read_ctts<T: Read>(src: &mut BMFFBox<T>) -> Result<CompositionOffsetBox> {
|
||||
})?;
|
||||
}
|
||||
|
||||
skip_box_remain(src)?;
|
||||
check_parser_state!(src.content);
|
||||
|
||||
Ok(CompositionOffsetBox { samples: offsets })
|
||||
}
|
||||
@ -3480,7 +3623,7 @@ fn read_ctts<T: Read>(src: &mut BMFFBox<T>) -> Result<CompositionOffsetBox> {
|
||||
fn read_stsz<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleSizeBox> {
|
||||
let (_, _) = read_fullbox_extra(src)?;
|
||||
let sample_size = be_u32(src)?;
|
||||
let sample_count = be_u32_with_limit(src)?;
|
||||
let sample_count = be_u32(src)?;
|
||||
let mut sample_sizes = TryVec::new();
|
||||
if sample_size == 0 {
|
||||
sample_sizes.reserve(sample_count.to_usize())?;
|
||||
@ -3502,10 +3645,10 @@ fn read_stsz<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleSizeBox> {
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.6.1.2
|
||||
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 sample_count = be_u32(src)?;
|
||||
let mut samples = TryVec::with_capacity(sample_count.to_usize())?;
|
||||
for _ in 0..sample_count {
|
||||
let sample_count = be_u32_with_limit(src)?;
|
||||
let sample_count = be_u32(src)?;
|
||||
let sample_delta = be_u32(src)?;
|
||||
samples.push(Sample {
|
||||
sample_count,
|
||||
@ -4122,20 +4265,50 @@ fn read_alac<T: Read>(src: &mut BMFFBox<T>) -> Result<ALACSpecificBox> {
|
||||
}
|
||||
|
||||
/// Parse a Handler Reference Box.
|
||||
/// See ISOBMFF (ISO 14496-12:2015) § 8.4.3
|
||||
fn read_hdlr<T: Read>(src: &mut BMFFBox<T>) -> Result<HandlerBox> {
|
||||
let (_, _) = read_fullbox_extra(src)?;
|
||||
/// See ISOBMFF (ISO 14496-12:2020) § 8.4.3
|
||||
fn read_hdlr<T: Read>(src: &mut BMFFBox<T>, strictness: ParseStrictness) -> Result<HandlerBox> {
|
||||
if read_fullbox_version_no_flags(src)? != 0 {
|
||||
return Err(Error::Unsupported("hdlr version"));
|
||||
}
|
||||
|
||||
// Skip uninteresting fields.
|
||||
skip(src, 4)?;
|
||||
let pre_defined = be_u32(src)?;
|
||||
if pre_defined != 0 {
|
||||
fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
"The HandlerBox 'pre_defined' field shall be 0 \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
)?;
|
||||
}
|
||||
|
||||
let handler_type = FourCC::from(be_u32(src)?);
|
||||
|
||||
// Skip uninteresting fields.
|
||||
skip(src, 12)?;
|
||||
for _ in 1..=3 {
|
||||
let reserved = be_u32(src)?;
|
||||
if reserved != 0 {
|
||||
fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
"The HandlerBox 'reserved' fields shall be 0 \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip name.
|
||||
skip_box_remain(src)?;
|
||||
match std::str::from_utf8(src.read_into_try_vec()?.as_slice()) {
|
||||
Ok(name) => {
|
||||
if name.bytes().last() != Some(b'\0') {
|
||||
fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
"The HandlerBox 'name' field shall be null-terminated \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
)?
|
||||
}
|
||||
}
|
||||
Err(_) => fail_if(
|
||||
strictness != ParseStrictness::Permissive,
|
||||
"The HandlerBox 'name' field shall be valid utf8 \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
)?,
|
||||
}
|
||||
|
||||
Ok(HandlerBox { handler_type })
|
||||
}
|
||||
@ -4809,10 +4982,6 @@ fn skip<T: Read>(src: &mut T, bytes: u64) -> Result<()> {
|
||||
|
||||
/// Read size bytes into a Vector or return error.
|
||||
fn read_buf<T: Read>(src: &mut T, size: u64) -> Result<TryVec<u8>> {
|
||||
if size > BUF_SIZE_LIMIT {
|
||||
return Err(Error::InvalidData("read_buf size exceeds BUF_SIZE_LIMIT"));
|
||||
}
|
||||
|
||||
let buf = src.take(size).read_into_try_vec()?;
|
||||
if buf.len().to_u64() != size {
|
||||
return Err(Error::InvalidData("failed buffer read"));
|
||||
@ -4845,16 +5014,6 @@ 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::OutOfMemory);
|
||||
}
|
||||
Ok(v)
|
||||
})
|
||||
}
|
||||
|
||||
fn be_u64<T: ReadBytesExt>(src: &mut T) -> Result<u64> {
|
||||
src.read_u64::<byteorder::BigEndian>().map_err(From::from)
|
||||
}
|
||||
|
178
third_party/rust/mp4parse/src/tests.rs
vendored
178
third_party/rust/mp4parse/src/tests.rs
vendored
@ -7,6 +7,7 @@
|
||||
|
||||
use super::read_mp4;
|
||||
use super::Error;
|
||||
use super::ParseStrictness;
|
||||
use fallible_collections::TryRead as _;
|
||||
|
||||
use std::convert::TryInto as _;
|
||||
@ -448,7 +449,7 @@ fn read_vpcc_version_1() {
|
||||
Ok(vpcc) => {
|
||||
assert_eq!(vpcc.bit_depth, 8);
|
||||
assert_eq!(vpcc.chroma_subsampling, 3);
|
||||
assert_eq!(vpcc.video_full_range_flag, false);
|
||||
assert!(!vpcc.video_full_range_flag);
|
||||
assert_eq!(vpcc.matrix_coefficients.unwrap(), 1);
|
||||
}
|
||||
_ => panic!("vpcc parsing error"),
|
||||
@ -470,7 +471,7 @@ fn read_hdlr() {
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
assert_eq!(stream.head.name, BoxType::HandlerBox);
|
||||
assert_eq!(stream.head.size, 45);
|
||||
let parsed = super::read_hdlr(&mut stream).unwrap();
|
||||
let parsed = super::read_hdlr(&mut stream, ParseStrictness::Normal).unwrap();
|
||||
assert_eq!(parsed.handler_type, b"vide");
|
||||
}
|
||||
|
||||
@ -483,10 +484,72 @@ fn read_hdlr_short_name() {
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
assert_eq!(stream.head.name, BoxType::HandlerBox);
|
||||
assert_eq!(stream.head.size, 33);
|
||||
let parsed = super::read_hdlr(&mut stream).unwrap();
|
||||
let parsed = super::read_hdlr(&mut stream, ParseStrictness::Normal).unwrap();
|
||||
assert_eq!(parsed.handler_type, b"vide");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_hdlr_unsupported_version() {
|
||||
let mut stream = make_fullbox(BoxSize::Short(32), b"hdlr", 1, |s| {
|
||||
s.B32(0).append_bytes(b"vide").B32(0).B32(0).B32(0)
|
||||
});
|
||||
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, 32);
|
||||
match super::read_hdlr(&mut stream, ParseStrictness::Normal) {
|
||||
Err(Error::Unsupported(msg)) => assert_eq!("hdlr version", msg),
|
||||
result => {
|
||||
eprintln!("{:?}", result);
|
||||
panic!("expected Error::Unsupported")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_hdlr_invalid_pre_defined_field() {
|
||||
let mut stream = make_fullbox(BoxSize::Short(32), b"hdlr", 0, |s| {
|
||||
s.B32(1).append_bytes(b"vide").B32(0).B32(0).B32(0)
|
||||
});
|
||||
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, 32);
|
||||
match super::read_hdlr(&mut stream, ParseStrictness::Normal) {
|
||||
Err(Error::InvalidData(msg)) => assert_eq!(
|
||||
"The HandlerBox 'pre_defined' field shall be 0 \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
msg
|
||||
),
|
||||
result => {
|
||||
eprintln!("{:?}", result);
|
||||
panic!("expected Error::InvalidData")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_hdlr_invalid_reserved_field() {
|
||||
let mut stream = make_fullbox(BoxSize::Short(32), b"hdlr", 0, |s| {
|
||||
s.B32(0).append_bytes(b"vide").B32(0).B32(1).B32(0)
|
||||
});
|
||||
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, 32);
|
||||
match super::read_hdlr(&mut stream, ParseStrictness::Normal) {
|
||||
Err(Error::InvalidData(msg)) => assert_eq!(
|
||||
"The HandlerBox 'reserved' fields shall be 0 \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
msg
|
||||
),
|
||||
result => {
|
||||
eprintln!("{:?}", result);
|
||||
panic!("expected Error::InvalidData")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_hdlr_zero_length_name() {
|
||||
let mut stream = make_fullbox(BoxSize::Short(32), b"hdlr", 0, |s| {
|
||||
@ -496,7 +559,29 @@ fn read_hdlr_zero_length_name() {
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
assert_eq!(stream.head.name, BoxType::HandlerBox);
|
||||
assert_eq!(stream.head.size, 32);
|
||||
let parsed = super::read_hdlr(&mut stream).unwrap();
|
||||
match super::read_hdlr(&mut stream, ParseStrictness::Normal) {
|
||||
Err(Error::InvalidData(msg)) => assert_eq!(
|
||||
"The HandlerBox 'name' field shall be null-terminated \
|
||||
per ISOBMFF (ISO 14496-12:2020) § 8.4.3.2",
|
||||
msg
|
||||
),
|
||||
result => {
|
||||
eprintln!("{:?}", result);
|
||||
panic!("expected Error::InvalidData")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_hdlr_zero_length_name_permissive() {
|
||||
let mut stream = make_fullbox(BoxSize::Short(32), b"hdlr", 0, |s| {
|
||||
s.B32(0).append_bytes(b"vide").B32(0).B32(0).B32(0)
|
||||
});
|
||||
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, 32);
|
||||
let parsed = super::read_hdlr(&mut stream, ParseStrictness::Permissive).unwrap();
|
||||
assert_eq!(parsed.handler_type, b"vide");
|
||||
}
|
||||
|
||||
@ -717,57 +802,8 @@ fn read_alac() {
|
||||
assert!(r.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn avcc_limit() {
|
||||
let mut stream = make_box(BoxSize::Auto, b"avc1", |s| {
|
||||
s.append_repeated(0, 6)
|
||||
.B16(1)
|
||||
.append_repeated(0, 16)
|
||||
.B16(320)
|
||||
.B16(240)
|
||||
.append_repeated(0, 14)
|
||||
.append_repeated(0, 32)
|
||||
.append_repeated(0, 4)
|
||||
.B32(0xffff_ffff)
|
||||
.append_bytes(b"avcC")
|
||||
.append_repeated(0, 100)
|
||||
});
|
||||
let mut iter = super::BoxIter::new(&mut stream);
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
match super::read_video_sample_entry(&mut stream) {
|
||||
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
|
||||
Ok(_) => panic!("expected an error result"),
|
||||
_ => panic!("expected a different error result"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn esds_limit() {
|
||||
let mut stream = make_box(BoxSize::Auto, b"mp4a", |s| {
|
||||
s.append_repeated(0, 6)
|
||||
.B16(1)
|
||||
.B32(0)
|
||||
.B32(0)
|
||||
.B16(2)
|
||||
.B16(16)
|
||||
.B16(0)
|
||||
.B16(0)
|
||||
.B32(48000 << 16)
|
||||
.B32(0xffff_ffff)
|
||||
.append_bytes(b"esds")
|
||||
.append_repeated(0, 100)
|
||||
});
|
||||
let mut iter = super::BoxIter::new(&mut stream);
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
match super::read_audio_sample_entry(&mut stream) {
|
||||
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
|
||||
Ok(_) => panic!("expected an error result"),
|
||||
_ => panic!("expected a different error result"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn esds_limit_2() {
|
||||
let mut stream = make_box(BoxSize::Auto, b"mp4a", |s| {
|
||||
s.append_repeated(0, 6)
|
||||
.B16(1)
|
||||
@ -1133,23 +1169,6 @@ fn read_f4v_stsd() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_table_limit() {
|
||||
let elst = make_fullbox(BoxSize::Auto, b"elst", 1, |s| {
|
||||
s.B32(super::TABLE_SIZE_LIMIT + 1)
|
||||
})
|
||||
.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::OutOfMemory) => (),
|
||||
Ok(_) => panic!("expected an error result"),
|
||||
_ => panic!("expected a different error result"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_video_sample_entry() {
|
||||
let unknown_codec = make_box(BoxSize::Auto, b"yyyy", |s| s.append_repeated(0, 16)).into_inner();
|
||||
@ -1237,25 +1256,6 @@ fn read_esds_redundant_descriptor() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_invalid_pssh() {
|
||||
// invalid pssh header length
|
||||
let pssh = vec![
|
||||
0x00, 0x00, 0x00, 0x01, 0x70, 0x73, 0x73, 0x68, 0x01, 0x00, 0x00, 0x00, 0x10, 0x77, 0xef,
|
||||
0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b, 0x00, 0x00,
|
||||
0x00, 0x02, 0x7e, 0x57, 0x1d, 0x01, 0x7e,
|
||||
];
|
||||
|
||||
let mut stream = make_box(BoxSize::Auto, b"moov", |s| s.append_bytes(pssh.as_slice()));
|
||||
let mut iter = super::BoxIter::new(&mut stream);
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
|
||||
match super::read_moov(&mut stream, None) {
|
||||
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
|
||||
_ => panic!("unexpected result with invalid descriptor"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_stsd_lpcm() {
|
||||
// Extract from sample converted by ffmpeg.
|
||||
|
5
third_party/rust/mp4parse/src/unstable.rs
vendored
5
third_party/rust/mp4parse/src/unstable.rs
vendored
@ -161,9 +161,8 @@ pub fn create_sample_table(
|
||||
// With large numbers of samples, the cost of many allocations dominates,
|
||||
// so it's worth iterating twice to allocate sample_table just once.
|
||||
let total_sample_count = sample_to_chunk_iter(&stsc.samples, &stco.offsets)
|
||||
.by_ref()
|
||||
.map(|(_, sample_counts)| sample_counts.to_usize())
|
||||
.sum();
|
||||
.try_fold(0usize, usize::checked_add)?;
|
||||
let mut sample_table = TryVec::with_capacity(total_sample_count).ok()?;
|
||||
|
||||
for i in sample_to_chunk_iter(&stsc.samples, &stco.offsets) {
|
||||
@ -226,7 +225,7 @@ pub fn create_sample_table(
|
||||
};
|
||||
|
||||
// sum_delta is the sum of stts_iter delta.
|
||||
// According to sepc:
|
||||
// According to spec:
|
||||
// decode time => DT(n) = DT(n-1) + STTS(n)
|
||||
// composition time => CT(n) = DT(n) + CTTS(n)
|
||||
// Note:
|
||||
|
BIN
third_party/rust/mp4parse/tests/clusterfuzz-testcase-minimized-mp4-6093954524250112
vendored
Normal file
BIN
third_party/rust/mp4parse/tests/clusterfuzz-testcase-minimized-mp4-6093954524250112
vendored
Normal file
Binary file not shown.
41
third_party/rust/mp4parse/tests/public.rs
vendored
41
third_party/rust/mp4parse/tests/public.rs
vendored
@ -105,7 +105,7 @@ fn public_api() {
|
||||
|
||||
// track.tkhd part
|
||||
let tkhd = track.tkhd.unwrap();
|
||||
assert_eq!(tkhd.disabled, false);
|
||||
assert!(!tkhd.disabled);
|
||||
assert_eq!(tkhd.duration, 40);
|
||||
assert_eq!(tkhd.width, 20_971_520);
|
||||
assert_eq!(tkhd.height, 15_728_640);
|
||||
@ -155,7 +155,7 @@ fn public_api() {
|
||||
|
||||
// track.tkhd part
|
||||
let tkhd = track.tkhd.unwrap();
|
||||
assert_eq!(tkhd.disabled, false);
|
||||
assert!(!tkhd.disabled);
|
||||
assert_eq!(tkhd.duration, 62);
|
||||
assert_eq!(tkhd.width, 0);
|
||||
assert_eq!(tkhd.height, 0);
|
||||
@ -242,9 +242,9 @@ fn public_metadata() {
|
||||
assert_eq!(meta.total_discs.unwrap(), 10);
|
||||
assert_eq!(meta.beats_per_minute.unwrap(), 128);
|
||||
assert_eq!(meta.composer.unwrap(), "Composer");
|
||||
assert_eq!(meta.compilation.unwrap(), true);
|
||||
assert_eq!(meta.gapless_playback.unwrap(), false);
|
||||
assert_eq!(meta.podcast.unwrap(), false);
|
||||
assert!(meta.compilation.unwrap());
|
||||
assert!(!meta.gapless_playback.unwrap());
|
||||
assert!(!meta.podcast.unwrap());
|
||||
assert_eq!(meta.advisory.unwrap(), mp4::AdvisoryRating::Clean);
|
||||
assert_eq!(meta.media_type.unwrap(), mp4::MediaType::Normal);
|
||||
assert_eq!(meta.rating.unwrap(), "50");
|
||||
@ -259,7 +259,7 @@ fn public_metadata() {
|
||||
assert_eq!(meta.tv_episode_number.unwrap(), 15);
|
||||
assert_eq!(meta.tv_season.unwrap(), 10);
|
||||
assert_eq!(meta.tv_show_name.unwrap(), "Show Name");
|
||||
assert_eq!(meta.hd_video.unwrap(), true);
|
||||
assert!(meta.hd_video.unwrap());
|
||||
assert_eq!(meta.owner.unwrap(), "Owner");
|
||||
assert_eq!(meta.sort_name.unwrap(), "Sort Name");
|
||||
assert_eq!(meta.sort_album.unwrap(), "Sort Album");
|
||||
@ -305,9 +305,9 @@ fn public_metadata_gnre() {
|
||||
assert_eq!(meta.total_discs.unwrap(), 10);
|
||||
assert_eq!(meta.beats_per_minute.unwrap(), 128);
|
||||
assert_eq!(meta.composer.unwrap(), "Composer");
|
||||
assert_eq!(meta.compilation.unwrap(), true);
|
||||
assert_eq!(meta.gapless_playback.unwrap(), false);
|
||||
assert_eq!(meta.podcast.unwrap(), false);
|
||||
assert!(meta.compilation.unwrap());
|
||||
assert!(!meta.gapless_playback.unwrap());
|
||||
assert!(!meta.podcast.unwrap());
|
||||
assert_eq!(meta.advisory.unwrap(), mp4::AdvisoryRating::Clean);
|
||||
assert_eq!(meta.media_type.unwrap(), mp4::MediaType::Normal);
|
||||
assert_eq!(meta.rating.unwrap(), "50");
|
||||
@ -322,7 +322,7 @@ fn public_metadata_gnre() {
|
||||
assert_eq!(meta.tv_episode_number.unwrap(), 15);
|
||||
assert_eq!(meta.tv_season.unwrap(), 10);
|
||||
assert_eq!(meta.tv_show_name.unwrap(), "Show Name");
|
||||
assert_eq!(meta.hd_video.unwrap(), true);
|
||||
assert!(meta.hd_video.unwrap());
|
||||
assert_eq!(meta.owner.unwrap(), "Owner");
|
||||
assert_eq!(meta.sort_name.unwrap(), "Sort Name");
|
||||
assert_eq!(meta.sort_album.unwrap(), "Sort Album");
|
||||
@ -362,7 +362,7 @@ fn public_invalid_metadata() {
|
||||
mp4::TrackType::Video => {
|
||||
// Check some of the values in the video tkhd.
|
||||
let tkhd = track.tkhd.unwrap();
|
||||
assert_eq!(tkhd.disabled, false);
|
||||
assert!(!tkhd.disabled);
|
||||
assert_eq!(tkhd.duration, 231232);
|
||||
assert_eq!(tkhd.width, 83_886_080);
|
||||
assert_eq!(tkhd.height, 47_185_920);
|
||||
@ -370,7 +370,7 @@ fn public_invalid_metadata() {
|
||||
mp4::TrackType::Audio => {
|
||||
// Check some of the values in the audio tkhd.
|
||||
let tkhd = track.tkhd.unwrap();
|
||||
assert_eq!(tkhd.disabled, false);
|
||||
assert!(!tkhd.disabled);
|
||||
assert_eq!(tkhd.duration, 231338);
|
||||
assert_eq!(tkhd.width, 0);
|
||||
assert_eq!(tkhd.height, 0);
|
||||
@ -401,7 +401,7 @@ fn public_audio_tenc() {
|
||||
};
|
||||
assert_eq!(a.codec_type, mp4::CodecType::EncryptedAudio);
|
||||
match a.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
|
||||
Some(ref p) => {
|
||||
Some(p) => {
|
||||
assert_eq!(p.original_format, b"mp4a");
|
||||
if let Some(ref schm) = p.scheme_type {
|
||||
assert_eq!(schm.scheme_type, b"cenc");
|
||||
@ -459,7 +459,7 @@ fn public_video_cenc() {
|
||||
};
|
||||
assert_eq!(v.codec_type, mp4::CodecType::EncryptedVideo);
|
||||
match v.protection_info.iter().find(|sinf| sinf.tenc.is_some()) {
|
||||
Some(ref p) => {
|
||||
Some(p) => {
|
||||
assert_eq!(p.original_format, b"avc1");
|
||||
if let Some(ref schm) = p.scheme_type {
|
||||
assert_eq!(schm.scheme_type, b"cenc");
|
||||
@ -671,7 +671,7 @@ fn public_video_av1() {
|
||||
|
||||
// track.tkhd part
|
||||
let tkhd = track.tkhd.unwrap();
|
||||
assert_eq!(tkhd.disabled, false);
|
||||
assert!(!tkhd.disabled);
|
||||
assert_eq!(tkhd.duration, 42);
|
||||
assert_eq!(tkhd.width, 4_194_304);
|
||||
assert_eq!(tkhd.height, 4_194_304);
|
||||
@ -693,11 +693,11 @@ fn public_video_av1() {
|
||||
assert_eq!(av1c.level, 0);
|
||||
assert_eq!(av1c.tier, 0);
|
||||
assert_eq!(av1c.bit_depth, 8);
|
||||
assert_eq!(av1c.monochrome, false);
|
||||
assert!(!av1c.monochrome);
|
||||
assert_eq!(av1c.chroma_subsampling_x, 1);
|
||||
assert_eq!(av1c.chroma_subsampling_y, 1);
|
||||
assert_eq!(av1c.chroma_sample_position, 0);
|
||||
assert_eq!(av1c.initial_presentation_delay_present, false);
|
||||
assert!(!av1c.initial_presentation_delay_present);
|
||||
assert_eq!(av1c.initial_presentation_delay_minus_one, 0);
|
||||
}
|
||||
_ => panic!("Invalid test condition"),
|
||||
@ -723,6 +723,13 @@ fn public_mp4_bug_1185230() {
|
||||
assert_eq!(number_audio_tracks, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn public_mp4_ctts_overflow() {
|
||||
let input = &mut File::open("tests/clusterfuzz-testcase-minimized-mp4-6093954524250112")
|
||||
.expect("Unknown file");
|
||||
assert_invalid_data(mp4::read_mp4(input), "insufficient data in 'ctts' box");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn public_avif_primary_item() {
|
||||
let input = &mut File::open(IMAGE_AVIF).expect("Unknown file");
|
||||
|
@ -1 +1 @@
|
||||
{"files":{"Cargo.toml":"b0653020f28155bfce958504c81c9fde20175e31774e5e42250dc7d3bc5b9985","cbindgen.toml":"e18e132e8c36a81af2629e7260529382486b0bb343f9aa57930348031480aecd","examples/dump.rs":"268093925d28d1636e106d93a2f2917fb1d7ddaf04ecd70880e1551fb578de1a","src/lib.rs":"0c473f2f08b0eb2455e01164c938dbca67978443c9917d48c0a0e1574510068e","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}
|
||||
{"files":{"Cargo.toml":"b0653020f28155bfce958504c81c9fde20175e31774e5e42250dc7d3bc5b9985","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"f776ed4bbb7b58a5684402a9c5c28dfe1fa02b6b184139b2c2c49384cc1e3723","cbindgen.toml":"d3241a7ccfcc4ea53f90b1b59941b28f345e6e6e29c264726b4cf99df672b4a7","examples/dump.rs":"268093925d28d1636e106d93a2f2917fb1d7ddaf04ecd70880e1551fb578de1a","src/lib.rs":"e7629d39c39f6b390219beb5ffb8d80484e37b82350067b15ef88eb2480b3c31","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}
|
373
third_party/rust/mp4parse_capi/LICENSE
vendored
Normal file
373
third_party/rust/mp4parse_capi/LICENSE
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
2
third_party/rust/mp4parse_capi/README.md
vendored
Normal file
2
third_party/rust/mp4parse_capi/README.md
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
`mp4parse-capi` is a C API that exposes the functionality of `mp4parse`.
|
||||
See [the README in the mp4parse-rust repo](https://github.com/mozilla/mp4parse-rust/blob/master/README.md) for more details.
|
1
third_party/rust/mp4parse_capi/cbindgen.toml
vendored
1
third_party/rust/mp4parse_capi/cbindgen.toml
vendored
@ -19,6 +19,7 @@ rename_variants = "QualifiedScreamingSnakeCase"
|
||||
[defines]
|
||||
"feature = 3gpp" = "MP4PARSE_FEATURE_3GPP"
|
||||
"feature = meta-xml" = "MP4PARSE_FEATURE_META_XML"
|
||||
"feature = unstable-api" = "MP4PARSE_UNSTABLE_API"
|
||||
|
||||
[parse]
|
||||
parse_deps = true
|
||||
|
35
third_party/rust/mp4parse_capi/src/lib.rs
vendored
35
third_party/rust/mp4parse_capi/src/lib.rs
vendored
@ -101,7 +101,7 @@ impl Default for Mp4parseTrackType {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub enum Mp4parseCodec {
|
||||
@ -175,7 +175,11 @@ impl Mp4parseByteData {
|
||||
fn with_data(slice: &[u8]) -> Self {
|
||||
Self {
|
||||
length: slice.len(),
|
||||
data: slice.as_ptr(),
|
||||
data: if !slice.is_empty() {
|
||||
slice.as_ptr()
|
||||
} else {
|
||||
std::ptr::null()
|
||||
},
|
||||
indices: std::ptr::null(),
|
||||
}
|
||||
}
|
||||
@ -328,6 +332,8 @@ pub struct Mp4parseAvifImage {
|
||||
pub primary_item: Mp4parseByteData,
|
||||
/// The size of the image; should never be null unless using permissive parsing
|
||||
pub spatial_extents: *const mp4parse::ImageSpatialExtentsProperty,
|
||||
pub nclx_colour_information: *const mp4parse::NclxColourInformation,
|
||||
pub icc_colour_information: Mp4parseByteData,
|
||||
pub image_rotation: mp4parse::ImageRotation,
|
||||
pub image_mirror: *const mp4parse::ImageMirror,
|
||||
/// If no alpha item exists, `.length` will be 0 and `.data` will be null
|
||||
@ -1073,25 +1079,32 @@ pub unsafe extern "C" fn mp4parse_avif_get_image(
|
||||
return Mp4parseStatus::BadArg;
|
||||
}
|
||||
|
||||
*avif_image = mp4parse_avif_get_image_safe(&*parser);
|
||||
|
||||
Mp4parseStatus::Ok
|
||||
if let Ok(image) = mp4parse_avif_get_image_safe(&*parser) {
|
||||
*avif_image = image;
|
||||
Mp4parseStatus::Ok
|
||||
} else {
|
||||
Mp4parseStatus::Invalid
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mp4parse_avif_get_image_safe(parser: &Mp4parseAvifParser) -> Mp4parseAvifImage {
|
||||
pub fn mp4parse_avif_get_image_safe(
|
||||
parser: &Mp4parseAvifParser,
|
||||
) -> mp4parse::Result<Mp4parseAvifImage> {
|
||||
let context = parser.context();
|
||||
|
||||
Mp4parseAvifImage {
|
||||
Ok(Mp4parseAvifImage {
|
||||
primary_item: Mp4parseByteData::with_data(context.primary_item()),
|
||||
spatial_extents: context.spatial_extents_ptr(),
|
||||
image_rotation: context.image_rotation(),
|
||||
image_mirror: context.image_mirror_ptr(),
|
||||
spatial_extents: context.spatial_extents_ptr()?,
|
||||
nclx_colour_information: context.nclx_colour_information_ptr()?,
|
||||
icc_colour_information: Mp4parseByteData::with_data(context.icc_colour_information()?),
|
||||
image_rotation: context.image_rotation()?,
|
||||
image_mirror: context.image_mirror_ptr()?,
|
||||
alpha_item: context
|
||||
.alpha_item()
|
||||
.map(Mp4parseByteData::with_data)
|
||||
.unwrap_or_default(),
|
||||
premultiplied_alpha: context.premultiplied_alpha,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Fill the supplied `Mp4parseByteData` with index information from `track`.
|
||||
|
@ -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 = "1bb484e96ae724309e3346968e8ffd4c25e61616" }
|
||||
mp4parse_capi = { git = "https://github.com/mozilla/mp4parse-rust", rev = "5326af6b54cec885cdb9e7be282a6db6e757b964" }
|
||||
nserror = { path = "../../../../xpcom/rust/nserror" }
|
||||
nsstring = { path = "../../../../xpcom/rust/nsstring" }
|
||||
netwerk_helper = { path = "../../../../netwerk/base/rust-helper" }
|
||||
|
Loading…
Reference in New Issue
Block a user