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

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

Issue 23125014: Run VDA::Decode on GPU IO thread if VDA supports it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix try bot errors Created 7 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 picture_id(-1) { 198 picture_id(-1) {
199 } 199 }
200 200
201 ExynosVideoDecodeAccelerator::GscOutputRecord::~GscOutputRecord() { 201 ExynosVideoDecodeAccelerator::GscOutputRecord::~GscOutputRecord() {
202 } 202 }
203 203
204 ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator( 204 ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator(
205 EGLDisplay egl_display, 205 EGLDisplay egl_display,
206 EGLContext egl_context, 206 EGLContext egl_context,
207 Client* client, 207 Client* client,
208 const base::Callback<bool(void)>& make_context_current) 208 const base::Callback<bool(void)>& make_context_current,
209 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy)
209 : child_message_loop_proxy_(base::MessageLoopProxy::current()), 210 : child_message_loop_proxy_(base::MessageLoopProxy::current()),
211 io_message_loop_proxy_(io_message_loop_proxy),
210 weak_this_(base::AsWeakPtr(this)), 212 weak_this_(base::AsWeakPtr(this)),
211 client_ptr_factory_(client), 213 client_ptr_factory_(client),
212 client_(client_ptr_factory_.GetWeakPtr()), 214 client_(client_ptr_factory_.GetWeakPtr()),
213 decoder_thread_("ExynosDecoderThread"), 215 decoder_thread_("ExynosDecoderThread"),
214 decoder_state_(kUninitialized), 216 decoder_state_(kUninitialized),
215 decoder_delay_bitstream_buffer_id_(-1), 217 decoder_delay_bitstream_buffer_id_(-1),
216 decoder_current_input_buffer_(-1), 218 decoder_current_input_buffer_(-1),
217 decoder_decode_buffer_tasks_scheduled_(0), 219 decoder_decode_buffer_tasks_scheduled_(0),
218 decoder_frames_at_client_(0), 220 decoder_frames_at_client_(0),
219 decoder_flushing_(false), 221 decoder_flushing_(false),
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 410
409 child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind( 411 child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind(
410 &Client::NotifyInitializeDone, client_)); 412 &Client::NotifyInitializeDone, client_));
411 return true; 413 return true;
412 } 414 }
413 415
414 void ExynosVideoDecodeAccelerator::Decode( 416 void ExynosVideoDecodeAccelerator::Decode(
415 const media::BitstreamBuffer& bitstream_buffer) { 417 const media::BitstreamBuffer& bitstream_buffer) {
416 DVLOG(1) << "Decode(): input_id=" << bitstream_buffer.id() 418 DVLOG(1) << "Decode(): input_id=" << bitstream_buffer.id()
417 << ", size=" << bitstream_buffer.size(); 419 << ", size=" << bitstream_buffer.size();
418 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 420 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
419
420 scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef(
421 client_, child_message_loop_proxy_,
422 new base::SharedMemory(bitstream_buffer.handle(), true),
423 bitstream_buffer.size(), bitstream_buffer.id()));
424 if (!bitstream_record->shm->Map(bitstream_buffer.size())) {
425 DLOG(ERROR) << "Decode(): could not map bitstream_buffer";
426 NOTIFY_ERROR(UNREADABLE_INPUT);
427 return;
428 }
429 DVLOG(3) << "Decode(): mapped to addr=" << bitstream_record->shm->memory();
430 421
431 // DecodeTask() will take care of running a DecodeBufferTask(). 422 // DecodeTask() will take care of running a DecodeBufferTask().
432 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 423 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
433 &ExynosVideoDecodeAccelerator::DecodeTask, base::Unretained(this), 424 &ExynosVideoDecodeAccelerator::DecodeTask, base::Unretained(this),
434 base::Passed(&bitstream_record))); 425 bitstream_buffer));
435 } 426 }
436 427
437 void ExynosVideoDecodeAccelerator::AssignPictureBuffers( 428 void ExynosVideoDecodeAccelerator::AssignPictureBuffers(
438 const std::vector<media::PictureBuffer>& buffers) { 429 const std::vector<media::PictureBuffer>& buffers) {
439 DVLOG(3) << "AssignPictureBuffers(): buffer_count=" << buffers.size(); 430 DVLOG(3) << "AssignPictureBuffers(): buffer_count=" << buffers.size();
440 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 431 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
441 432
442 if (buffers.size() != gsc_output_buffer_map_.size()) { 433 if (buffers.size() != gsc_output_buffer_map_.size()) {
443 DLOG(ERROR) << "AssignPictureBuffers(): Failed to provide requested picture" 434 DLOG(ERROR) << "AssignPictureBuffers(): Failed to provide requested picture"
444 " buffers. (Got " << buffers.size() << ", requested " << 435 " buffers. (Got " << buffers.size() << ", requested " <<
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 if (mali_egl_image_get_buffer_ext_phandle == NULL) { 594 if (mali_egl_image_get_buffer_ext_phandle == NULL) {
604 DPLOG(ERROR) << "PostSandboxInitialization(): failed to dlsym() " 595 DPLOG(ERROR) << "PostSandboxInitialization(): failed to dlsym() "
605 << "mali_egl_image_get_buffer_ext_phandle: " << dlerror(); 596 << "mali_egl_image_get_buffer_ext_phandle: " << dlerror();
606 return false; 597 return false;
607 } 598 }
608 599
609 return true; 600 return true;
610 } 601 }
611 602
612 void ExynosVideoDecodeAccelerator::DecodeTask( 603 void ExynosVideoDecodeAccelerator::DecodeTask(
613 scoped_ptr<BitstreamBufferRef> bitstream_record) { 604 const media::BitstreamBuffer& bitstream_buffer) {
Ami GONE FROM CHROMIUM 2013/08/27 17:10:33 This is problematic: bitstream_buffer may go out o
Pawel Osciak 2013/08/28 08:36:49 Probably. Or create BBR in Decode and only Map() h
wuchengli 2013/08/28 13:18:21 This should be OK. callback.h says "By default Bin
wuchengli 2013/08/28 13:18:21 I agree with Antoine that we should make IO thread
614 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_record->input_id; 605 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id();
615 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); 606 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
616 DCHECK_NE(decoder_state_, kUninitialized); 607 DCHECK_NE(decoder_state_, kUninitialized);
617 TRACE_EVENT1("Video Decoder", "EVDA::DecodeTask", "input_id", 608 TRACE_EVENT1("Video Decoder", "EVDA::DecodeTask", "input_id",
618 bitstream_record->input_id); 609 bitstream_buffer.id());
610
611 scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef(
612 client_, child_message_loop_proxy_,
613 new base::SharedMemory(bitstream_buffer.handle(), true),
614 bitstream_buffer.size(), bitstream_buffer.id()));
615 if (!bitstream_record->shm->Map(bitstream_buffer.size())) {
616 DLOG(ERROR) << "Decode(): could not map bitstream_buffer";
617 NOTIFY_ERROR(UNREADABLE_INPUT);
618 return;
619 }
620 DVLOG(3) << "Decode(): mapped to addr=" << bitstream_record->shm->memory();
619 621
620 if (decoder_state_ == kResetting || decoder_flushing_) { 622 if (decoder_state_ == kResetting || decoder_flushing_) {
621 // In the case that we're resetting or flushing, we need to delay decoding 623 // In the case that we're resetting or flushing, we need to delay decoding
622 // the BitstreamBuffers that come after the Reset() or Flush() call. When 624 // the BitstreamBuffers that come after the Reset() or Flush() call. When
623 // we're here, we know that this DecodeTask() was scheduled by a Decode() 625 // we're here, we know that this DecodeTask() was scheduled by a Decode()
624 // call that came after (in the client thread) the Reset() or Flush() call; 626 // call that came after (in the client thread) the Reset() or Flush() call;
625 // thus set up the delay if necessary. 627 // thus set up the delay if necessary.
626 if (decoder_delay_bitstream_buffer_id_ == -1) 628 if (decoder_delay_bitstream_buffer_id_ == -1)
627 decoder_delay_bitstream_buffer_id_ = bitstream_record->input_id; 629 decoder_delay_bitstream_buffer_id_ = bitstream_record->input_id;
628 } else if (decoder_state_ == kError) { 630 } else if (decoder_state_ == kError) {
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 DestroyGscOutputBuffers(); 2445 DestroyGscOutputBuffers();
2444 DestroyMfcOutputBuffers(); 2446 DestroyMfcOutputBuffers();
2445 2447
2446 // Finish resolution change on decoder thread. 2448 // Finish resolution change on decoder thread.
2447 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 2449 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
2448 &ExynosVideoDecodeAccelerator::FinishResolutionChange, 2450 &ExynosVideoDecodeAccelerator::FinishResolutionChange,
2449 base::Unretained(this))); 2451 base::Unretained(this)));
2450 } 2452 }
2451 2453
2452 } // namespace content 2454 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698