Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: media/base/video_codecs_unittest.cc

Issue 2723833002: WebM support for new multipart VP9 string. (Closed)
Patch Set: Put parsing behind a flag (--enable-hdr-output OR --enable-new-vp9-codec-string) Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_codecs.h" 5 #include "media/base/video_codecs.h"
6 6
7 #include <set>
8
9 #include "base/logging.h"
7 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
8 11
9 namespace media { 12 namespace media {
10 13
14 TEST(ParseVP9CodecId, NewStyleVP9CodecIDs) {
15 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN;
16 uint8_t level = 0;
17 gfx::ColorSpace::TransferID eotf = gfx::ColorSpace::TransferID::INVALID;
18
19 // Old style is not subset of new style.
20 EXPECT_FALSE(ParseNewStyleVp9CodecID("vp8", &profile, &level, &eotf));
21 EXPECT_FALSE(ParseNewStyleVp9CodecID("vp9", &profile, &level, &eotf));
22
23 // Parsing should fail when first 4 required fields are not provided.
24 EXPECT_FALSE(ParseNewStyleVp9CodecID("vp09", &profile, &level, &eotf));
25 EXPECT_FALSE(ParseNewStyleVp9CodecID("vp09.00", &profile, &level, &eotf));
26 EXPECT_FALSE(ParseNewStyleVp9CodecID("vp09.00.01", &profile, &level, &eotf));
27
28 // Expect success when all required fields supplied (and valid).
29 // TrnasferID not specified by string, should default to 709.
30 EXPECT_TRUE(
31 ParseNewStyleVp9CodecID("vp09.00.01.08", &profile, &level, &eotf));
32 EXPECT_EQ(VP9PROFILE_PROFILE0, profile);
33 EXPECT_EQ(1, level);
34 EXPECT_EQ(gfx::ColorSpace::TransferID::BT709, eotf);
35
36 // Verify profile's 1 and 2 parse correctly.
37 EXPECT_TRUE(
38 ParseNewStyleVp9CodecID("vp09.01.01.08", &profile, &level, &eotf));
39 EXPECT_EQ(VP9PROFILE_PROFILE1, profile);
40 EXPECT_TRUE(
41 ParseNewStyleVp9CodecID("vp09.02.01.08", &profile, &level, &eotf));
42 EXPECT_EQ(VP9PROFILE_PROFILE2, profile);
43 EXPECT_TRUE(
44 ParseNewStyleVp9CodecID("vp09.03.01.08", &profile, &level, &eotf));
45 EXPECT_EQ(VP9PROFILE_PROFILE3, profile);
46 // Profile 4 is not a thing.
47 EXPECT_FALSE(
48 ParseNewStyleVp9CodecID("vp09.04.01.08", &profile, &level, &eotf));
49
50 // Verify valid levels parse correctly.
51 const std::set<int> kValidVp9Levels = {1, 2, 3, 4, 5, 6, 11,
52 21, 31, 41, 51, 52, 61, 62};
53 size_t num_valid_levels = 0;
54 for (int i = 0; i < 99; ++i) {
55 // Write "i" as the level.
56 char codec_string[14];
57 snprintf(codec_string, 14, "vp09.00.%02d.08", i);
58 if (kValidVp9Levels.find(i) != kValidVp9Levels.end()) {
59 EXPECT_TRUE(
60 ParseNewStyleVp9CodecID(codec_string, &profile, &level, &eotf));
61 EXPECT_EQ(VP9PROFILE_PROFILE0, profile);
62 EXPECT_EQ(i, level);
63 EXPECT_EQ(gfx::ColorSpace::TransferID::BT709, eotf);
64 num_valid_levels++;
65 } else {
66 EXPECT_FALSE(
67 ParseNewStyleVp9CodecID(codec_string, &profile, &level, &eotf));
68 }
69 }
70 EXPECT_EQ(kValidVp9Levels.size(), num_valid_levels);
71
72 // Verify a few common EOTFs parse correctly.
73 EXPECT_TRUE(
74 ParseNewStyleVp9CodecID("vp09.02.01.10.01.01", &profile, &level, &eotf));
75 EXPECT_EQ(gfx::ColorSpace::TransferID::BT709, eotf);
76 EXPECT_TRUE(
77 ParseNewStyleVp9CodecID("vp09.02.01.10.01.04", &profile, &level, &eotf));
78 EXPECT_EQ(gfx::ColorSpace::TransferID::GAMMA22, eotf);
79 EXPECT_TRUE(
80 ParseNewStyleVp9CodecID("vp09.02.01.10.01.06", &profile, &level, &eotf));
81 EXPECT_EQ(gfx::ColorSpace::TransferID::SMPTE170M, eotf);
82 EXPECT_TRUE(
83 ParseNewStyleVp9CodecID("vp09.02.01.10.01.14", &profile, &level, &eotf));
84 EXPECT_EQ(gfx::ColorSpace::TransferID::BT2020_10, eotf);
85 EXPECT_TRUE(
86 ParseNewStyleVp9CodecID("vp09.02.01.12.01.15", &profile, &level, &eotf));
87 EXPECT_EQ(gfx::ColorSpace::TransferID::BT2020_12, eotf);
88 EXPECT_TRUE(
89 ParseNewStyleVp9CodecID("vp09.02.01.10.01.13", &profile, &level, &eotf));
90 EXPECT_EQ(gfx::ColorSpace::TransferID::IEC61966_2_1, eotf);
91 EXPECT_TRUE(
92 ParseNewStyleVp9CodecID("vp09.02.01.10.01.16", &profile, &level, &eotf));
93 EXPECT_EQ(gfx::ColorSpace::TransferID::SMPTEST2084, eotf);
94
95 // Verify 0 and 3 are reserved EOTF values.
96 EXPECT_FALSE(
97 ParseNewStyleVp9CodecID("vp09.02.01.08.01.00", &profile, &level, &eotf));
98 EXPECT_FALSE(
99 ParseNewStyleVp9CodecID("vp09.02.01.08.01.03", &profile, &level, &eotf));
100 }
101
11 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 102 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
12 TEST(ParseHEVCCodecIdTest, InvalidHEVCCodecIds) { 103 TEST(ParseHEVCCodecIdTest, InvalidHEVCCodecIds) {
13 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; 104 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN;
14 uint8_t level_idc = 0; 105 uint8_t level_idc = 0;
15 106
16 // Both hev1 and hvc1 should be supported 107 // Both hev1 and hvc1 should be supported
17 EXPECT_TRUE(ParseHEVCCodecId("hev1.1.6.L93.B0", &profile, &level_idc)); 108 EXPECT_TRUE(ParseHEVCCodecId("hev1.1.6.L93.B0", &profile, &level_idc));
18 EXPECT_EQ(profile, HEVCPROFILE_MAIN); 109 EXPECT_EQ(profile, HEVCPROFILE_MAIN);
19 EXPECT_EQ(level_idc, 93); 110 EXPECT_EQ(level_idc, 93);
20 EXPECT_TRUE(ParseHEVCCodecId("hvc1.1.6.L93.B0", &profile, &level_idc)); 111 EXPECT_TRUE(ParseHEVCCodecId("hvc1.1.6.L93.B0", &profile, &level_idc));
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7", &profile, &level_id)); 300 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7", &profile, &level_id));
210 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7.", &profile, &level_id)); 301 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7.", &profile, &level_id));
211 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7..", &profile, &level_id)); 302 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7..", &profile, &level_id));
212 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7...", &profile, &level_id)); 303 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe.5.7...", &profile, &level_id));
213 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe..5", &profile, &level_id)); 304 EXPECT_FALSE(ParseDolbyVisionCodecId("dvhe..5", &profile, &level_id));
214 #endif 305 #endif
215 } 306 }
216 #endif 307 #endif
217 308
218 } // namespace media 309 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698