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

Side by Side Diff: media/gpu/vaapi_jpeg_decoder_unittest.cc

Issue 2061823003: media: Drop "media::" in media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work around clang format by adding an empty line Created 4 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 unified diff | Download patch
« no previous file with comments | « media/gpu/vaapi_jpeg_decoder.cc ('k') | media/gpu/vaapi_video_decode_accelerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include <string> 8 #include <string>
9 9
10 // This has to be included first. 10 // This has to be included first.
(...skipping 25 matching lines...) Expand all
36 class VaapiJpegDecoderTest : public ::testing::Test { 36 class VaapiJpegDecoderTest : public ::testing::Test {
37 protected: 37 protected:
38 VaapiJpegDecoderTest() {} 38 VaapiJpegDecoderTest() {}
39 39
40 void SetUp() override { 40 void SetUp() override {
41 base::Closure report_error_cb = base::Bind(&LogOnError); 41 base::Closure report_error_cb = base::Bind(&LogOnError);
42 wrapper_ = VaapiWrapper::Create(VaapiWrapper::kDecode, 42 wrapper_ = VaapiWrapper::Create(VaapiWrapper::kDecode,
43 VAProfileJPEGBaseline, report_error_cb); 43 VAProfileJPEGBaseline, report_error_cb);
44 ASSERT_TRUE(wrapper_); 44 ASSERT_TRUE(wrapper_);
45 45
46 base::FilePath input_file = media::GetTestDataFilePath(kTestFilename); 46 base::FilePath input_file = GetTestDataFilePath(kTestFilename);
47 47
48 ASSERT_TRUE(base::ReadFileToString(input_file, &jpeg_data_)) 48 ASSERT_TRUE(base::ReadFileToString(input_file, &jpeg_data_))
49 << "failed to read input data from " << input_file.value(); 49 << "failed to read input data from " << input_file.value();
50 } 50 }
51 51
52 void TearDown() override { wrapper_ = nullptr; } 52 void TearDown() override { wrapper_ = nullptr; }
53 53
54 bool VerifyDecode(const media::JpegParseResult& parse_result, 54 bool VerifyDecode(const JpegParseResult& parse_result,
55 const std::string& md5sum); 55 const std::string& md5sum);
56 56
57 protected: 57 protected:
58 scoped_refptr<VaapiWrapper> wrapper_; 58 scoped_refptr<VaapiWrapper> wrapper_;
59 std::string jpeg_data_; 59 std::string jpeg_data_;
60 }; 60 };
61 61
62 bool VaapiJpegDecoderTest::VerifyDecode( 62 bool VaapiJpegDecoderTest::VerifyDecode(const JpegParseResult& parse_result,
63 const media::JpegParseResult& parse_result, 63 const std::string& expected_md5sum) {
64 const std::string& expected_md5sum) {
65 gfx::Size size(parse_result.frame_header.coded_width, 64 gfx::Size size(parse_result.frame_header.coded_width,
66 parse_result.frame_header.coded_height); 65 parse_result.frame_header.coded_height);
67 66
68 std::vector<VASurfaceID> va_surfaces; 67 std::vector<VASurfaceID> va_surfaces;
69 if (!wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, size, 1, &va_surfaces)) 68 if (!wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, size, 1, &va_surfaces))
70 return false; 69 return false;
71 70
72 if (!VaapiJpegDecoder::Decode(wrapper_.get(), parse_result, va_surfaces[0])) { 71 if (!VaapiJpegDecoder::Decode(wrapper_.get(), parse_result, va_surfaces[0])) {
73 LOG(ERROR) << "Decode failed"; 72 LOG(ERROR) << "Decode failed";
74 return false; 73 return false;
75 } 74 }
76 75
77 VAImage image; 76 VAImage image;
78 VAImageFormat format; 77 VAImageFormat format;
79 const uint32_t kI420Fourcc = VA_FOURCC('I', '4', '2', '0'); 78 const uint32_t kI420Fourcc = VA_FOURCC('I', '4', '2', '0');
80 memset(&image, 0, sizeof(image)); 79 memset(&image, 0, sizeof(image));
81 memset(&format, 0, sizeof(format)); 80 memset(&format, 0, sizeof(format));
82 format.fourcc = kI420Fourcc; 81 format.fourcc = kI420Fourcc;
83 format.byte_order = VA_LSB_FIRST; 82 format.byte_order = VA_LSB_FIRST;
84 format.bits_per_pixel = 12; // 12 for I420 83 format.bits_per_pixel = 12; // 12 for I420
85 84
86 void* mem; 85 void* mem;
87 if (!wrapper_->GetVaImage(va_surfaces[0], &format, size, &image, &mem)) { 86 if (!wrapper_->GetVaImage(va_surfaces[0], &format, size, &image, &mem)) {
88 LOG(ERROR) << "Cannot get VAImage"; 87 LOG(ERROR) << "Cannot get VAImage";
89 return false; 88 return false;
90 } 89 }
91 EXPECT_EQ(kI420Fourcc, image.format.fourcc); 90 EXPECT_EQ(kI420Fourcc, image.format.fourcc);
92 91
93 base::StringPiece result( 92 base::StringPiece result(reinterpret_cast<const char*>(mem),
94 reinterpret_cast<const char*>(mem), 93 VideoFrame::AllocationSize(PIXEL_FORMAT_I420, size));
95 media::VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420, size));
96 EXPECT_EQ(expected_md5sum, base::MD5String(result)); 94 EXPECT_EQ(expected_md5sum, base::MD5String(result));
97 95
98 wrapper_->ReturnVaImage(&image); 96 wrapper_->ReturnVaImage(&image);
99 97
100 return true; 98 return true;
101 } 99 }
102 100
103 TEST_F(VaapiJpegDecoderTest, DecodeSuccess) { 101 TEST_F(VaapiJpegDecoderTest, DecodeSuccess) {
104 media::JpegParseResult parse_result; 102 JpegParseResult parse_result;
105 ASSERT_TRUE(media::ParseJpegPicture( 103 ASSERT_TRUE(
106 reinterpret_cast<const uint8_t*>(jpeg_data_.data()), jpeg_data_.size(), 104 ParseJpegPicture(reinterpret_cast<const uint8_t*>(jpeg_data_.data()),
107 &parse_result)); 105 jpeg_data_.size(), &parse_result));
108 106
109 EXPECT_TRUE(VerifyDecode(parse_result, kExpectedMd5Sum)); 107 EXPECT_TRUE(VerifyDecode(parse_result, kExpectedMd5Sum));
110 } 108 }
111 109
112 TEST_F(VaapiJpegDecoderTest, DecodeFail) { 110 TEST_F(VaapiJpegDecoderTest, DecodeFail) {
113 media::JpegParseResult parse_result; 111 JpegParseResult parse_result;
114 ASSERT_TRUE(media::ParseJpegPicture( 112 ASSERT_TRUE(
115 reinterpret_cast<const uint8_t*>(jpeg_data_.data()), jpeg_data_.size(), 113 ParseJpegPicture(reinterpret_cast<const uint8_t*>(jpeg_data_.data()),
116 &parse_result)); 114 jpeg_data_.size(), &parse_result));
117 115
118 // Not supported by VAAPI. 116 // Not supported by VAAPI.
119 parse_result.frame_header.num_components = 1; 117 parse_result.frame_header.num_components = 1;
120 parse_result.scan.num_components = 1; 118 parse_result.scan.num_components = 1;
121 119
122 gfx::Size size(parse_result.frame_header.coded_width, 120 gfx::Size size(parse_result.frame_header.coded_width,
123 parse_result.frame_header.coded_height); 121 parse_result.frame_header.coded_height);
124 122
125 std::vector<VASurfaceID> va_surfaces; 123 std::vector<VASurfaceID> va_surfaces;
126 ASSERT_TRUE( 124 ASSERT_TRUE(
127 wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, size, 1, &va_surfaces)); 125 wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, size, 1, &va_surfaces));
128 126
129 EXPECT_FALSE( 127 EXPECT_FALSE(
130 VaapiJpegDecoder::Decode(wrapper_.get(), parse_result, va_surfaces[0])); 128 VaapiJpegDecoder::Decode(wrapper_.get(), parse_result, va_surfaces[0]));
131 } 129 }
132 130
133 } // namespace 131 } // namespace
134 } // namespace media 132 } // namespace media
135 133
136 int main(int argc, char** argv) { 134 int main(int argc, char** argv) {
137 testing::InitGoogleTest(&argc, argv); 135 testing::InitGoogleTest(&argc, argv);
138 base::AtExitManager exit_manager; 136 base::AtExitManager exit_manager;
139 media::VaapiWrapper::PreSandboxInitialization(); 137 media::VaapiWrapper::PreSandboxInitialization();
140 return RUN_ALL_TESTS(); 138 return RUN_ALL_TESTS();
141 } 139 }
OLDNEW
« no previous file with comments | « media/gpu/vaapi_jpeg_decoder.cc ('k') | media/gpu/vaapi_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698