shithub: openh264

Download patch

ref: 93db6511a84a56950390eec7d71f9e3255dd4c75
parent: 57fc3e991792ea277a309bcc9351bb800d46b380
author: Sindre Aamås <[email protected]>
date: Mon Apr 11 11:55:20 EDT 2016

[UT] Test VAA routines with a wider variety of resolutions

Test even and odd multiples of 32 width because some AVX2 routines
have conditional logic based on that.

--- a/test/processing/ProcessUT_VaaCalc.cpp
+++ b/test/processing/ProcessUT_VaaCalc.cpp
@@ -590,20 +590,22 @@
     int32_t pic_height_a; \
     int32_t pic_stride_a; \
     int32_t psadframe_a; \
-    pic_width_c  = pic_width_a = 320-16; \
-    pic_height_c = pic_height_a = 320; \
-    pic_stride_c = pic_stride_a = 320; \
-    psadframe_c = psadframe_a = 0; \
-    for (int j=0; j<BUFFER_SIZE; j++) { \
-        cur_data_c[j] = cur_data_a[j] = (rand()%256); \
-        ref_data_c[j] = ref_data_a[j] = (rand()%256); \
-        psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+    for (int i=0; i<4; i++) { \
+        pic_width_c  = pic_width_a = 320-16*i; \
+        pic_height_c = pic_height_a = 320; \
+        pic_stride_c = pic_stride_a = 320; \
+        psadframe_c = psadframe_a = 0; \
+        for (int j=0; j<BUFFER_SIZE; j++) { \
+            cur_data_c[j] = cur_data_a[j] = (rand()%256); \
+            ref_data_c[j] = ref_data_a[j] = (rand()%256); \
+            psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+        } \
+        VAACalcSad_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c); \
+        func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a); \
+        ASSERT_EQ (psadframe_a, psadframe_c); \
+        for (int j=0; j<(BUFFER_SIZE/64); j++) \
+            ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
     } \
-    VAACalcSad_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c); \
-    func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a); \
-    ASSERT_EQ (psadframe_a, psadframe_c); \
-    for (int j=0; j<(BUFFER_SIZE/64); j++) \
-        ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
 }
 
 
@@ -633,25 +635,27 @@
     int32_t pic_height_a; \
     int32_t pic_stride_a; \
     int32_t psadframe_a; \
-    pic_width_c  = pic_width_a = 320-16; \
-    pic_height_c = pic_height_a = 320; \
-    pic_stride_c = pic_stride_a = 320; \
-    psadframe_c = psadframe_a = 0; \
-    for (int j=0; j<BUFFER_SIZE; j++) { \
-        cur_data_c[j] = cur_data_a[j] = (rand()%256); \
-        ref_data_c[j] = ref_data_a[j] = (rand()%256); \
-        psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
-        psd8x8_c[j%(BUFFER_SIZE/64)]  = psd8x8_a[j%(BUFFER_SIZE/64)]  = (rand()%256); \
-        pmad8x8_c[j%(BUFFER_SIZE/64)] = pmad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+    for (int i=0; i<4; i++) { \
+        pic_width_c  = pic_width_a = 320-16*i; \
+        pic_height_c = pic_height_a = 320; \
+        pic_stride_c = pic_stride_a = 320; \
+        psadframe_c = psadframe_a = 0; \
+        for (int j=0; j<BUFFER_SIZE; j++) { \
+            cur_data_c[j] = cur_data_a[j] = (rand()%256); \
+            ref_data_c[j] = ref_data_a[j] = (rand()%256); \
+            psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+            psd8x8_c[j%(BUFFER_SIZE/64)]  = psd8x8_a[j%(BUFFER_SIZE/64)]  = (rand()%256); \
+            pmad8x8_c[j%(BUFFER_SIZE/64)] = pmad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+        } \
+        VAACalcSadBgd_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psd8x8_c, pmad8x8_c); \
+        func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psd8x8_a, pmad8x8_a); \
+        ASSERT_EQ (psadframe_a, psadframe_c); \
+        for (int j=0; j<(BUFFER_SIZE/64); j++) {\
+            ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
+            ASSERT_EQ (psd8x8_a[j], psd8x8_c[j]); \
+            ASSERT_EQ (pmad8x8_a[j], pmad8x8_c[j]); \
+        } \
     } \
