summaryrefslogtreecommitdiff
path: root/chromium/media/filters/vp9_parser_unittest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 15:05:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:33:47 +0000
commite684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch)
treed55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/media/filters/vp9_parser_unittest.cc
parent2b94bfe47ccb6c08047959d1c26e392919550e86 (diff)
downloadqtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922 Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/media/filters/vp9_parser_unittest.cc')
-rw-r--r--chromium/media/filters/vp9_parser_unittest.cc433
1 files changed, 431 insertions, 2 deletions
diff --git a/chromium/media/filters/vp9_parser_unittest.cc b/chromium/media/filters/vp9_parser_unittest.cc
index f5d4fe6cd71..0780c39daec 100644
--- a/chromium/media/filters/vp9_parser_unittest.cc
+++ b/chromium/media/filters/vp9_parser_unittest.cc
@@ -15,6 +15,8 @@
// If |should_update| is true, it follows by the frame context to update.
#include <stdint.h>
#include <string.h>
+#include <utility>
+#include <vector>
#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
@@ -50,6 +52,11 @@ const struct TestParams kTestParams[] = {
{"test-25fps.vp9_2", 2, 10, 320, 240, true, 8, 79, 115,
Vp9InterpolationFilter::SWITCHABLE, 46, 10}};
+const char kInitialIV[] = "aaaaaaaaaaaaaaaa";
+const char kIVIncrementOne[] = "aaaaaaaaaaaaaaab";
+const char kIVIncrementTwo[] = "aaaaaaaaaaaaaaac";
+const char kKeyID[] = "key-id";
+
} // anonymous namespace
class Vp9ParserTest : public TestWithParam<TestParams> {
@@ -98,6 +105,11 @@ class Vp9ParserTest : public TestWithParam<TestParams> {
}
Vp9Parser::Result ParseNextFrame(struct Vp9FrameHeader* frame_hdr);
+ void CheckSubsampleValues(
+ const uint8_t* superframe,
+ size_t framesize,
+ std::unique_ptr<DecryptConfig> config,
+ std::vector<std::unique_ptr<DecryptConfig>>& expected_split);
const Vp9SegmentationParams& GetSegmentation() const {
return vp9_parser_->context().segmentation();
@@ -121,7 +133,8 @@ class Vp9ParserTest : public TestWithParam<TestParams> {
Vp9Parser::Result Vp9ParserTest::ParseNextFrame(Vp9FrameHeader* fhdr) {
while (1) {
- Vp9Parser::Result res = vp9_parser_->ParseNextFrame(fhdr);
+ std::unique_ptr<DecryptConfig> null_config;
+ Vp9Parser::Result res = vp9_parser_->ParseNextFrame(fhdr, &null_config);
if (res == Vp9Parser::kEOStream) {
IvfFrameHeader ivf_frame_header;
const uint8_t* ivf_payload;
@@ -129,7 +142,7 @@ Vp9Parser::Result Vp9ParserTest::ParseNextFrame(Vp9FrameHeader* fhdr) {
if (!ivf_parser_.ParseNextFrame(&ivf_frame_header, &ivf_payload))
return Vp9Parser::kEOStream;
- vp9_parser_->SetStream(ivf_payload, ivf_frame_header.frame_size);
+ vp9_parser_->SetStream(ivf_payload, ivf_frame_header.frame_size, nullptr);
continue;
}
@@ -137,6 +150,413 @@ Vp9Parser::Result Vp9ParserTest::ParseNextFrame(Vp9FrameHeader* fhdr) {
}
}
+void Vp9ParserTest::CheckSubsampleValues(
+ const uint8_t* superframe,
+ size_t framesize,
+ std::unique_ptr<DecryptConfig> config,
+ std::vector<std::unique_ptr<DecryptConfig>>& expected_split) {
+ vp9_parser_->SetStream(superframe, framesize, std::move(config));
+ for (auto& expected : expected_split) {
+ std::unique_ptr<DecryptConfig> actual =
+ vp9_parser_->NextFrameDecryptContextForTesting();
+ EXPECT_EQ(actual->iv(), expected->iv());
+ EXPECT_EQ(actual->subsamples().size(), expected->subsamples().size());
+ }
+}
+
+uint8_t make_marker_byte(bool is_superframe, const uint8_t frame_count) {
+ DCHECK_LE(frame_count, 8);
+ const uint8_t superframe_marker_byte =
+ // superframe marker byte
+ // marker (0b110) encoded at bits 6, 7, 8
+ // or non-superframe marker (0b111)
+ (0xE0 & ((is_superframe ? 0x06 : 0x07) << 5)) |
+ // magnitude - 1 encoded at bits 4, 5
+ (0x18 & (0x00 << 3)) |
+ // frame count - 2 encoded at bits 1, 2, 3
+ (0x07 & (frame_count - 1));
+ return superframe_marker_byte;
+}
+
+// ┌───────────────────┬────────────────────┐
+// │ frame 1 │ frame 2 │
+// ┝━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━┥
+// │ clear1 | cipher 1 │ clear 2 | cipher 2 │
+// └───────────────────┴────────────────────┘
+TEST_F(Vp9ParserTest, AlignedFrameSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(true, 2);
+ const uint8_t kSuperframe[] = {
+ // First frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Second frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x20,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ std::vector<std::unique_ptr<DecryptConfig>> expected;
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 16)}, base::nullopt));
+
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kIVIncrementOne, {SubsampleEntry(16, 16)}, base::nullopt));
+
+ CheckSubsampleValues(
+ kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 16), SubsampleEntry(16, 16)}),
+ expected);
+}
+
+// ┌───────────────────┬────────────────────┐
+// │ frame 1 │ frame 2 │
+// ┝━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┥
+// │ clear1 | cipher 1 │
+// └────────────────────────────────────────┘
+TEST_F(Vp9ParserTest, UnalignedFrameSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(true, 2);
+ const uint8_t kSuperframe[] = {
+ // First frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Second frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x20,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ std::vector<std::unique_ptr<DecryptConfig>> expected;
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(32, 0)}, base::nullopt));
+
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 16)}, base::nullopt));
+
+ CheckSubsampleValues(kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(48, 16)}),
+ expected);
+}
+
+// ┌─────────────────────────┬────────────────────┐
+// │ frame 1 │ frame 2 │
+// ┝━━━━━━━━━━━━━━━━━━━┯━━━━━┷━━━━━━━━━━━━━━━━━━━━┥
+// │ clear1 | cipher 1 │ clear 2 | cipher 2 │
+// └───────────────────┴──────────────────────────┘
+TEST_F(Vp9ParserTest, ClearSectionRollsOverSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(true, 2);
+ const uint8_t kSuperframe[] = {
+ // First frame; 48 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Second frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x30,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ std::vector<std::unique_ptr<DecryptConfig>> expected;
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 16), SubsampleEntry(16, 0)},
+ base::nullopt));
+
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kIVIncrementOne, {SubsampleEntry(16, 16)}, base::nullopt));
+
+ CheckSubsampleValues(
+ kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 16), SubsampleEntry(32, 16)}),
+ expected);
+}
+
+// ┌────────────────────────────────────────┬────────────────────┐
+// │ frame 1 │ frame 2 │
+// ┝━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━┥
+// │ clear1 | cipher 1 │ clear 2 | cipher 2 │ clear 3 | cipher 3 │
+// └───────────────────┴────────────────────┴────────────────────┘
+TEST_F(Vp9ParserTest, FirstFrame2xSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(true, 2);
+ const uint8_t kSuperframe[] = {
+ // First frame; 64 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ // Second frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x40,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ std::vector<std::unique_ptr<DecryptConfig>> expected;
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 16), SubsampleEntry(16, 16)},
+ base::nullopt));
+
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kIVIncrementTwo, {SubsampleEntry(16, 16)}, base::nullopt));
+
+ CheckSubsampleValues(kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV,
+ {SubsampleEntry(16, 16), SubsampleEntry(16, 16),
+ SubsampleEntry(16, 16)}),
+ expected);
+}
+
+// ┌─────────────────────────────────────────────┬───────────────┐
+// │ frame 1 │ frame 2 │
+// ┝━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━┷━━━━━━━━━━━━━━━┥
+// │ clear1 | cipher 1 │ clear 2 | cipher 2 │ clear 3 | cipher 3 │
+// └───────────────────┴────────────────────┴────────────────────┘
+TEST_F(Vp9ParserTest, UnalignedBigFrameSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(true, 2);
+ const uint8_t kSuperframe[] = {
+ // First frame; 72 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Second frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x48,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ std::vector<std::unique_ptr<DecryptConfig>> expected;
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kInitialIV,
+ {SubsampleEntry(16, 16), SubsampleEntry(16, 16), SubsampleEntry(8, 0)},
+ base::nullopt));
+
+ expected.push_back(DecryptConfig::CreateCbcsConfig(
+ kKeyID, kIVIncrementTwo, {SubsampleEntry(16, 16)}, base::nullopt));
+
+ CheckSubsampleValues(
+ kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(kKeyID, kInitialIV,
+ {
+ SubsampleEntry(16, 16),
+ SubsampleEntry(16, 16),
+ SubsampleEntry(24, 16),
+ }),
+ expected);
+}
+
+// ┌───────────────────┬────────────────────┐
+// │ frame 1 │ frame 2 │
+// ┝━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┥
+// │ clear1 | cipher 1 │
+// └────────────────────────────────────────┘
+TEST_F(Vp9ParserTest, UnalignedInvalidSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(true, 2);
+ const uint8_t kSuperframe[] = {
+ // First frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Second frame; 32 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x20,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ vp9_parser_->SetStream(kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(16, 32)}));
+
+ ASSERT_EQ(vp9_parser_->NextFrameDecryptContextForTesting().get(), nullptr);
+}
+
+// ┌─────────────────────────────────────┬─────────┐
+// │ single frame in superframe │ marker │
+// ┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┥
+// │ clear1 = 0 | cipher 1 │
+// └───────────────────────────────────────────────┘
+TEST_F(Vp9ParserTest, CipherBytesCoverSuperframeMarkerSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(false, 1);
+ const uint8_t kSuperframe[] = {
+ // First frame; 44 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x20,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ vp9_parser_->SetStream(kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(0, 48)}));
+
+ std::unique_ptr<DecryptConfig> actual =
+ vp9_parser_->NextFrameDecryptContextForTesting();
+
+ EXPECT_EQ(actual->iv(), kInitialIV);
+ EXPECT_EQ(actual->subsamples().size(), 1lu);
+}
+
+// ┌─────────────────────────────────────┬─────────┐
+// │ single frame in superframe │ marker │
+// ┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┥
+// │ clear1 │
+// └───────────────────────────────────────────────┘
+TEST_F(Vp9ParserTest, ClearBytesCoverSuperframeMarkerSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(false, 1);
+ const uint8_t kSuperframe[] = {
+ // First frame; 44 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x20,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ vp9_parser_->SetStream(kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(
+ kKeyID, kInitialIV, {SubsampleEntry(48, 0)}));
+
+ std::unique_ptr<DecryptConfig> actual =
+ vp9_parser_->NextFrameDecryptContextForTesting();
+
+ EXPECT_EQ(actual->iv(), kInitialIV);
+ EXPECT_EQ(actual->subsamples().size(), 1lu);
+}
+
+// ┌─────────────────────────────────────┬─────────┐
+// │ single frame in superframe │ marker │
+// ┝━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┷━━━━━━━━━┥
+// │ clear 1 | cipher 1 │ clear 2 │
+// └────────────────────┴──────────────────────────┘
+TEST_F(Vp9ParserTest, SecondClearSubsampleSuperframeMarkerSubsampleParsing) {
+ vp9_parser_.reset(new Vp9Parser(false));
+
+ const uint8_t superframe_marker_byte = make_marker_byte(false, 1);
+ const uint8_t kSuperframe[] = {
+ // First frame; 44 bytes.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Superframe marker goes before and after frame index.
+ superframe_marker_byte,
+ // First frame length (magnitude 1)
+ 0x20,
+ // Second frame length (magnigude 1)
+ 0x20,
+ // marker again.
+ superframe_marker_byte};
+
+ vp9_parser_->SetStream(
+ kSuperframe, sizeof(kSuperframe),
+ DecryptConfig::CreateCencConfig(kKeyID, kInitialIV,
+ {
+ SubsampleEntry(16, 16),
+ SubsampleEntry(16, 0),
+ }));
+
+ std::unique_ptr<DecryptConfig> actual =
+ vp9_parser_->NextFrameDecryptContextForTesting();
+
+ EXPECT_EQ(actual->iv(), kInitialIV);
+ EXPECT_EQ(actual->subsamples().size(), 2lu);
+}
+
+TEST_F(Vp9ParserTest, TestIncrementIV) {
+ std::vector<std::tuple<char const*, uint32_t, char const*>> input_output = {
+ {"--------aaaaaaaa", 1, "--------aaaaaaab"},
+ {"--------aaaaaaa\377", 1, "--------aaaaaab\0"},
+ {"--------aaaaaaa\377", 2, "--------aaaaaab\1"},
+ {"--------\377\377\377\377\377\377\377\377", 2,
+ "--------\0\0\0\0\0\0\0\1"}};
+
+ for (auto& testcase : input_output) {
+ EXPECT_EQ(
+ vp9_parser_->IncrementIVForTesting(
+ std::string(std::get<0>(testcase), 16), std::get<1>(testcase)),
+ std::string(std::get<2>(testcase), 16));
+ }
+}
+
TEST_F(Vp9ParserTest, StreamFileParsingWithoutCompressedHeader) {
Initialize("test-25fps.vp9", false);
@@ -343,4 +763,13 @@ TEST_P(Vp9ParserTest, VerifyFirstFrame) {
INSTANTIATE_TEST_CASE_P(, Vp9ParserTest, ::testing::ValuesIn(kTestParams));
+TEST_F(Vp9ParserTest, CheckColorSpace) {
+ Vp9FrameHeader fhdr{};
+ EXPECT_FALSE(fhdr.GetColorSpace().IsSpecified());
+ fhdr.color_space = Vp9ColorSpace::BT_709;
+ EXPECT_EQ(VideoColorSpace::REC709(), fhdr.GetColorSpace());
+ fhdr.color_space = Vp9ColorSpace::BT_601;
+ EXPECT_EQ(VideoColorSpace::REC601(), fhdr.GetColorSpace());
+}
+
} // namespace media