Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // This has to be included first. | 5 // This has to be included first. |
| 6 // See http://code.google.com/p/googletest/issues/detail?id=371 | 6 // See http://code.google.com/p/googletest/issues/detail?id=371 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 } | 170 } |
| 171 if (g_save_to_file) { | 171 if (g_save_to_file) { |
| 172 SaveToFile(bitstream_buffer_id); | 172 SaveToFile(bitstream_buffer_id); |
| 173 } | 173 } |
| 174 | 174 |
| 175 double difference = GetMeanAbsoluteDifference(bitstream_buffer_id); | 175 double difference = GetMeanAbsoluteDifference(bitstream_buffer_id); |
| 176 if (difference <= kDecodeSimilarityThreshold) { | 176 if (difference <= kDecodeSimilarityThreshold) { |
| 177 SetState(CS_DECODE_PASS); | 177 SetState(CS_DECODE_PASS); |
| 178 } else { | 178 } else { |
| 179 LOG(ERROR) << "The mean absolute difference between software and hardware " | 179 LOG(ERROR) << "The mean absolute difference between software and hardware " |
| 180 "decode is " | 180 << "decode is " << difference; |
| 181 << difference; | |
| 182 SetState(CS_ERROR); | 181 SetState(CS_ERROR); |
| 183 } | 182 } |
| 184 } | 183 } |
| 185 | 184 |
| 186 void JpegClient::NotifyError(int32_t bitstream_buffer_id, | 185 void JpegClient::NotifyError(int32_t bitstream_buffer_id, |
| 187 JpegDecodeAccelerator::Error error) { | 186 JpegDecodeAccelerator::Error error) { |
| 188 LOG(ERROR) << "Notifying of error " << error << " for buffer id " | 187 LOG(ERROR) << "Notifying of error " << error << " for buffer id " |
| 189 << bitstream_buffer_id; | 188 << bitstream_buffer_id; |
| 190 SetState(CS_ERROR); | 189 SetState(CS_ERROR); |
| 191 } | 190 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 TestImageFile* image_file = test_image_files_[bitstream_buffer_id]; | 247 TestImageFile* image_file = test_image_files_[bitstream_buffer_id]; |
| 249 | 248 |
| 250 PrepareMemory(bitstream_buffer_id); | 249 PrepareMemory(bitstream_buffer_id); |
| 251 | 250 |
| 252 base::SharedMemoryHandle dup_handle; | 251 base::SharedMemoryHandle dup_handle; |
| 253 dup_handle = base::SharedMemory::DuplicateHandle(in_shm_->handle()); | 252 dup_handle = base::SharedMemory::DuplicateHandle(in_shm_->handle()); |
| 254 media::BitstreamBuffer bitstream_buffer(bitstream_buffer_id, dup_handle, | 253 media::BitstreamBuffer bitstream_buffer(bitstream_buffer_id, dup_handle, |
| 255 image_file->data_str.size()); | 254 image_file->data_str.size()); |
| 256 scoped_refptr<media::VideoFrame> out_frame_ = | 255 scoped_refptr<media::VideoFrame> out_frame_ = |
| 257 media::VideoFrame::WrapExternalSharedMemory( | 256 media::VideoFrame::WrapExternalSharedMemory( |
| 258 media::PIXEL_FORMAT_I420, image_file->visible_size, | 257 media::PIXEL_FORMAT_I420, |
|
kcwu
2016/05/12 09:42:42
How about add comments at the end of each line?
It
Pawel Osciak
2016/05/13 06:07:22
Thanks for the suggestion, on the other hand, it m
| |
| 259 gfx::Rect(image_file->visible_size), image_file->visible_size, | 258 image_file->visible_size, |
| 260 static_cast<uint8_t*>(hw_out_shm_->memory()), image_file->output_size, | 259 gfx::Rect(image_file->visible_size), |
| 261 hw_out_shm_->handle(), 0, base::TimeDelta()); | 260 image_file->visible_size, |
| 261 static_cast<uint8_t*>(hw_out_shm_->memory()), | |
| 262 image_file->output_size, | |
| 263 hw_out_shm_->handle(), | |
| 264 0, | |
| 265 base::TimeDelta()); | |
| 262 LOG_ASSERT(out_frame_.get()); | 266 LOG_ASSERT(out_frame_.get()); |
| 263 decoder_->Decode(bitstream_buffer, out_frame_); | 267 decoder_->Decode(bitstream_buffer, out_frame_); |
| 264 } | 268 } |
| 265 | 269 |
| 266 bool JpegClient::GetSoftwareDecodeResult(int32_t bitstream_buffer_id) { | 270 bool JpegClient::GetSoftwareDecodeResult(int32_t bitstream_buffer_id) { |
| 267 media::VideoPixelFormat format = media::PIXEL_FORMAT_I420; | 271 media::VideoPixelFormat format = media::PIXEL_FORMAT_I420; |
| 268 TestImageFile* image_file = test_image_files_[bitstream_buffer_id]; | 272 TestImageFile* image_file = test_image_files_[bitstream_buffer_id]; |
| 269 | 273 |
| 270 uint8_t* yplane = static_cast<uint8_t*>(sw_out_shm_->memory()); | 274 uint8_t* yplane = static_cast<uint8_t*>(sw_out_shm_->memory()); |
| 271 uint8_t* uplane = | 275 uint8_t* uplane = |
| 272 yplane + | 276 yplane + |
| 273 media::VideoFrame::PlaneSize(format, media::VideoFrame::kYPlane, | 277 media::VideoFrame::PlaneSize(format, media::VideoFrame::kYPlane, |
| 274 image_file->visible_size) | 278 image_file->visible_size) |
| 275 .GetArea(); | 279 .GetArea(); |
| 276 uint8_t* vplane = | 280 uint8_t* vplane = |
| 277 uplane + | 281 uplane + |
| 278 media::VideoFrame::PlaneSize(format, media::VideoFrame::kUPlane, | 282 media::VideoFrame::PlaneSize(format, media::VideoFrame::kUPlane, |
| 279 image_file->visible_size) | 283 image_file->visible_size) |
| 280 .GetArea(); | 284 .GetArea(); |
| 281 int yplane_stride = image_file->visible_size.width(); | 285 int yplane_stride = image_file->visible_size.width(); |
| 282 int uv_plane_stride = yplane_stride / 2; | 286 int uv_plane_stride = yplane_stride / 2; |
| 283 | 287 |
| 284 if (libyuv::ConvertToI420( | 288 if (libyuv::ConvertToI420( |
| 285 static_cast<uint8_t*>(in_shm_->memory()), image_file->data_str.size(), | 289 static_cast<uint8_t*>(in_shm_->memory()), |
| 286 yplane, yplane_stride, uplane, uv_plane_stride, vplane, | 290 image_file->data_str.size(), |
| 287 uv_plane_stride, 0, 0, image_file->visible_size.width(), | 291 yplane, |
| 288 image_file->visible_size.height(), image_file->visible_size.width(), | 292 yplane_stride, |
| 289 image_file->visible_size.height(), libyuv::kRotate0, | 293 uplane, |
| 294 uv_plane_stride, | |
| 295 vplane, | |
| 296 uv_plane_stride, | |
| 297 0, | |
| 298 0, | |
| 299 image_file->visible_size.width(), | |
| 300 image_file->visible_size.height(), | |
| 301 image_file->visible_size.width(), | |
| 302 image_file->visible_size.height(), | |
| 303 libyuv::kRotate0, | |
| 290 libyuv::FOURCC_MJPG) != 0) { | 304 libyuv::FOURCC_MJPG) != 0) { |
| 291 LOG(ERROR) << "Software decode " << image_file->filename << " failed."; | 305 LOG(ERROR) << "Software decode " << image_file->filename << " failed."; |
| 292 return false; | 306 return false; |
| 293 } | 307 } |
| 294 return true; | 308 return true; |
| 295 } | 309 } |
| 296 | 310 |
| 297 class JpegDecodeAcceleratorTestEnvironment : public ::testing::Environment { | 311 class JpegDecodeAcceleratorTestEnvironment : public ::testing::Environment { |
| 298 public: | 312 public: |
| 299 JpegDecodeAcceleratorTestEnvironment( | 313 JpegDecodeAcceleratorTestEnvironment( |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 578 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 565 media::VaapiWrapper::PreSandboxInitialization(); | 579 media::VaapiWrapper::PreSandboxInitialization(); |
| 566 #endif | 580 #endif |
| 567 | 581 |
| 568 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( | 582 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( |
| 569 testing::AddGlobalTestEnvironment( | 583 testing::AddGlobalTestEnvironment( |
| 570 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); | 584 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); |
| 571 | 585 |
| 572 return RUN_ALL_TESTS(); | 586 return RUN_ALL_TESTS(); |
| 573 } | 587 } |
| OLD | NEW |