forked from victorvde/jpeg2png
-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.c
36 lines (34 loc) · 1.38 KB
/
box.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
#include "box.h"
#include "utils.h"
// convert from 8x8 blocks to normal order
void unbox(float* in, float* out, unsigned w, unsigned h) {
ASSUME((w & 7) == 0);
ASSUME((h & 7) == 0);
ASSUME_ALIGNED(in);
ASSUME_ALIGNED(out);
for(unsigned block_y = 0; block_y < h / 8; block_y++) {
for(unsigned block_x = 0; block_x < w / 8; block_x++) {
for(unsigned in_y = 0; in_y < 8; in_y++) {
for(unsigned in_x = 0; in_x < 8; in_x++) {
*p(out, block_x * 8 + in_x, block_y * 8 + in_y, w, h) = *in++;
}
}
}
}
}
// convert from normal order to 8x8 blocks
void box(float* in, float* out, unsigned w, unsigned h) {
ASSUME((w & 7) == 0);
ASSUME((h & 7) == 0);
ASSUME_ALIGNED(in);
ASSUME_ALIGNED(out);
for(unsigned block_y = 0; block_y < h / 8; block_y++) {
for(unsigned block_x = 0; block_x < w / 8; block_x++) {
for(unsigned in_y = 0; in_y < 8; in_y++) {
for(unsigned in_x = 0; in_x < 8; in_x++) {
*out++ = *p(in, block_x * 8 + in_x, block_y * 8 + in_y, w, h);
}
}
}
}
}