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

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: rebase Created 8 years, 7 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
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..171b2aa067039fa621e0f7302c23f75c3f19661a
--- /dev/null
+++ b/content/common/gpu/media/avc_config_record_builder_unittest.cc
@@ -0,0 +1,77 @@
+// 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_t SPS_DATA[] = {
Ami GONE FROM CHROMIUM 2012/05/23 19:41:19 kSPSData (here and below).
sail 2012/05/28 21:45:46 Done.
+ 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_t* SPS_DATA_END = SPS_DATA + sizeof(SPS_DATA);
Ami GONE FROM CHROMIUM 2012/05/23 19:41:19 Instead of the _END's, use arraysize() at the use-
sail 2012/05/28 21:45:46 Done.
sail 2012/05/28 21:45:46 Done.
+
+const uint8_t PPS_DATA[] = {
+ 0x68, 0xef, 0xb2, 0xc8, 0xb0,
+};
+const uint8_t* PPS_DATA_END = PPS_DATA + sizeof(PPS_DATA);
+
+const uint8_t NALU_HEADER[] = {
+ 0x00, 0x00, 0x00, 0x01
+};
+const uint8_t* NALU_HEADER_END = NALU_HEADER + sizeof(NALU_HEADER);
+
+} // namespace
+
+TEST(AVCConfigRecordBuilderTest, BuildConfig) {
+ std::vector<uint8_t> stream;
+ stream.insert(stream.end(), NALU_HEADER, NALU_HEADER_END);
Ami GONE FROM CHROMIUM 2012/05/23 19:41:19 s/.insert/.append/ here and below?
sail 2012/05/28 21:45:46 hm... vector doesn't seem to have an append method
+ stream.insert(stream.end(), SPS_DATA, SPS_DATA_END);
+ stream.insert(stream.end(), NALU_HEADER, NALU_HEADER_END);
+ stream.insert(stream.end(), PPS_DATA, PPS_DATA_END);
+
+ content::H264Parser parser;
+ parser.SetStream(&stream[0], stream.size());
+ content::H264NALU nalu;
+ content::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu);
+ ASSERT_EQ(result, content::H264Parser::kOk);
+
+ content::AVCConfigRecordBuilder config;
+ bool did_consume_nalu = false;
+ EXPECT_TRUE(config.ProcessNextNALU(&parser, &nalu, &did_consume_nalu));
+ EXPECT_TRUE(did_consume_nalu);
+ EXPECT_FALSE(config.can_build_record());
+
+ result = parser.AdvanceToNextNALU(&nalu);
+ ASSERT_EQ(result, content::H264Parser::kOk);
+
+ EXPECT_TRUE(config.ProcessNextNALU(&parser, &nalu, &did_consume_nalu));
+ EXPECT_TRUE(did_consume_nalu);
+ EXPECT_FALSE(config.can_build_record());
+
+ nalu.nal_unit_type = content::H264NALU::kIDRSlice;
+ EXPECT_TRUE(config.ProcessNextNALU(&parser, &nalu, &did_consume_nalu));
+ EXPECT_FALSE(did_consume_nalu);
+ EXPECT_TRUE(config.can_build_record());
+ EXPECT_EQ(config.coded_width(), 1280);
+ EXPECT_EQ(config.coded_height(), 720);
+
+ std::vector<uint8_t> config_data(config.BuildConfigRecord());
+
+ const uint8_t EXPECTED_DATA[] = {
+ 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,
+ };
+ EXPECT_TRUE(std::equal(
+ config_data.begin(), config_data.end(), EXPECTED_DATA));
Ami GONE FROM CHROMIUM 2012/05/23 19:41:19 If you replaced this with: std::vector<uint8_t> ex
sail 2012/05/28 21:45:46 Done.
+}

Powered by Google App Engine
This is Rietveld 408576698