Commit 17b27839 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2ip: use buffer affinity tracker

When using DMABUFs, it is preferable to use the same V4L2 buffer with
the same underlying buffer, as failure to do so results in memory
unmappings/remappings in the driver. Use the newly introduced buffer
affinity tracker and V4L2Queue::GetFreeBufferForFrame() method to
achieve this transparently in the image processor.

BUG=b:159688625
TEST=video.DecodeAccel.h264 passes on Kukui.

Change-Id: I9df69431d0e532c40c0f49ca4e3bb31843b0814b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2413946
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813091}
parent cd0011d4
...@@ -613,8 +613,26 @@ void V4L2ImageProcessorBackend::ProcessJobsTask() { ...@@ -613,8 +613,26 @@ void V4L2ImageProcessorBackend::ProcessJobsTask() {
} }
// We need one input and one output buffer to schedule the job // We need one input and one output buffer to schedule the job
auto input_buffer = input_queue_->GetFreeBuffer(); base::Optional<V4L2WritableBufferRef> input_buffer;
auto output_buffer = output_queue_->GetFreeBuffer(); // If we are using DMABUF frames, try to always obtain the same V4L2 buffer.
if (input_memory_type_ == V4L2_MEMORY_DMABUF) {
const VideoFrame& input_frame =
*(input_job_queue_.front()->input_frame.get());
input_buffer = input_queue_->GetFreeBufferForFrame(input_frame);
}
if (!input_buffer)
input_buffer = input_queue_->GetFreeBuffer();
base::Optional<V4L2WritableBufferRef> output_buffer;
// If we are using DMABUF frames, try to always obtain the same V4L2 buffer.
if (output_memory_type_ == V4L2_MEMORY_DMABUF) {
const VideoFrame& output_frame =
*(input_job_queue_.front()->output_frame.get());
output_buffer = output_queue_->GetFreeBufferForFrame(output_frame);
}
if (!output_buffer)
output_buffer = output_queue_->GetFreeBuffer();
if (!input_buffer || !output_buffer) if (!input_buffer || !output_buffer)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment