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

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 review comments and rebase Created 4 years, 9 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 <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 private: 249 private:
250 scoped_refptr<VaapiDecodeSurface> VP9PictureToVaapiDecodeSurface( 250 scoped_refptr<VaapiDecodeSurface> VP9PictureToVaapiDecodeSurface(
251 const scoped_refptr<VP9Picture>& pic); 251 const scoped_refptr<VP9Picture>& pic);
252 252
253 VaapiWrapper* vaapi_wrapper_; 253 VaapiWrapper* vaapi_wrapper_;
254 VaapiVideoDecodeAccelerator* vaapi_dec_; 254 VaapiVideoDecodeAccelerator* vaapi_dec_;
255 255
256 DISALLOW_COPY_AND_ASSIGN(VaapiVP9Accelerator); 256 DISALLOW_COPY_AND_ASSIGN(VaapiVP9Accelerator);
257 }; 257 };
258 258
259 VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0), size(0) { 259 VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0) {}
260 }
261 260
262 VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() { 261 VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() {
263 } 262 }
264 263
265 void VaapiVideoDecodeAccelerator::NotifyError(Error error) { 264 void VaapiVideoDecodeAccelerator::NotifyError(Error error) {
266 if (message_loop_ != base::MessageLoop::current()) { 265 if (message_loop_ != base::MessageLoop::current()) {
267 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); 266 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
268 message_loop_->PostTask(FROM_HERE, base::Bind( 267 message_loop_->PostTask(FROM_HERE, base::Bind(
269 &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error)); 268 &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error));
270 return; 269 return;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 439
441 void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer( 440 void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer(
442 const media::BitstreamBuffer& bitstream_buffer) { 441 const media::BitstreamBuffer& bitstream_buffer) {
443 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 442 DCHECK_EQ(message_loop_, base::MessageLoop::current());
444 TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id", 443 TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id",
445 bitstream_buffer.id()); 444 bitstream_buffer.id());
446 445
447 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() 446 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id()
448 << " size: " << (int)bitstream_buffer.size(); 447 << " size: " << (int)bitstream_buffer.size();
449 448
450 scoped_ptr<base::SharedMemory> shm( 449 scoped_ptr<SharedMemoryRegion> shm(
451 new base::SharedMemory(bitstream_buffer.handle(), true)); 450 new SharedMemoryRegion(bitstream_buffer, true));
452 RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(bitstream_buffer.size()), 451 RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(), "Failed to map input buffer",
453 "Failed to map input buffer", UNREADABLE_INPUT,); 452 UNREADABLE_INPUT, );
454 453
455 base::AutoLock auto_lock(lock_); 454 base::AutoLock auto_lock(lock_);
456 455
457 // Set up a new input buffer and queue it for later. 456 // Set up a new input buffer and queue it for later.
458 linked_ptr<InputBuffer> input_buffer(new InputBuffer()); 457 linked_ptr<InputBuffer> input_buffer(new InputBuffer());
459 input_buffer->shm.reset(shm.release()); 458 input_buffer->shm.reset(shm.release());
460 input_buffer->id = bitstream_buffer.id(); 459 input_buffer->id = bitstream_buffer.id();
461 input_buffer->size = bitstream_buffer.size();
462 460
463 ++num_stream_bufs_at_decoder_; 461 ++num_stream_bufs_at_decoder_;
464 TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder", 462 TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder",
465 num_stream_bufs_at_decoder_); 463 num_stream_bufs_at_decoder_);
466 464
467 input_buffers_.push(input_buffer); 465 input_buffers_.push(input_buffer);
468 input_ready_.Signal(); 466 input_ready_.Signal();
469 } 467 }
470 468
471 bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() { 469 bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() {
(...skipping 18 matching lines...) Expand all
490 if (input_buffers_.empty()) 488 if (input_buffers_.empty())
491 return false; 489 return false;
492 // else fallthrough 490 // else fallthrough
493 case kDecoding: 491 case kDecoding:
494 case kIdle: 492 case kIdle:
495 DCHECK(!input_buffers_.empty()); 493 DCHECK(!input_buffers_.empty());
496 494
497 curr_input_buffer_ = input_buffers_.front(); 495 curr_input_buffer_ = input_buffers_.front();
498 input_buffers_.pop(); 496 input_buffers_.pop();
499 497
500 DVLOG(4) << "New current bitstream buffer, id: " 498 DVLOG(4) << "New current bitstream buffer, id: " << curr_input_buffer_->id
501 << curr_input_buffer_->id 499 << " size: " << curr_input_buffer_->shm->size();
502 << " size: " << curr_input_buffer_->size;
503 500
504 decoder_->SetStream( 501 decoder_->SetStream(
505 static_cast<uint8_t*>(curr_input_buffer_->shm->memory()), 502 static_cast<uint8_t*>(curr_input_buffer_->shm->memory()),
506 curr_input_buffer_->size); 503 curr_input_buffer_->shm->size());
507 return true; 504 return true;
508 505
509 default: 506 default:
510 // We got woken up due to being destroyed/reset, ignore any already 507 // We got woken up due to being destroyed/reset, ignore any already
511 // queued inputs. 508 // queued inputs.
512 return false; 509 return false;
513 } 510 }
514 } 511 }
515 512
516 void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() { 513 void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() {
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 return vaapi_pic->dec_surface(); 1745 return vaapi_pic->dec_surface();
1749 } 1746 }
1750 1747
1751 // static 1748 // static
1752 media::VideoDecodeAccelerator::SupportedProfiles 1749 media::VideoDecodeAccelerator::SupportedProfiles
1753 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1750 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1754 return VaapiWrapper::GetSupportedDecodeProfiles(); 1751 return VaapiWrapper::GetSupportedDecodeProfiles();
1755 } 1752 }
1756 1753
1757 } // namespace content 1754 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_video_decode_accelerator.h ('k') | content/common/gpu/media/vaapi_video_encode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698