[Mesa-dev] [PATCH v2] st/va: Fix scaling list ordering for H.265

Christian König deathsimple at vodafone.de
Mon Jul 17 13:50:03 UTC 2017


Am 15.07.2017 um 20:51 schrieb Mark Thompson:
> Mesa here requires the scaling lists in diagonal scan order, but
> VAAPI passes them in raster scan order.  Therefore, rearrange the
> elements when copying.
>
> v2: Move scan tables to vl_zscan.c.
>      Fix type in size assertion.
>
> Signed-off-by: Mark Thompson <sw at jkqxz.net>

Reviewed-by: Christian König <christian.koenig at amd.com>

You still don't have write access to Mesa, don't you?

Thanks for the help,
Christian.

> ---
> On 14/07/17 11:01, Christian König wrote:
>> That just looks like the inversed Z-scan order we already have in vl_zscan.[hc].
>>
>> Please use that one instead and/or add new defines into that file if necessary.
> They are not the same as any of the existing orders, so I've added new tables.
>
> Thanks,
>
> - Mark
>
>
>   src/gallium/auxiliary/vl/vl_zscan.c          | 21 ++++++++++++++++++
>   src/gallium/auxiliary/vl/vl_zscan.h          |  2 ++
>   src/gallium/state_trackers/va/picture_hevc.c | 33 ++++++++++++++++++++++------
>   3 files changed, 49 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c
> index 24d64525b7..75013c42bf 100644
> --- a/src/gallium/auxiliary/vl/vl_zscan.c
> +++ b/src/gallium/auxiliary/vl/vl_zscan.c
> @@ -95,6 +95,27 @@ const int vl_zscan_alternate[] =
>      38,46,54,62,39,47,55,63
>   };
>   
> +const int vl_zscan_h265_up_right_diagonal_16[] =
> +{
> +   /* Up-right diagonal scan order for 4x4 blocks - see H.265 section 6.5.3. */
> +    0,  4,  1,  8,  5,  2, 12,  9,
> +    6,  3, 13, 10,  7, 14, 11, 15,
> +};
> +
> +const int vl_zscan_h265_up_right_diagonal[] =
> +{
> +   /* Up-right diagonal scan order for 8x8 blocks - see H.265 section 6.5.3. */
> +    0,  8,  1, 16,  9,  2, 24, 17,
> +   10,  3, 32, 25, 18, 11,  4, 40,
> +   33, 26, 19, 12,  5, 48, 41, 34,
> +   27, 20, 13,  6, 56, 49, 42, 35,
> +   28, 21, 14,  7, 57, 50, 43, 36,
> +   29, 22, 15, 58, 51, 44, 37, 30,
> +   23, 59, 52, 45, 38, 31, 60, 53,
> +   46, 39, 61, 54, 47, 62, 55, 63,
> +};
> +
> +
>   static void *
>   create_vert_shader(struct vl_zscan *zscan)
>   {
> diff --git a/src/gallium/auxiliary/vl/vl_zscan.h b/src/gallium/auxiliary/vl/vl_zscan.h
> index 268cf0a6e3..292152e873 100644
> --- a/src/gallium/auxiliary/vl/vl_zscan.h
> +++ b/src/gallium/auxiliary/vl/vl_zscan.h
> @@ -68,6 +68,8 @@ extern const int vl_zscan_normal_16[];
>   extern const int vl_zscan_linear[];
>   extern const int vl_zscan_normal[];
>   extern const int vl_zscan_alternate[];
> +extern const int vl_zscan_h265_up_right_diagonal_16[];
> +extern const int vl_zscan_h265_up_right_diagonal[];
>   
>   struct pipe_sampler_view *
>   vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line);
> diff --git a/src/gallium/state_trackers/va/picture_hevc.c b/src/gallium/state_trackers/va/picture_hevc.c
> index 28743ee7aa..e879259ae1 100644
> --- a/src/gallium/state_trackers/va/picture_hevc.c
> +++ b/src/gallium/state_trackers/va/picture_hevc.c
> @@ -25,6 +25,7 @@
>    *
>    **************************************************************************/
>   
> +#include "vl/vl_zscan.h"
>   #include "va_private.h"
>   
>   void vlVaHandlePictureParameterBufferHEVC(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
> @@ -179,14 +180,32 @@ void vlVaHandlePictureParameterBufferHEVC(vlVaDriver *drv, vlVaContext *context,
>   void vlVaHandleIQMatrixBufferHEVC(vlVaContext *context, vlVaBuffer *buf)
>   {
>      VAIQMatrixBufferHEVC *h265 = buf->data;
> +   int i, j;
>   
> -   assert(buf->size >= sizeof(VAIQMatrixBufferH264) && buf->num_elements == 1);
> -   memcpy(&context->desc.h265.pps->sps->ScalingList4x4, h265->ScalingList4x4, 6 * 16);
> -   memcpy(&context->desc.h265.pps->sps->ScalingList8x8, h265->ScalingList8x8, 6 * 64);
> -   memcpy(&context->desc.h265.pps->sps->ScalingList16x16, h265->ScalingList16x16, 6 * 64);
> -   memcpy(&context->desc.h265.pps->sps->ScalingList32x32, h265->ScalingList32x32, 2 * 64);
> -   memcpy(&context->desc.h265.pps->sps->ScalingListDCCoeff16x16, h265->ScalingListDC16x16, 6);
> -   memcpy(&context->desc.h265.pps->sps->ScalingListDCCoeff32x32, h265->ScalingListDC32x32, 2);
> +   assert(buf->size >= sizeof(VAIQMatrixBufferHEVC) && buf->num_elements == 1);
> +
> +   for (i = 0; i < 6; i++) {
> +      for (j = 0; j < 16; j++)
> +         context->desc.h265.pps->sps->ScalingList4x4[i][j] =
> +                                h265->ScalingList4x4[i][vl_zscan_h265_up_right_diagonal_16[j]];
> +
> +      for (j = 0; j < 64; j++) {
> +         context->desc.h265.pps->sps->ScalingList8x8[i][j] =
> +                                h265->ScalingList8x8[i][vl_zscan_h265_up_right_diagonal[j]];
> +         context->desc.h265.pps->sps->ScalingList16x16[i][j] =
> +                                h265->ScalingList16x16[i][vl_zscan_h265_up_right_diagonal[j]];
> +
> +         if (i < 2)
> +            context->desc.h265.pps->sps->ScalingList32x32[i][j] =
> +                                   h265->ScalingList32x32[i][vl_zscan_h265_up_right_diagonal[j]];
> +      }
> +
> +      context->desc.h265.pps->sps->ScalingListDCCoeff16x16[i] =
> +                             h265->ScalingListDC16x16[i];
> +      if (i < 2)
> +         context->desc.h265.pps->sps->ScalingListDCCoeff32x32[i] =
> +                                h265->ScalingListDC32x32[i];
> +   }
>   }
>   
>   void vlVaHandleSliceParameterBufferHEVC(vlVaContext *context, vlVaBuffer *buf)




More information about the mesa-dev mailing list