optimize speed a bit

This commit is contained in:
zongor 2023-04-13 19:08:22 -04:00
parent fdafcdb95b
commit bc14ee2c7a
2 changed files with 13 additions and 8 deletions

1
.gitignore vendored
View File

@ -52,3 +52,4 @@ Module.symvers
Mkfile.old
dkms.conf
.ccls-cache/

20
main.c
View File

@ -122,14 +122,18 @@ static unsigned interval_ms = 1000 / FRAME_RATE;
static uint8_t frame_buffer[FRAME_WIDTH * FRAME_HEIGHT * 2];
static void get_frame(uint8_t *buffer) {
for (int i = 0; i < FRAME_HEIGHT; i++) {
for (int j = 0; j < FRAME_WIDTH * 2; j += 4) {
uint8_t c =
config.image_buf[(2 + 320 - 2 * i) * 324 + (2 + 40 + 2 * (j / 2))];
buffer[2 * FRAME_WIDTH * i + j] = c;
buffer[2 * FRAME_WIDTH * i + j + 1] = 128;
buffer[2 * FRAME_WIDTH * i + j + 2] = c;
buffer[2 * FRAME_WIDTH * i + j + 3] = 128;
uint8_t *ptr = buffer;
int offset, i, j;
uint8_t c;
for (i = 0; i < FRAME_HEIGHT; i++) {
offset = (-648 * i) + 104370;
for (j = 0; j < FRAME_WIDTH * 2; j += 4) {
c = config.image_buf[offset + j];
*ptr++ = c;
*ptr++ = 128;
*ptr++ = c;
*ptr++ = 128;
}
}
}