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

Unified Diff: content/common/gpu/media/v4l2_video_decode_accelerator.cc

Issue 1207043002: Introduce a client minimum picture pool size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved constant to shared header, validate min_picture_size now in resource proxy as well as host co… Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/v4l2_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
index bc7d8e12b1c96a17cf64819e67e056d07bb8fff6..8d6f76572556afffce1512e1347a3c9155c54f86 100644
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
@@ -322,10 +322,13 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffers(
DVLOG(3) << "AssignPictureBuffers(): buffer_count=" << buffers.size();
DCHECK(child_task_runner_->BelongsToCurrentThread());
- if (buffers.size() != output_buffer_map_.size()) {
+ const uint32_t req_buffer_count =
+ output_dpb_size_ + kDpbOutputBufferExtraCount;
+
+ if (buffers.size() < req_buffer_count) {
LOG(ERROR) << "AssignPictureBuffers(): Failed to provide requested picture"
" buffers. (Got " << buffers.size()
- << ", requested " << output_buffer_map_.size() << ")";
+ << ", requested " << req_buffer_count << ")";
NOTIFY_ERROR(INVALID_ARGUMENT);
return;
}
@@ -340,6 +343,23 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffers(
// It's safe to manipulate all the buffer state here, because the decoder
// thread is waiting on pictures_assigned_.
+
+ // Allocate the output buffers.
+ struct v4l2_requestbuffers reqbufs;
+ memset(&reqbufs, 0, sizeof(reqbufs));
+ reqbufs.count = buffers.size();
+ reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ reqbufs.memory = V4L2_MEMORY_MMAP;
+ IOCTL_OR_ERROR_RETURN(VIDIOC_REQBUFS, &reqbufs);
+
+ if (reqbufs.count != buffers.size()) {
+ DLOG(ERROR) << "Could not allocate enough output buffers";
+ NOTIFY_ERROR(PLATFORM_FAILURE);
+ return;
+ }
+
+ output_buffer_map_.resize(buffers.size());
+
DCHECK(free_output_buffers_.empty());
for (size_t i = 0; i < output_buffer_map_.size(); ++i) {
DCHECK(buffers[i].size() == coded_size_);
@@ -1861,22 +1881,13 @@ bool V4L2VideoDecodeAccelerator::CreateOutputBuffers() {
// Output format setup in Initialize().
- // Allocate the output buffers.
- struct v4l2_requestbuffers reqbufs;
- memset(&reqbufs, 0, sizeof(reqbufs));
- reqbufs.count = output_dpb_size_ + kDpbOutputBufferExtraCount;
- reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- reqbufs.memory = V4L2_MEMORY_MMAP;
- IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs);
-
- output_buffer_map_.resize(reqbufs.count);
-
+ const uint32_t buffer_count = output_dpb_size_ + kDpbOutputBufferExtraCount;
DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): "
- << "buffer_count=" << output_buffer_map_.size()
+ << "buffer_count=" << buffer_count
<< ", coded_size=" << coded_size_.ToString();
child_task_runner_->PostTask(
FROM_HERE, base::Bind(&Client::ProvidePictureBuffers, client_,
- output_buffer_map_.size(), coded_size_,
+ buffer_count, coded_size_,
device_->GetTextureTarget()));
// Wait for the client to call AssignPictureBuffers() on the Child thread.

Powered by Google App Engine
This is Rietveld 408576698