Commit b2a7b0cc authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2vea: 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 video encoder.

BUG=b:159688625
BUG=b:167412992
TEST=video.EncodeAccel.h264_360p_i420 passes on Kukui.

Change-Id: I050c29ecf8b364869f687c3d8632718aef868144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2415910
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813514}
parent 79163435
...@@ -1029,7 +1029,21 @@ void V4L2VideoEncodeAccelerator::Enqueue() { ...@@ -1029,7 +1029,21 @@ void V4L2VideoEncodeAccelerator::Enqueue() {
encoder_state_ = kFlushing; encoder_state_ = kFlushing;
break; break;
} }
auto input_buffer = input_queue_->GetFreeBuffer();
base::Optional<V4L2WritableBufferRef> input_buffer;
switch (input_memory_type_) {
case V4L2_MEMORY_DMABUF:
input_buffer = input_queue_->GetFreeBufferForFrame(
*encoder_input_queue_.front().frame);
// We may have failed to preserve buffer affinity, fallback to any
// buffer in that case.
if (!input_buffer)
input_buffer = input_queue_->GetFreeBuffer();
break;
default:
input_buffer = input_queue_->GetFreeBuffer();
break;
}
// input_buffer cannot be base::nullopt since we checked for // input_buffer cannot be base::nullopt since we checked for
// input_queue_->FreeBuffersCount() > 0 before entering the loop. // input_queue_->FreeBuffersCount() > 0 before entering the loop.
DCHECK(input_buffer); DCHECK(input_buffer);
......
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