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

Unified Diff: content/common/gpu/media/avc_config_record_builder_unittest.cc

Issue 10411085: Build AVC decoder configuration record (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compontent build Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/media/avc_config_record_builder.cc ('k') | content/common/gpu/media/h264_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/avc_config_record_builder_unittest.cc
diff --git a/content/common/gpu/media/avc_config_record_builder_unittest.cc b/content/common/gpu/media/avc_config_record_builder_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..150adca44696c30f38a052e26b9fa853b50768a7
--- /dev/null
+++ b/content/common/gpu/media/avc_config_record_builder_unittest.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/gpu/media/avc_config_record_builder.h"
+
+#include "content/common/gpu/media/h264_parser.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+const uint8 kSPSData[] = {
+ 0x67, 0x64, 0x00, 0x1f, 0xac, 0x34, 0xec, 0x05,
+ 0x00, 0x5b, 0xa1, 0x00, 0x00, 0x03, 0x00, 0x01,
+ 0x00, 0x00, 0x03, 0x00, 0x32, 0x0f, 0x18, 0x31,
+ 0x38,
+};
+
+const uint8 kPPSData[] = {
+ 0x68, 0xef, 0xb2, 0xc8, 0xb0,
+};
+
+const uint8 kNALUHeader[] = {
+ 0x00, 0x00, 0x00, 0x01
+};
+
+} // namespace
+
+TEST(AVCConfigRecordBuilderTest, BuildConfig) {
+ std::vector<uint8> stream;
+ stream.insert(stream.end(), kNALUHeader,
+ kNALUHeader + arraysize(kNALUHeader));
+ stream.insert(stream.end(), kSPSData, kSPSData + arraysize(kSPSData));
+ stream.insert(stream.end(), kNALUHeader,
+ kNALUHeader + arraysize(kNALUHeader));
+ stream.insert(stream.end(), kPPSData, kPPSData + arraysize(kPPSData));
+
+ content::H264Parser parser;
+ parser.SetStream(&stream[0], stream.size());
+ content::H264NALU nalu;
+ ASSERT_EQ(parser.AdvanceToNextNALU(&nalu), content::H264Parser::kOk);
+
+ content::AVCConfigRecordBuilder config;
+ std::vector<uint8> config_data;
+ EXPECT_TRUE(config.ProcessNALU(&parser, nalu, &config_data));
+ EXPECT_TRUE(config_data.empty());
+
+ ASSERT_EQ(parser.AdvanceToNextNALU(&nalu), content::H264Parser::kOk);
+
+ EXPECT_TRUE(config.ProcessNALU(&parser, nalu, &config_data));
+ EXPECT_TRUE(config_data.empty());
+
+ nalu.nal_unit_type = content::H264NALU::kIDRSlice;
+ EXPECT_TRUE(config.ProcessNALU(&parser, nalu, &config_data));
+ EXPECT_FALSE(config_data.empty());
+ EXPECT_EQ(config.coded_width(), 1280);
+ EXPECT_EQ(config.coded_height(), 720);
+
+ const uint8 kExpectedData[] = {
+ 0x01, 0x64, 0x00, 0x1f, 0xff, 0xe1, 0x00, 0x19,
+ 0x67, 0x64, 0x00, 0x1f, 0xac, 0x34, 0xec, 0x05,
+ 0x00, 0x5b, 0xa1, 0x00, 0x00, 0x03, 0x00, 0x01,
+ 0x00, 0x00, 0x03, 0x00, 0x32, 0x0f, 0x18, 0x31,
+ 0x38, 0x01, 0x00, 0x05, 0x68, 0xef, 0xb2, 0xc8,
+ 0xb0,
+ };
+ std::vector<uint8> expected_config_data(
+ kExpectedData, kExpectedData + arraysize(kExpectedData));
+ EXPECT_EQ(config_data, expected_config_data);
+}
+
+// Test building a config record with zero SPS and PPS data.
+TEST(AVCConfigRecordBuilderTest, EmptyConfig) {
+ content::AVCConfigRecordBuilder config;
+ content::H264Parser parser;
+ std::vector<uint8> config_data;
+
+ // Feed the builder a slice right away.
+ content::H264NALU nalu;
+ nalu.nal_unit_type = content::H264NALU::kIDRSlice;
+ EXPECT_TRUE(config.ProcessNALU(&parser, nalu, &config_data));
+ EXPECT_FALSE(config_data.empty());
+ EXPECT_EQ(config.coded_width(), 0);
+ EXPECT_EQ(config.coded_height(), 0);
+
+ const uint8 kExpectedData[] = {
+ 0x01, 0x0, 0x00, 0x0, 0xff, 0xe0, 0x00,
+ };
+ std::vector<uint8> expected_config_data(
+ kExpectedData, kExpectedData + arraysize(kExpectedData));
+ EXPECT_EQ(config_data, expected_config_data);
+}
« no previous file with comments | « content/common/gpu/media/avc_config_record_builder.cc ('k') | content/common/gpu/media/h264_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698