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

Side by Side 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: Created 5 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 <dlfcn.h> 5 #include <dlfcn.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/videodev2.h> 8 #include <linux/videodev2.h>
9 #include <poll.h> 9 #include <poll.h>
10 #include <sys/eventfd.h> 10 #include <sys/eventfd.h>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 output_dpb_size_(0), 185 output_dpb_size_(0),
186 output_planes_count_(0), 186 output_planes_count_(0),
187 picture_clearing_count_(0), 187 picture_clearing_count_(0),
188 pictures_assigned_(false, false), 188 pictures_assigned_(false, false),
189 device_poll_thread_("V4L2DevicePollThread"), 189 device_poll_thread_("V4L2DevicePollThread"),
190 make_context_current_(make_context_current), 190 make_context_current_(make_context_current),
191 egl_display_(egl_display), 191 egl_display_(egl_display),
192 egl_context_(egl_context), 192 egl_context_(egl_context),
193 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), 193 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN),
194 output_format_fourcc_(0), 194 output_format_fourcc_(0),
195 min_picture_count_(0),
195 weak_this_factory_(this) { 196 weak_this_factory_(this) {
196 weak_this_ = weak_this_factory_.GetWeakPtr(); 197 weak_this_ = weak_this_factory_.GetWeakPtr();
197 } 198 }
198 199
199 V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() { 200 V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() {
200 DCHECK(!decoder_thread_.IsRunning()); 201 DCHECK(!decoder_thread_.IsRunning());
201 DCHECK(!device_poll_thread_.IsRunning()); 202 DCHECK(!device_poll_thread_.IsRunning());
202 203
203 DestroyInputBuffers(); 204 DestroyInputBuffers();
204 DestroyOutputBuffers(); 205 DestroyOutputBuffers();
205 206
206 // These maps have members that should be manually destroyed, e.g. file 207 // These maps have members that should be manually destroyed, e.g. file
207 // descriptors, mmap() segments, etc. 208 // descriptors, mmap() segments, etc.
208 DCHECK(input_buffer_map_.empty()); 209 DCHECK(input_buffer_map_.empty());
209 DCHECK(output_buffer_map_.empty()); 210 DCHECK(output_buffer_map_.empty());
210 } 211 }
211 212
212 bool V4L2VideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, 213 bool V4L2VideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
214 uint32_t min_picture_count,
213 Client* client) { 215 Client* client) {
214 DVLOG(3) << "Initialize()"; 216 DVLOG(3) << "Initialize()";
215 DCHECK(child_task_runner_->BelongsToCurrentThread()); 217 DCHECK(child_task_runner_->BelongsToCurrentThread());
216 DCHECK_EQ(decoder_state_, kUninitialized); 218 DCHECK_EQ(decoder_state_, kUninitialized);
217 219
218 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 220 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
219 client_ = client_ptr_factory_->GetWeakPtr(); 221 client_ = client_ptr_factory_->GetWeakPtr();
220 222
221 switch (profile) { 223 switch (profile) {
222 case media::H264PROFILE_BASELINE: 224 case media::H264PROFILE_BASELINE:
223 DVLOG(2) << "Initialize(): profile H264PROFILE_BASELINE"; 225 DVLOG(2) << "Initialize(): profile H264PROFILE_BASELINE";
224 break; 226 break;
225 case media::H264PROFILE_MAIN: 227 case media::H264PROFILE_MAIN:
226 DVLOG(2) << "Initialize(): profile H264PROFILE_MAIN"; 228 DVLOG(2) << "Initialize(): profile H264PROFILE_MAIN";
227 break; 229 break;
228 case media::H264PROFILE_HIGH: 230 case media::H264PROFILE_HIGH:
229 DVLOG(2) << "Initialize(): profile H264PROFILE_HIGH"; 231 DVLOG(2) << "Initialize(): profile H264PROFILE_HIGH";
230 break; 232 break;
231 case media::VP8PROFILE_ANY: 233 case media::VP8PROFILE_ANY:
232 DVLOG(2) << "Initialize(): profile VP8PROFILE_ANY"; 234 DVLOG(2) << "Initialize(): profile VP8PROFILE_ANY";
233 break; 235 break;
234 case media::VP9PROFILE_ANY: 236 case media::VP9PROFILE_ANY:
235 DVLOG(2) << "Initialize(): profile VP9PROFILE_ANY"; 237 DVLOG(2) << "Initialize(): profile VP9PROFILE_ANY";
236 break; 238 break;
237 default: 239 default:
238 DLOG(ERROR) << "Initialize(): unsupported profile=" << profile; 240 DLOG(ERROR) << "Initialize(): unsupported profile=" << profile;
239 return false; 241 return false;
240 }; 242 };
241 video_profile_ = profile; 243 video_profile_ = profile;
244 min_picture_count_ = min_picture_count;
242 245
243 if (egl_display_ == EGL_NO_DISPLAY) { 246 if (egl_display_ == EGL_NO_DISPLAY) {
244 LOG(ERROR) << "Initialize(): could not get EGLDisplay"; 247 LOG(ERROR) << "Initialize(): could not get EGLDisplay";
245 return false; 248 return false;
246 } 249 }
247 250
248 // We need the context to be initialized to query extensions. 251 // We need the context to be initialized to query extensions.
249 if (!make_context_current_.Run()) { 252 if (!make_context_current_.Run()) {
250 LOG(ERROR) << "Initialize(): could not make context current"; 253 LOG(ERROR) << "Initialize(): could not make context current";
251 return false; 254 return false;
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 memset(&ctrl, 0, sizeof(ctrl)); 1832 memset(&ctrl, 0, sizeof(ctrl));
1830 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; 1833 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE;
1831 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); 1834 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl);
1832 output_dpb_size_ = ctrl.value; 1835 output_dpb_size_ = ctrl.value;
1833 1836
1834 // Output format setup in Initialize(). 1837 // Output format setup in Initialize().
1835 1838
1836 // Allocate the output buffers. 1839 // Allocate the output buffers.
1837 struct v4l2_requestbuffers reqbufs; 1840 struct v4l2_requestbuffers reqbufs;
1838 memset(&reqbufs, 0, sizeof(reqbufs)); 1841 memset(&reqbufs, 0, sizeof(reqbufs));
1839 reqbufs.count = output_dpb_size_ + kDpbOutputBufferExtraCount; 1842 reqbufs.count = std::max(min_picture_count_,
1843 static_cast<uint32_t>(
1844 output_dpb_size_ + kDpbOutputBufferExtraCount));
1840 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 1845 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1841 reqbufs.memory = V4L2_MEMORY_MMAP; 1846 reqbufs.memory = V4L2_MEMORY_MMAP;
1842 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs); 1847 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs);
1843 1848
1844 output_buffer_map_.resize(reqbufs.count); 1849 output_buffer_map_.resize(reqbufs.count);
1845 1850
1846 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " 1851 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): "
1847 << "buffer_count=" << output_buffer_map_.size() 1852 << "buffer_count=" << output_buffer_map_.size()
1848 << ", coded_size=" << coded_size_.ToString(); 1853 << ", coded_size=" << coded_size_.ToString();
1849 child_task_runner_->PostTask( 1854 child_task_runner_->PostTask(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width), 2033 gfx::Size new_coded_size(base::checked_cast<int>(format.fmt.pix_mp.width),
2029 base::checked_cast<int>(format.fmt.pix_mp.height)); 2034 base::checked_cast<int>(format.fmt.pix_mp.height));
2030 if (coded_size_ != new_coded_size) { 2035 if (coded_size_ != new_coded_size) {
2031 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; 2036 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected";
2032 return true; 2037 return true;
2033 } 2038 }
2034 return false; 2039 return false;
2035 } 2040 }
2036 2041
2037 } // namespace content 2042 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698