-    VAACalcSadBgd_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psd8x8_c, pmad8x8_c); \
-    func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psd8x8_a, pmad8x8_a); \
-    ASSERT_EQ (psadframe_a, psadframe_c); \
-    for (int j=0; j<(BUFFER_SIZE/64); j++) {\
-        ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
-        ASSERT_EQ (psd8x8_a[j], psd8x8_c[j]); \
-        ASSERT_EQ (pmad8x8_a[j], pmad8x8_c[j]); \
-    } \
 }
 
 #define GENERATE_VAACalcSadSsd_UT(func, ASM, CPUFLAGS) \
@@ -682,29 +686,31 @@
     int32_t pic_height_a; \
     int32_t pic_stride_a; \
     int32_t psadframe_a; \
-    pic_width_c  = pic_width_a = 320-16; \
-    pic_height_c = pic_height_a = 320; \
-    pic_stride_c = pic_stride_a = 320; \
-    psadframe_c = psadframe_a = 0; \
-    for (int j=0; j<BUFFER_SIZE; j++) { \
-        cur_data_c[j] = cur_data_a[j] = (rand()%256); \
-        ref_data_c[j] = ref_data_a[j] = (rand()%256); \
-        psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
-        psum16x16_c[j%(BUFFER_SIZE/256)]    = psum16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
-        psqsum16x16_c[j%(BUFFER_SIZE/256)]  = psqsum16x16_a[j%(BUFFER_SIZE/256)]  = (rand()%256); \
-        psqdiff16x16_c[j%(BUFFER_SIZE/256)] = psqdiff16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
+    for (int i=0; i<4; i++) { \
+        pic_width_c  = pic_width_a = 320-16*i; \
+        pic_height_c = pic_height_a = 320; \
+        pic_stride_c = pic_stride_a = 320; \
+        psadframe_c = psadframe_a = 0; \
+        for (int j=0; j<BUFFER_SIZE; j++) { \
+            cur_data_c[j] = cur_data_a[j] = (rand()%256); \
+            ref_data_c[j] = ref_data_a[j] = (rand()%256); \
+            psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+            psum16x16_c[j%(BUFFER_SIZE/256)]    = psum16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
+            psqsum16x16_c[j%(BUFFER_SIZE/256)]  = psqsum16x16_a[j%(BUFFER_SIZE/256)]  = (rand()%256); \
+            psqdiff16x16_c[j%(BUFFER_SIZE/256)] = psqdiff16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
+        } \
+        VAACalcSadSsd_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psum16x16_c, psqsum16x16_c, psqdiff16x16_c); \
+        func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psum16x16_a, psqsum16x16_a, psqdiff16x16_a); \
+        ASSERT_EQ (psadframe_a, psadframe_c); \
+        for (int j=0; j<(BUFFER_SIZE/64); j++) {\
+            ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
+        } \
+        for (int j=0; j<(BUFFER_SIZE/256); j++) {\
+            ASSERT_EQ (psum16x16_a[j], psum16x16_c[j]); \
+            ASSERT_EQ (psqsum16x16_a[j], psqsum16x16_c[j]); \
+            ASSERT_EQ (psqdiff16x16_a[j], psqdiff16x16_c[j]); \
+        } \
     } \
-    VAACalcSadSsd_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psum16x16_c, psqsum16x16_c, psqdiff16x16_c); \
-    func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psum16x16_a, psqsum16x16_a, psqdiff16x16_a); \
-    ASSERT_EQ (psadframe_a, psadframe_c); \
-    for (int j=0; j<(BUFFER_SIZE/64); j++) {\
-        ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
-    } \
-    for (int j=0; j<(BUFFER_SIZE/256); j++) {\
-        ASSERT_EQ (psum16x16_a[j], psum16x16_c[j]); \
-        ASSERT_EQ (psqsum16x16_a[j], psqsum16x16_c[j]); \
-        ASSERT_EQ (psqdiff16x16_a[j], psqdiff16x16_c[j]); \
-    } \
 }
 
 #define GENERATE_VAACalcSadVar_UT(func, ASM, CPUFLAGS) \
