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

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

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle the offset with a helper class Created 4 years, 12 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 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 "content/common/gpu/media/vaapi_video_encode_accelerator.h" 5 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 struct VaapiVideoEncodeAccelerator::InputFrameRef { 90 struct VaapiVideoEncodeAccelerator::InputFrameRef {
91 InputFrameRef(const scoped_refptr<media::VideoFrame>& frame, 91 InputFrameRef(const scoped_refptr<media::VideoFrame>& frame,
92 bool force_keyframe) 92 bool force_keyframe)
93 : frame(frame), force_keyframe(force_keyframe) {} 93 : frame(frame), force_keyframe(force_keyframe) {}
94 const scoped_refptr<media::VideoFrame> frame; 94 const scoped_refptr<media::VideoFrame> frame;
95 const bool force_keyframe; 95 const bool force_keyframe;
96 }; 96 };
97 97
98 struct VaapiVideoEncodeAccelerator::BitstreamBufferRef { 98 struct VaapiVideoEncodeAccelerator::BitstreamBufferRef {
99 BitstreamBufferRef(int32 id, scoped_ptr<base::SharedMemory> shm, size_t size) 99 BitstreamBufferRef(int32 id, scoped_ptr<SharedMemoryRegion> shm)
100 : id(id), shm(shm.Pass()), size(size) {} 100 : id(id), shm(shm.Pass()) {}
Pawel Osciak 2015/12/31 02:05:54 std::move
Owen Lin 2016/01/04 08:54:18 Done.
101 const int32 id; 101 const int32 id;
102 const scoped_ptr<base::SharedMemory> shm; 102 const scoped_ptr<base::SharedMemory> shm;
103 const size_t size;
104 }; 103 };
105 104
106 media::VideoEncodeAccelerator::SupportedProfiles 105 media::VideoEncodeAccelerator::SupportedProfiles
107 VaapiVideoEncodeAccelerator::GetSupportedProfiles() { 106 VaapiVideoEncodeAccelerator::GetSupportedProfiles() {
108 return VaapiWrapper::GetSupportedEncodeProfiles(); 107 return VaapiWrapper::GetSupportedEncodeProfiles();
109 } 108 }
110 109
111 static unsigned int Log2OfPowerOf2(unsigned int x) { 110 static unsigned int Log2OfPowerOf2(unsigned int x) {
112 CHECK_GT(x, 0u); 111 CHECK_GT(x, 0u);
113 DCHECK_EQ(x & (x - 1), 0u); 112 DCHECK_EQ(x & (x - 1), 0u);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 void VaapiVideoEncodeAccelerator::UseOutputBitstreamBuffer( 655 void VaapiVideoEncodeAccelerator::UseOutputBitstreamBuffer(
657 const media::BitstreamBuffer& buffer) { 656 const media::BitstreamBuffer& buffer) {
658 DVLOGF(4) << "id: " << buffer.id(); 657 DVLOGF(4) << "id: " << buffer.id();
659 DCHECK(child_task_runner_->BelongsToCurrentThread()); 658 DCHECK(child_task_runner_->BelongsToCurrentThread());
660 659
661 if (buffer.size() < output_buffer_byte_size_) { 660 if (buffer.size() < output_buffer_byte_size_) {
662 NOTIFY_ERROR(kInvalidArgumentError, "Provided bitstream buffer too small"); 661 NOTIFY_ERROR(kInvalidArgumentError, "Provided bitstream buffer too small");
663 return; 662 return;
664 } 663 }
665 664
666 scoped_ptr<base::SharedMemory> shm( 665 scoped_ptr<SharedMemoryRegion> shm(new SharedMemoryRegion(buffer, false));
667 new base::SharedMemory(buffer.handle(), false)); 666 if (!shm->Map()) {
668 if (!shm->Map(buffer.size())) {
669 NOTIFY_ERROR(kPlatformFailureError, "Failed mapping shared memory."); 667 NOTIFY_ERROR(kPlatformFailureError, "Failed mapping shared memory.");
670 return; 668 return;
671 } 669 }
672 670
673 scoped_ptr<BitstreamBufferRef> buffer_ref( 671 scoped_ptr<BitstreamBufferRef> buffer_ref(new BitstreamBufferRef(
674 new BitstreamBufferRef(buffer.id(), shm.Pass(), buffer.size())); 672 buffer.id(), shm.Pass(), buffer.offset(), buffer.size()));
Pawel Osciak 2015/12/31 02:05:54 I think we don't have this constructor in Bitstrea
Owen Lin 2016/01/04 08:54:18 Done.
675 673
676 encoder_thread_task_runner_->PostTask( 674 encoder_thread_task_runner_->PostTask(
677 FROM_HERE, 675 FROM_HERE,
678 base::Bind(&VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask, 676 base::Bind(&VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask,
679 base::Unretained(this), base::Passed(&buffer_ref))); 677 base::Unretained(this), base::Passed(&buffer_ref)));
680 } 678 }
681 679
682 void VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask( 680 void VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask(
683 scoped_ptr<BitstreamBufferRef> buffer_ref) { 681 scoped_ptr<BitstreamBufferRef> buffer_ref) {
684 DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); 682 DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread());
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 } 1050 }
1053 1051
1054 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() 1052 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob()
1055 : coded_buffer(VA_INVALID_ID), keyframe(false) { 1053 : coded_buffer(VA_INVALID_ID), keyframe(false) {
1056 } 1054 }
1057 1055
1058 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { 1056 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {
1059 } 1057 }
1060 1058
1061 } // namespace content 1059 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698