| 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 "media/gpu/v4l2_video_decode_accelerator.h" | 5 #include "media/gpu/v4l2_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <linux/videodev2.h> | 10 #include <linux/videodev2.h> |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 512 } |
| 513 | 513 |
| 514 bool V4L2VideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( | 514 bool V4L2VideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( |
| 515 const base::WeakPtr<Client>& decode_client, | 515 const base::WeakPtr<Client>& decode_client, |
| 516 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { | 516 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { |
| 517 decode_client_ = decode_client_; | 517 decode_client_ = decode_client_; |
| 518 decode_task_runner_ = decode_task_runner; | 518 decode_task_runner_ = decode_task_runner; |
| 519 return true; | 519 return true; |
| 520 } | 520 } |
| 521 | 521 |
| 522 media::VideoPixelFormat V4L2VideoDecodeAccelerator::GetOutputFormat() const { |
| 523 return V4L2Device::V4L2PixFmtToVideoPixelFormat(egl_image_format_fourcc_); |
| 524 } |
| 525 |
| 522 // static | 526 // static |
| 523 media::VideoDecodeAccelerator::SupportedProfiles | 527 media::VideoDecodeAccelerator::SupportedProfiles |
| 524 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { | 528 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { |
| 525 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 529 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 526 if (!device) | 530 if (!device) |
| 527 return SupportedProfiles(); | 531 return SupportedProfiles(); |
| 528 | 532 |
| 529 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_), | 533 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_), |
| 530 supported_input_fourccs_); | 534 supported_input_fourccs_); |
| 531 } | 535 } |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; | 2029 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; |
| 2026 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); | 2030 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); |
| 2027 output_dpb_size_ = ctrl.value; | 2031 output_dpb_size_ = ctrl.value; |
| 2028 | 2032 |
| 2029 // Output format setup in Initialize(). | 2033 // Output format setup in Initialize(). |
| 2030 | 2034 |
| 2031 const uint32_t buffer_count = output_dpb_size_ + kDpbOutputBufferExtraCount; | 2035 const uint32_t buffer_count = output_dpb_size_ + kDpbOutputBufferExtraCount; |
| 2032 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " | 2036 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " |
| 2033 << "buffer_count=" << buffer_count | 2037 << "buffer_count=" << buffer_count |
| 2034 << ", coded_size=" << egl_image_size_.ToString(); | 2038 << ", coded_size=" << egl_image_size_.ToString(); |
| 2035 | |
| 2036 DCHECK(egl_image_format_fourcc_); | |
| 2037 VideoPixelFormat pixel_format = | |
| 2038 V4L2Device::V4L2PixFmtToVideoPixelFormat(egl_image_format_fourcc_); | |
| 2039 | |
| 2040 child_task_runner_->PostTask( | 2039 child_task_runner_->PostTask( |
| 2041 FROM_HERE, base::Bind(&Client::ProvidePictureBuffers, client_, | 2040 FROM_HERE, |
| 2042 buffer_count, pixel_format, 1, egl_image_size_, | 2041 base::Bind(&Client::ProvidePictureBuffers, client_, buffer_count, 1, |
| 2043 device_->GetTextureTarget())); | 2042 egl_image_size_, device_->GetTextureTarget())); |
| 2044 | 2043 |
| 2045 // Wait for the client to call AssignPictureBuffers() on the Child thread. | 2044 // Wait for the client to call AssignPictureBuffers() on the Child thread. |
| 2046 // We do this, because if we continue decoding without finishing buffer | 2045 // We do this, because if we continue decoding without finishing buffer |
| 2047 // allocation, we may end up Resetting before AssignPictureBuffers arrives, | 2046 // allocation, we may end up Resetting before AssignPictureBuffers arrives, |
| 2048 // resulting in unnecessary complications and subtle bugs. | 2047 // resulting in unnecessary complications and subtle bugs. |
| 2049 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) | 2048 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) |
| 2050 // in a sequence, and Decode(Input1) results in us getting here and exiting | 2049 // in a sequence, and Decode(Input1) results in us getting here and exiting |
| 2051 // without waiting, we might end up running Reset{,Done}Task() before | 2050 // without waiting, we might end up running Reset{,Done}Task() before |
| 2052 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers | 2051 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers |
| 2053 // to the free_output_buffers_ map twice. If we somehow marked buffers as | 2052 // to the free_output_buffers_ map twice. If we somehow marked buffers as |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 Enqueue(); | 2243 Enqueue(); |
| 2245 } | 2244 } |
| 2246 } | 2245 } |
| 2247 | 2246 |
| 2248 void V4L2VideoDecodeAccelerator::ImageProcessorError() { | 2247 void V4L2VideoDecodeAccelerator::ImageProcessorError() { |
| 2249 LOG(ERROR) << "Image processor error"; | 2248 LOG(ERROR) << "Image processor error"; |
| 2250 NOTIFY_ERROR(PLATFORM_FAILURE); | 2249 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 2251 } | 2250 } |
| 2252 | 2251 |
| 2253 } // namespace media | 2252 } // namespace media |
| OLD | NEW |