@@ -733,27 +739,29 @@
     int32_t pic_height_a; \
     int32_t pic_stride_a; \
     int32_t psadframe_a; \
-    pic_width_c  = pic_width_a = 320-16; \
-    pic_height_c = pic_height_a = 320; \
-    pic_stride_c = pic_stride_a = 320; \
-    psadframe_c = psadframe_a = 0; \
-    for (int j=0; j<BUFFER_SIZE; j++) { \
-        cur_data_c[j] = cur_data_a[j] = (rand()%256); \
-        ref_data_c[j] = ref_data_a[j] = (rand()%256); \
-        psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
-        psum16x16_c[j%(BUFFER_SIZE/256)]    = psum16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
-        psqsum16x16_c[j%(BUFFER_SIZE/256)]  = psqsum16x16_a[j%(BUFFER_SIZE/256)]  = (rand()%256); \
+    for (int i=0; i<4; i++) { \
+        pic_width_c  = pic_width_a = 320-16*i; \
+        pic_height_c = pic_height_a = 320; \
+        pic_stride_c = pic_stride_a = 320; \
+        psadframe_c = psadframe_a = 0; \
+        for (int j=0; j<BUFFER_SIZE; j++) { \
+            cur_data_c[j] = cur_data_a[j] = (rand()%256); \
+            ref_data_c[j] = ref_data_a[j] = (rand()%256); \
+            psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+            psum16x16_c[j%(BUFFER_SIZE/256)]    = psum16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
+            psqsum16x16_c[j%(BUFFER_SIZE/256)]  = psqsum16x16_a[j%(BUFFER_SIZE/256)]  = (rand()%256); \
+        } \
+        VAACalcSadVar_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psum16x16_c, psqsum16x16_c); \
+        func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psum16x16_a, psqsum16x16_a); \
+        ASSERT_EQ (psadframe_a, psadframe_c); \
+        for (int j=0; j<(BUFFER_SIZE/64); j++) {\
+            ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
+        } \
+        for (int j=0; j<(BUFFER_SIZE/256); j++) {\
+            ASSERT_EQ (psum16x16_a[j], psum16x16_c[j]); \
+            ASSERT_EQ (psqsum16x16_a[j], psqsum16x16_c[j]); \
+        } \
     } \
-    VAACalcSadVar_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psum16x16_c, psqsum16x16_c); \
-    func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psum16x16_a, psqsum16x16_a); \
-    ASSERT_EQ (psadframe_a, psadframe_c); \
-    for (int j=0; j<(BUFFER_SIZE/64); j++) {\
-        ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
-    } \
-    for (int j=0; j<(BUFFER_SIZE/256); j++) {\
-        ASSERT_EQ (psum16x16_a[j], psum16x16_c[j]); \
-        ASSERT_EQ (psqsum16x16_a[j], psqsum16x16_c[j]); \
-    } \
 }
 
 #define GENERATE_VAACalcSadSsdBgd_UT(func, ASM, CPUFLAGS) \
@@ -788,32 +796,34 @@
     int32_t pic_height_a; \
     int32_t pic_stride_a; \
     int32_t psadframe_a; \
