OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 5 #include <string> |
6 | 6 |
7 // This has to be included first. | 7 // This has to be included first. |
8 // See http://code.google.com/p/googletest/issues/detail?id=371 | 8 // See http://code.google.com/p/googletest/issues/detail?id=371 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return true; | 160 return true; |
161 } | 161 } |
162 | 162 |
163 bool VaapiH264DecoderLoop::Run() { | 163 bool VaapiH264DecoderLoop::Run() { |
164 while (1) { | 164 while (1) { |
165 switch (decoder_->Decode()) { | 165 switch (decoder_->Decode()) { |
166 case VaapiH264Decoder::kDecodeError: | 166 case VaapiH264Decoder::kDecodeError: |
167 LOG(ERROR) << "Decode Error"; | 167 LOG(ERROR) << "Decode Error"; |
168 return false; | 168 return false; |
169 case VaapiH264Decoder::kAllocateNewSurfaces: | 169 case VaapiH264Decoder::kAllocateNewSurfaces: |
170 VLOG(1) << "Allocate new surfaces"; | 170 DVLOG(1) << "Allocate new surfaces"; |
171 if (!AllocateNewSurfaces()) { | 171 if (!AllocateNewSurfaces()) { |
172 LOG(ERROR) << "Failed to allocate new surfaces"; | 172 LOG(ERROR) << "Failed to allocate new surfaces"; |
173 return false; | 173 return false; |
174 } | 174 } |
175 break; | 175 break; |
176 case VaapiH264Decoder::kRanOutOfStreamData: { | 176 case VaapiH264Decoder::kRanOutOfStreamData: { |
177 bool rc = decoder_->Flush(); | 177 bool rc = decoder_->Flush(); |
178 VLOG(1) << "Flush returns " << rc; | 178 DVLOG(1) << "Flush returns " << rc; |
179 return rc; | 179 return rc; |
180 } | 180 } |
181 case VaapiH264Decoder::kRanOutOfSurfaces: | 181 case VaapiH264Decoder::kRanOutOfSurfaces: |
182 VLOG(1) << "Ran out of surfaces"; | 182 DVLOG(1) << "Ran out of surfaces"; |
183 RefillSurfaces(); | 183 RefillSurfaces(); |
184 break; | 184 break; |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 std::string VaapiH264DecoderLoop::GetMD5Sum() { | 189 std::string VaapiH264DecoderLoop::GetMD5Sum() { |
190 base::MD5Digest digest; | 190 base::MD5Digest digest; |
191 base::MD5Final(&digest, &md5_context_); | 191 base::MD5Final(&digest, &md5_context_); |
192 return MD5DigestToBase16(digest); | 192 return MD5DigestToBase16(digest); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 const char* buf = reinterpret_cast<const char*>(frame->data(i)); | 251 const char* buf = reinterpret_cast<const char*>(frame->data(i)); |
252 if (!base::AppendToFile(output_file_, buf, to_write)) | 252 if (!base::AppendToFile(output_file_, buf, to_write)) |
253 return false; | 253 return false; |
254 } | 254 } |
255 return true; | 255 return true; |
256 } | 256 } |
257 | 257 |
258 void VaapiH264DecoderLoop::OutputPicture( | 258 void VaapiH264DecoderLoop::OutputPicture( |
259 int32 input_id, | 259 int32 input_id, |
260 const scoped_refptr<VASurface>& va_surface) { | 260 const scoped_refptr<VASurface>& va_surface) { |
261 VLOG(1) << "OutputPicture: picture " << num_outputted_pictures_++; | 261 DVLOG(1) << "OutputPicture: picture " << num_outputted_pictures_++; |
262 | 262 |
263 VAImage image; | 263 VAImage image; |
264 void* mem; | 264 void* mem; |
265 | 265 |
266 if (!wrapper_->GetVaImageForTesting(va_surface->id(), &image, &mem)) { | 266 if (!wrapper_->GetVaImageForTesting(va_surface->id(), &image, &mem)) { |
267 LOG(ERROR) << "Cannot get VAImage."; | 267 LOG(ERROR) << "Cannot get VAImage."; |
268 return; | 268 return; |
269 } | 269 } |
270 | 270 |
271 if (image.format.fourcc != VA_FOURCC_NV12) { | 271 if (image.format.fourcc != VA_FOURCC_NV12) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 std::string md5sum = g_md5sum; | 321 std::string md5sum = g_md5sum; |
322 | 322 |
323 // If nothing specified, use the default file in the source tree. | 323 // If nothing specified, use the default file in the source tree. |
324 if (input_file.empty() && output_file.empty() && md5sum.empty()) { | 324 if (input_file.empty() && output_file.empty() && md5sum.empty()) { |
325 input_file = base::FilePath(kDefaultInputFile); | 325 input_file = base::FilePath(kDefaultInputFile); |
326 md5sum = kDefaultMD5Sum; | 326 md5sum = kDefaultMD5Sum; |
327 } else { | 327 } else { |
328 ASSERT_FALSE(input_file.empty()) << "Need to specify --input_file"; | 328 ASSERT_FALSE(input_file.empty()) << "Need to specify --input_file"; |
329 } | 329 } |
330 | 330 |
331 VLOG(1) << "Input File: " << input_file.value(); | 331 DVLOG(1) << "Input File: " << input_file.value(); |
332 VLOG(1) << "Output File: " << output_file.value(); | 332 DVLOG(1) << "Output File: " << output_file.value(); |
333 VLOG(1) << "Expected MD5 sum: " << md5sum; | 333 DVLOG(1) << "Expected MD5 sum: " << md5sum; |
334 | 334 |
335 content::VaapiH264DecoderLoop loop; | 335 content::VaapiH264DecoderLoop loop; |
336 ASSERT_TRUE(loop.Initialize(input_file, output_file)) | 336 ASSERT_TRUE(loop.Initialize(input_file, output_file)) |
337 << "initialize decoder loop failed"; | 337 << "initialize decoder loop failed"; |
338 ASSERT_TRUE(loop.Run()) << "run decoder loop failed"; | 338 ASSERT_TRUE(loop.Run()) << "run decoder loop failed"; |
339 | 339 |
340 if (!md5sum.empty()) { | 340 if (!md5sum.empty()) { |
341 std::string actual = loop.GetMD5Sum(); | 341 std::string actual = loop.GetMD5Sum(); |
342 VLOG(1) << "Actual MD5 sum: " << actual; | 342 DVLOG(1) << "Actual MD5 sum: " << actual; |
343 EXPECT_EQ(md5sum, actual); | 343 EXPECT_EQ(md5sum, actual); |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 } // namespace | 347 } // namespace |
348 } // namespace content | 348 } // namespace content |
349 | 349 |
350 int main(int argc, char** argv) { | 350 int main(int argc, char** argv) { |
351 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 351 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
352 base::CommandLine::Init(argc, argv); | 352 base::CommandLine::Init(argc, argv); |
(...skipping 23 matching lines...) Expand all Loading... |
376 content::g_md5sum = it->second; | 376 content::g_md5sum = it->second; |
377 continue; | 377 continue; |
378 } | 378 } |
379 if (it->first == "v" || it->first == "vmodule") | 379 if (it->first == "v" || it->first == "vmodule") |
380 continue; | 380 continue; |
381 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 381 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
382 } | 382 } |
383 | 383 |
384 return RUN_ALL_TESTS(); | 384 return RUN_ALL_TESTS(); |
385 } | 385 } |
OLD | NEW |