--- sad.c 2003/02/15 15:22:19 1.13 +++ sad.c 2003/06/09 01:22:52 1.13.2.3 @@ -42,10 +42,12 @@ #include "../global.h" #include "sad.h" +#include + sad16FuncPtr sad16; sad8FuncPtr sad8; sad16biFuncPtr sad16bi; -sad8biFuncPtr sad8bi; // not really sad16, but no difference in prototype +sad8biFuncPtr sad8bi; /* not really sad16, but no difference in prototype */ dev16FuncPtr dev16; sad16vFuncPtr sad16v; @@ -65,22 +67,22 @@ uint8_t const *ptr_ref = ref; for (j = 0; j < 16; j++) { - sad += ABS(ptr_cur[0] - ptr_ref[0]); - sad += ABS(ptr_cur[1] - ptr_ref[1]); - sad += ABS(ptr_cur[2] - ptr_ref[2]); - sad += ABS(ptr_cur[3] - ptr_ref[3]); - sad += ABS(ptr_cur[4] - ptr_ref[4]); - sad += ABS(ptr_cur[5] - ptr_ref[5]); - sad += ABS(ptr_cur[6] - ptr_ref[6]); - sad += ABS(ptr_cur[7] - ptr_ref[7]); - sad += ABS(ptr_cur[8] - ptr_ref[8]); - sad += ABS(ptr_cur[9] - ptr_ref[9]); - sad += ABS(ptr_cur[10] - ptr_ref[10]); - sad += ABS(ptr_cur[11] - ptr_ref[11]); - sad += ABS(ptr_cur[12] - ptr_ref[12]); - sad += ABS(ptr_cur[13] - ptr_ref[13]); - sad += ABS(ptr_cur[14] - ptr_ref[14]); - sad += ABS(ptr_cur[15] - ptr_ref[15]); + sad += abs(ptr_cur[0] - ptr_ref[0]); + sad += abs(ptr_cur[1] - ptr_ref[1]); + sad += abs(ptr_cur[2] - ptr_ref[2]); + sad += abs(ptr_cur[3] - ptr_ref[3]); + sad += abs(ptr_cur[4] - ptr_ref[4]); + sad += abs(ptr_cur[5] - ptr_ref[5]); + sad += abs(ptr_cur[6] - ptr_ref[6]); + sad += abs(ptr_cur[7] - ptr_ref[7]); + sad += abs(ptr_cur[8] - ptr_ref[8]); + sad += abs(ptr_cur[9] - ptr_ref[9]); + sad += abs(ptr_cur[10] - ptr_ref[10]); + sad += abs(ptr_cur[11] - ptr_ref[11]); + sad += abs(ptr_cur[12] - ptr_ref[12]); + sad += abs(ptr_cur[13] - ptr_ref[13]); + sad += abs(ptr_cur[14] - ptr_ref[14]); + sad += abs(ptr_cur[15] - ptr_ref[15]); if (sad >= best_sad) return sad; @@ -111,14 +113,7 @@ for (i = 0; i < 16; i++) { int pixel = (ptr_ref1[i] + ptr_ref2[i] + 1) / 2; - - if (pixel < 0) { - pixel = 0; - } else if (pixel > 255) { - pixel = 255; - } - - sad += ABS(ptr_cur[i] - pixel); + sad += abs(ptr_cur[i] - pixel); } ptr_cur += stride; @@ -148,14 +143,7 @@ for (i = 0; i < 8; i++) { int pixel = (ptr_ref1[i] + ptr_ref2[i] + 1) / 2; - - if (pixel < 0) { - pixel = 0; - } else if (pixel > 255) { - pixel = 255; - } - - sad += ABS(ptr_cur[i] - pixel); + sad += abs(ptr_cur[i] - pixel); } ptr_cur += stride; @@ -182,14 +170,14 @@ for (j = 0; j < 8; j++) { - sad += ABS(ptr_cur[0] - ptr_ref[0]); - sad += ABS(ptr_cur[1] - ptr_ref[1]); - sad += ABS(ptr_cur[2] - ptr_ref[2]); - sad += ABS(ptr_cur[3] - ptr_ref[3]); - sad += ABS(ptr_cur[4] - ptr_ref[4]); - sad += ABS(ptr_cur[5] - ptr_ref[5]); - sad += ABS(ptr_cur[6] - ptr_ref[6]); - sad += ABS(ptr_cur[7] - ptr_ref[7]); + sad += abs(ptr_cur[0] - ptr_ref[0]); + sad += abs(ptr_cur[1] - ptr_ref[1]); + sad += abs(ptr_cur[2] - ptr_ref[2]); + sad += abs(ptr_cur[3] - ptr_ref[3]); + sad += abs(ptr_cur[4] - ptr_ref[4]); + sad += abs(ptr_cur[5] - ptr_ref[5]); + sad += abs(ptr_cur[6] - ptr_ref[6]); + sad += abs(ptr_cur[7] - ptr_ref[7]); ptr_cur += stride; ptr_ref += stride; @@ -227,7 +215,7 @@ for (j = 0; j < 16; j++) { for (i = 0; i < 16; i++) - dev += ABS(*(ptr_cur + i) - (int32_t) mean); + dev += abs(*(ptr_cur + i) - (int32_t) mean); ptr_cur += stride; @@ -295,7 +283,7 @@ for (i = 0; i < 16; i++) { - sad += ABS(*(ptr_cur + i) - *(ptr_ref + i) - mean); + sad += abs(*(ptr_cur + i) - *(ptr_ref + i) - mean); if (sad >= best_sad) { return MRSAD16_CORRFACTOR * sad; }