-    pic_width_c  = pic_width_a = 320-16; \
-    pic_height_c = pic_height_a = 320; \
-    pic_stride_c = pic_stride_a = 320; \
-    psadframe_c = psadframe_a = 0; \
-    for (int j=0; j<BUFFER_SIZE; j++) { \
-        cur_data_c[j] = cur_data_a[j] = (rand()%256); \
-        ref_data_c[j] = ref_data_a[j] = (rand()%256); \
-        psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
-        psd8x8_c[j%(BUFFER_SIZE/64)]  = psd8x8_a[j%(BUFFER_SIZE/64)]  = (rand()%256); \
-        pmad8x8_c[j%(BUFFER_SIZE/64)] = pmad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
-        psum16x16_c[j%(BUFFER_SIZE/256)]    = psum16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
-        psqsum16x16_c[j%(BUFFER_SIZE/256)]  = psqsum16x16_a[j%(BUFFER_SIZE/256)]  = (rand()%256); \
-        psqdiff16x16_c[j%(BUFFER_SIZE/256)] = psqdiff16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
-    } \
-    VAACalcSadSsdBgd_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psum16x16_c, psqsum16x16_c, psqdiff16x16_c, psd8x8_c, pmad8x8_c); \
-    func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psum16x16_a, psqsum16x16_a, psqdiff16x16_a, psd8x8_a, pmad8x8_a); \
-    ASSERT_EQ (psadframe_a, psadframe_c); \
-    for (int j=0; j<(BUFFER_SIZE/64); j++) {\
-        ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
-        ASSERT_EQ (psd8x8_a[j], psd8x8_c[j]); \
-        ASSERT_EQ (pmad8x8_a[j], pmad8x8_c[j]); \
-    } \
-    for (int j=0; j<(BUFFER_SIZE/256); j++) {\
-        ASSERT_EQ (psum16x16_a[j], psum16x16_c[j]); \
-        ASSERT_EQ (psqsum16x16_a[j], psqsum16x16_c[j]); \
-        ASSERT_EQ (psqdiff16x16_a[j], psqdiff16x16_c[j]); \
+    for (int i=0; i<4; i++) { \
+        pic_width_c  = pic_width_a = 320-16*i; \
+        pic_height_c = pic_height_a = 320; \
+        pic_stride_c = pic_stride_a = 320; \
+        psadframe_c = psadframe_a = 0; \
+        for (int j=0; j<BUFFER_SIZE; j++) { \
+            cur_data_c[j] = cur_data_a[j] = (rand()%256); \
+            ref_data_c[j] = ref_data_a[j] = (rand()%256); \
+            psad8x8_c[j%(BUFFER_SIZE/64)] = psad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+            psd8x8_c[j%(BUFFER_SIZE/64)]  = psd8x8_a[j%(BUFFER_SIZE/64)]  = (rand()%256); \
+            pmad8x8_c[j%(BUFFER_SIZE/64)] = pmad8x8_a[j%(BUFFER_SIZE/64)] = (rand()%256); \
+            psum16x16_c[j%(BUFFER_SIZE/256)]    = psum16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
+            psqsum16x16_c[j%(BUFFER_SIZE/256)]  = psqsum16x16_a[j%(BUFFER_SIZE/256)]  = (rand()%256); \
+            psqdiff16x16_c[j%(BUFFER_SIZE/256)] = psqdiff16x16_a[j%(BUFFER_SIZE/256)] = (rand()%256); \
+        } \
+        VAACalcSadSsdBgd_ref (cur_data_c, ref_data_c, pic_width_c, pic_height_c, pic_stride_c, &psadframe_c, psad8x8_c, psum16x16_c, psqsum16x16_c, psqdiff16x16_c, psd8x8_c, pmad8x8_c); \
+        func (cur_data_a, ref_data_a, pic_width_a, pic_height_a, pic_stride_a, &psadframe_a, psad8x8_a, psum16x16_a, psqsum16x16_a, psqdiff16x16_a, psd8x8_a, pmad8x8_a); \
+        ASSERT_EQ (psadframe_a, psadframe_c); \
+        for (int j=0; j<(BUFFER_SIZE/64); j++) {\
+            ASSERT_EQ (psad8x8_a[j], psad8x8_c[j]); \
+            ASSERT_EQ (psd8x8_a[j], psd8x8_c[j]); \
+            ASSERT_EQ (pmad8x8_a[j], pmad8x8_c[j]); \
+        } \
+        for (int j=0; j<(BUFFER_SIZE/256); j++) {\
+            ASSERT_EQ (psum16x16_a[j], psum16x16_c[j]); \
+            ASSERT_EQ (psqsum16x16_a[j], psqsum16x16_c[j]); \
+            ASSERT_EQ (psqdiff16x16_a[j], psqdiff16x16_c[j]); \
+        } \
     } \
 }