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 | |
526 // static | 522 // static |
527 media::VideoDecodeAccelerator::SupportedProfiles | 523 media::VideoDecodeAccelerator::SupportedProfiles |
528 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { | 524 V4L2VideoDecodeAccelerator::GetSupportedProfiles() { |
529 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 525 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
530 if (!device) | 526 if (!device) |
531 return SupportedProfiles(); | 527 return SupportedProfiles(); |
532 | 528 |
533 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_), | 529 return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_), |
534 supported_input_fourccs_); | 530 supported_input_fourccs_); |
535 } | 531 } |
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; | 2025 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; |
2030 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); | 2026 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); |
2031 output_dpb_size_ = ctrl.value; | 2027 output_dpb_size_ = ctrl.value; |
2032 | 2028 |
2033 // Output format setup in Initialize(). | 2029 // Output format setup in Initialize(). |
2034 | 2030 |
2035 const uint32_t buffer_count = output_dpb_size_ + kDpbOutputBufferExtraCount; | 2031 const uint32_t buffer_count = output_dpb_size_ + kDpbOutputBufferExtraCount; |
2036 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " | 2032 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " |
2037 << "buffer_count=" << buffer_count | 2033 << "buffer_count=" << buffer_count |
2038 << ", coded_size=" << egl_image_size_.ToString(); | 2034 << ", coded_size=" << egl_image_size_.ToString(); |
| 2035 |
2039 child_task_runner_->PostTask( | 2036 child_task_runner_->PostTask( |
2040 FROM_HERE, | 2037 FROM_HERE, base::Bind(&Client::ProvidePictureBuffers, client_, |
2041 base::Bind(&Client::ProvidePictureBuffers, client_, buffer_count, 1, | 2038 buffer_count, PIXEL_FORMAT_UNKNOWN, 1, |
2042 egl_image_size_, device_->GetTextureTarget())); | 2039 egl_image_size_, device_->GetTextureTarget())); |
2043 | 2040 |
2044 // Wait for the client to call AssignPictureBuffers() on the Child thread. | 2041 // Wait for the client to call AssignPictureBuffers() on the Child thread. |
2045 // We do this, because if we continue decoding without finishing buffer | 2042 // We do this, because if we continue decoding without finishing buffer |
2046 // allocation, we may end up Resetting before AssignPictureBuffers arrives, | 2043 // allocation, we may end up Resetting before AssignPictureBuffers arrives, |
2047 // resulting in unnecessary complications and subtle bugs. | 2044 // resulting in unnecessary complications and subtle bugs. |
2048 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) | 2045 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) |
2049 // 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 |
2050 // without waiting, we might end up running Reset{,Done}Task() before | 2047 // without waiting, we might end up running Reset{,Done}Task() before |
2051 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers | 2048 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers |
2052 // 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... |
2243 Enqueue(); | 2240 Enqueue(); |
2244 } | 2241 } |
2245 } | 2242 } |
2246 | 2243 |
2247 void V4L2VideoDecodeAccelerator::ImageProcessorError() { | 2244 void V4L2VideoDecodeAccelerator::ImageProcessorError() { |
2248 LOG(ERROR) << "Image processor error"; | 2245 LOG(ERROR) << "Image processor error"; |
2249 NOTIFY_ERROR(PLATFORM_FAILURE); | 2246 NOTIFY_ERROR(PLATFORM_FAILURE); |
2250 } | 2247 } |
2251 | 2248 |
2252 } // namespace media | 2249 } // namespace media |
OLD | NEW |