| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // Otherwise, call the destroy task directly. | 560 // Otherwise, call the destroy task directly. |
| 570 DestroyTask(); | 561 DestroyTask(); |
| 571 } | 562 } |
| 572 | 563 |
| 573 // Set to kError state just in case. | 564 // Set to kError state just in case. |
| 574 SetDecoderState(kError); | 565 SetDecoderState(kError); |
| 575 | 566 |
| 576 delete this; | 567 delete this; |
| 577 } | 568 } |
| 578 | 569 |
| 570 bool ExynosVideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } |
| 571 |
| 579 // static | 572 // static |
| 580 void ExynosVideoDecodeAccelerator::PreSandboxInitialization() { | 573 void ExynosVideoDecodeAccelerator::PreSandboxInitialization() { |
| 581 DVLOG(3) << "PreSandboxInitialization()"; | 574 DVLOG(3) << "PreSandboxInitialization()"; |
| 582 dlerror(); | 575 dlerror(); |
| 583 | 576 |
| 584 libmali_handle = dlopen(kMaliDriver, RTLD_LAZY | RTLD_LOCAL); | 577 libmali_handle = dlopen(kMaliDriver, RTLD_LAZY | RTLD_LOCAL); |
| 585 if (libmali_handle == NULL) { | 578 if (libmali_handle == NULL) { |
| 586 DPLOG(ERROR) << "failed to dlopen() " << kMaliDriver << ": " << dlerror(); | 579 DPLOG(ERROR) << "failed to dlopen() " << kMaliDriver << ": " << dlerror(); |
| 587 } | 580 } |
| 588 } | 581 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 603 if (mali_egl_image_get_buffer_ext_phandle == NULL) { | 596 if (mali_egl_image_get_buffer_ext_phandle == NULL) { |
| 604 DPLOG(ERROR) << "PostSandboxInitialization(): failed to dlsym() " | 597 DPLOG(ERROR) << "PostSandboxInitialization(): failed to dlsym() " |
| 605 << "mali_egl_image_get_buffer_ext_phandle: " << dlerror(); | 598 << "mali_egl_image_get_buffer_ext_phandle: " << dlerror(); |
| 606 return false; | 599 return false; |
| 607 } | 600 } |
| 608 | 601 |
| 609 return true; | 602 return true; |
| 610 } | 603 } |
| 611 | 604 |
| 612 void ExynosVideoDecodeAccelerator::DecodeTask( | 605 void ExynosVideoDecodeAccelerator::DecodeTask( |
| 613 scoped_ptr<BitstreamBufferRef> bitstream_record) { | 606 const media::BitstreamBuffer& bitstream_buffer) { |
| 614 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_record->input_id; | 607 DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id(); |
| 615 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 608 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| 616 DCHECK_NE(decoder_state_, kUninitialized); | 609 DCHECK_NE(decoder_state_, kUninitialized); |
| 617 TRACE_EVENT1("Video Decoder", "EVDA::DecodeTask", "input_id", | 610 TRACE_EVENT1("Video Decoder", "EVDA::DecodeTask", "input_id", |
| 618 bitstream_record->input_id); | 611 bitstream_buffer.id()); |
| 612 |
| 613 scoped_ptr<BitstreamBufferRef> bitstream_record(new BitstreamBufferRef( |
| 614 client_, child_message_loop_proxy_, |
| 615 new base::SharedMemory(bitstream_buffer.handle(), true), |
| 616 bitstream_buffer.size(), bitstream_buffer.id())); |
| 617 if (!bitstream_record->shm->Map(bitstream_buffer.size())) { |
| 618 DLOG(ERROR) << "Decode(): could not map bitstream_buffer"; |
| 619 NOTIFY_ERROR(UNREADABLE_INPUT); |
| 620 return; |
| 621 } |
| 622 DVLOG(3) << "Decode(): mapped to addr=" << bitstream_record->shm->memory(); |
| 619 | 623 |
| 620 if (decoder_state_ == kResetting || decoder_flushing_) { | 624 if (decoder_state_ == kResetting || decoder_flushing_) { |
| 621 // In the case that we're resetting or flushing, we need to delay decoding | 625 // 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 | 626 // 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() | 627 // 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; | 628 // call that came after (in the client thread) the Reset() or Flush() call; |
| 625 // thus set up the delay if necessary. | 629 // thus set up the delay if necessary. |
| 626 if (decoder_delay_bitstream_buffer_id_ == -1) | 630 if (decoder_delay_bitstream_buffer_id_ == -1) |
| 627 decoder_delay_bitstream_buffer_id_ = bitstream_record->input_id; | 631 decoder_delay_bitstream_buffer_id_ = bitstream_record->input_id; |
| 628 } else if (decoder_state_ == kError) { | 632 } else if (decoder_state_ == kError) { |
| (...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 DestroyGscOutputBuffers(); | 2447 DestroyGscOutputBuffers(); |
| 2444 DestroyMfcOutputBuffers(); | 2448 DestroyMfcOutputBuffers(); |
| 2445 | 2449 |
| 2446 // Finish resolution change on decoder thread. | 2450 // Finish resolution change on decoder thread. |
| 2447 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 2451 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| 2448 &ExynosVideoDecodeAccelerator::FinishResolutionChange, | 2452 &ExynosVideoDecodeAccelerator::FinishResolutionChange, |
| 2449 base::Unretained(this))); | 2453 base::Unretained(this))); |
| 2450 } | 2454 } |
| 2451 | 2455 |
| 2452 } // namespace content | 2456 } // namespace content |
| OLD | NEW |