Commit 59b895e8 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2(s)vda: harmonize buffer import code

Both decoders are supposed to do the same thing here, but small
differences in the code design could make the reader believe that they
don't. In particular, the IP is only supposed to be created in IMPORT
mode for both cases.

Make sure both decoders run the same version. We are going to reorganize
and factorize this code, but this little cleanup ensures it is safe to
do so.

BUG=None
TEST=Youtube desktop and Android both play on Hana and Kukui.

Change-Id: Ic572763b519f74337adc31714f6fa738d9bce194
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2011783Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733875}
parent 51213036
...@@ -1488,6 +1488,7 @@ void V4L2SliceVideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -1488,6 +1488,7 @@ void V4L2SliceVideoDecodeAccelerator::ImportBufferForPictureTask(
// However the size of PictureBuffer might not be adjusted by ARC++. So we // However the size of PictureBuffer might not be adjusted by ARC++. So we
// keep this until ARC++ side is fixed. // keep this until ARC++ side is fixed.
if (output_mode_ == Config::OutputMode::IMPORT) { if (output_mode_ == Config::OutputMode::IMPORT) {
DCHECK_GT(handle.planes.size(), 0u);
const int32_t stride = handle.planes[0].stride; const int32_t stride = handle.planes[0].stride;
const int plane_horiz_bits_per_pixel = const int plane_horiz_bits_per_pixel =
VideoFrame::PlaneHorizontalBitsPerPixel( VideoFrame::PlaneHorizontalBitsPerPixel(
...@@ -1499,21 +1500,30 @@ void V4L2SliceVideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -1499,21 +1500,30 @@ void V4L2SliceVideoDecodeAccelerator::ImportBufferForPictureTask(
NOTIFY_ERROR(INVALID_ARGUMENT); NOTIFY_ERROR(INVALID_ARGUMENT);
return; return;
} }
int adjusted_coded_width = stride * 8 / plane_horiz_bits_per_pixel; int adjusted_coded_width = stride * 8 / plane_horiz_bits_per_pixel;
// If this is the first picture, then adjust the EGL width.
// Otherwise just check that it remains the same.
if (state_ == kAwaitingPictureBuffers) {
DCHECK_GE(adjusted_coded_width, gl_image_size_.width());
gl_image_size_.set_width(adjusted_coded_width);
}
DCHECK_EQ(gl_image_size_.width(), adjusted_coded_width);
DVLOGF(3) << "Original gl_image_size=" << gl_image_size_.ToString()
<< ", adjusted coded width=" << adjusted_coded_width;
// For allocate mode, the IP will already have been created in
// AssignPictureBuffersTask.
if (image_processor_device_ && !image_processor_) { if (image_processor_device_ && !image_processor_) {
DCHECK_EQ(kAwaitingPictureBuffers, state_); DCHECK_EQ(kAwaitingPictureBuffers, state_);
// This is the first buffer import. Create the image processor and change // This is the first buffer import. Create the image processor and change
// the decoder state. The client may adjust the coded width. We don't have // the decoder state. The client may adjust the coded width. We don't have
// the final coded size in AssignPictureBuffers yet. Use the adjusted // the final coded size in AssignPictureBuffers yet. Use the adjusted
// coded width to create the image processor. // coded width to create the image processor.
DVLOGF(3) << "Original gl_image_size=" << gl_image_size_.ToString()
<< ", adjusted coded width=" << adjusted_coded_width;
DCHECK_GE(adjusted_coded_width, gl_image_size_.width());
gl_image_size_.set_width(adjusted_coded_width);
if (!CreateImageProcessor()) if (!CreateImageProcessor())
return; return;
} }
DCHECK_EQ(gl_image_size_.width(), adjusted_coded_width);
} }
// Put us in kIdle to allow further event processing. // Put us in kIdle to allow further event processing.
......
...@@ -632,8 +632,9 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -632,8 +632,9 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask(
if (output_mode_ == Config::OutputMode::IMPORT) { if (output_mode_ == Config::OutputMode::IMPORT) {
DCHECK_GT(handle.planes.size(), 0u); DCHECK_GT(handle.planes.size(), 0u);
const int32_t stride = handle.planes[0].stride; const int32_t stride = handle.planes[0].stride;
int plane_horiz_bits_per_pixel = VideoFrame::PlaneHorizontalBitsPerPixel( const int plane_horiz_bits_per_pixel =
egl_image_format_fourcc_->ToVideoPixelFormat(), 0); VideoFrame::PlaneHorizontalBitsPerPixel(
egl_image_format_fourcc_->ToVideoPixelFormat(), 0);
if (plane_horiz_bits_per_pixel == 0 || if (plane_horiz_bits_per_pixel == 0 ||
(stride * 8) % plane_horiz_bits_per_pixel != 0) { (stride * 8) % plane_horiz_bits_per_pixel != 0) {
VLOGF(1) << "Invalid format " << egl_image_format_fourcc_->ToString() VLOGF(1) << "Invalid format " << egl_image_format_fourcc_->ToString()
...@@ -653,16 +654,18 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -653,16 +654,18 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask(
DVLOGF(3) << "Original egl_image_size=" << egl_image_size_.ToString() DVLOGF(3) << "Original egl_image_size=" << egl_image_size_.ToString()
<< ", adjusted coded width=" << adjusted_coded_width; << ", adjusted coded width=" << adjusted_coded_width;
}
if (image_processor_device_ && !image_processor_) { // For allocate mode, the IP will already have been created in
DCHECK_EQ(kAwaitingPictureBuffers, decoder_state_); // AssignPictureBuffersTask.
// This is the first buffer import. Create the image processor and change if (image_processor_device_ && !image_processor_) {
// the decoder state. The client may adjust the coded width. We don't have DCHECK_EQ(kAwaitingPictureBuffers, decoder_state_);
// the final coded size in AssignPictureBuffers yet. Use the adjusted coded // This is the first buffer import. Create the image processor and change
// width to create the image processor. // the decoder state. The client may adjust the coded width. We don't have
if (!CreateImageProcessor()) // the final coded size in AssignPictureBuffers yet. Use the adjusted
return; // coded width to create the image processor.
if (!CreateImageProcessor())
return;
}
} }
if (reset_pending_) { if (reset_pending_) {
......
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