kopia lustrzana https://gitlab.com/sane-project/backends
				
				
				
			genesys: Use separate translation unit for conversion functions
							rodzic
							
								
									9f44bab6e0
								
							
						
					
					
						commit
						b5e4d86eb2
					
				| 
						 | 
				
			
			@ -489,6 +489,7 @@ libgenesys_la_SOURCES = genesys/genesys.cpp genesys/genesys.h \
 | 
			
		|||
    genesys/buffer.h genesys/buffer.cpp \
 | 
			
		||||
    genesys/calibration.h \
 | 
			
		||||
    genesys/command_set.h \
 | 
			
		||||
    genesys/conv.h genesys/conv.cpp \
 | 
			
		||||
    genesys/device.h genesys/device.cpp \
 | 
			
		||||
    genesys/enums.h \
 | 
			
		||||
    genesys/error.h genesys/error.cpp \
 | 
			
		||||
| 
						 | 
				
			
			@ -524,8 +525,6 @@ libsane_genesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys
 | 
			
		|||
libsane_genesys_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS)
 | 
			
		||||
libsane_genesys_la_LIBADD = $(COMMON_LIBS) libgenesys.la  ../sanei/sanei_magic.lo ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS)
 | 
			
		||||
EXTRA_DIST += genesys.conf.in
 | 
			
		||||
# TODO: Why are this distributed but not compiled?
 | 
			
		||||
EXTRA_DIST += genesys/conv.cpp
 | 
			
		||||
 | 
			
		||||
libgphoto2_i_la_SOURCES = gphoto2.c gphoto2.h
 | 
			
		||||
libgphoto2_i_la_CPPFLAGS = $(AM_CPPFLAGS) $(GPHOTO2_CPPFLAGS) -DBACKEND_NAME=gphoto2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,11 +42,12 @@
 | 
			
		|||
   If you do not wish that, delete this exception notice.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Conversion filters for genesys backend
 | 
			
		||||
 */
 | 
			
		||||
#define DEBUG_DECLARE_ONLY
 | 
			
		||||
 | 
			
		||||
static void genesys_reverse_bits(uint8_t* src_data, uint8_t* dst_data, size_t bytes)
 | 
			
		||||
#include "conv.h"
 | 
			
		||||
#include "sane/sanei_magic.h"
 | 
			
		||||
 | 
			
		||||
