CR3-Qstep table: avoid wrong 64-bit code generation
authorAlex Tutubalin <lexa@lexa.ru>
Thu, 4 Jan 2024 12:36:38 +0000 (15:36 +0300)
committerBenjamin Drung <bdrung@debian.org>
Wed, 28 Feb 2024 19:43:42 +0000 (19:43 +0000)
Gbp-Pq: Name 0001-CR3-Qstep-table-avoid-wrong-64-bit-code-generation.patch

src/decoders/crx.cpp

index 30a702054ed11534d76c061f37881f5efdf713c0..0289c075b83a9577352000b49d825f481f17c608 100644 (file)
@@ -2032,7 +2032,7 @@ int crxMakeQStep(CrxImage *img, CrxTile *tile, int32_t *qpTable, uint32_t /*tota
         // not sure about this nonsense - why is it not just avg like with 2 levels?\r
         quantVal = ((quantVal < 0) * 3 + quantVal) >> 2;\r
         if (quantVal / 6 >= 6)\r
-          *qStepTbl = q_step_tbl[quantVal % 6] * (1 << (quantVal / 6 + 26));\r
+          *qStepTbl = q_step_tbl[quantVal % 6] << ((quantVal / 6 - 6 ) & 0x1f);\r
         else\r
           *qStepTbl = q_step_tbl[quantVal % 6] >> (6 - quantVal / 6);\r
       }\r
@@ -2052,7 +2052,7 @@ int crxMakeQStep(CrxImage *img, CrxTile *tile, int32_t *qpTable, uint32_t /*tota
       {\r
         int32_t quantVal = (qpTable[row0Idx++] + qpTable[row1Idx++]) / 2;\r
         if (quantVal / 6 >= 6)\r
-          *qStepTbl = q_step_tbl[quantVal % 6] * (1 << (quantVal / 6 + 26));\r
+          *qStepTbl = q_step_tbl[quantVal % 6] << ((quantVal / 6 - 6) & 0x1f);\r
         else\r
           *qStepTbl = q_step_tbl[quantVal % 6] >> (6 - quantVal / 6);\r
       }\r
@@ -2066,7 +2066,7 @@ int crxMakeQStep(CrxImage *img, CrxTile *tile, int32_t *qpTable, uint32_t /*tota
     for (int qpRow = 0; qpRow < qpHeight; ++qpRow)\r
       for (int qpCol = 0; qpCol < qpWidth; ++qpCol, ++qStepTbl, ++qpTable)\r
         if (*qpTable / 6 >= 6)\r
-          *qStepTbl = q_step_tbl[*qpTable % 6] * (1 << (*qpTable / 6 + 26));\r
+          *qStepTbl = q_step_tbl[*qpTable % 6] << ((*qpTable / 6 - 6) & 0x1f);\r
         else\r
           *qStepTbl = q_step_tbl[*qpTable % 6] >> (6 - *qpTable / 6);\r
 \r