From 55cc50baa0bec788bd052c73eaeda8294ced8632 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Tue, 5 Jun 2018 18:31:21 -0700 Subject: [PATCH] Use new vp09 codec string for WebM by default Configurable under flag --use_legacy_vp9_codec_string, which defaults to false as all major browsers and platforms support new style vp09 codec string already. Closes #406. Change-Id: I22e917777f9d66db815ff9d55eb47b6d55806269 --- .../vp9-webm-with-blockgroup/output.mpd | 2 +- .../app/test/testdata/vp9-webm/output.mpd | 2 +- .../webm-subsample-encryption/output.mpd | 2 +- .../output.mpd | 2 +- packager/mpd/base/mpd_utils.cc | 15 +++++++++-- packager/mpd/base/representation_unittest.cc | 27 +++++++++++++++++-- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd b/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd index fb3aeef4be..99aad3ec97 100644 --- a/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd +++ b/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd @@ -3,7 +3,7 @@ - + bear-vp9-blockgroup-video.webm diff --git a/packager/app/test/testdata/vp9-webm/output.mpd b/packager/app/test/testdata/vp9-webm/output.mpd index de85cd81a3..4a1df9ba95 100644 --- a/packager/app/test/testdata/vp9-webm/output.mpd +++ b/packager/app/test/testdata/vp9-webm/output.mpd @@ -12,7 +12,7 @@ - + bear-320x240-vp9-opus-video.webm diff --git a/packager/app/test/testdata/webm-subsample-encryption/output.mpd b/packager/app/test/testdata/webm-subsample-encryption/output.mpd index d50519d9ed..f2c8a061ae 100644 --- a/packager/app/test/testdata/webm-subsample-encryption/output.mpd +++ b/packager/app/test/testdata/webm-subsample-encryption/output.mpd @@ -6,7 +6,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-320x180-vp9-altref-video.webm diff --git a/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd b/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd index d50519d9ed..f2c8a061ae 100644 --- a/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd +++ b/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd @@ -6,7 +6,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-320x180-vp9-altref-video.webm diff --git a/packager/mpd/base/mpd_utils.cc b/packager/mpd/base/mpd_utils.cc index 08fc5dc095..fa97e530fb 100644 --- a/packager/mpd/base/mpd_utils.cc +++ b/packager/mpd/base/mpd_utils.cc @@ -6,6 +6,7 @@ #include "packager/mpd/base/mpd_utils.h" +#include #include #include "packager/base/base64.h" @@ -18,6 +19,14 @@ #include "packager/mpd/base/representation.h" #include "packager/mpd/base/xml/scoped_xml_ptr.h" +DEFINE_bool( + use_legacy_vp9_codec_string, + false, + "Use legacy vp9 codec string 'vp9' if set to true; otherwise new style " + "vp09.xx.xx.xx... codec string will be used. Default to false as indicated " + "in https://github.com/google/shaka-packager/issues/406, all major " + "browsers and platforms already support the new 'vp09' codec string."); + namespace shaka { namespace { @@ -97,8 +106,10 @@ std::string GetCodecs(const MediaInfo& media_info) { // new codec strings. if (codec == "vp08") return "vp8"; - if (codec == "vp09") - return "vp9"; + if (FLAGS_use_legacy_vp9_codec_string) { + if (codec == "vp09") + return "vp9"; + } } return media_info.video_info().codec(); } diff --git a/packager/mpd/base/representation_unittest.cc b/packager/mpd/base/representation_unittest.cc index f25e453da8..7fb55f4965 100644 --- a/packager/mpd/base/representation_unittest.cc +++ b/packager/mpd/base/representation_unittest.cc @@ -6,6 +6,7 @@ #include "packager/mpd/base/representation.h" +#include #include #include #include @@ -22,6 +23,8 @@ using ::testing::Not; using ::testing::Values; using ::testing::WithParamInterface; +DECLARE_bool(use_legacy_vp9_codec_string); + namespace shaka { namespace { @@ -210,9 +213,29 @@ TEST_F(RepresentationTest, CheckVideoInfoVp8CodecInWebm) { EXPECT_THAT(representation->GetXml().get(), AttributeEqual("codecs", "vp8")); } -// Check that vp9 codec string will be updated for backward compatibility -// support in webm. TEST_F(RepresentationTest, CheckVideoInfoVp9CodecInWebm) { + const char kTestMediaInfoCodecVp9[] = + "video_info {\n" + " codec: 'vp09.00.00.08.01.01.00.00'\n" + " width: 1280\n" + " height: 720\n" + " time_scale: 10\n" + " frame_duration: 10\n" + " pixel_width: 1\n" + " pixel_height: 1\n" + "}\n" + "container_type: 3\n"; + auto representation = + CreateRepresentation(ConvertToMediaInfo(kTestMediaInfoCodecVp9), + kAnyRepresentationId, NoListener()); + ASSERT_TRUE(representation->Init()); + EXPECT_THAT(representation->GetXml().get(), + AttributeEqual("codecs", "vp09.00.00.08.01.01.00.00")); +} + +TEST_F(RepresentationTest, CheckVideoInfoLegacyVp9CodecInWebm) { + FLAGS_use_legacy_vp9_codec_string = true; + const char kTestMediaInfoCodecVp9[] = "video_info {\n" " codec: 'vp09.00.00.08.01.01.00.00'\n"