From b5570c833d8b41100cbeca41bf3f08ce968f3441 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 1 Feb 2013 08:22:59 +0100 Subject: Also put frame_average into util Not yet needed by other tools than cuttime, but its really just a utility function. --- src/cuttime.c | 19 ------------------- src/util.c | 20 ++++++++++++++++++++ src/util.h | 3 +++ 3 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/cuttime.c b/src/cuttime.c index 422e4be..4b1a494 100644 --- a/src/cuttime.c +++ b/src/cuttime.c @@ -18,25 +18,6 @@ start_new_szene(int64_t prev_szene_end, int64_t start) prev_dts_start = start; } -static double -frame_average(struct video_frame *frame) -{ - double average = 0; - uint8_t *row = frame->data; - uint8_t *col = NULL; - - for (int y = 0; y < frame->height; ++y) { - col = row; - for (int x = 0; x < frame->width; ++x) { - average += *col; - col++; - } - row += frame->stride; - } - - return average / (frame->width * frame->height); -} - static void usage(void) { diff --git a/src/util.c b/src/util.c index e642762..ddd46d3 100644 --- a/src/util.c +++ b/src/util.c @@ -103,6 +103,26 @@ frame_diff(struct video_frame *frame_a, struct video_frame *frame_b) return average / (frame_a->width * frame_a->height); } +double +frame_average(struct video_frame *frame) +{ + double average = 0; + uint8_t *row = frame->data; + uint8_t *col = NULL; + + for (int y = 0; y < frame->height; ++y) { + col = row; + for (int x = 0; x < frame->width; ++x) { + average += *col; + col++; + } + row += frame->stride; + } + + return average / (frame->width * frame->height); +} + + /* print time in format: "hh:mm:ss.xxx" */ void print_time(int64_t msec) { diff --git a/src/util.h b/src/util.h index bc926b6..4666b06 100644 --- a/src/util.h +++ b/src/util.h @@ -26,6 +26,9 @@ 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 +frame_average(struct video_frame *frame); + void print_time(int64_t msec); -- cgit