| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include <CoreVideo/CoreVideo.h> | 7 #include <CoreVideo/CoreVideo.h> |
| 8 #include <OpenGL/CGLIOSurface.h> | 8 #include <OpenGL/CGLIOSurface.h> |
| 9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
| 10 | 10 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } else { | 497 } else { |
| 498 Frame* frame = reinterpret_cast<Frame*>(source_frame_refcon); | 498 Frame* frame = reinterpret_cast<Frame*>(source_frame_refcon); |
| 499 frame->image.reset(image_buffer, base::scoped_policy::RETAIN); | 499 frame->image.reset(image_buffer, base::scoped_policy::RETAIN); |
| 500 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( | 500 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 501 &VTVideoDecodeAccelerator::DecodeDone, weak_this_, frame)); | 501 &VTVideoDecodeAccelerator::DecodeDone, weak_this_, frame)); |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 | 504 |
| 505 void VTVideoDecodeAccelerator::DecodeDone(Frame* frame) { | 505 void VTVideoDecodeAccelerator::DecodeDone(Frame* frame) { |
| 506 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 506 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 507 DCHECK_EQ(frame->bitstream_id, pending_frames_.front()->bitstream_id); | 507 DCHECK_EQ(1u, pending_frames_.count(frame->bitstream_id)); |
| 508 Task task(TASK_FRAME); | 508 Task task(TASK_FRAME); |
| 509 task.frame = pending_frames_.front(); | 509 task.frame = pending_frames_[frame->bitstream_id]; |
| 510 pending_frames_.pop(); | 510 pending_frames_.erase(frame->bitstream_id); |
| 511 task_queue_.push(task); | 511 task_queue_.push(task); |
| 512 ProcessWorkQueues(); | 512 ProcessWorkQueues(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void VTVideoDecodeAccelerator::FlushTask(TaskType type) { | 515 void VTVideoDecodeAccelerator::FlushTask(TaskType type) { |
| 516 DCHECK(decoder_thread_.message_loop_proxy()->BelongsToCurrentThread()); | 516 DCHECK(decoder_thread_.message_loop_proxy()->BelongsToCurrentThread()); |
| 517 FinishDelayedFrames(); | 517 FinishDelayedFrames(); |
| 518 | 518 |
| 519 // Always queue a task, even if FinishDelayedFrames() fails, so that | 519 // Always queue a task, even if FinishDelayedFrames() fails, so that |
| 520 // destruction always completes. | 520 // destruction always completes. |
| 521 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( | 521 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 522 &VTVideoDecodeAccelerator::FlushDone, weak_this_, type)); | 522 &VTVideoDecodeAccelerator::FlushDone, weak_this_, type)); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void VTVideoDecodeAccelerator::FlushDone(TaskType type) { | 525 void VTVideoDecodeAccelerator::FlushDone(TaskType type) { |
| 526 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 526 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 527 task_queue_.push(Task(type)); | 527 task_queue_.push(Task(type)); |
| 528 ProcessWorkQueues(); | 528 ProcessWorkQueues(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void VTVideoDecodeAccelerator::Decode(const media::BitstreamBuffer& bitstream) { | 531 void VTVideoDecodeAccelerator::Decode(const media::BitstreamBuffer& bitstream) { |
| 532 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 532 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 533 DCHECK_EQ(assigned_bitstream_ids_.count(bitstream.id()), 0u); | 533 DCHECK_EQ(0u, assigned_bitstream_ids_.count(bitstream.id())); |
| 534 assigned_bitstream_ids_.insert(bitstream.id()); | 534 assigned_bitstream_ids_.insert(bitstream.id()); |
| 535 Frame* frame = new Frame(bitstream.id()); | 535 Frame* frame = new Frame(bitstream.id()); |
| 536 pending_frames_.push(make_linked_ptr(frame)); | 536 pending_frames_[frame->bitstream_id] = make_linked_ptr(frame); |
| 537 decoder_thread_.message_loop_proxy()->PostTask(FROM_HERE, base::Bind( | 537 decoder_thread_.message_loop_proxy()->PostTask(FROM_HERE, base::Bind( |
| 538 &VTVideoDecodeAccelerator::DecodeTask, base::Unretained(this), | 538 &VTVideoDecodeAccelerator::DecodeTask, base::Unretained(this), |
| 539 bitstream, frame)); | 539 bitstream, frame)); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void VTVideoDecodeAccelerator::AssignPictureBuffers( | 542 void VTVideoDecodeAccelerator::AssignPictureBuffers( |
| 543 const std::vector<media::PictureBuffer>& pictures) { | 543 const std::vector<media::PictureBuffer>& pictures) { |
| 544 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 544 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 545 | 545 |
| 546 for (const media::PictureBuffer& picture : pictures) { | 546 for (const media::PictureBuffer& picture : pictures) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 assigned_bitstream_ids_.clear(); | 800 assigned_bitstream_ids_.clear(); |
| 801 state_ = STATE_DESTROYING; | 801 state_ = STATE_DESTROYING; |
| 802 QueueFlush(TASK_DESTROY); | 802 QueueFlush(TASK_DESTROY); |
| 803 } | 803 } |
| 804 | 804 |
| 805 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { | 805 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { |
| 806 return false; | 806 return false; |
| 807 } | 807 } |
| 808 | 808 |
| 809 } // namespace content | 809 } // namespace content |
| OLD | NEW |