frontends/va: fixed an av1 decoding image corruption issue.
authorRuijing Dong <ruijing.dong@amd.com>
Tue, 18 Oct 2022 20:33:42 +0000 (16:33 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 19 Oct 2022 20:03:23 +0000 (20:03 +0000)
problem:
When playing back some clips with loop restoration parameters
enabled, the display image could be corrupted.

solution:
correct loop restoration unit size logic in vaapi interface.

CC: 22.2 <mesa-stable>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19146>

src/gallium/frontends/va/picture_av1.c

index f5563ec..4278486 100644 (file)
@@ -112,6 +112,7 @@ void vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context,
 {
    VADecPictureParameterBufferAV1 *av1 = buf->data;
    int i, j;
+   bool use_lr;
 
    assert(buf->size >= sizeof(VADecPictureParameterBufferAV1) && buf->num_elements == 1);
 
@@ -290,13 +291,19 @@ void vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context,
       av1->loop_restoration_fields.bits.lr_unit_shift;
    context->desc.av1.picture_parameter.loop_restoration_fields.lr_uv_shift =
       av1->loop_restoration_fields.bits.lr_uv_shift;
-   if (!av1->loop_restoration_fields.bits.lr_unit_shift) {
-      context->desc.av1.picture_parameter.lr_unit_size[0] =
-         256 >> (2 - av1->loop_restoration_fields.bits.lr_unit_shift);
-      context->desc.av1.picture_parameter.lr_unit_size[1] =
-         context->desc.av1.picture_parameter.lr_unit_size[2] =
-         (context->desc.av1.picture_parameter.lr_unit_size[0] >>
-          av1->loop_restoration_fields.bits.lr_uv_shift);
+
+   use_lr = av1->loop_restoration_fields.bits.yframe_restoration_type ||
+            av1->loop_restoration_fields.bits.cbframe_restoration_type ||
+            av1->loop_restoration_fields.bits.crframe_restoration_type;
+
+   if (use_lr) {
+      context->desc.av1.picture_parameter.lr_unit_size[0]
+         = 1 << (6 + av1->loop_restoration_fields.bits.lr_unit_shift);
+      context->desc.av1.picture_parameter.lr_unit_size[1]
+         = 1 << (6 + av1->loop_restoration_fields.bits.lr_unit_shift
+                   - av1->loop_restoration_fields.bits.lr_uv_shift);
+      context->desc.av1.picture_parameter.lr_unit_size[2]
+         = context->desc.av1.picture_parameter.lr_unit_size[1];
    } else {
       for (i = 0; i < 3; ++i)
          context->desc.av1.picture_parameter.lr_unit_size[i] = (1 << 8);