diff options
author | Jan Klemkow <j.klemkow@wemelug.de> | 2012-11-15 08:25:35 +0100 |
---|---|---|
committer | Jan Klemkow <j.klemkow@wemelug.de> | 2012-11-15 08:25:35 +0100 |
commit | c7c47cdf23892f7209bbd2acaf420a8d34336406 (patch) | |
tree | 80b1abbaedd13de9bd188b91c63a887ded603286 /src/util.c | |
parent | bfcb903f8ff64c55cf3b4d0789369be495e5dac8 (diff) | |
download | advtime-c7c47cdf23892f7209bbd2acaf420a8d34336406.tar.gz advtime-c7c47cdf23892f7209bbd2acaf420a8d34336406.tar.bz2 advtime-c7c47cdf23892f7209bbd2acaf420a8d34336406.zip |
Add frame mix saving for high diffs.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -1,3 +1,8 @@ +#include <stdio.h> + +#include "video_decode.h" +#include "util.h" + void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename) { @@ -10,3 +15,30 @@ pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename) fwrite(buf + i * wrap, 1, xsize, f); fclose(f); } + +void +frame_mix_pgm_save(struct video_frame *frame_a, struct video_frame *frame_b, + char *filename) +{ + uint8_t *row_a = frame_a->data, *col_a = NULL; + uint8_t *row_b = frame_b->data, *col_b = NULL; + + for (int y = 0; y < frame_a->height; ++y) { + col_a = row_a; + col_b = row_b; + for (int x = 0; x < frame_a->width; ++x) { + if (x > frame_a->width / 2) + *col_a = *col_b; + col_a++; + col_b++; + } + row_a += frame_a->stride; + row_b += frame_b->stride; + } + + FILE *f = fopen(filename, "w"); + fprintf(f, "P5\n%d %d\n%d\n", frame_a->width, frame_a->height, 255); + for (int i = 0; i < frame_a->height; i++) + fwrite(frame_a->data+i*frame_a->stride, 1, frame_a->width, f); + fclose(f); +} |