fpi-assembling.h 3.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
 * Copyright (C) 2015 Vasily Khoruzhick <anarsoul@gmail.com>
 *
 * 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
 */

Bastien Nocera's avatar
Bastien Nocera committed
20 21
#ifndef __FPI_ASSEMBLING_H__
#define __FPI_ASSEMBLING_H__
22

23
#include <fprint.h>
24

25 26 27 28 29 30 31 32 33 34
/**
 * fpi_frame:
 * @delta_x: X offset of the frame
 * @delta_y: Y offset of the frame
 * @data: bitmap
 *
 * #fpi_frame is used to store frames for swipe sensors. Driver should
 * populate delta_x and delta_y if device supports hardware movement
 * estimation
 */
35 36 37 38 39 40
struct fpi_frame {
	int delta_x;
	int delta_y;
	unsigned char data[0];
};

41 42 43 44 45 46 47 48 49 50 51 52
/**
 * fpi_frame_asmbl_ctx
 * @frame_width: width of frame
 * @frame_height: height of frame
 * @image_width: resulting image width
 * @get_pixel: pixel accessor, returns pixel brightness at x,y of frame
 *
 * #fpi_frame_asmbl_ctx is context for frame assembling routines.
 * Driver should define its own #fpi_frame_asmbl_ctx depending on
 * hardware parameters of scanner. image_width is usually 25% wider than
 * frame_width to take into account horizontal movement
 */
53
struct fpi_frame_asmbl_ctx {
54 55 56
	unsigned int frame_width;
	unsigned int frame_height;
	unsigned int image_width;
57 58
	unsigned char (*get_pixel)(struct fpi_frame_asmbl_ctx *ctx,
				   struct fpi_frame *frame,
59 60
				   unsigned int x,
				   unsigned int y);
61 62
};

63 64
void fpi_do_movement_estimation(struct fpi_frame_asmbl_ctx *ctx,
			    GSList *stripes, size_t stripes_len);
65 66 67 68

struct fp_img *fpi_assemble_frames(struct fpi_frame_asmbl_ctx *ctx,
			    GSList *stripes, size_t stripes_len);

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
/**
 * fpi_line_asmbl_ctx
 * @line_width: width of line
 * @max_height: maximal height of assembled image
 * @resolution: scale factor used for line assembling routines.
 * @median_filter_size: size of median filter for movement estimation
 * @max_search_offset: indicates how many lines forward should assemlbing
 *		       routines look while searching for next line.
 *		       Value depends on how fast hardware sends frames.
 * @get_deviation: function that returns numerical difference between two
 *		   lines. Higher values means lines are more different.
 *		   If scanner returns two lines at a time, this function
 *		   should estimate difference between second lines.
 * @get_pixel: pixel accessor, returns pixel brightness at x of line
 *
 * #fpi_line_asmbl_ctx is context for line assembling routines.
 * Driver should define its own #fpi_line_asmbl_ctx depending on
 * hardware parameters of scanner. Swipe scanners of this type usually
 * return two lines, second line is often narrower than first and is used
 * for movement estimation.
 */
90
struct fpi_line_asmbl_ctx {
91 92 93 94 95
	unsigned int line_width;
	unsigned int max_height;
	unsigned int resolution;
	unsigned int median_filter_size;
	unsigned int max_search_offset;
96 97 98 99
	int (*get_deviation)(struct fpi_line_asmbl_ctx *ctx,
			     GSList *line1, GSList *line2);
	unsigned char (*get_pixel)(struct fpi_line_asmbl_ctx *ctx,
				   GSList *line,
100
				   unsigned int x);
101 102 103 104 105
};

struct fp_img *fpi_assemble_lines(struct fpi_line_asmbl_ctx *ctx,
				  GSList *lines, size_t lines_len);

106
#endif