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

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

Issue 753713002: Remove reliance on VideoToolbox frame ordering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vt_pic_order
Patch Set: Created 6 years 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 <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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } else { 498 } else {
499 Frame* frame = reinterpret_cast<Frame*>(source_frame_refcon); 499 Frame* frame = reinterpret_cast<Frame*>(source_frame_refcon);
500 frame->image.reset(image_buffer, base::scoped_policy::RETAIN); 500 frame->image.reset(image_buffer, base::scoped_policy::RETAIN);
501 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( 501 gpu_task_runner_->PostTask(FROM_HERE, base::Bind(
502 &VTVideoDecodeAccelerator::DecodeDone, weak_this_, frame)); 502 &VTVideoDecodeAccelerator::DecodeDone, weak_this_, frame));
503 } 503 }
504 } 504 }
505 505
506 void VTVideoDecodeAccelerator::DecodeDone(Frame* frame) { 506 void VTVideoDecodeAccelerator::DecodeDone(Frame* frame) {
507 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 507 DCHECK(gpu_thread_checker_.CalledOnValidThread());
508 DCHECK_EQ(frame->bitstream_id, pending_frames_.front()->bitstream_id); 508 DCHECK_EQ(1u, pending_frames_.count(frame));
509 Task task(TASK_FRAME); 509 Task task(TASK_FRAME);
510 task.frame = pending_frames_.front(); 510 task.frame = pending_frames_[frame];
511 pending_frames_.pop(); 511 pending_frames_.erase(frame);
512 task_queue_.push(task); 512 task_queue_.push(task);
513 ProcessWorkQueues(); 513 ProcessWorkQueues();
514 } 514 }
515 515
516 void VTVideoDecodeAccelerator::FlushTask(TaskType type) { 516 void VTVideoDecodeAccelerator::FlushTask(TaskType type) {
517 DCHECK(decoder_thread_.message_loop_proxy()->BelongsToCurrentThread()); 517 DCHECK(decoder_thread_.message_loop_proxy()->BelongsToCurrentThread());
518 FinishDelayedFrames(); 518 FinishDelayedFrames();
519 519
520 // Always queue a task, even if FinishDelayedFrames() fails, so that 520 // Always queue a task, even if FinishDelayedFrames() fails, so that
521 // destruction always completes. 521 // destruction always completes.
522 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( 522 gpu_task_runner_->PostTask(FROM_HERE, base::Bind(
523 &VTVideoDecodeAccelerator::FlushDone, weak_this_, type)); 523 &VTVideoDecodeAccelerator::FlushDone, weak_this_, type));
524 } 524 }
525 525
526 void VTVideoDecodeAccelerator::FlushDone(TaskType type) { 526 void VTVideoDecodeAccelerator::FlushDone(TaskType type) {
527 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 527 DCHECK(gpu_thread_checker_.CalledOnValidThread());
528 task_queue_.push(Task(type)); 528 task_queue_.push(Task(type));
529 ProcessWorkQueues(); 529 ProcessWorkQueues();
530 } 530 }
531 531
532 void VTVideoDecodeAccelerator::Decode(const media::BitstreamBuffer& bitstream) { 532 void VTVideoDecodeAccelerator::Decode(const media::BitstreamBuffer& bitstream) {
533 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 533 DCHECK(gpu_thread_checker_.CalledOnValidThread());
534 DCHECK_EQ(assigned_bitstream_ids_.count(bitstream.id()), 0u); 534 DCHECK_EQ(0u, assigned_bitstream_ids_.count(bitstream.id()));
535 assigned_bitstream_ids_.insert(bitstream.id()); 535 assigned_bitstream_ids_.insert(bitstream.id());
536 Frame* frame = new Frame(bitstream.id()); 536 Frame* frame = new Frame(bitstream.id());
537 pending_frames_.push(make_linked_ptr(frame)); 537 pending_frames_[frame] = make_linked_ptr(frame);
538 decoder_thread_.message_loop_proxy()->PostTask(FROM_HERE, base::Bind( 538 decoder_thread_.message_loop_proxy()->PostTask(FROM_HERE, base::Bind(
539 &VTVideoDecodeAccelerator::DecodeTask, base::Unretained(this), 539 &VTVideoDecodeAccelerator::DecodeTask, base::Unretained(this),
540 bitstream, frame)); 540 bitstream, frame));
541 } 541 }
542 542
543 void VTVideoDecodeAccelerator::AssignPictureBuffers( 543 void VTVideoDecodeAccelerator::AssignPictureBuffers(
544 const std::vector<media::PictureBuffer>& pictures) { 544 const std::vector<media::PictureBuffer>& pictures) {
545 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 545 DCHECK(gpu_thread_checker_.CalledOnValidThread());
546 546
547 for (const media::PictureBuffer& picture : pictures) { 547 for (const media::PictureBuffer& picture : pictures) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 assigned_bitstream_ids_.clear(); 792 assigned_bitstream_ids_.clear();
793 state_ = STATE_DESTROYING; 793 state_ = STATE_DESTROYING;
794 QueueFlush(TASK_DESTROY); 794 QueueFlush(TASK_DESTROY);
795 } 795 }
796 796
797 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { 797 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() {
798 return false; 798 return false;
799 } 799 }
800 800
801 } // namespace content 801 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698