Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: media/gpu/v4l2_video_decode_accelerator.cc

Issue 1942123002: Plumb decoded video pixel format from GPU process to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
2036 DCHECK(egl_image_format_fourcc_);
2037 VideoPixelFormat pixel_format =
2038 V4L2Device::V4L2PixFmtToVideoPixelFormat(egl_image_format_fourcc_);
2039
2039 child_task_runner_->PostTask( 2040 child_task_runner_->PostTask(
2040 FROM_HERE, 2041 FROM_HERE, base::Bind(&Client::ProvidePictureBuffers, client_,
2041 base::Bind(&Client::ProvidePictureBuffers, client_, buffer_count, 1, 2042 buffer_count, pixel_format, 1, egl_image_size_,
2042 egl_image_size_, device_->GetTextureTarget())); 2043 device_->GetTextureTarget()));
2043 2044
2044 // Wait for the client to call AssignPictureBuffers() on the Child thread. 2045 // Wait for the client to call AssignPictureBuffers() on the Child thread.
2045 // We do this, because if we continue decoding without finishing buffer 2046 // We do this, because if we continue decoding without finishing buffer
2046 // allocation, we may end up Resetting before AssignPictureBuffers arrives, 2047 // allocation, we may end up Resetting before AssignPictureBuffers arrives,
2047 // resulting in unnecessary complications and subtle bugs. 2048 // resulting in unnecessary complications and subtle bugs.
2048 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) 2049 // 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 2050 // 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 2051 // without waiting, we might end up running Reset{,Done}Task() before
2051 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers 2052 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers
2052 // to the free_output_buffers_ map twice. If we somehow marked buffers as 2053 // 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
2243 Enqueue(); 2244 Enqueue();
2244 } 2245 }
2245 } 2246 }
2246 2247
2247 void V4L2VideoDecodeAccelerator::ImageProcessorError() { 2248 void V4L2VideoDecodeAccelerator::ImageProcessorError() {
2248 LOG(ERROR) << "Image processor error"; 2249 LOG(ERROR) << "Image processor error";
2249 NOTIFY_ERROR(PLATFORM_FAILURE); 2250 NOTIFY_ERROR(PLATFORM_FAILURE);
2250 } 2251 }
2251 2252
2252 } // namespace media 2253 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698