Commit 51294a2a authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/vaapi: Don't reuse VASliceData on VP9 decoding

When the VASliceData buffer is re-used, decoded frames randomly
have artifacts. This is a workaround of the issue. VASliceData
is always created on submitting each frame.

Bug: b:166646505, b:169725321
Test: Play swirl_128x128_vp9.webm on eve-kernelnext
Change-Id: I85d9b7902496b84fd905da0e80dd604298db0bd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2448272
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Auto-Submit: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814005}
parent 09ed2af0
...@@ -24,7 +24,6 @@ VP9VaapiVideoDecoderDelegate::VP9VaapiVideoDecoderDelegate( ...@@ -24,7 +24,6 @@ VP9VaapiVideoDecoderDelegate::VP9VaapiVideoDecoderDelegate(
VP9VaapiVideoDecoderDelegate::~VP9VaapiVideoDecoderDelegate() { VP9VaapiVideoDecoderDelegate::~VP9VaapiVideoDecoderDelegate() {
DCHECK(!picture_params_); DCHECK(!picture_params_);
DCHECK(!slice_params_); DCHECK(!slice_params_);
DCHECK(!encoded_data_);
} }
scoped_refptr<VP9Picture> VP9VaapiVideoDecoderDelegate::CreateVP9Picture() { scoped_refptr<VP9Picture> VP9VaapiVideoDecoderDelegate::CreateVP9Picture() {
...@@ -65,14 +64,13 @@ bool VP9VaapiVideoDecoderDelegate::SubmitDecode( ...@@ -65,14 +64,13 @@ bool VP9VaapiVideoDecoderDelegate::SubmitDecode(
if (!slice_params_) if (!slice_params_)
return false; return false;
} }
// |encoded_data_| has to match perfectly |frame_hdr->frame_size| or decoding // Always re-create |encoded_data| because reusing the buffer causes horrific
// will have horrific artifacts. // artifacts in decoded buffers. TODO(b/169725321): This seems to be a driver
if (!encoded_data_ || encoded_data_->size() != frame_hdr->frame_size) { // bug, fix it and reuse the buffer.
encoded_data_ = vaapi_wrapper_->CreateVABuffer(VASliceDataBufferType, auto encoded_data = vaapi_wrapper_->CreateVABuffer(VASliceDataBufferType,
frame_hdr->frame_size); frame_hdr->frame_size);
if (!encoded_data_) if (!encoded_data)
return false; return false;
}
pic_param.frame_width = base::checked_cast<uint16_t>(frame_hdr->frame_width); pic_param.frame_width = base::checked_cast<uint16_t>(frame_hdr->frame_width);
pic_param.frame_height = pic_param.frame_height =
...@@ -167,8 +165,8 @@ bool VP9VaapiVideoDecoderDelegate::SubmitDecode( ...@@ -167,8 +165,8 @@ bool VP9VaapiVideoDecoderDelegate::SubmitDecode(
{picture_params_->type(), picture_params_->size(), &pic_param}}, {picture_params_->type(), picture_params_->size(), &pic_param}},
{slice_params_->id(), {slice_params_->id(),
{slice_params_->type(), slice_params_->size(), &slice_param}}, {slice_params_->type(), slice_params_->size(), &slice_param}},
{encoded_data_->id(), {encoded_data->id(),
{encoded_data_->type(), frame_hdr->frame_size, frame_hdr->data}}}); {encoded_data->type(), frame_hdr->frame_size, frame_hdr->data}}});
} }
bool VP9VaapiVideoDecoderDelegate::OutputPicture( bool VP9VaapiVideoDecoderDelegate::OutputPicture(
...@@ -199,7 +197,6 @@ void VP9VaapiVideoDecoderDelegate::OnVAContextDestructionSoon() { ...@@ -199,7 +197,6 @@ void VP9VaapiVideoDecoderDelegate::OnVAContextDestructionSoon() {
// that will be destroyed soon. // that will be destroyed soon.
picture_params_.reset(); picture_params_.reset();
slice_params_.reset(); slice_params_.reset();
encoded_data_.reset();
} }
} // namespace media } // namespace media
...@@ -42,7 +42,6 @@ class VP9VaapiVideoDecoderDelegate : public VP9Decoder::VP9Accelerator, ...@@ -42,7 +42,6 @@ class VP9VaapiVideoDecoderDelegate : public VP9Decoder::VP9Accelerator,
private: private:
std::unique_ptr<ScopedVABuffer> picture_params_; std::unique_ptr<ScopedVABuffer> picture_params_;
std::unique_ptr<ScopedVABuffer> slice_params_; std::unique_ptr<ScopedVABuffer> slice_params_;
std::unique_ptr<ScopedVABuffer> encoded_data_;
DISALLOW_COPY_AND_ASSIGN(VP9VaapiVideoDecoderDelegate); DISALLOW_COPY_AND_ASSIGN(VP9VaapiVideoDecoderDelegate);
}; };
......
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