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