| 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 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { | 37 void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { |
| 38 // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this | 38 // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this |
| 39 // function is to just keep reference of |shm| to make sure it lives util | 39 // function is to just keep reference of |shm| to make sure it lives util |
| 40 // decode finishes. | 40 // decode finishes. |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool VerifyDecodeParams(const AcceleratedJpegDecoderMsg_Decode_Params& params) { | 43 bool VerifyDecodeParams(const AcceleratedJpegDecoderMsg_Decode_Params& params) { |
| 44 if (params.input_buffer_id < 0) { | |
| 45 LOG(ERROR) << "BitstreamBuffer id " << params.input_buffer_id | |
| 46 << " out of range"; | |
| 47 return false; | |
| 48 } | |
| 49 | |
| 50 const int kJpegMaxDimension = UINT16_MAX; | 44 const int kJpegMaxDimension = UINT16_MAX; |
| 51 if (params.coded_size.IsEmpty() || | 45 if (params.coded_size.IsEmpty() || |
| 52 params.coded_size.width() > kJpegMaxDimension || | 46 params.coded_size.width() > kJpegMaxDimension || |
| 53 params.coded_size.height() > kJpegMaxDimension) { | 47 params.coded_size.height() > kJpegMaxDimension) { |
| 54 LOG(ERROR) << "invalid coded_size " << params.coded_size.ToString(); | 48 LOG(ERROR) << "invalid coded_size " << params.coded_size.ToString(); |
| 55 return false; | 49 return false; |
| 56 } | 50 } |
| 57 | 51 |
| 58 if (!base::SharedMemory::IsHandleValid(params.input_buffer_handle)) { | |
| 59 LOG(ERROR) << "invalid input_buffer_handle"; | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 if (!base::SharedMemory::IsHandleValid(params.output_video_frame_handle)) { | 52 if (!base::SharedMemory::IsHandleValid(params.output_video_frame_handle)) { |
| 64 LOG(ERROR) << "invalid output_video_frame_handle"; | 53 LOG(ERROR) << "invalid output_video_frame_handle"; |
| 65 return false; | 54 return false; |
| 66 } | 55 } |
| 67 | 56 |
| 68 if (params.output_buffer_size < | 57 if (params.output_buffer_size < |
| 69 media::VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420, | 58 media::VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420, |
| 70 params.coded_size)) { | 59 params.coded_size)) { |
| 71 LOG(ERROR) << "output_buffer_size is too small: " | 60 LOG(ERROR) << "output_buffer_size is too small: " |
| 72 << params.output_buffer_size; | 61 << params.output_buffer_size; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 for (const auto& create_jda_function : create_jda_fps) { | 421 for (const auto& create_jda_function : create_jda_fps) { |
| 433 scoped_ptr<media::JpegDecodeAccelerator> accelerator = | 422 scoped_ptr<media::JpegDecodeAccelerator> accelerator = |
| 434 (*create_jda_function)(base::ThreadTaskRunnerHandle::Get()); | 423 (*create_jda_function)(base::ThreadTaskRunnerHandle::Get()); |
| 435 if (accelerator && accelerator->IsSupported()) | 424 if (accelerator && accelerator->IsSupported()) |
| 436 return true; | 425 return true; |
| 437 } | 426 } |
| 438 return false; | 427 return false; |
| 439 } | 428 } |
| 440 | 429 |
| 441 } // namespace content | 430 } // namespace content |
| OLD | NEW |