[PATCH] fill 32x32 scaling matrices
authorDirk Farin <dirk.farin@gmail.com>
Tue, 23 Feb 2021 15:29:01 +0000 (16:29 +0100)
committerPhilipp Kern <pkern@debian.org>
Sun, 16 Oct 2022 13:26:20 +0000 (14:26 +0100)
Gbp-Pq: Name 0001-fill-32x32-scaling-matrices.patch

libde265/sps.cc
libde265/sps.h
libde265/transform.cc

index 476cdbb1e7ade5136a38bb701a328113a89700db..47c157a4ded0a30f9fc1250009177b31756fc74e 100644 (file)
@@ -873,10 +873,10 @@ de265_error read_scaling_list(bitreader* br, const seq_parameter_set* sps,
   int dc_coeff[4][6];
 
   for (int sizeId=0;sizeId<4;sizeId++) {
-    int n = ((sizeId==3) ? 2 : 6);
+    //int n = ((sizeId==3) ? 2 : 6);
     uint8_t scaling_list[6][32*32];
 
-    for (int matrixId=0;matrixId<n;matrixId++) {
+    for (int matrixId=0 ; matrixId<6 ; matrixId += (sizeId==3 ? 3 : 1)) {
       uint8_t* curr_scaling_list = scaling_list[matrixId];
       int scaling_list_dc_coef;
 
@@ -982,6 +982,27 @@ de265_error read_scaling_list(bitreader* br, const seq_parameter_set* sps,
     }
   }
 
+
+  // --- fill 32x32 matrices for chroma
+
+  const position* scan = get_scan_order(3, 0 /* diag */);
+       
+  for (int matrixId=0;matrixId<6;matrixId++)
+    if (matrixId!=0 && matrixId!=3) {
+      for (int i=0;i<64;i++) {
+       int x = scan[i].x;
+       int y = scan[i].y;
+       int v = sclist->ScalingFactor_Size1[matrixId][y][x];
+
+       for (int dy=0;dy<4;dy++)
+         for (int dx=0;dx<4;dx++) {
+           sclist->ScalingFactor_Size3[matrixId][4*y+dy][4*x+dx] = v;
+         }
+      }
+
+      sclist->ScalingFactor_Size3[matrixId][0][0] = sclist->ScalingFactor_Size1[matrixId][0][0];
+    }
+  
   return DE265_OK;
 }
 
index b06151d2343704f309666863c6b16640b469a110..2204f657925049044e7d9dad2627c316d9438a60 100644 (file)
@@ -54,7 +54,7 @@ typedef struct scaling_list_data {
   uint8_t ScalingFactor_Size0[6][4][4];
   uint8_t ScalingFactor_Size1[6][8][8];
   uint8_t ScalingFactor_Size2[6][16][16];
-  uint8_t ScalingFactor_Size3[2][32][32];
+  uint8_t ScalingFactor_Size3[6][32][32];
 } scaling_list_data;
 
 
index ef404f8e53483a7733158a4b000d668c4e8ed435..cf07460614ea67d75416bed985f2ee3ca00233b9 100644 (file)
@@ -504,10 +504,8 @@ void scale_coefficients_internal(thread_context* tctx,
 
       for (int i=0;i<tctx->nCoeff[cIdx];i++) {
         int pos = tctx->coeffPos[cIdx][i];
-        int x = pos%nT;
-        int y = pos/nT;
 
-        const int m_x_y = sclist[x+y*nT];
+        const int m_x_y = sclist[pos];
         const int fact = m_x_y * levelScale[qP%6] << (qP/6);
 
         int64_t currCoeff  = tctx->coeffList[cIdx][i];