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

Side by Side Diff: content/common/gpu/media/v4l2_slice_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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <fcntl.h> 5 #include <fcntl.h>
6 #include <linux/videodev2.h> 6 #include <linux/videodev2.h>
7 #include <poll.h> 7 #include <poll.h>
8 #include <sys/eventfd.h> 8 #include <sys/eventfd.h>
9 #include <sys/ioctl.h> 9 #include <sys/ioctl.h>
10 #include <sys/mman.h> 10 #include <sys/mman.h>
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 coded_size_.SetSize(base::checked_cast<int>(format.fmt.pix_mp.width), 722 coded_size_.SetSize(base::checked_cast<int>(format.fmt.pix_mp.width),
723 base::checked_cast<int>(format.fmt.pix_mp.height)); 723 base::checked_cast<int>(format.fmt.pix_mp.height));
724 DCHECK_EQ(coded_size_.width() % 16, 0); 724 DCHECK_EQ(coded_size_.width() % 16, 0);
725 DCHECK_EQ(coded_size_.height() % 16, 0); 725 DCHECK_EQ(coded_size_.height() % 16, 0);
726 726
727 if (!gfx::Rect(coded_size_).Contains(gfx::Rect(visible_size_))) { 727 if (!gfx::Rect(coded_size_).Contains(gfx::Rect(visible_size_))) {
728 LOG(ERROR) << "Got invalid adjusted coded size: " << coded_size_.ToString(); 728 LOG(ERROR) << "Got invalid adjusted coded size: " << coded_size_.ToString();
729 return false; 729 return false;
730 } 730 }
731 731
732 struct v4l2_requestbuffers reqbufs; 732 DVLOGF(3) << "buffer_count=" << num_pictures
733 memset(&reqbufs, 0, sizeof(reqbufs));
734 reqbufs.count = num_pictures;
735 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
736 reqbufs.memory = V4L2_MEMORY_MMAP;
737 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs);
738
739 if (reqbufs.count < num_pictures) {
740 PLOG(ERROR) << "Could not allocate enough output buffers";
741 return false;
742 }
743
744 output_buffer_map_.resize(reqbufs.count);
745
746 DVLOGF(3) << "buffer_count=" << output_buffer_map_.size()
747 << ", visible size=" << visible_size_.ToString() 733 << ", visible size=" << visible_size_.ToString()
748 << ", coded size=" << coded_size_.ToString(); 734 << ", coded size=" << coded_size_.ToString();
749 735
750 child_task_runner_->PostTask( 736 child_task_runner_->PostTask(
751 FROM_HERE, 737 FROM_HERE,
752 base::Bind(&VideoDecodeAccelerator::Client::ProvidePictureBuffers, 738 base::Bind(&VideoDecodeAccelerator::Client::ProvidePictureBuffers,
753 client_, output_buffer_map_.size(), coded_size_, 739 client_, num_pictures, coded_size_,
754 device_->GetTextureTarget())); 740 device_->GetTextureTarget()));
755 741
756 // Wait for the client to call AssignPictureBuffers() on the Child thread. 742 // Wait for the client to call AssignPictureBuffers() on the Child thread.
757 // We do this, because if we continue decoding without finishing buffer 743 // We do this, because if we continue decoding without finishing buffer
758 // allocation, we may end up Resetting before AssignPictureBuffers arrives, 744 // allocation, we may end up Resetting before AssignPictureBuffers arrives,
759 // resulting in unnecessary complications and subtle bugs. 745 // resulting in unnecessary complications and subtle bugs.
760 pictures_assigned_.Wait(); 746 pictures_assigned_.Wait();
761 747
762 return true; 748 return true;
763 } 749 }
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs); 1411 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs);
1426 1412
1427 return true; 1413 return true;
1428 } 1414 }
1429 1415
1430 void V4L2SliceVideoDecodeAccelerator::AssignPictureBuffers( 1416 void V4L2SliceVideoDecodeAccelerator::AssignPictureBuffers(
1431 const std::vector<media::PictureBuffer>& buffers) { 1417 const std::vector<media::PictureBuffer>& buffers) {
1432 DVLOGF(3); 1418 DVLOGF(3);
1433 DCHECK(child_task_runner_->BelongsToCurrentThread()); 1419 DCHECK(child_task_runner_->BelongsToCurrentThread());
1434 1420
1435 if (buffers.size() != output_buffer_map_.size()) { 1421 const uint32_t req_buffer_count = decoder_->GetRequiredNumOfPictures();
1422
1423 if (buffers.size() < req_buffer_count) {
1436 DLOG(ERROR) << "Failed to provide requested picture buffers. " 1424 DLOG(ERROR) << "Failed to provide requested picture buffers. "
1437 << "(Got " << buffers.size() 1425 << "(Got " << buffers.size()
1438 << ", requested " << output_buffer_map_.size() << ")"; 1426 << ", requested " << req_buffer_count << ")";
1439 NOTIFY_ERROR(INVALID_ARGUMENT); 1427 NOTIFY_ERROR(INVALID_ARGUMENT);
1440 return; 1428 return;
1441 } 1429 }
1442 1430
1443 if (!make_context_current_.Run()) { 1431 if (!make_context_current_.Run()) {
1444 DLOG(ERROR) << "could not make context current"; 1432 DLOG(ERROR) << "could not make context current";
1445 NOTIFY_ERROR(PLATFORM_FAILURE); 1433 NOTIFY_ERROR(PLATFORM_FAILURE);
1446 return; 1434 return;
1447 } 1435 }
1448 1436
1449 gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0); 1437 gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0);
1450 1438
1451 // It's safe to manipulate all the buffer state here, because the decoder 1439 // It's safe to manipulate all the buffer state here, because the decoder
1452 // thread is waiting on pictures_assigned_. 1440 // thread is waiting on pictures_assigned_.
1441
1442 // Allocate the output buffers.
1443 struct v4l2_requestbuffers reqbufs;
1444 memset(&reqbufs, 0, sizeof(reqbufs));
1445 reqbufs.count = buffers.size();
1446 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1447 reqbufs.memory = V4L2_MEMORY_MMAP;
1448 IOCTL_OR_ERROR_RETURN(VIDIOC_REQBUFS, &reqbufs);
1449
1450 if (reqbufs.count != buffers.size()) {
1451 DLOG(ERROR) << "Could not allocate enough output buffers";
1452 NOTIFY_ERROR(PLATFORM_FAILURE);
1453 return;
1454 }
1455
1456 output_buffer_map_.resize(buffers.size());
1457
1453 DCHECK(free_output_buffers_.empty()); 1458 DCHECK(free_output_buffers_.empty());
1454 for (size_t i = 0; i < output_buffer_map_.size(); ++i) { 1459 for (size_t i = 0; i < output_buffer_map_.size(); ++i) {
1455 DCHECK(buffers[i].size() == coded_size_); 1460 DCHECK(buffers[i].size() == coded_size_);
1456 1461
1457 OutputRecord& output_record = output_buffer_map_[i]; 1462 OutputRecord& output_record = output_buffer_map_[i];
1458 DCHECK(!output_record.at_device); 1463 DCHECK(!output_record.at_device);
1459 DCHECK(!output_record.at_client); 1464 DCHECK(!output_record.at_client);
1460 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR); 1465 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR);
1461 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); 1466 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR);
1462 DCHECK_EQ(output_record.picture_id, -1); 1467 DCHECK_EQ(output_record.picture_id, -1);
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 if (!device) 2533 if (!device)
2529 return SupportedProfiles(); 2534 return SupportedProfiles();
2530 2535
2531 const uint32_t supported_formats[] = { 2536 const uint32_t supported_formats[] = {
2532 V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME}; 2537 V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME};
2533 return device->GetSupportedDecodeProfiles(arraysize(supported_formats), 2538 return device->GetSupportedDecodeProfiles(arraysize(supported_formats),
2534 supported_formats); 2539 supported_formats);
2535 } 2540 }
2536 2541
2537 } // namespace content 2542 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator.cc ('k') | content/common/gpu/media/v4l2_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698