|
@@ -10,33 +10,33 @@ Differential Revision: https://phabricator.services.mozilla.com/D3365
|
|
|
diff --git a/dom/media/VideoUtils.cpp b/dom/media/VideoUtils.cpp
|
|
|
--- a/dom/media/VideoUtils.cpp
|
|
|
+++ b/dom/media/VideoUtils.cpp
|
|
|
-@@ -713,17 +713,18 @@ IsVP9CodecString(const nsAString& aCodec
|
|
|
- aCodec.EqualsLiteral("vp9.0") ||
|
|
|
+@@ -636,17 +636,18 @@ bool IsVP9CodecString(const nsAString& a
|
|
|
+ uint8_t bitDepth = 0;
|
|
|
+ return aCodec.EqualsLiteral("vp9") || aCodec.EqualsLiteral("vp9.0") ||
|
|
|
(StartsWith(NS_ConvertUTF16toUTF8(aCodec), "vp09") &&
|
|
|
ExtractVPXCodecDetails(aCodec, profile, level, bitDepth));
|
|
|
}
|
|
|
|
|
|
- bool
|
|
|
- IsAV1CodecString(const nsAString& aCodec)
|
|
|
+ bool IsAV1CodecString(const nsAString& aCodec)
|
|
|
{
|
|
|
- return aCodec.EqualsLiteral("av1"); // AV1
|
|
|
+ return aCodec.EqualsLiteral("av1") ||
|
|
|
+ StartsWith(NS_ConvertUTF16toUTF8(aCodec), "av01");
|
|
|
}
|
|
|
|
|
|
- UniquePtr<TrackInfo>
|
|
|
- CreateTrackInfoWithMIMEType(const nsACString& aCodecMIMEType)
|
|
|
- {
|
|
|
+ UniquePtr<TrackInfo> CreateTrackInfoWithMIMEType(
|
|
|
+ const nsACString& aCodecMIMEType) {
|
|
|
UniquePtr<TrackInfo> trackInfo;
|
|
|
if (StartsWith(aCodecMIMEType, "audio/")) {
|
|
|
trackInfo.reset(new AudioInfo());
|
|
|
+ trackInfo->mMimeType = aCodecMIMEType;
|
|
|
diff --git a/dom/media/mp4/DecoderData.cpp b/dom/media/mp4/DecoderData.cpp
|
|
|
--- a/dom/media/mp4/DecoderData.cpp
|
|
|
+++ b/dom/media/mp4/DecoderData.cpp
|
|
|
-@@ -121,16 +121,18 @@ void
|
|
|
- MP4VideoInfo::Update(const Mp4parseTrackInfo* track,
|
|
|
- const Mp4parseTrackVideoInfo* video)
|
|
|
- {
|
|
|
+@@ -107,16 +107,18 @@ void MP4AudioInfo::Update(const Mp4parse
|
|
|
+
|
|
|
+ void MP4VideoInfo::Update(const Mp4parseTrackInfo* track,
|
|
|
+ const Mp4parseTrackVideoInfo* video) {
|
|
|
UpdateTrackProtectedInfo(*this, video->protected_data);
|
|
|
if (track->codec == MP4PARSE_CODEC_AVC) {
|
|
|
mMimeType = NS_LITERAL_CSTRING("video/avc");
|
|
@@ -55,15 +55,15 @@ diff --git a/dom/media/mp4/DecoderData.cpp b/dom/media/mp4/DecoderData.cpp
|
|
|
diff --git a/dom/media/mp4/MP4Decoder.cpp b/dom/media/mp4/MP4Decoder.cpp
|
|
|
--- a/dom/media/mp4/MP4Decoder.cpp
|
|
|
+++ b/dom/media/mp4/MP4Decoder.cpp
|
|
|
-@@ -112,16 +112,24 @@ MP4Decoder::GetTracksInfo(const MediaCon
|
|
|
- uint8_t level = 0;
|
|
|
- uint8_t bitDepth = 0;
|
|
|
- if (ExtractVPXCodecDetails(codec, profile, level, bitDepth)) {
|
|
|
- trackInfo->GetAsVideoInfo()->mBitDepth = bitDepth;
|
|
|
+@@ -111,16 +111,24 @@ bool MP4Decoder::IsSupportedType(const M
|
|
|
+ uint8_t level = 0;
|
|
|
+ uint8_t bitDepth = 0;
|
|
|
+ if (ExtractVPXCodecDetails(codec, profile, level, bitDepth)) {
|
|
|
+ trackInfo->GetAsVideoInfo()->mBitDepth = bitDepth;
|
|
|
+ }
|
|
|
+ trackInfos.AppendElement(Move(trackInfo));
|
|
|
+ continue;
|
|
|
}
|
|
|
- tracks.AppendElement(std::move(trackInfo));
|
|
|
- continue;
|
|
|
- }
|
|
|
+#ifdef MOZ_AV1
|
|
|
+ if (IsAV1CodecString(codec)) {
|
|
|
+ tracks.AppendElement(
|
|
@@ -71,36 +71,38 @@ diff --git a/dom/media/mp4/MP4Decoder.cpp b/dom/media/mp4/MP4Decoder.cpp
|
|
|
+ NS_LITERAL_CSTRING("video/") + NS_ConvertUTF16toUTF8(codec), aType));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
-+#endif
|
|
|
- if (isVideo && IsWhitelistedH264Codec(codec)) {
|
|
|
- auto trackInfo =
|
|
|
- CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters(
|
|
|
- NS_LITERAL_CSTRING("video/avc"), aType);
|
|
|
- uint8_t profile = 0, constraint = 0, level = 0;
|
|
|
- MOZ_ALWAYS_TRUE(
|
|
|
- ExtractH264CodecDetails(codec, profile, constraint, level));
|
|
|
- uint32_t width = aType.ExtendedType().GetWidth().refOr(1280);
|
|
|
+++#endif
|
|
|
+ // Note: Only accept H.264 in a video content type, not in an audio
|
|
|
+ // content type.
|
|
|
+ if (IsWhitelistedH264Codec(codec) && isVideo) {
|
|
|
+ trackInfos.AppendElement(
|
|
|
+ CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters(
|
|
|
+ NS_LITERAL_CSTRING("video/avc"), aType));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
diff --git a/dom/media/mp4/MP4Metadata.cpp b/dom/media/mp4/MP4Metadata.cpp
|
|
|
--- a/dom/media/mp4/MP4Metadata.cpp
|
|
|
+++ b/dom/media/mp4/MP4Metadata.cpp
|
|
|
-@@ -250,16 +250,17 @@ MP4Metadata::GetTrackInfo(mozilla::Track
|
|
|
- switch (info.codec) {
|
|
|
- case MP4PARSE_CODEC_UNKNOWN: codec_string = "unknown"; break;
|
|
|
- case MP4PARSE_CODEC_AAC: codec_string = "aac"; break;
|
|
|
- case MP4PARSE_CODEC_OPUS: codec_string = "opus"; break;
|
|
|
- case MP4PARSE_CODEC_FLAC: codec_string = "flac"; break;
|
|
|
- case MP4PARSE_CODEC_ALAC: codec_string = "alac"; break;
|
|
|
- case MP4PARSE_CODEC_AVC: codec_string = "h.264"; break;
|
|
|
- case MP4PARSE_CODEC_VP9: codec_string = "vp9"; break;
|
|
|
-+ case MP4PARSE_CODEC_AV1: codec_string = "av1"; break;
|
|
|
- case MP4PARSE_CODEC_MP3: codec_string = "mp3"; break;
|
|
|
- case MP4PARSE_CODEC_MP4V: codec_string = "mp4v"; break;
|
|
|
- case MP4PARSE_CODEC_JPEG: codec_string = "jpeg"; break;
|
|
|
- case MP4PARSE_CODEC_AC3: codec_string = "ac-3"; break;
|
|
|
- case MP4PARSE_CODEC_EC3: codec_string = "ec-3"; break;
|
|
|
- }
|
|
|
- MOZ_LOG(gMP4MetadataLog, LogLevel::Debug,
|
|
|
- ("track codec %s (%u)\n", codec_string, info.codec));
|
|
|
+@@ -237,16 +237,19 @@ MP4Metadata::ResultAndTrackInfo MP4Metad
|
|
|
+ codec_string = "alac";
|
|
|
+ break;
|
|
|
+ case MP4PARSE_CODEC_AVC:
|
|
|
+ codec_string = "h.264";
|
|
|
+ break;
|
|
|
+ case MP4PARSE_CODEC_VP9:
|
|
|
+ codec_string = "vp9";
|
|
|
+ break;
|
|
|
++ case MP4PARSE_CODEC_AV1:
|
|
|
++ codec_string = "av1";
|
|
|
++ break;
|
|
|
+ case MP4PARSE_CODEC_MP3:
|
|
|
+ codec_string = "mp3";
|
|
|
+ break;
|
|
|
+ case MP4PARSE_CODEC_MP4V:
|
|
|
+ codec_string = "mp4v";
|
|
|
+ break;
|
|
|
+ case MP4PARSE_CODEC_JPEG:
|
|
|
+ codec_string = "jpeg";
|
|
|
diff --git a/media/mp4parse-rust/mp4parse.h b/media/mp4parse-rust/mp4parse.h
|
|
|
--- a/media/mp4parse-rust/mp4parse.h
|
|
|
+++ b/media/mp4parse-rust/mp4parse.h
|
|
@@ -147,7 +149,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/boxes.rs b/media/mp4parse-rust/mp4
|
|
|
diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4parse/src/lib.rs
|
|
|
--- a/media/mp4parse-rust/mp4parse/src/lib.rs
|
|
|
+++ b/media/mp4parse-rust/mp4parse/src/lib.rs
|
|
|
-@@ -319,16 +319,17 @@ pub struct AudioSampleEntry {
|
|
|
+@@ -314,16 +314,17 @@ pub struct AudioSampleEntry {
|
|
|
pub codec_specific: AudioCodecSpecific,
|
|
|
pub protection_info: Vec<ProtectionSchemeInfoBox>,
|
|
|
}
|
|
@@ -165,7 +167,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4pa
|
|
|
data_reference_index: u16,
|
|
|
pub width: u16,
|
|
|
pub height: u16,
|
|
|
-@@ -346,16 +347,31 @@ pub struct VPxConfigBox {
|
|
|
+@@ -341,16 +342,31 @@ pub struct VPxConfigBox {
|
|
|
pub chroma_subsampling: u8,
|
|
|
transfer_function: u8,
|
|
|
matrix: Option<u8>, // Available in 'VP Codec ISO Media File Format' version 1 only.
|
|
@@ -197,8 +199,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4pa
|
|
|
/// Represet a FLACSpecificBox 'dfLa'
|
|
|
#[derive(Debug, Clone)]
|
|
|
pub struct FLACSpecificBox {
|
|
|
-@@ -451,17 +467,17 @@ impl Default for TrackType {
|
|
|
- pub enum CodecType {
|
|
|
+@@ -446,16 +462,17 @@ pub enum CodecType {
|
|
|
Unknown,
|
|
|
MP3,
|
|
|
AAC,
|
|
@@ -206,7 +207,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4pa
|
|
|
Opus,
|
|
|
H264, // 14496-10
|
|
|
MP4V, // 14496-2
|
|
|
-- VP10,
|
|
|
+ VP10,
|
|
|
+ AV1,
|
|
|
VP9,
|
|
|
VP8,
|
|
@@ -216,7 +217,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4pa
|
|
|
ALAC,
|
|
|
}
|
|
|
|
|
|
-@@ -1364,16 +1380,65 @@ fn read_vpcc<T: Read>(src: &mut BMFFBox<
|
|
|
+@@ -1347,16 +1364,65 @@ fn read_vpcc<T: Read>(src: &mut BMFFBox<
|
|
|
chroma_subsampling: chroma_subsampling,
|
|
|
transfer_function: transfer_function,
|
|
|
matrix: matrix,
|
|
@@ -282,7 +283,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4pa
|
|
|
return Err(Error::InvalidData(
|
|
|
"FLACMetadataBlock larger than parent box"));
|
|
|
}
|
|
|
-@@ -1756,16 +1821,17 @@ fn read_hdlr<T: Read>(src: &mut BMFFBox<
|
|
|
+@@ -1739,16 +1805,17 @@ fn read_hdlr<T: Read>(src: &mut BMFFBox<
|
|
|
/// Parse an video description inside an stsd box.
|
|
|
fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType, SampleEntry)> {
|
|
|
let name = src.get_header().name;
|
|
@@ -300,7 +301,7 @@ diff --git a/media/mp4parse-rust/mp4parse/src/lib.rs b/media/mp4parse-rust/mp4pa
|
|
|
};
|
|
|
|
|
|
// Skip uninteresting fields.
|
|
|
-@@ -1806,16 +1872,23 @@ fn read_video_sample_entry<T: Read>(src:
|
|
|
+@@ -1789,16 +1856,23 @@ fn read_video_sample_entry<T: Read>(src:
|
|
|
name != BoxType::VP9SampleEntry &&
|
|
|
name != BoxType::ProtectedVisualSampleEntry) ||
|
|
|
codec_specific.is_some() {
|
|
@@ -365,7 +366,7 @@ diff --git a/media/mp4parse-rust/mp4parse/tests/public.rs b/media/mp4parse-rust/
|
|
|
assert_eq!(track.empty_duration, Some(mp4::MediaScaledTime(0)));
|
|
|
assert_eq!(track.media_time, Some(mp4::TrackScaledTime(1024, 1)));
|
|
|
assert_eq!(track.timescale, Some(mp4::TrackTimeScale(48000, 1)));
|
|
|
-@@ -211,8 +215,61 @@ fn public_video_cenc() {
|
|
|
+@@ -211,8 +215,69 @@ fn public_video_cenc() {
|
|
|
assert_eq!(pssh.system_id, system_id);
|
|
|
for kid_id in pssh.kid {
|
|
|
assert_eq!(kid_id, kid);
|
|
@@ -375,7 +376,7 @@ diff --git a/media/mp4parse-rust/mp4parse/tests/public.rs b/media/mp4parse-rust/
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
-+#[test]
|
|
|
++[test]
|
|
|
+fn public_video_av1() {
|
|
|
+ let mut fd = File::open(VIDEO_AV1_MP4).expect("Unknown file");
|
|
|
+ let mut buf = Vec::new();
|
|
@@ -397,6 +398,14 @@ diff --git a/media/mp4parse-rust/mp4parse/tests/public.rs b/media/mp4parse-rust/
|
|
|
+ assert_eq!(v.height, 64);
|
|
|
+
|
|
|
+ // track.tkhd part
|
|
|
++ assert_eq!(track.duration, Some(mp4::TrackScaledTime(512, 0)));
|
|
|
++ assert_eq!(track.empty_duration, Some(mp4::MediaScaledTime(0)));
|
|
|
++ assert_eq!(track.media_time, Some(mp4::TrackScaledTime(0,0)));
|
|
|
++ assert_eq!(track.timescale, Some(mp4::TrackTimeScale(12288, 0)));
|
|
|
++ assert_eq!(v.width, 64);
|
|
|
++ assert_eq!(v.height, 64);
|
|
|
++
|
|
|
++ // track.tkhd part
|
|
|
+ let tkhd = track.tkhd.unwrap();
|
|
|
+ assert_eq!(tkhd.disabled, false);
|
|
|
+ assert_eq!(tkhd.duration, 42);
|
|
@@ -477,7 +486,7 @@ Bk*xp#
|
|
|
diff --git a/media/mp4parse-rust/mp4parse_capi/src/lib.rs b/media/mp4parse-rust/mp4parse_capi/src/lib.rs
|
|
|
--- a/media/mp4parse-rust/mp4parse_capi/src/lib.rs
|
|
|
+++ b/media/mp4parse-rust/mp4parse_capi/src/lib.rs
|
|
|
-@@ -89,16 +89,17 @@ impl Default for Mp4parseTrackType {
|
|
|
+@@ -88,16 +88,17 @@ impl Default for Mp4parseTrackType {
|
|
|
#[derive(PartialEq, Debug)]
|
|
|
pub enum Mp4parseCodec {
|
|
|
Unknown,
|
|
@@ -495,7 +504,7 @@ diff --git a/media/mp4parse-rust/mp4parse_capi/src/lib.rs b/media/mp4parse-rust/
|
|
|
Alac,
|
|
|
}
|
|
|
|
|
|
-@@ -427,16 +428,18 @@ pub unsafe extern fn mp4parse_get_track_
|
|
|
+@@ -425,16 +426,18 @@ pub unsafe extern fn mp4parse_get_track_
|
|
|
AudioCodecSpecific::MP3 =>
|
|
|
Mp4parseCodec::Mp3,
|
|
|
AudioCodecSpecific::ALACSpecificBox(_) =>
|
|
@@ -517,14 +526,12 @@ diff --git a/media/mp4parse-rust/mp4parse_capi/src/lib.rs b/media/mp4parse-rust/
|
|
|
diff --git a/media/mp4parse-rust/update-rust.sh b/media/mp4parse-rust/update-rust.sh
|
|
|
--- a/media/mp4parse-rust/update-rust.sh
|
|
|
+++ b/media/mp4parse-rust/update-rust.sh
|
|
|
-@@ -1,15 +1,15 @@
|
|
|
- #!/bin/sh
|
|
|
+@@ -1,13 +1,13 @@
|
|
|
+ #!/bin/sh -e
|
|
|
# Script to update mp4parse-rust sources to latest upstream
|
|
|
|
|
|
- set -e
|
|
|
-
|
|
|
# Default version.
|
|
|
--VER="643f48e137592e6318f6c780448374324908da31"
|
|
|
+-VER="2dc5127a69bc9bf891972e269e3abde0b77612f5"
|
|
|
+VER="681ce17e3a600e31844a9abbad6d46e413b2beba"
|
|
|
|
|
|
# Accept version or commit from the command line.
|
|
@@ -534,4 +541,3 @@ diff --git a/media/mp4parse-rust/update-rust.sh b/media/mp4parse-rust/update-rus
|
|
|
|
|
|
echo "Fetching sources..."
|
|
|
rm -rf _upstream
|
|
|
-
|