shithub: openh264

Download patch

ref: 31453e3072781a67674c4605b3ef9c8d74fe1d98
parent: 853423b5ada4f731ee5159a08ae4c44f0e1f68e7
author: Martin Storsjö <[email protected]>
date: Fri May 15 06:04:16 EDT 2015

Revert broken big-endian fix for DeblockingBsMarginalMBAvcbase

The function actually was correct for big-endian use already
(and the changes in 239e22d0 actually broke normal decoding tests),
it was only the test function itself that needed fixing for big-endian.

--- a/codec/decoder/core/src/deblocking.cpp
+++ b/codec/decoder/core/src/deblocking.cpp
@@ -279,7 +279,8 @@
 
 uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) {
   int32_t i, j;
-  uint8_t pBS[4];
+  uint32_t uiBSx4;
+  uint8_t* pBS = (uint8_t*) (&uiBSx4);
   const uint8_t* pBIdx      = &g_kuiTableBIdx[iEdge][0];
   const uint8_t* pBnIdx     = &g_kuiTableBIdx[iEdge][4];
   const uint8_t* pB8x8Idx   = &g_kuiTableB8x8Idx[iEdge][0];
@@ -348,7 +349,7 @@
     }
   }
 
-  return pBS[0] | (pBS[1] << 8) | (pBS[2] << 16) | (pBS[3] << 24);
+  return uiBSx4;
 }
 int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) {
   int32_t iMbY = pCurDqLayer->iMbY;
--- a/test/decoder/DecUT_DeblockCommon.cpp
+++ b/test/decoder/DecUT_DeblockCommon.cpp
@@ -773,6 +773,8 @@
   int8_t iNoZeroCount[24 * 2]; // (*pNzc)[24]
   int8_t iLayerRefIndex[2][16 * 2]; // (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM];
   int16_t iLayerMv[2][16 * 2][2]; //(*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
+  uint32_t uiBSx4;
+  uint8_t* pBS = (uint8_t*) (&uiBSx4);
 
   sDqLayer.pNzc = (int8_t (*)[24])iNoZeroCount;
   sDqLayer.pRefIndex[0] = (int8_t (*)[16])&iLayerRefIndex[0];
@@ -790,6 +792,10 @@
   memset(iLayerRefIndex, 0, sizeof(int8_t)*2*16*2); \
   memset(iLayerMv, 0, sizeof(int16_t)*2*16*2*2);
 
+#define SET_REF_VALUE(value, pos) \
+  uiBSx4 = 0; \
+  pBS[pos] = value;
+
   int32_t iCurrBlock, iNeighborBlock;
 
   /* Cycle for each block and its neighboring block */
@@ -801,21 +807,24 @@
       // (1) iEdge == 0, current block NoZeroCount != 0
       UT_DB_CLEAN_STATUS
       iNoZeroCount[0 * 24 + iCurrBlock] = 1; // Current MB_block position
+      SET_REF_VALUE(2, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (2u << (iPos * 8))) << iEdge << " " << iPos << " NoZeroCount!=0";
+                   0) == uiBSx4) << iEdge << " " << iPos << " NoZeroCount!=0";
 
       // (2) iEdge == 0, neighbor block NoZeroCount != 0
       UT_DB_CLEAN_STATUS
       iNoZeroCount[1 * 24 + iNeighborBlock ] = 1; // Neighbor MB_block position
+      SET_REF_VALUE(2, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (2u << (iPos * 8))) << iEdge << " " << iPos << " NoZeroCount!=0";
+                   0) == uiBSx4) << iEdge << " " << iPos << " NoZeroCount!=0";
 
       // (3) iEdge == 0, reference idx diff
       UT_DB_CLEAN_STATUS
       iLayerRefIndex[0][0 * 16 + iCurrBlock] = 0;
       iLayerRefIndex[0][1 * 16 + iNeighborBlock] = 1;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " Ref idx diff";
+                   0) == uiBSx4) << iEdge << " " << iPos << " Ref idx diff";
 
       // (4) iEdge == 0, abs(mv diff) < 4
       UT_DB_CLEAN_STATUS
@@ -837,35 +846,41 @@
       // (5) iEdge == 0, abs(mv diff) > 4
       UT_DB_CLEAN_STATUS
       iLayerMv[0][0 * 16 + iCurrBlock][0] = 4;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " diff_mv == 4";
+                   0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
 
       UT_DB_CLEAN_STATUS
       iLayerMv[0][0 * 16 + iCurrBlock][1] = 4;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " diff_mv == 4";
+                   0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
 
       UT_DB_CLEAN_STATUS
       iLayerMv[0][1 * 16 + iNeighborBlock][0] = 4;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " diff_mv == 4";
+                   0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
 
       UT_DB_CLEAN_STATUS
       iLayerMv[0][1 * 16 + iNeighborBlock][1] = 4;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " diff_mv == 4";
+                   0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
 
       UT_DB_CLEAN_STATUS
       iLayerMv[0][0 * 16 + iCurrBlock][0] = -2048;
       iLayerMv[0][1 * 16 + iNeighborBlock][0] = 2047;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " diff_mv == maximum";
+                   0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == maximum";
 
       UT_DB_CLEAN_STATUS
       iLayerMv[0][0 * 16 + iCurrBlock][1] = -2048;
       iLayerMv[0][1 * 16 + iNeighborBlock][1] = 2047;
+      SET_REF_VALUE(1, iPos);
       EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sDqLayer, iEdge, 1,
-                   0) == (1u << (iPos * 8))) << iEdge << " " << iPos << " diff_mv == maximum";
+                   0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == maximum";
     }
   }
 }