Am 13.07.2017 um 22:38 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.

Nice catch, just one note below.

(This ordering was likely inherited from
VDPAU, which does pass them in diagonal scan order.)

IIRC it's just how they are encoded in the stream and as the firmware expects it to be.

Signed-off-by: Mark Thompson <s...@jkqxz.net>
---
Fixes some of the related conformance tests (SLIST_A_Sony_4 and 
SLIST_C_Sony_3).  Not sure what's going on with the other SLIST ones, so 
someone with more H.265 knowledge than me might want to look at this.

Also fixes Sony_4K_HDR_Camp, as reported in 
<https://github.com/mpv-player/mpv/issues/4555>.


  src/gallium/state_trackers/va/picture_hevc.c | 39 +++++++++++++++++++++++-----
  1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture_hevc.c 
b/src/gallium/state_trackers/va/picture_hevc.c
index 28743ee7aa..a4825aeb92 100644
--- a/src/gallium/state_trackers/va/picture_hevc.c
+++ b/src/gallium/state_trackers/va/picture_hevc.c
@@ -179,14 +179,41 @@ void vlVaHandlePictureParameterBufferHEVC(vlVaDriver 
*drv, vlVaContext *context,
  void vlVaHandleIQMatrixBufferHEVC(vlVaContext *context, vlVaBuffer *buf)
  {
     VAIQMatrixBufferHEVC *h265 = buf->data;
+   int i, j;
+
+   static const uint8_t diagonal_scan_4x4[16] = {
+       0,  4,  1,  8,  5,  2, 12,  9,  6,  3, 13, 10,  7, 14, 11, 15,
+   };
+   static const uint8_t diagonal_scan_8x8[64] = {
+       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,
+   };

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.

Thanks for the help,
Christian.

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);
+
+   for (i = 0; i < 6; i++) {
+      for (j = 0; j < 16; j++)
+         context->desc.h265.pps->sps->ScalingList4x4[i][j] = 
h265->ScalingList4x4[i][diagonal_scan_4x4[j]];
+
+      for (j = 0; j < 64; j++) {
+         context->desc.h265.pps->sps->ScalingList8x8[i][j] =
+                                h265->ScalingList8x8[i][diagonal_scan_8x8[j]];
+         context->desc.h265.pps->sps->ScalingList16x16[i][j] =
+                                
h265->ScalingList16x16[i][diagonal_scan_8x8[j]];
+
+         if (i < 2)
+            context->desc.h265.pps->sps->ScalingList32x32[i][j] =
+                                   
h265->ScalingList32x32[i][diagonal_scan_8x8[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)


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to