lib: move frame assembling routines into a separate file and make them usable by non-aes drivers

Frame assembling routines are not aes-specific, so move them into a separate file
and add an accessor for peeking a pixel.
This commit is contained in:
Vasily Khoruzhick
2015-08-31 21:25:20 -07:00
parent 6664f87d8f
commit e40f7bd1f7
12 changed files with 422 additions and 302 deletions

View File

@@ -28,6 +28,7 @@
#include <libusb.h>
#include <assembling.h>
#include <aeslib.h>
#include <fp_internal.h>
@@ -58,6 +59,7 @@ static void complete_deactivation(struct fp_img_dev *dev);
#define FRAME_WIDTH 192
#define FRAME_HEIGHT 16
#define FRAME_SIZE (FRAME_WIDTH * FRAME_HEIGHT)
#define IMAGE_WIDTH (FRAME_WIDTH + (FRAME_WIDTH / 2))
/* maximum number of frames to read during a scan */
/* FIXME reduce substantially */
#define MAX_FRAMES 150
@@ -72,6 +74,13 @@ struct aes2501_dev {
int no_finger_cnt;
};
static struct fpi_frame_asmbl_ctx assembling_ctx = {
.frame_width = FRAME_WIDTH,
.frame_height = FRAME_HEIGHT,
.image_width = IMAGE_WIDTH,
.get_pixel = aes_get_pixel,
};
typedef void (*aes2501_read_regs_cb)(struct fp_img_dev *dev, int status,
unsigned char *regs, void *user_data);
@@ -484,18 +493,18 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
unsigned int height, rev_height;
aesdev->strips = g_slist_reverse(aesdev->strips);
height = aes_calc_delta(aesdev->strips, aesdev->strips_len,
FRAME_WIDTH, FRAME_HEIGHT, FALSE);
rev_height = aes_calc_delta(aesdev->strips, aesdev->strips_len,
FRAME_WIDTH, FRAME_HEIGHT, TRUE);
height = fpi_do_movement_estimation(&assembling_ctx,
aesdev->strips, aesdev->strips_len, FALSE);
rev_height = fpi_do_movement_estimation(&assembling_ctx,
aesdev->strips, aesdev->strips_len, TRUE);
fp_dbg("heights: %d rev: %d", height, rev_height);
if (rev_height < height) {
fp_dbg("Reversed direction");
height = aes_calc_delta(aesdev->strips, aesdev->strips_len,
FRAME_WIDTH, FRAME_HEIGHT, FALSE);
height = fpi_do_movement_estimation(&assembling_ctx,
aesdev->strips, aesdev->strips_len, FALSE);
}
img = aes_assemble(aesdev->strips, aesdev->strips_len,
FRAME_WIDTH, FRAME_HEIGHT, FRAME_WIDTH + FRAME_WIDTH / 2);
img = fpi_assemble_frames(&assembling_ctx,
aesdev->strips, aesdev->strips_len);
g_slist_free_full(aesdev->strips, g_free);
aesdev->strips = NULL;
aesdev->strips_len = 0;
@@ -509,7 +518,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
} else {
/* obtain next strip */
/* FIXME: would preallocating strip buffers be a decent optimization? */
struct aes_stripe *stripe = g_malloc(FRAME_WIDTH * FRAME_HEIGHT / 2 + sizeof(struct aes_stripe));
struct fpi_frame *stripe = g_malloc(FRAME_WIDTH * FRAME_HEIGHT / 2 + sizeof(struct fpi_frame));
stripe->delta_x = 0;
stripe->delta_y = 0;
stripdata = stripe->data;
@@ -881,7 +890,7 @@ struct fp_img_driver aes2501_driver = {
},
.flags = 0,
.img_height = -1,
.img_width = FRAME_WIDTH + FRAME_WIDTH / 2,
.img_width = IMAGE_WIDTH,
.open = dev_init,
.close = dev_deinit,