summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 7b7077d..e642762 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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) {