From 2818d940109d81dcb39593e173ef9f1b02d8b7ea Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 27 Sep 2018 16:49:20 +0200 Subject: [PATCH] lib: Split off fp_img helpers And rename img.c to fpi-img.c, as well as pixman.c to fpi-img-pixman.c --- libfprint/drivers_api.h | 26 +----------- libfprint/fp_internal.h | 24 +---------- libfprint/{pixman.c => fpi-img-pixman.c} | 0 libfprint/{img.c => fpi-img.c} | 0 libfprint/fpi-img.h | 51 ++++++++++++++++++++++++ libfprint/meson.build | 5 ++- 6 files changed, 56 insertions(+), 50 deletions(-) rename libfprint/{pixman.c => fpi-img-pixman.c} (100%) rename libfprint/{img.c => fpi-img.c} (100%) create mode 100644 libfprint/fpi-img.h diff --git a/libfprint/drivers_api.h b/libfprint/drivers_api.h index b61aa14..432f1e3 100644 --- a/libfprint/drivers_api.h +++ b/libfprint/drivers_api.h @@ -35,6 +35,7 @@ #include "fpi-dev.h" #include "fpi-usb.h" #include "fpi-data.h" +#include "fpi-img.h" #include "assembling.h" #include "drivers/driver_ids.h" @@ -127,31 +128,6 @@ struct fp_img_driver { struct fp_minutiae; -/* bit values for fp_img.flags */ -#define FP_IMG_V_FLIPPED (1<<0) -#define FP_IMG_H_FLIPPED (1<<1) -#define FP_IMG_COLORS_INVERTED (1<<2) -#define FP_IMG_BINARIZED_FORM (1<<3) -#define FP_IMG_PARTIAL (1<<4) - -#define FP_IMG_STANDARDIZATION_FLAGS (FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED \ - | FP_IMG_COLORS_INVERTED) - -struct fp_img { - int width; - int height; - size_t length; - uint16_t flags; - struct fp_minutiae *minutiae; - unsigned char *binarized; - unsigned char data[0]; -}; - -struct fp_img *fpi_img_new(size_t length); -struct fp_img *fpi_img_new_for_imgdev(struct fp_img_dev *dev); -struct fp_img *fpi_img_resize(struct fp_img *img, size_t newsize); -struct fp_img *fpi_im_resize(struct fp_img *img, unsigned int w_factor, unsigned int h_factor); - void fpi_drvcb_open_complete(struct fp_dev *dev, int status); void fpi_drvcb_close_complete(struct fp_dev *dev); diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index ab24df8..deb520a 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -31,6 +31,7 @@ #include "fpi-log.h" #include "fpi-dev.h" #include "fpi-data.h" +#include "fpi-img.h" #include "drivers/driver_ids.h" #define container_of(ptr, type, member) ({ \ @@ -264,28 +265,6 @@ struct fp_minutiae { struct fp_minutia **list; }; -/* bit values for fp_img.flags */ -#define FP_IMG_V_FLIPPED (1<<0) -#define FP_IMG_H_FLIPPED (1<<1) -#define FP_IMG_COLORS_INVERTED (1<<2) -#define FP_IMG_BINARIZED_FORM (1<<3) -#define FP_IMG_PARTIAL (1<<4) - -#define FP_IMG_STANDARDIZATION_FLAGS (FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED \ - | FP_IMG_COLORS_INVERTED) - -struct fp_img { - int width; - int height; - size_t length; - uint16_t flags; - struct fp_minutiae *minutiae; - unsigned char *binarized; - unsigned char data[0]; -}; - -struct fp_img *fpi_img_new(size_t length); -struct fp_img *fpi_img_resize(struct fp_img *img, size_t newsize); gboolean fpi_img_is_sane(struct fp_img *img); int fpi_img_to_print_data(struct fp_img_dev *imgdev, struct fp_img *img, struct fp_print_data **ret); @@ -293,7 +272,6 @@ int fpi_img_compare_print_data(struct fp_print_data *enrolled_print, struct fp_print_data *new_print); int fpi_img_compare_print_data_to_gallery(struct fp_print_data *print, struct fp_print_data **gallery, int match_threshold, size_t *match_offset); -struct fp_img *fpi_im_resize(struct fp_img *img, unsigned int w_factor, unsigned int h_factor); /* polling */ void fpi_timeout_cancel_all_for_dev(struct fp_dev *dev); diff --git a/libfprint/pixman.c b/libfprint/fpi-img-pixman.c similarity index 100% rename from libfprint/pixman.c rename to libfprint/fpi-img-pixman.c diff --git a/libfprint/img.c b/libfprint/fpi-img.c similarity index 100% rename from libfprint/img.c rename to libfprint/fpi-img.c diff --git a/libfprint/fpi-img.h b/libfprint/fpi-img.h new file mode 100644 index 0000000..87709ff --- /dev/null +++ b/libfprint/fpi-img.h @@ -0,0 +1,51 @@ +/* + * Driver API definitions + * Copyright (C) 2007-2008 Daniel Drake + * Copyright (C) 2018 Bastien Nocera + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __FPI_IMG_H__ +#define __FPI_IMG_H__ + +#include + +/* bit values for fp_img.flags */ +#define FP_IMG_V_FLIPPED (1<<0) +#define FP_IMG_H_FLIPPED (1<<1) +#define FP_IMG_COLORS_INVERTED (1<<2) +#define FP_IMG_BINARIZED_FORM (1<<3) +#define FP_IMG_PARTIAL (1<<4) + +#define FP_IMG_STANDARDIZATION_FLAGS (FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED \ + | FP_IMG_COLORS_INVERTED) + +struct fp_img { + int width; + int height; + size_t length; + uint16_t flags; + struct fp_minutiae *minutiae; + unsigned char *binarized; + unsigned char data[0]; +}; + +struct fp_img *fpi_img_new(size_t length); +struct fp_img *fpi_img_new_for_imgdev(struct fp_img_dev *dev); +struct fp_img *fpi_img_resize(struct fp_img *img, size_t newsize); +struct fp_img *fpi_im_resize(struct fp_img *img, unsigned int w_factor, unsigned int h_factor); + +#endif diff --git a/libfprint/meson.build b/libfprint/meson.build index 1d9079e..f25db93 100644 --- a/libfprint/meson.build +++ b/libfprint/meson.build @@ -7,6 +7,8 @@ libfprint_sources = [ 'fpi-data.h', 'fpi-dev.c', 'fpi-dev.h', + 'fpi-img.c', + 'fpi-img.h', 'fpi-log.h', 'fpi-ssm.c', 'fpi-ssm.h', @@ -14,7 +16,6 @@ libfprint_sources = [ 'fpi-poll.c', 'fpi-usb.h', 'fpi-usb.c', - 'img.c', 'imgdev.c', 'sync.c', 'assembling.c', @@ -155,7 +156,7 @@ endif other_sources = [] if imaging_dep.found() - other_sources += [ 'pixman.c' ] + other_sources += [ 'fpi-img-pixman.c' ] endif libfprint_sources += configure_file(input: 'empty_file',