From 53aa775ea488c0ffd3a2e1cb78ad000154e414e1 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Fri, 12 Oct 2018 13:16:18 -0700 Subject: [PATCH] Omit all optional fields in AV1 codec string The spec requires the optional fields to be mutually inclusive (all or none). Issue #453. Change-Id: I6d62bb862957abe7a3517058510f614995a92dd9 --- .../app/test/testdata/av1-mp4-to-webm/output.m3u8 | 2 +- .../app/test/testdata/av1-mp4-to-webm/output.mpd | 2 +- .../testdata/av1-mp4-with-encryption/output.m3u8 | 2 +- .../testdata/av1-mp4-with-encryption/output.mpd | 2 +- packager/app/test/testdata/av1-mp4/output.m3u8 | 2 +- packager/app/test/testdata/av1-mp4/output.mpd | 2 +- .../testdata/av1-webm-with-encryption/output.m3u8 | 2 +- .../testdata/av1-webm-with-encryption/output.mpd | 2 +- packager/app/test/testdata/av1-webm/output.m3u8 | 2 +- packager/app/test/testdata/av1-webm/output.mpd | 2 +- .../media/codecs/av1_codec_configuration_record.cc | 14 ++++++++------ .../av1_codec_configuration_record_unittest.cc | 4 ++-- 12 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 b/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 index 815dd2738a..285a3b19e7 100644 --- a/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 +++ b/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-STREAM-INF:BANDWIDTH=69160,AVERAGE-BANDWIDTH=69160,CODECS="av01.0.00M.08.0.110",RESOLUTION=320x240 +#EXT-X-STREAM-INF:BANDWIDTH=69160,AVERAGE-BANDWIDTH=69160,CODECS="av01.0.00M.08",RESOLUTION=320x240 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-mp4-to-webm/output.mpd b/packager/app/test/testdata/av1-mp4-to-webm/output.mpd index 4ca0b2846b..85644a0f2c 100644 --- a/packager/app/test/testdata/av1-mp4-to-webm/output.mpd +++ b/packager/app/test/testdata/av1-mp4-to-webm/output.mpd @@ -3,7 +3,7 @@ - + bear-av1-video.webm diff --git a/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 b/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 index 2ced9b0908..f47182b80a 100644 --- a/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-STREAM-INF:BANDWIDTH=69777,AVERAGE-BANDWIDTH=69777,CODECS="av01.0.00M.08.0.110",RESOLUTION=320x240 +#EXT-X-STREAM-INF:BANDWIDTH=69777,AVERAGE-BANDWIDTH=69777,CODECS="av01.0.00M.08",RESOLUTION=320x240 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-mp4-with-encryption/output.mpd b/packager/app/test/testdata/av1-mp4-with-encryption/output.mpd index 9b12e8ca71..1fb10af8e2 100644 --- a/packager/app/test/testdata/av1-mp4-with-encryption/output.mpd +++ b/packager/app/test/testdata/av1-mp4-with-encryption/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-av1-video.mp4 diff --git a/packager/app/test/testdata/av1-mp4/output.m3u8 b/packager/app/test/testdata/av1-mp4/output.m3u8 index 2ced9b0908..f47182b80a 100644 --- a/packager/app/test/testdata/av1-mp4/output.m3u8 +++ b/packager/app/test/testdata/av1-mp4/output.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-STREAM-INF:BANDWIDTH=69777,AVERAGE-BANDWIDTH=69777,CODECS="av01.0.00M.08.0.110",RESOLUTION=320x240 +#EXT-X-STREAM-INF:BANDWIDTH=69777,AVERAGE-BANDWIDTH=69777,CODECS="av01.0.00M.08",RESOLUTION=320x240 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-mp4/output.mpd b/packager/app/test/testdata/av1-mp4/output.mpd index c30fbb8ea8..c24f476651 100644 --- a/packager/app/test/testdata/av1-mp4/output.mpd +++ b/packager/app/test/testdata/av1-mp4/output.mpd @@ -3,7 +3,7 @@ - + bear-av1-video.mp4 diff --git a/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 b/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 index 720cf71c45..72f2d46353 100644 --- a/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-STREAM-INF:BANDWIDTH=69426,AVERAGE-BANDWIDTH=69426,CODECS="av01.0.00M.08.0.110",RESOLUTION=320x240 +#EXT-X-STREAM-INF:BANDWIDTH=69426,AVERAGE-BANDWIDTH=69426,CODECS="av01.0.00M.08",RESOLUTION=320x240 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-webm-with-encryption/output.mpd b/packager/app/test/testdata/av1-webm-with-encryption/output.mpd index c42890dfc2..7293bb07c4 100644 --- a/packager/app/test/testdata/av1-webm-with-encryption/output.mpd +++ b/packager/app/test/testdata/av1-webm-with-encryption/output.mpd @@ -6,7 +6,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-av1-video.webm diff --git a/packager/app/test/testdata/av1-webm/output.m3u8 b/packager/app/test/testdata/av1-webm/output.m3u8 index 7f14f48547..a746aaa65c 100644 --- a/packager/app/test/testdata/av1-webm/output.m3u8 +++ b/packager/app/test/testdata/av1-webm/output.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-STREAM-INF:BANDWIDTH=70752,AVERAGE-BANDWIDTH=70752,CODECS="av01.0.00M.08.0.110",RESOLUTION=320x240 +#EXT-X-STREAM-INF:BANDWIDTH=70752,AVERAGE-BANDWIDTH=70752,CODECS="av01.0.00M.08",RESOLUTION=320x240 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-webm/output.mpd b/packager/app/test/testdata/av1-webm/output.mpd index dfeb67c4e6..7e350c63a1 100644 --- a/packager/app/test/testdata/av1-webm/output.mpd +++ b/packager/app/test/testdata/av1-webm/output.mpd @@ -3,7 +3,7 @@ - + bear-av1-video.mp4 diff --git a/packager/media/codecs/av1_codec_configuration_record.cc b/packager/media/codecs/av1_codec_configuration_record.cc index 81f156ee28..c88b313360 100644 --- a/packager/media/codecs/av1_codec_configuration_record.cc +++ b/packager/media/codecs/av1_codec_configuration_record.cc @@ -77,13 +77,15 @@ bool AV1CodecConfigurationRecord::Parse(const uint8_t* data, size_t data_size) { // ..... // ... // . -// The parameters starting from colorPrimaries are omitted as they are not -// present in AV1 Codec Configuration Record and they are optional. +// The parameters sample entry 4CC, profile, level, tier, and bitDepth are all +// mandatory fields. +// All the other fields (including their leading '.') are optional, mutually +// inclusive (all or none) fields. +// Since some of the optional fields (e.g. colorPrimaries) are not present in +// AV1CodecConfigurationRecord, we omit all the optional fields. std::string AV1CodecConfigurationRecord::GetCodecString() const { - return base::StringPrintf("av01.%d.%02d%c.%02d.%d.%d%d%d", profile_, level_, - tier_ ? 'H' : 'M', bit_depth_, mono_chrome_, - chroma_subsampling_x_, chroma_subsampling_y_, - chroma_sample_position_); + return base::StringPrintf("av01.%d.%02d%c.%02d", profile_, level_, + tier_ ? 'H' : 'M', bit_depth_); } } // namespace media diff --git a/packager/media/codecs/av1_codec_configuration_record_unittest.cc b/packager/media/codecs/av1_codec_configuration_record_unittest.cc index 7c877f3f7a..8ec180a086 100644 --- a/packager/media/codecs/av1_codec_configuration_record_unittest.cc +++ b/packager/media/codecs/av1_codec_configuration_record_unittest.cc @@ -27,7 +27,7 @@ TEST(AV1CodecConfigurationRecordTest, Success) { std::vector(std::begin(kAV1CodecConfigurationData), std::end(kAV1CodecConfigurationData)))); - EXPECT_EQ(av1_config.GetCodecString(), "av01.0.04M.10.0.112"); + EXPECT_EQ(av1_config.GetCodecString(), "av01.0.04M.10"); } TEST(AV1CodecConfigurationRecordTest, Success2) { @@ -46,7 +46,7 @@ TEST(AV1CodecConfigurationRecordTest, Success2) { std::vector(std::begin(kAV1CodecConfigurationData), std::end(kAV1CodecConfigurationData)))); - EXPECT_EQ(av1_config.GetCodecString(), "av01.1.21H.12.1.010"); + EXPECT_EQ(av1_config.GetCodecString(), "av01.1.21H.12"); } TEST(AV1CodecConfigurationRecordTest, InsufficientData) {