115 lines
3.7 KiB
Diff
115 lines
3.7 KiB
Diff
From 9b0c2e8bad87100f042144bc251b60b64f646c99 Mon Sep 17 00:00:00 2001
|
|
From: Benjamin Berg <bberg@redhat.com>
|
|
Date: Fri, 6 Dec 2019 18:55:52 +0100
|
|
Subject: [PATCH 158/181] fpi-assembling: Fix offsets to be relative to the
|
|
previous frame
|
|
|
|
The offset stored for a frame was not always relative to the previous
|
|
frame. This was the case for reverse movement, but for forwrad movement
|
|
the offset was the one to the next frame.
|
|
|
|
Make the offset handling consistent and alwasy store the offset to the
|
|
previous frame. Also update the frame assembling code to add the offset
|
|
before blitting the frame (i.e. making it relative to the previous frame
|
|
there too).
|
|
|
|
Note that fpi_assemble_lines already made the assumption that this was
|
|
the case as it forced the offset for the first frame to be zero. As
|
|
such, the code was inconsistent.
|
|
|
|
This could affect the AES drivers slightly as they use hardware reported
|
|
values which might not adhere to these assumptions.
|
|
---
|
|
libfprint/fpi-assembling.c | 34 +++++++++++++++++-----------------
|
|
1 file changed, 17 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/libfprint/fpi-assembling.c b/libfprint/fpi-assembling.c
|
|
index a809a2d..6d34679 100644
|
|
--- a/libfprint/fpi-assembling.c
|
|
+++ b/libfprint/fpi-assembling.c
|
|
@@ -99,6 +99,8 @@ static void
|
|
find_overlap (struct fpi_frame_asmbl_ctx *ctx,
|
|
struct fpi_frame *first_frame,
|
|
struct fpi_frame *second_frame,
|
|
+ int *dx_out,
|
|
+ int *dy_out,
|
|
unsigned int *min_error)
|
|
{
|
|
int dx, dy;
|
|
@@ -120,8 +122,8 @@ find_overlap (struct fpi_frame_asmbl_ctx *ctx,
|
|
if (err < *min_error)
|
|
{
|
|
*min_error = err;
|
|
- second_frame->delta_x = -dx;
|
|
- second_frame->delta_y = dy;
|
|
+ *dx_out = -dx;
|
|
+ *dy_out = dy;
|
|
}
|
|
}
|
|
}
|
|
@@ -133,7 +135,7 @@ do_movement_estimation (struct fpi_frame_asmbl_ctx *ctx,
|
|
{
|
|
GSList *l;
|
|
GTimer *timer;
|
|
- guint num_frames = 0;
|
|
+ guint num_frames = 1;
|
|
struct fpi_frame *prev_stripe;
|
|
unsigned int min_error;
|
|
/* Max error is width * height * 255, for AES2501 which has the largest
|
|
@@ -143,20 +145,27 @@ do_movement_estimation (struct fpi_frame_asmbl_ctx *ctx,
|
|
unsigned long long total_error = 0;
|
|
|
|
timer = g_timer_new ();
|
|
+
|
|
+ /* Skip the first frame */
|
|
prev_stripe = stripes->data;
|
|
- for (l = stripes; l != NULL; l = l->next, num_frames++)
|
|
+
|
|
+ for (l = stripes->next; l != NULL; l = l->next, num_frames++)
|
|
{
|
|
struct fpi_frame *cur_stripe = l->data;
|
|
|
|
if (reverse)
|
|
{
|
|
- find_overlap (ctx, prev_stripe, cur_stripe, &min_error);
|
|
+ find_overlap (ctx, prev_stripe, cur_stripe,
|
|
+ &cur_stripe->delta_x, &cur_stripe->delta_y,
|
|
+ &min_error);
|
|
cur_stripe->delta_y = -cur_stripe->delta_y;
|
|
cur_stripe->delta_x = -cur_stripe->delta_x;
|
|
}
|
|
else
|
|
{
|
|
- find_overlap (ctx, cur_stripe, prev_stripe, &min_error);
|
|
+ find_overlap (ctx, cur_stripe, prev_stripe,
|
|
+ &cur_stripe->delta_x, &cur_stripe->delta_y,
|
|
+ &min_error);
|
|
}
|
|
total_error += min_error;
|
|
|
|
@@ -328,19 +337,10 @@ fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx,
|
|
{
|
|
fpi_frame = l->data;
|
|
|
|
- if(reverse)
|
|
- {
|
|
- y += fpi_frame->delta_y;
|
|
- x += fpi_frame->delta_x;
|
|
- }
|
|
+ y += fpi_frame->delta_y;
|
|
+ x += fpi_frame->delta_x;
|
|
|
|
aes_blit_stripe (ctx, img, fpi_frame, x, y);
|
|
-
|
|
- if(!reverse)
|
|
- {
|
|
- y += fpi_frame->delta_y;
|
|
- x += fpi_frame->delta_x;
|
|
- }
|
|
}
|
|
|
|
return img;
|
|
--
|
|
2.24.1
|
|
|