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

Side by Side 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 5 years, 12 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/at_exit.h"
6 #include "base/files/memory_mapped_file.h"
7 #include "base/path_service.h"
8 #include "content/common/gpu/media/vaapi_jpeg_parser.h"
9 #include "media/base/test_data_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace content {
13
14 TEST(VaapiJpegParserTest, Parsing) {
15 base::FilePath data_dir;
16 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir));
17 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
18 .AppendASCII("test")
19 .AppendASCII("data")
20 .AppendASCII("jpeg");
21
22 // This sample frame is captured from Chromebook Pixel
23 base::FilePath file_path = data_dir.AppendASCII("pixel-1280x720.jpg");
24
25 base::MemoryMappedFile stream;
26 ASSERT_TRUE(stream.Initialize(file_path))
27 << "Couldn't open stream file: " << file_path.MaybeAsASCII();
28
29 VaapiJpegParser parser(stream.data(), stream.length());
30
31 const JpegParseResult* result = parser.Parse();
32 ASSERT_TRUE(result != NULL);
33
34 // Verify selected fields
35 // SOF fields
36 EXPECT_EQ(1280, result->visible_width);
37 EXPECT_EQ(720, result->visible_height);
38 EXPECT_EQ(3, result->num_component);
39 EXPECT_EQ(1, result->components[0].id);
40 EXPECT_EQ(2, result->components[0].horizontal_sampling_factor);
41 EXPECT_EQ(1, result->components[0].vertical_sampling_factor);
42 EXPECT_EQ(0, result->components[0].quantization_table_selector);
43 EXPECT_EQ(2, result->components[1].id);
44 EXPECT_EQ(1, result->components[1].horizontal_sampling_factor);
45 EXPECT_EQ(1, result->components[1].vertical_sampling_factor);
46 EXPECT_EQ(1, result->components[1].quantization_table_selector);
47 EXPECT_EQ(3, result->components[2].id);
48 EXPECT_EQ(1, result->components[2].horizontal_sampling_factor);
49 EXPECT_EQ(1, result->components[2].vertical_sampling_factor);
50 EXPECT_EQ(1, result->components[2].quantization_table_selector);
51
52 // DRI fields
53 EXPECT_EQ(0, result->restart_interval);
54
55 // DQT fields
56 EXPECT_TRUE(result->q_table[0].valid);
57 EXPECT_TRUE(result->q_table[1].valid);
58 EXPECT_FALSE(result->q_table[2].valid);
59 EXPECT_FALSE(result->q_table[3].valid);
60
61 // DHT fields (no DHT marker)
62 EXPECT_FALSE(result->dc_table[0].valid);
63 EXPECT_FALSE(result->ac_table[0].valid);
64 EXPECT_FALSE(result->dc_table[1].valid);
65 EXPECT_FALSE(result->ac_table[1].valid);
66
67 // SOS fields
68 EXPECT_EQ(3, result->scan.num_component);
69 EXPECT_EQ(1, result->scan.components[0].component_selector);
70 EXPECT_EQ(0, result->scan.components[0].dc_selector);
71 EXPECT_EQ(0, result->scan.components[0].ac_selector);
72 EXPECT_EQ(2, result->scan.components[1].component_selector);
73 EXPECT_EQ(1, result->scan.components[1].dc_selector);
74 EXPECT_EQ(1, result->scan.components[1].ac_selector);
75 EXPECT_EQ(3, result->scan.components[2].component_selector);
76 EXPECT_EQ(1, result->scan.components[2].dc_selector);
77 EXPECT_EQ(1, result->scan.components[2].ac_selector);
78 EXPECT_EQ(121150u, result->scan.data_size);
79 }
80
81 TEST(VaapiJpegParserTest, ParsingFail) {
82 const uint8_t data[] = {0, 1, 2, 3}; // not jpeg
83 VaapiJpegParser parser(data, sizeof(data));
84 const JpegParseResult* result = parser.Parse();
85 EXPECT_EQ(NULL, result);
86 }
87
88 } // namespace content
89
90 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
91 testing::InitGoogleTest(&argc, argv);
92 base::AtExitManager exit_manager;
93 return RUN_ALL_TESTS();
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698