diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-02-01 08:20:48 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-02-01 08:20:48 +0100 |
commit | 279db4fbc92aab6eb3d1c3e6a31ca23aea7d4ba6 (patch) | |
tree | b2f8debc20ca90c4755e193f483303a05cfb241f | |
parent | 2957803c5da9aab1cecac3dcdfaf7fcd9c5e49fd (diff) | |
download | advtime-279db4fbc92aab6eb3d1c3e6a31ca23aea7d4ba6.tar.gz advtime-279db4fbc92aab6eb3d1c3e6a31ca23aea7d4ba6.tar.bz2 advtime-279db4fbc92aab6eb3d1c3e6a31ca23aea7d4ba6.zip |
Put frame_diff and pswap into util
-rw-r--r-- | src/cuttime.c | 32 | ||||
-rw-r--r-- | src/overlap.c | 32 | ||||
-rw-r--r-- | src/util.c | 22 | ||||
-rw-r--r-- | src/util.h | 13 |
4 files changed, 35 insertions, 64 deletions
diff --git a/src/cuttime.c b/src/cuttime.c index 8fd8a7a..422e4be 100644 --- a/src/cuttime.c +++ b/src/cuttime.c @@ -7,16 +7,6 @@ #include "video_decode.h" #include "util.h" -static inline void -pswap(void **p1, void **p2) -{ - void *tmp; - - tmp = *p1; - *p1 = *p2; - *p2 = tmp; -} - static void start_new_szene(int64_t prev_szene_end, int64_t start) { @@ -29,28 +19,6 @@ start_new_szene(int64_t prev_szene_end, int64_t start) } static double -frame_diff(struct video_frame *frame_a, struct video_frame *frame_b) -{ - double average = 0; - 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) { - average += abs(*col_a - *col_b); - col_a++; - col_b++; - } - row_a += frame_a->stride; - row_b += frame_b->stride; - } - - return average / (frame_a->width * frame_a->height); -} - -static double frame_average(struct video_frame *frame) { double average = 0; diff --git a/src/overlap.c b/src/overlap.c index a989ccb..207a306 100644 --- a/src/overlap.c +++ b/src/overlap.c @@ -7,38 +7,6 @@ #include "video_decode.h" #include "util.h" -static inline void -pswap(void **p1, void **p2) -{ - void *tmp; - - tmp = *p1; - *p1 = *p2; - *p2 = tmp; -} - -static double -frame_diff(struct video_frame *frame_a, struct video_frame *frame_b) -{ - double average = 0; - 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) { - average += abs(*col_a - *col_b); - col_a++; - col_b++; - } - row_a += frame_a->stride; - row_b += frame_b->stride; - } - - return average / (frame_a->width * frame_a->height); -} - static void usage(void) { @@ -81,6 +81,28 @@ frame_mix(struct video_frame *frame_a, struct video_frame *frame_b) } } +double +frame_diff(struct video_frame *frame_a, struct video_frame *frame_b) +{ + double average = 0; + 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) { + average += abs(*col_a - *col_b); + col_a++; + col_b++; + } + row_a += frame_a->stride; + row_b += frame_b->stride; + } + + return average / (frame_a->width * frame_a->height); +} + /* print time in format: "hh:mm:ss.xxx" */ void print_time(int64_t msec) { @@ -3,6 +3,16 @@ #include <stdint.h> +static inline void +pswap(void **p1, void **p2) +{ + void *tmp; + + tmp = *p1; + *p1 = *p2; + *p2 = tmp; +} + int pgm_read(char *filename, unsigned char **buf, int *xsize, int *ysize); @@ -13,6 +23,9 @@ pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename); void frame_mix(struct video_frame *frame_a, struct video_frame *frame_b); +double +frame_diff(struct video_frame *frame_a, struct video_frame *frame_b); + void print_time(int64_t msec); |