-
Notifications
You must be signed in to change notification settings - Fork 110
/
p_sad8x8.c
49 lines (47 loc) · 1.14 KB
/
p_sad8x8.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <pal.h>
/**
* This function returns a scalar sum of the absolute differences between the
* source block 'x' and an 8×8 sub image 'img'.
*
* Notes: cols must be a multiple of 2
*
* @param x Pointer to input image, a 2D array of size 'rows' x 'cols'
*
* @param img Pointer to an 8x8 sub image
*
* @param r Result scalar
*
* @param cols Number of columns in input image
*
* @param rows Number of rows in input image
*
* @return None
*/
void p_sad8x8_f32(const float *x, const float *img, float *r, int rows, int cols)
{
union {
float f;
uint32_t u;
} tmp;
int i,j ;
int k,l ;
const float *px, *pk ;
float *pr=r ;
float sum ;
for (i=0 ; i< cols-8+1 ; i++){
for(j=0 ; j< rows-8+1; j++){
sum = 0 ;
px = x + (i * cols + j);
pk = img ;
for(k=0; k<8 ; k++){
for(l=0; l<8 ; l++){
tmp.f = *(pk++) - *(px++);
tmp.u &= 0x7FFFFFFF ;
sum += tmp.f ;
}
px += cols - 8 ;
}
*(pr++) = sum ;
}
}
}