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

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

Issue 748023002: Add JPEG parser for JPEG decode acceleration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/vaapi_jpeg_parser_unittest.cc
diff --git a/content/common/gpu/media/vaapi_jpeg_parser_unittest.cc b/content/common/gpu/media/vaapi_jpeg_parser_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da33d80d6213ede7d58c3c16f81d919bf2862a6a
--- /dev/null
+++ b/content/common/gpu/media/vaapi_jpeg_parser_unittest.cc
@@ -0,0 +1,94 @@
+// Copyright 2014 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 "base/at_exit.h"
+#include "base/files/memory_mapped_file.h"
+#include "base/path_service.h"
+#include "content/common/gpu/media/vaapi_jpeg_parser.h"
+#include "media/base/test_data_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+TEST(VaapiJpegParserTest, Parsing) {
+ base::FilePath data_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir));
+ data_dir = data_dir.AppendASCII("content")
Owen Lin 2014/12/26 07:13:39 How about data_dir.Append(FILE_PATH_LITERAL('cont
kcwu 2014/12/27 13:27:36 Make the code more portable. Windows use "\" path
+ .AppendASCII("test")
+ .AppendASCII("data")
+ .AppendASCII("jpeg");
+
+ // This sample frame is captured from Chromebook Pixel
+ base::FilePath file_path = data_dir.AppendASCII("pixel-1280x720.jpg");
+
+ base::MemoryMappedFile stream;
+ ASSERT_TRUE(stream.Initialize(file_path))
+ << "Couldn't open stream file: " << file_path.MaybeAsASCII();
+
+ VaapiJpegParser parser(stream.data(), stream.length());
+
+ const JpegParseResult* result = parser.Parse();
+ ASSERT_TRUE(result != NULL);
+
+ // Verify selected fields
+ // SOF fields
+ EXPECT_EQ(1280, result->visible_width);
+ EXPECT_EQ(720, result->visible_height);
+ EXPECT_EQ(3, result->num_component);
+ EXPECT_EQ(1, result->components[0].id);
+ EXPECT_EQ(2, result->components[0].horizontal_sampling_factor);
+ EXPECT_EQ(1, result->components[0].vertical_sampling_factor);
+ EXPECT_EQ(0, result->components[0].quantization_table_selector);
+ EXPECT_EQ(2, result->components[1].id);
+ EXPECT_EQ(1, result->components[1].horizontal_sampling_factor);
+ EXPECT_EQ(1, result->components[1].vertical_sampling_factor);
+ EXPECT_EQ(1, result->components[1].quantization_table_selector);
+ EXPECT_EQ(3, result->components[2].id);
+ EXPECT_EQ(1, result->components[2].horizontal_sampling_factor);
+ EXPECT_EQ(1, result->components[2].vertical_sampling_factor);
+ EXPECT_EQ(1, result->components[2].quantization_table_selector);
+
+ // DRI fields
+ EXPECT_EQ(0, result->restart_interval);
+
+ // DQT fields
+ EXPECT_TRUE(result->q_table[0].valid);
+ EXPECT_TRUE(result->q_table[1].valid);
+ EXPECT_FALSE(result->q_table[2].valid);
+ EXPECT_FALSE(result->q_table[3].valid);
+
+ // DHT fields (no DHT marker)
+ EXPECT_FALSE(result->dc_table[0].valid);
+ EXPECT_FALSE(result->ac_table[0].valid);
+ EXPECT_FALSE(result->dc_table[1].valid);
+ EXPECT_FALSE(result->ac_table[1].valid);
+
+ // SOS fields
+ EXPECT_EQ(3, result->scan.num_component);
+ EXPECT_EQ(1, result->scan.components[0].component_selector);
+ EXPECT_EQ(0, result->scan.components[0].dc_selector);
+ EXPECT_EQ(0, result->scan.components[0].ac_selector);
+ EXPECT_EQ(2, result->scan.components[1].component_selector);
+ EXPECT_EQ(1, result->scan.components[1].dc_selector);
+ EXPECT_EQ(1, result->scan.components[1].ac_selector);
+ EXPECT_EQ(3, result->scan.components[2].component_selector);
+ EXPECT_EQ(1, result->scan.components[2].dc_selector);
+ EXPECT_EQ(1, result->scan.components[2].ac_selector);
+ EXPECT_EQ(121150u, result->scan.data_size);
+}
+
+TEST(VaapiJpegParserTest, ParsingFail) {
+ const uint8_t data[] = {0, 1, 2, 3}; // not jpeg
+ VaapiJpegParser parser(data, sizeof(data));
+ const JpegParseResult* result = parser.Parse();
+ EXPECT_EQ(NULL, result);
+}
+
+} // namespace content
+
+int main(int argc, char** argv) {
Owen Lin 2014/12/26 07:13:39 I think it could be part of the content_unittests.
kcwu 2014/12/27 13:27:36 moved to media_unittests
+ testing::InitGoogleTest(&argc, argv);
+ base::AtExitManager exit_manager;
+ return RUN_ALL_TESTS();
+}

Powered by Google App Engine
This is Rietveld 408576698