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

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

Issue 1822983002: Support external buffer import in VDA interface and add a V4L2SVDA impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <string.h> 10 #include <string.h>
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 DCHECK(input_buffer_map_.empty()); 198 DCHECK(input_buffer_map_.empty());
199 DCHECK(output_buffer_map_.empty()); 199 DCHECK(output_buffer_map_.empty());
200 } 200 }
201 201
202 bool V4L2VideoDecodeAccelerator::Initialize(const Config& config, 202 bool V4L2VideoDecodeAccelerator::Initialize(const Config& config,
203 Client* client) { 203 Client* client) {
204 DVLOG(3) << "Initialize()"; 204 DVLOG(3) << "Initialize()";
205 DCHECK(child_task_runner_->BelongsToCurrentThread()); 205 DCHECK(child_task_runner_->BelongsToCurrentThread());
206 DCHECK_EQ(decoder_state_, kUninitialized); 206 DCHECK_EQ(decoder_state_, kUninitialized);
207 207
208 if (get_gl_context_cb_.is_null() || make_context_current_cb_.is_null()) { 208 if (!device_->SupportsDecodeProfileForV4L2PixelFormats(
209 NOTREACHED() << "GL callbacks are required for this VDA"; 209 config.profile, arraysize(supported_input_fourccs_),
210 supported_input_fourccs_)) {
211 DVLOG(1) << "Initialize(): unsupported profile=" << config.profile;
210 return false; 212 return false;
211 } 213 }
212 214
213 if (config.is_encrypted) { 215 if (config.is_encrypted) {
214 NOTREACHED() << "Encrypted streams are not supported for this VDA"; 216 NOTREACHED() << "Encrypted streams are not supported for this VDA";
215 return false; 217 return false;
216 } 218 }
217 219
218 if (!device_->SupportsDecodeProfileForV4L2PixelFormats( 220 if (config.output_mode != Config::OutputMode::ALLOCATE) {
219 config.profile, arraysize(supported_input_fourccs_), 221 NOTREACHED() << "Only ALLOCATE OutputMode is supported by this VDA";
220 supported_input_fourccs_)) {
221 DVLOG(1) << "Initialize(): unsupported profile=" << config.profile;
222 return false; 222 return false;
223 } 223 }
224 224
225 if (get_gl_context_cb_.is_null() || make_context_current_cb_.is_null()) {
226 NOTREACHED() << "GL callbacks are required for this VDA";
227 return false;
228 }
229
225 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); 230 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
226 client_ = client_ptr_factory_->GetWeakPtr(); 231 client_ = client_ptr_factory_->GetWeakPtr();
227 // If we haven't been set up to decode on separate thread via 232 // If we haven't been set up to decode on separate thread via
228 // TryToSetupDecodeOnSeparateThread(), use the main thread/client for 233 // TryToSetupDecodeOnSeparateThread(), use the main thread/client for
229 // decode tasks. 234 // decode tasks.
230 if (!decode_task_runner_) { 235 if (!decode_task_runner_) {
231 decode_task_runner_ = child_task_runner_; 236 decode_task_runner_ = child_task_runner_;
232 DCHECK(!decode_client_); 237 DCHECK(!decode_client_);
233 decode_client_ = client_; 238 decode_client_ = client_;
234 } 239 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 DCHECK(buffers[i].size() == coded_size_); 372 DCHECK(buffers[i].size() == coded_size_);
368 373
369 OutputRecord& output_record = output_buffer_map_[i]; 374 OutputRecord& output_record = output_buffer_map_[i];
370 DCHECK(!output_record.at_device); 375 DCHECK(!output_record.at_device);
371 DCHECK(!output_record.at_client); 376 DCHECK(!output_record.at_client);
372 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR); 377 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR);
373 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); 378 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR);
374 DCHECK_EQ(output_record.picture_id, -1); 379 DCHECK_EQ(output_record.picture_id, -1);
375 DCHECK_EQ(output_record.cleared, false); 380 DCHECK_EQ(output_record.cleared, false);
376 381
382 std::vector<base::ScopedFD> dmabuf_fds;
383 dmabuf_fds = device_->GetDmabufsForV4L2Buffer(
384 i, output_planes_count_, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
385 if (dmabuf_fds.empty()) {
386 NOTIFY_ERROR(PLATFORM_FAILURE);
387 return;
388 }
389
377 EGLImageKHR egl_image = device_->CreateEGLImage(egl_display_, 390 EGLImageKHR egl_image = device_->CreateEGLImage(egl_display_,
378 gl_context->GetHandle(), 391 gl_context->GetHandle(),
379 buffers[i].texture_id(), 392 buffers[i].texture_id(),
380 coded_size_, 393 coded_size_,
381 i, 394 i,
382 output_format_fourcc_, 395 output_format_fourcc_,
383 output_planes_count_); 396 dmabuf_fds);
384 if (egl_image == EGL_NO_IMAGE_KHR) { 397 if (egl_image == EGL_NO_IMAGE_KHR) {
385 LOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; 398 LOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR";
386 // Ownership of EGLImages allocated in previous iterations of this loop 399 // Ownership of EGLImages allocated in previous iterations of this loop
387 // has been transferred to output_buffer_map_. After we error-out here 400 // has been transferred to output_buffer_map_. After we error-out here
388 // the destructor will handle their cleanup. 401 // the destructor will handle their cleanup.
389 NOTIFY_ERROR(PLATFORM_FAILURE); 402 NOTIFY_ERROR(PLATFORM_FAILURE);
390 return; 403 return;
391 } 404 }
392 405
393 output_record.egl_image = egl_image; 406 output_record.egl_image = egl_image;
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 2059
2047 void V4L2VideoDecodeAccelerator::PictureCleared() { 2060 void V4L2VideoDecodeAccelerator::PictureCleared() {
2048 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; 2061 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_;
2049 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); 2062 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
2050 DCHECK_GT(picture_clearing_count_, 0); 2063 DCHECK_GT(picture_clearing_count_, 0);
2051 picture_clearing_count_--; 2064 picture_clearing_count_--;
2052 SendPictureReady(); 2065 SendPictureReady();
2053 } 2066 }
2054 2067
2055 } // namespace content 2068 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698