shithub: openh264

Download patch

ref: 9b0a9428b410ae2f6dfff88238f1bf3deb149595
parent: 1f770c488cfd5400e6e0092a3e49aef841f6c5de
author: Sindre Aamås <[email protected]>
date: Wed Jul 20 05:04:49 EDT 2016

[UT] Test for out-of-bound stores in MC halfpel tests

Initialize destination with random data and verify that no out-of-bound
data is mutated.

--- a/test/encoder/EncUT_MotionCompensation.cpp
+++ b/test/encoder/EncUT_MotionCompensation.cpp
@@ -324,6 +324,7 @@
             int32_t height = iH; \
             uint8_t uAnchor[4][MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
             uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
+            uint8_t uRand[MC_BUFF_HEIGHT][MC_BUFF_DST_STRIDE]; \
             ENFORCE_STACK_ALIGN_2D (uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
             uint8_t* uAnchors[4]; \
             int16_t pBuf[MC_BUFF_DST_STRIDE]; \
@@ -337,6 +338,7 @@
             for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) { \
                 for (int32_t i = 0; i < MC_BUFF_SRC_STRIDE; i++) { \
                     uAnchor[0][j][i] = uSrcTest[j][i] = rand() % 256; \
+                    uRand[j][i] = rand() % 256; \
                 } \
             } \
              \
@@ -344,6 +346,7 @@
             InitMcFunc (&sMcFunc, uiCpuFlag); \
              \
             MCHalfPelFilterAnchor (uAnchors[1], uAnchors[2], uAnchors[3], uAnchors[0], MC_BUFF_SRC_STRIDE, width + 1, height + 1, pBuf + 4); \
+            memcpy (&uDstTest[0][0], &uRand[0][0], sizeof uRand); \
             sMcFunc.pfLumaHalfpelHor (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width + 1, height); \
             for (int32_t j = 0; j < height; j++) { \
                 for (int32_t i = 0; i < width + 1; i++) { \
@@ -350,6 +353,12 @@
                     ASSERT_EQ (uAnchor[1][4 + j][4 + i], uDstTest[j][i]); \
                 } \
             } \
+            for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) { \
+                for (int32_t i = j < height ? width + 1 : 0; i < MC_BUFF_DST_STRIDE; i++) { \
+                    ASSERT_EQ (uRand[j][i], uDstTest[j][i]); \
+                } \
+            } \
+            memcpy (&uDstTest[0][0], &uRand[0][0], sizeof uRand); \
             sMcFunc.pfLumaHalfpelVer (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width, height + 1); \
             for (int32_t j = 0; j < height + 1; j++) { \
                 for (int32_t i = 0; i < width; i++) { \
@@ -356,10 +365,21 @@
                     ASSERT_EQ (uAnchor[2][4 + j][4 + i], uDstTest[j][i]); \
                 } \
             } \
+            for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) { \
+                for (int32_t i = j < height + 1 ? width : 0; i < MC_BUFF_DST_STRIDE; i++) { \
+                    ASSERT_EQ (uRand[j][i], uDstTest[j][i]); \
+                } \
+            } \
+            memcpy (&uDstTest[0][0], &uRand[0][0], sizeof uRand); \
             sMcFunc.pfLumaHalfpelCen (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width + 1, height + 1); \
             for (int32_t j = 0; j < height + 1; j++) { \
                 for (int32_t i = 0; i < width + 1; i++) { \
                     ASSERT_EQ (uAnchor[3][4 + j][4 + i], uDstTest[j][i]); \
+                } \
+            } \
+            for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) { \
+                for (int32_t i = j < height + 1 ? width + 1 : 0; i < MC_BUFF_DST_STRIDE; i++) { \
+                    ASSERT_EQ (uRand[j][i], uDstTest[j][i]); \
                 } \
             } \
         } \