aeslib: image assembly

All 3 authentec drivers now use a shared image assembly function.
This commit is contained in:
Daniel Drake 2007-11-26 23:28:14 +00:00
parent e228f2c7da
commit 3479dee0e4
5 changed files with 33 additions and 44 deletions

View file

@ -93,3 +93,18 @@ int aes_write_regv(struct fp_img_dev *dev, struct aes_regwrite *regs,
return 0;
}
int aes_assemble_image(unsigned char *input, size_t width, size_t height,
unsigned char *output)
{
size_t frame_size = width * height;
size_t row, column;
for (column = 0; column < width; column++) {
for (row = 0; row < height; row += 2) {
output[width * row + column] = (*input & 0x07) * 36;
output[width * (row + 1) + column] = ((*input & 0x70) >> 4) * 36;
input++;
}
}
}

View file

@ -30,5 +30,8 @@ struct aes_regwrite {
int aes_write_regv(struct fp_img_dev *dev, struct aes_regwrite *regs,
unsigned int num);
int aes_assemble_image(unsigned char *input, size_t width, size_t height,
unsigned char *output);
#endif

View file

@ -231,15 +231,8 @@ static unsigned int assemble(unsigned char *input, unsigned char *output,
if (reverse)
output += (num_strips - 1) * FRAME_SIZE;
for (frame = 0; frame < num_strips; frame++) {
int column;
for (column = 0; column < FRAME_WIDTH; column++) {
int row;
for (row = 0; row < (FRAME_HEIGHT / 2); row++) {
output[FRAME_WIDTH * ( 2 * row) + column] = *input & 0x0F;
output[FRAME_WIDTH * ( 2 * row + 1) + column] = *input >> 4;
input++;
}
}
aes_assemble_image(input, FRAME_WIDTH, FRAME_HEIGHT, output);
input += FRAME_WIDTH * (FRAME_HEIGHT / 2);
if (reverse)
output -= FRAME_SIZE;
@ -410,6 +403,7 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
unsigned char *cooked;
unsigned char *imgptr;
unsigned char buf[665];
int final_size;
int sum;
unsigned int count_blank = 0;
int i;
@ -511,10 +505,9 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
fp_dbg("reversed scan direction");
}
for (i = 0; i < img->height * FRAME_WIDTH; i++)
img->data[i] = (cooked[i] << 4) | 0xf;
img = fpi_img_resize(img, img->height * FRAME_WIDTH);
final_size = img->height * FRAME_WIDTH;
memcpy(img->data, cooked, final_size);
img = fpi_img_resize(img, final_size);
*ret = img;
return 0;
err:

View file

@ -394,15 +394,8 @@ static unsigned int assemble(unsigned char *input, unsigned char *output,
if (reverse)
output += (num_strips - 1) * FRAME_SIZE;
for (frame = 0; frame < num_strips; frame++) {
int column;
for (column = 0; column < FRAME_WIDTH; column++) {
int row;
for (row = 0; row < (FRAME_HEIGHT / 2); row++) {
output[FRAME_WIDTH * ( 2 * row) + column] = *input & 0x0F;
output[FRAME_WIDTH * ( 2 * row + 1) + column] = *input >> 4;
input++;
}
}
aes_assemble_image(input, FRAME_WIDTH, FRAME_HEIGHT, output);
input += FRAME_WIDTH * (FRAME_HEIGHT / 2);
if (reverse)
output -= FRAME_SIZE;
@ -492,8 +485,8 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
unsigned char *cooked;
unsigned char *imgptr;
unsigned char buf[1705];
int final_size;
int sum;
int i;
/* FIXME can do better here in terms of buffer management? */
fp_dbg("");
@ -563,10 +556,9 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
fp_dbg("reversed scan direction");
}
for (i = 0; i < img->height * FRAME_WIDTH; i++)
img->data[i] = (cooked[i] << 4) | 0xf;
img = fpi_img_resize(img, img->height * FRAME_WIDTH);
final_size = img->height * FRAME_WIDTH;
memcpy(img->data, cooked, final_size);
img = fpi_img_resize(img, final_size);
*ret = img;
return 0;
err:

View file

@ -34,20 +34,6 @@
#define NR_SUBARRAYS 6
#define SUBARRAY_LEN 768
static void process_subarray(unsigned char *src, unsigned char *dst)
{
int col, row;
int offset = -1;
for (col = 95; col >= 0; col--) {
for (row = 15; row >= 0; row -= 2) {
unsigned char val = src[++offset];
dst[(row * 96) + col] = (val & 0x7) * 36;
dst[((row - 1) * 96) + col] = ((val & 0x70) >> 4) * 36;
}
}
}
static const struct aes_regwrite init_reqs[] = {
/* master reset */
{ 0x80, 0x01 },
@ -156,14 +142,14 @@ retry:
goto err;
}
for (i = NR_SUBARRAYS - 1; i >= 0; i--) {
for (i = 0; i < NR_SUBARRAYS; i++) {
fp_dbg("subarray header byte %02x", *ptr);
ptr++;
process_subarray(ptr, img->data + (i * 96 * 16));
aes_assemble_image(ptr, 96, 16, img->data + (i * 96 * 16));
ptr += SUBARRAY_LEN;
}
img->flags = FP_IMG_COLORS_INVERTED;
img->flags = FP_IMG_COLORS_INVERTED | FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED;
*ret = img;
g_free(data);
return 0;