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

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: Created 4 years, 8 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
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 b4b46b0da454249a619c6f9a6357041eeead1c85..272a4ae04aa61012a211482f3f82be234c388397 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,20 @@ 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);
+ if (buffers_pending_import_[index].is_valid()) {
Pawel Osciak 2016/05/09 07:27:38 Could you please add a comment explaining that if
Owen Lin 2016/05/10 08:26:33 Done.
+ std::vector<gfx::GpuMemoryBufferHandle> buffers;
Pawel Osciak 2016/05/09 07:27:38 Would std::vector<gfx::GpuMemoryBufferHandle> buff
Owen Lin 2016/05/10 08:26:33 I will use the brace initialization syntax (sugges
+ buffers.push_back(gfx::GpuMemoryBufferHandle());
+#if defined(USE_OZONE)
+ buffers.back().native_pixmap_handle.fd = base::FileDescriptor(
+ buffers_pending_import_[index].release(), true);
dcheng 2016/05/07 06:18:11 Out of curiosity, how does this actually get fd ge
Owen Lin 2016/05/09 07:04:41 posciak@ should know more about why choosing "GpuM
Pawel Osciak 2016/05/09 07:27:38 The contract is that the implementation of ImportB
+#endif
+ vda_->ImportBufferForPicture(index, buffers);
+ } else {
+ vda_->ReusePictureBuffer(index);
+ }
break;
}
default:
@@ -231,6 +237,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,
@@ -283,11 +298,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: "
@@ -317,11 +327,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() {
@@ -353,28 +359,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,

Powered by Google App Engine
This is Rietveld 408576698