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

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

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address posciak's comments Created 4 years, 11 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 "content/common/gpu/media/vaapi_video_decode_accelerator.h" 5 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 private: 247 private:
248 scoped_refptr<VaapiDecodeSurface> VP9PictureToVaapiDecodeSurface( 248 scoped_refptr<VaapiDecodeSurface> VP9PictureToVaapiDecodeSurface(
249 const scoped_refptr<VP9Picture>& pic); 249 const scoped_refptr<VP9Picture>& pic);
250 250
251 VaapiWrapper* vaapi_wrapper_; 251 VaapiWrapper* vaapi_wrapper_;
252 VaapiVideoDecodeAccelerator* vaapi_dec_; 252 VaapiVideoDecodeAccelerator* vaapi_dec_;
253 253
254 DISALLOW_COPY_AND_ASSIGN(VaapiVP9Accelerator); 254 DISALLOW_COPY_AND_ASSIGN(VaapiVP9Accelerator);
255 }; 255 };
256 256
257 VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0), size(0) { 257 VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0) {}
258 }
259 258
260 VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() { 259 VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() {
261 } 260 }
262 261
263 void VaapiVideoDecodeAccelerator::NotifyError(Error error) { 262 void VaapiVideoDecodeAccelerator::NotifyError(Error error) {
264 if (message_loop_ != base::MessageLoop::current()) { 263 if (message_loop_ != base::MessageLoop::current()) {
265 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); 264 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
266 message_loop_->PostTask(FROM_HERE, base::Bind( 265 message_loop_->PostTask(FROM_HERE, base::Bind(
267 &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error)); 266 &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error));
268 return; 267 return;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 437
439 void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer( 438 void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer(
440 const media::BitstreamBuffer& bitstream_buffer) { 439 const media::BitstreamBuffer& bitstream_buffer) {
441 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 440 DCHECK_EQ(message_loop_, base::MessageLoop::current());
442 TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id", 441 TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id",
443 bitstream_buffer.id()); 442 bitstream_buffer.id());
444 443
445 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() 444 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id()
446 << " size: " << (int)bitstream_buffer.size(); 445 << " size: " << (int)bitstream_buffer.size();
447 446
448 scoped_ptr<base::SharedMemory> shm( 447 scoped_ptr<SharedMemoryRegion> shm(
449 new base::SharedMemory(bitstream_buffer.handle(), true)); 448 new SharedMemoryRegion(bitstream_buffer, true));
450 RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(bitstream_buffer.size()), 449 RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(), "Failed to map input buffer",
451 "Failed to map input buffer", UNREADABLE_INPUT,); 450 UNREADABLE_INPUT, );
452 451
453 base::AutoLock auto_lock(lock_); 452 base::AutoLock auto_lock(lock_);
454 453
455 // Set up a new input buffer and queue it for later. 454 // Set up a new input buffer and queue it for later.
456 linked_ptr<InputBuffer> input_buffer(new InputBuffer()); 455 linked_ptr<InputBuffer> input_buffer(new InputBuffer());
457 input_buffer->shm.reset(shm.release()); 456 input_buffer->shm.reset(shm.release());
458 input_buffer->id = bitstream_buffer.id(); 457 input_buffer->id = bitstream_buffer.id();
459 input_buffer->size = bitstream_buffer.size();
460 458
461 ++num_stream_bufs_at_decoder_; 459 ++num_stream_bufs_at_decoder_;
462 TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder", 460 TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder",
463 num_stream_bufs_at_decoder_); 461 num_stream_bufs_at_decoder_);
464 462
465 input_buffers_.push(input_buffer); 463 input_buffers_.push(input_buffer);
466 input_ready_.Signal(); 464 input_ready_.Signal();
467 } 465 }
468 466
469 bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() { 467 bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() {
(...skipping 18 matching lines...) Expand all
488 if (input_buffers_.empty()) 486 if (input_buffers_.empty())
489 return false; 487 return false;
490 // else fallthrough 488 // else fallthrough
491 case kDecoding: 489 case kDecoding:
492 case kIdle: 490 case kIdle:
493 DCHECK(!input_buffers_.empty()); 491 DCHECK(!input_buffers_.empty());
494 492
495 curr_input_buffer_ = input_buffers_.front(); 493 curr_input_buffer_ = input_buffers_.front();
496 input_buffers_.pop(); 494 input_buffers_.pop();
497 495
498 DVLOG(4) << "New current bitstream buffer, id: " 496 DVLOG(4) << "New current bitstream buffer, id: " << curr_input_buffer_->id
499 << curr_input_buffer_->id 497 << " size: " << curr_input_buffer_->shm->size();
500 << " size: " << curr_input_buffer_->size;
501 498
502 decoder_->SetStream( 499 decoder_->SetStream(
503 static_cast<uint8*>(curr_input_buffer_->shm->memory()), 500 static_cast<uint8*>(curr_input_buffer_->shm->memory()),
504 curr_input_buffer_->size); 501 curr_input_buffer_->shm->size());
505 return true; 502 return true;
506 503
507 default: 504 default:
508 // We got woken up due to being destroyed/reset, ignore any already 505 // We got woken up due to being destroyed/reset, ignore any already
509 // queued inputs. 506 // queued inputs.
510 return false; 507 return false;
511 } 508 }
512 } 509 }
513 510
514 void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() { 511 void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() {
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 return vaapi_pic->dec_surface(); 1736 return vaapi_pic->dec_surface();
1740 } 1737 }
1741 1738
1742 // static 1739 // static
1743 media::VideoDecodeAccelerator::SupportedProfiles 1740 media::VideoDecodeAccelerator::SupportedProfiles
1744 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1741 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1745 return VaapiWrapper::GetSupportedDecodeProfiles(); 1742 return VaapiWrapper::GetSupportedDecodeProfiles();
1746 } 1743 }
1747 1744
1748 } // namespace content 1745 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698