void genesys_reverse_bits(uint8_t* src_data, uint8_t* dst_data, size_t bytes)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
    size_t i;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +64,7 @@ static void genesys_reverse_bits(uint8_t* src_data, uint8_t* dst_data, size_t by
 | 
			
		|||
 * @param dst pointer where to store result
 | 
			
		||||
 * @param width width of the processed line
 | 
			
		||||
 * */
 | 
			
		||||
static void binarize_line(Genesys_Device* dev, uint8_t* src, uint8_t* dst, int width)
 | 
			
		||||
void binarize_line(Genesys_Device* dev, std::uint8_t* src, std::uint8_t* dst, int width)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
  int j, windowX, sum = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +73,7 @@ static void binarize_line(Genesys_Device* dev, uint8_t* src, uint8_t* dst, int w
 | 
			
		|||
  unsigned char mask;
 | 
			
		||||
 | 
			
		||||
  int x;
 | 
			
		||||
  uint8_t min, max;
 | 
			
		||||
    std::uint8_t min, max;
 | 
			
		||||
 | 
			
		||||
  /* normalize line */
 | 
			
		||||
  min = 255;
 | 
			
		||||
| 
						 | 
				
			
			@ -146,15 +147,14 @@ static void binarize_line(Genesys_Device* dev, uint8_t* src, uint8_t* dst, int w
 | 
			
		|||
 * software lineart using data from a 8 bit gray scan. We assume true gray
 | 
			
		||||
 * or monochrome scan as input.
 | 
			
		||||
 */
 | 
			
		||||
static void genesys_gray_lineart(Genesys_Device* dev,
 | 
			
		||||
                                 uint8_t* src_data, uint8_t* dst_data,
 | 
			
		||||
                                 size_t pixels, size_t lines, uint8_t threshold)
 | 
			
		||||
void genesys_gray_lineart(Genesys_Device* dev,
 | 
			
		||||
                          std::uint8_t* src_data, std::uint8_t* dst_data,
 | 
			
		||||
                          std::size_t pixels, std::size_t lines, std::uint8_t threshold)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
  size_t y;
 | 
			
		||||
    std::size_t y;
 | 
			
		||||
 | 
			
		||||
  DBG(DBG_io2, "%s: converting %lu lines of %lu pixels\n", __func__, (unsigned long)lines,
 | 
			
		||||
      (unsigned long)pixels);
 | 
			
		||||
    DBG(DBG_io2, "%s: converting %zu lines of %zu pixels\n", __func__, lines, pixels);
 | 
			
		||||
  DBG(DBG_io2, "%s: threshold=%d\n", __func__, threshold);
 | 
			
		||||
 | 
			
		||||
  for (y = 0; y < lines; y++)
 | 
			
		||||
| 
						 | 
				
			
			@ -166,7 +166,7 @@ static void genesys_gray_lineart(Genesys_Device* dev,
 | 
			
		|||
 | 
			
		||||
/** Look in image for likely left/right/bottom paper edges, then crop image.
 | 
			
		||||
 */
 | 
			
		||||
static void genesys_crop(Genesys_Scanner* s)
 | 
			
		||||
void genesys_crop(Genesys_Scanner* s)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
  Genesys_Device *dev = s->dev;
 | 
			
		||||
| 
						 | 
				
			
			@ -193,7 +193,7 @@ static void genesys_crop(Genesys_Scanner* s)
 | 
			
		|||
/** Look in image for likely upper and left paper edges, then rotate
 | 
			
		||||
 * image so that upper left corner of paper is upper left of image.
 | 
			
		||||
 */
 | 
			
		||||
static void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor)
 | 
			
		||||
void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
  Genesys_Device *dev = s->dev;
 | 
			
		||||
| 
						 | 
				
			
			@ -219,7 +219,7 @@ static void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor)
 | 
			
		|||
 | 
			
		||||
/** remove lone dots
 | 
			
		||||
 */
 | 
			
		||||
static void genesys_despeck(Genesys_Scanner* s)
 | 
			
		||||
void genesys_despeck(Genesys_Scanner* s)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
    TIE(sanei_magic_despeck(&s->params, s->dev->img_buffer.data(), s->despeck));
 | 
			
		||||
| 
						 | 
				
			
			@ -227,7 +227,7 @@ static void genesys_despeck(Genesys_Scanner* s)
 | 
			
		|||
 | 
			
		||||
/** Look if image needs rotation and apply it
 | 
			
		||||
 * */
 | 
			
		||||
static void genesys_derotate (Genesys_Scanner * s)
 | 
			
		||||
void genesys_derotate(Genesys_Scanner* s)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
  int angle = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,67 @@
 | 
			
		|||
/* sane - Scanner Access Now Easy.
 | 
			
		||||
 | 
			
		||||
   Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
 | 
			
		||||
 | 
			
		||||
   This file is part of the SANE package.
 | 
			
		||||
 | 
			
		||||
   This program is free software; you can redistribute it and/or
 | 
			
		||||
   modify it under the terms of the GNU General Public License as
 | 
			
		||||
   published by the Free Software Foundation; either version 2 of the
 | 
			
		||||
   License, or (at your option) any later version.
 | 
			
		||||
 | 
			
		||||
   This program 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
 | 
			
		||||
   General Public License for more details.
 | 
			
		||||
 | 
			
		||||
   You should have received a copy of the GNU General Public License
 | 
			
		||||
   along with this program; if not, write to the Free Software
 | 
			
		||||
   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 | 
			
		||||
   MA 02111-1307, USA.
 | 
			
		||||
 | 
			
		||||
   As a special exception, the authors of SANE give permission for
 | 
			
		||||
   additional uses of the libraries contained in this release of SANE.
 | 
			
		||||
 | 
			
		||||
   The exception is that, if you link a SANE library with other files
 | 
			
		||||
   to produce an executable, this does not by itself cause the
 | 
			
		||||
   resulting executable to be covered by the GNU General Public
 | 
			
		||||
   License.  Your use of that executable is in no way restricted on
 | 
			
		||||
   account of linking the SANE library code into it.
 | 
			
		||||
 | 
			
		||||
   This exception does not, however, invalidate any other reasons why
 | 
			
		||||
   the executable file might be covered by the GNU General Public
 | 
			
		||||
   License.
 | 
			
		||||
 | 
			
		||||
   If you submit changes to SANE to the maintainers to be included in
 | 
			
		||||
   a subsequent release, you agree by submitting the changes that
 | 
			
		||||
   those changes may be distributed with this exception intact.
 | 
			
		||||
 | 
			
		||||
   If you write modifications of your own for SANE, it is your choice
 | 
			
		||||
   whether to permit this exception to apply to your modifications.
 | 
			
		||||
   If you do not wish that, delete this exception notice.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef BACKEND_GENESYS_CONV_H
 | 
			
		||||
#define BACKEND_GENESYS_CONV_H
 | 
			
		||||
 | 
			
		||||
#include "device.h"
 | 
			
		||||
#include "sensor.h"
 | 
			
		||||
#include "genesys.h"
 | 
			
		||||
 | 
			
		||||
void genesys_reverse_bits(uint8_t* src_data, uint8_t* dst_data, size_t bytes);
 | 
			
		||||
 | 
			
		||||
void binarize_line(Genesys_Device* dev, std::uint8_t* src, std::uint8_t* dst, int width);
 | 
			
		||||
 | 
			
		||||
void genesys_gray_lineart(Genesys_Device* dev,
 | 
			
		||||
                          std::uint8_t* src_data, std::uint8_t* dst_data,
 | 
			
		||||
                          std::size_t pixels, size_t lines, std::uint8_t threshold);
 | 
			
		||||
 | 
			
		||||
void genesys_crop(Genesys_Scanner* s);
 | 
			
		||||
 | 
			
		||||
void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor);
 | 
			
		||||
 | 
			
		||||
void genesys_despeck(Genesys_Scanner* s);
 | 
			
		||||
 | 
			
		||||
void genesys_derotate(Genesys_Scanner* s);
 | 
			
		||||
 | 
			
		||||
#endif // BACKEND_GENESYS_CONV_H
 | 
			
		||||
| 
						 | 
				
			
			@ -61,6 +61,7 @@
 | 
			
		|||
#define DEBUG_NOT_STATIC
 | 
			
		||||
 | 
			
		||||
#include "genesys.h"
 | 
			
		||||
#include "conv.h"
 | 
			
		||||
#include "sanei.h"
 | 
			
		||||
#include "../include/sane/sanei_config.h"
 | 
			
		||||
#include "../include/sane/sanei_magic.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -3327,11 +3328,6 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#include "conv.cpp"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
static void genesys_fill_read_buffer(Genesys_Device* dev)
 | 
			
		||||
{
 | 
			
		||||
    DBG_HELPER(dbg);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,10 +19,11 @@ TESTS = $(check_PROGRAMS)
 | 
			
		|||
AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include $(USB_CFLAGS) \
 | 
			
		||||
    -DBACKEND_NAME=genesys
 | 
			
		||||
 | 
			
		||||
genesys_tests_SOURCES = tests.cc tests.h minigtest.cc minigtest.h tests_printers.h \
 | 
			
		||||
    tests_calibration.cc \
 | 
			
		||||
    tests_image.cc \
 | 
			
		||||
    tests_image_pipeline.cc \
 | 
			
		||||
    tests_row_buffer.cc
 | 
			
		||||
genesys_tests_SOURCES = tests.cpp tests.h \
 | 
			
		||||
    minigtest.cpp minigtest.h tests_printers.h \
 | 
			
		||||
    tests_calibration.cpp \
 | 
			
		||||
    tests_image.cpp \
 | 
			
		||||
    tests_image_pipeline.cpp \
 | 
			
		||||
    tests_row_buffer.cpp
 | 
			
		||||
 | 
			
		||||
genesys_tests_LDADD = $(TEST_LDADD)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
#include "tests.h"
 | 
			
		||||
#include "minigtest.h"
 | 
			
		||||
 | 
			
		||||
#include "../../../backend/genesys_low.h"
 | 
			
		||||
#include "../../../backend/genesys/low.h"
 | 
			
		||||
 | 
			
		||||
#include <sstream>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,8 +26,8 @@
 | 
			
		|||
#include "minigtest.h"
 | 
			
		||||
#include "tests_printers.h"
 | 
			
		||||
 | 
			
		||||
#include "../../../backend/genesys_image.h"
 | 
			
		||||
#include "../../../backend/genesys_image_pipeline.h"
 | 
			
		||||
#include "../../../backend/genesys/image.h"
 | 
			
		||||
#include "../../../backend/genesys/image_pipeline.h"
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
void test_get_pixel_from_row()
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +26,7 @@
 | 
			
		|||
#include "minigtest.h"
 | 
			
		||||
#include "tests_printers.h"
 | 
			
		||||
 | 
			
		||||
#include "../../../backend/genesys_image_pipeline.h"
 | 
			
		||||
#include "../../../backend/genesys/image_pipeline.h"
 | 
			
		||||
 | 
			
		||||
#include <numeric>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,7 @@
 | 
			
		|||
#ifndef SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H
 | 
			
		||||
#define SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H
 | 
			
		||||
 | 
			
		||||
#include "../../../backend/genesys_image_pixel.h"
 | 
			
		||||
#include "../../../backend/genesys/image_pixel.h"
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <iomanip>
 | 
			
		||||
#include <vector>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@
 | 
			
		|||
#include "minigtest.h"
 | 
			
		||||
#include "tests_printers.h"
 | 
			
		||||
 | 
			
		||||
#include "../../../backend/genesys_low.h"
 | 
			
		||||
#include "../../../backend/genesys/low.h"
 | 
			
		||||
 | 
			
		||||
#include <numeric>
 | 
			
		||||
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue