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

Unified Diff: chrome/gpu/arc_gpu_video_decode_accelerator.cc

Issue 1945543002: Use explicit flush for ArcVideoAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and update version Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/gpu/arc_gpu_video_decode_accelerator.h ('k') | chrome/gpu/arc_video_accelerator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/gpu/arc_gpu_video_decode_accelerator.cc
diff --git a/chrome/gpu/arc_gpu_video_decode_accelerator.cc b/chrome/gpu/arc_gpu_video_decode_accelerator.cc
index ce07adc4a3e2059786a8eae90303c7d5d227b89e..594de85f973a3f3a46be89ea77af789731c6d32d 100644
--- a/chrome/gpu/arc_gpu_video_decode_accelerator.cc
+++ b/chrome/gpu/arc_gpu_video_decode_accelerator.cc
@@ -33,8 +33,7 @@ ArcGpuVideoDecodeAccelerator::InputBufferInfo::InputBufferInfo(
ArcGpuVideoDecodeAccelerator::InputBufferInfo::~InputBufferInfo() {}
ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator()
- : pending_eos_output_buffer_(false),
- arc_client_(nullptr),
+ : arc_client_(nullptr),
next_bitstream_buffer_id_(0),
output_buffer_size_(0) {}
@@ -208,13 +207,21 @@ void ArcGpuVideoDecodeAccelerator::UseBuffer(PortType port,
vda_->Decode(media::BitstreamBuffer(
bitstream_buffer_id, base::SharedMemoryHandle(dup_fd, true),
metadata.bytes_used, input_info->offset));
- if (metadata.flags & BUFFER_FLAG_EOS) {
- vda_->Flush();
- }
break;
}
case PORT_OUTPUT: {
- SendEosIfNeededOrReusePicture(index);
+ // is_valid() is true for the first time the buffer is passed to the VDA.
+ // In that case, VDA needs to import the buffer first.
+ if (buffers_pending_import_[index].is_valid()) {
+ gfx::GpuMemoryBufferHandle handle;
+#if defined(USE_OZONE)
+ handle.native_pixmap_handle.fd = base::FileDescriptor(
+ buffers_pending_import_[index].release(), true);
+#endif
+ vda_->ImportBufferForPicture(index, {handle});
+ } else {
+ vda_->ReusePictureBuffer(index);
+ }
break;
}
default:
@@ -231,6 +238,15 @@ void ArcGpuVideoDecodeAccelerator::Reset() {
vda_->Reset();
}
+void ArcGpuVideoDecodeAccelerator::Flush() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!vda_) {
+ DLOG(ERROR) << "VDA not initialized";
+ return;
+ }
+ vda_->Flush();
+}
+
void ArcGpuVideoDecodeAccelerator::ProvidePictureBuffers(
uint32_t requested_num_of_buffers,
uint32_t textures_per_buffer,
@@ -286,11 +302,6 @@ void ArcGpuVideoDecodeAccelerator::PictureReady(const media::Picture& picture) {
<< ", bitstream_buffer_id=" << picture.bitstream_buffer_id();
DCHECK(thread_checker_.CalledOnValidThread());
- // Empty buffer, returned in Flushing.
- if (picture.bitstream_buffer_id() == -1) {
- buffers_pending_eos_.push(picture.picture_buffer_id());
- return;
- }
InputRecord* input_record = FindInputRecord(picture.bitstream_buffer_id());
if (input_record == nullptr) {
DLOG(ERROR) << "Cannot find for bitstream buffer id: "
@@ -320,11 +331,7 @@ void ArcGpuVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer(
void ArcGpuVideoDecodeAccelerator::NotifyFlushDone() {
DCHECK(thread_checker_.CalledOnValidThread());
- pending_eos_output_buffer_ = true;
- while (!buffers_pending_eos_.empty()) {
- SendEosIfNeededOrReusePicture(buffers_pending_eos_.front());
- buffers_pending_eos_.pop();
- }
+ arc_client_->OnFlushDone();
}
void ArcGpuVideoDecodeAccelerator::NotifyResetDone() {
@@ -356,28 +363,6 @@ void ArcGpuVideoDecodeAccelerator::NotifyError(
arc_client_->OnError(ConvertErrorCode(error));
}
-void ArcGpuVideoDecodeAccelerator::SendEosIfNeededOrReusePicture(
- uint32_t index) {
- if (pending_eos_output_buffer_) {
- BufferMetadata metadata;
- metadata.flags = BUFFER_FLAG_EOS;
- arc_client_->OnBufferDone(PORT_OUTPUT, index, metadata);
- pending_eos_output_buffer_ = false;
- } else {
- if (buffers_pending_import_[index].is_valid()) {
- std::vector<gfx::GpuMemoryBufferHandle> buffers;
- buffers.push_back(gfx::GpuMemoryBufferHandle());
-#if defined(USE_OZONE)
- buffers.back().native_pixmap_handle.fd =
- base::FileDescriptor(buffers_pending_import_[index].release(), true);
-#endif
- vda_->ImportBufferForPicture(index, buffers);
- } else {
- vda_->ReusePictureBuffer(index);
- }
- }
-}
-
void ArcGpuVideoDecodeAccelerator::CreateInputRecord(
int32_t bitstream_buffer_id,
uint32_t buffer_index,
« no previous file with comments | « chrome/gpu/arc_gpu_video_decode_accelerator.h ('k') | chrome/gpu/arc_video_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698