Lines 6-39
Link Here
|
6 |
/* LIMIT: convert a 16.16 fixed-point value to a byte, with clipping. */ |
6 |
/* LIMIT: convert a 16.16 fixed-point value to a byte, with clipping. */ |
7 |
#define LIMIT(x) ((x)>0xffffff?0xff: ((x)<=0xffff?0:((x)>>16))) |
7 |
#define LIMIT(x) ((x)>0xffffff?0xff: ((x)<=0xffff?0:((x)>>16))) |
8 |
|
8 |
|
9 |
unsigned char yuv420p_to_rgb(unsigned char *image, unsigned char *temp, int x, int y, int z) |
|
|
10 |
{ |
11 |
const int numpix = x * y; |
12 |
const int bytes = z; // (z*8) >> 3; |
13 |
int i, j, y00, y01, y10, y11, u, v; |
14 |
unsigned char *pY = image; |
15 |
unsigned char *pU = pY + numpix; |
16 |
unsigned char *pV = pU + numpix / 4; |
17 |
unsigned char *image2 = temp; |
18 |
|
19 |
for(j = 0; j <= y - 2; j += 2) { |
20 |
for(i = 0; i <= x - 2; i += 2) { |
21 |
y00 = *pY; |
22 |
y01 = *(pY + 1); |
23 |
y10 = *(pY + x); |
24 |
y11 = *(pY + x + 1); |
25 |
u = (*pU++) - 128; |
26 |
v = (*pV++) - 128; |
27 |
|
28 |
move_420_block(y00, y01, y10, y11, u, v, x, image2, z * 8); |
29 |
|
30 |
pY += 2; |
31 |
image2 += 2 * bytes; |
32 |
} |
33 |
pY += x; |
34 |
image2 += x * bytes; |
35 |
} |
36 |
} |
37 |
static inline void move_420_block(int yTL, int yTR, int yBL, int yBR, int u, int v, |
9 |
static inline void move_420_block(int yTL, int yTR, int yBL, int yBR, int u, int v, |
38 |
int rowPixels, unsigned char *rgb, int bits) |
10 |
int rowPixels, unsigned char *rgb, int bits) |
39 |
{ |
11 |
{ |
Lines 103-108
Link Here
|
103 |
| (LIMIT(r + yBR) & 0xF8); |
75 |
| (LIMIT(r + yBR) & 0xF8); |
104 |
} |
76 |
} |
105 |
} |
77 |
} |
|
|
78 |
unsigned char yuv420p_to_rgb(unsigned char *image, unsigned char *temp, int x, int y, int z) |
79 |
{ |
80 |
const int numpix = x * y; |
81 |
const int bytes = z; // (z*8) >> 3; |
82 |
int i, j, y00, y01, y10, y11, u, v; |
83 |
unsigned char *pY = image; |
84 |
unsigned char *pU = pY + numpix; |
85 |
unsigned char *pV = pU + numpix / 4; |
86 |
unsigned char *image2 = temp; |
87 |
|
88 |
for(j = 0; j <= y - 2; j += 2) { |
89 |
for(i = 0; i <= x - 2; i += 2) { |
90 |
y00 = *pY; |
91 |
y01 = *(pY + 1); |
92 |
y10 = *(pY + x); |
93 |
y11 = *(pY + x + 1); |
94 |
u = (*pU++) - 128; |
95 |
v = (*pV++) - 128; |
96 |
|
97 |
move_420_block(y00, y01, y10, y11, u, v, x, image2, z * 8); |
98 |
|
99 |
pY += 2; |
100 |
image2 += 2 * bytes; |
101 |
} |
102 |
pY += x; |
103 |
image2 += x * bytes; |
104 |
} |
105 |
} |
106 |
|
106 |
|
107 |
void fix_colour(char *image, int x, int y) |
107 |
void fix_colour(char *image, int x, int y) |
108 |
{ |
108 |
{ |