Merge branch 'genesys-cleanup' into 'master'

genesys: Miscellaneous cleanup

See merge request sane-project/backends!470
merge-requests/244/head
Povilas Kanapickas 2020-05-24 17:59:40 +00:00
commit b7ec6da949
5 zmienionych plików z 7 dodań i 100 usunięć

Wyświetl plik

@ -4185,25 +4185,10 @@ static Genesys_Settings calculate_scan_settings(Genesys_Scanner* s)
settings.depth = 1;
}
settings.disable_interpolation = s->disable_interpolation;
const auto& resolutions = dev->model->get_resolution_settings(settings.scan_method);
// FIXME: use correct sensor
const auto& sensor = sanei_genesys_find_sensor_any(dev);
// hardware settings
if (static_cast<unsigned>(s->resolution) > sensor.full_resolution &&
settings.disable_interpolation)
{
settings.xres = sensor.full_resolution;
} else {
settings.xres = s->resolution;
}
settings.yres = s->resolution;
settings.xres = pick_resolution(resolutions.resolutions_x, settings.xres, "X");
settings.yres = pick_resolution(resolutions.resolutions_y, settings.yres, "Y");
settings.xres = pick_resolution(resolutions.resolutions_x, s->resolution, "X");
settings.yres = pick_resolution(resolutions.resolutions_y, s->resolution, "Y");
settings.tl_x = fixed_to_float(s->pos_top_left_x);
settings.tl_y = fixed_to_float(s->pos_top_left_y);
@ -4726,19 +4711,6 @@ static void init_options(Genesys_Scanner* s)
s->opt[OPT_EXTRAS_GROUP].size = 0;
s->opt[OPT_EXTRAS_GROUP].constraint_type = SANE_CONSTRAINT_NONE;
/* disable_interpolation */
s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation";
s->opt[OPT_DISABLE_INTERPOLATION].title =
SANE_I18N ("Disable interpolation");
s->opt[OPT_DISABLE_INTERPOLATION].desc =
SANE_I18N
("When using high resolutions where the horizontal resolution is smaller "
"than the vertical resolution this disables horizontal interpolation.");
s->opt[OPT_DISABLE_INTERPOLATION].type = SANE_TYPE_BOOL;
s->opt[OPT_DISABLE_INTERPOLATION].unit = SANE_UNIT_NONE;
s->opt[OPT_DISABLE_INTERPOLATION].constraint_type = SANE_CONSTRAINT_NONE;
s->disable_interpolation = false;
/* color filter */
s->opt[OPT_COLOR_FILTER].name = "color-filter";
s->opt[OPT_COLOR_FILTER].title = SANE_I18N ("Color filter");
@ -5628,9 +5600,6 @@ static void get_option_value(Genesys_Scanner* s, int option, void* val)
case OPT_PREVIEW:
*reinterpret_cast<SANE_Word*>(val) = s->preview;
break;
case OPT_DISABLE_INTERPOLATION:
*reinterpret_cast<SANE_Word*>(val) = s->disable_interpolation;
break;
case OPT_LAMP_OFF:
*reinterpret_cast<SANE_Word*>(val) = s->lamp_off;
break;
@ -5831,11 +5800,6 @@ static void set_option_value(Genesys_Scanner* s, int option, void *val, SANE_Int
calc_parameters(s);
*myinfo |= SANE_INFO_RELOAD_PARAMS;
break;
case OPT_DISABLE_INTERPOLATION:
s->disable_interpolation = *reinterpret_cast<SANE_Word*>(val);
calc_parameters(s);
*myinfo |= SANE_INFO_RELOAD_PARAMS;
break;
case OPT_LAMP_OFF:
s->lamp_off = *reinterpret_cast<SANE_Word*>(val);
calc_parameters(s);

Wyświetl plik

@ -113,7 +113,6 @@ enum Genesys_Option
OPT_EXTRAS_GROUP,
OPT_LAMP_OFF_TIME,
OPT_LAMP_OFF,
OPT_DISABLE_INTERPOLATION,
OPT_COLOR_FILTER,
OPT_CALIBRATION_FILE,
OPT_EXPIRATION_TIME,
@ -206,7 +205,6 @@ struct Genesys_Scanner
SANE_Word bit_depth = 0;
SANE_Word resolution = 0;
bool preview = false; // TODO: currently not used
bool disable_interpolation = false;
bool lamp_off = false;
SANE_Word lamp_off_time = 0;
SANE_Word contrast = 0;

Wyświetl plik

@ -653,42 +653,6 @@ void sanei_genesys_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& s
}
}
static unsigned align_int_up(unsigned num, unsigned alignment)
{
unsigned mask = alignment - 1;
if (num & mask)
num = (num & ~mask) + alignment;
return num;
}
void compute_session_pipeline(const Genesys_Device* dev, ScanSession& s)
{
auto channels = s.params.channels;
auto depth = s.params.depth;
s.pipeline_needs_reorder = true;
if (channels != 3 && depth != 16) {
s.pipeline_needs_reorder = false;
}
#ifndef WORDS_BIGENDIAN
if (channels != 3 && depth == 16) {
s.pipeline_needs_reorder = false;
}
if (channels == 3 && depth == 16 && !dev->model->is_cis &&
dev->model->line_mode_color_order == ColorOrder::RGB)
{
s.pipeline_needs_reorder = false;
}
#endif
if (channels == 3 && depth == 8 && !dev->model->is_cis &&
dev->model->line_mode_color_order == ColorOrder::RGB)
{
s.pipeline_needs_reorder = false;
}
s.pipeline_needs_ccd = s.max_color_shift_lines + s.num_staggered_lines > 0;
s.pipeline_needs_shrink = dev->settings.requested_pixels != s.output_pixels;
}
void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
const Genesys_Sensor& sensor)
{
@ -759,7 +723,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
if (dev->model->asic_type == AsicType::GL841 ||
dev->model->asic_type == AsicType::GL842)
{
s.optical_pixels = align_int_up(s.optical_pixels, 2);
s.optical_pixels = align_multiple_ceil(s.optical_pixels, 2);
}
if (dev->model->asic_type == AsicType::GL646 && s.params.xres == 400) {
@ -769,8 +733,8 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
if (dev->model->asic_type == AsicType::GL843) {
// ensure the number of optical pixels is divisible by 2.
// In quarter-CCD mode optical_pixels is 4x larger than the actual physical number
s.optical_pixels = align_int_up(s.optical_pixels,
2 * s.full_resolution / s.optical_resolution);
s.optical_pixels = align_multiple_ceil(s.optical_pixels,
2 * s.full_resolution / s.optical_resolution);
if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200 ||
dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I ||
@ -779,7 +743,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I ||
dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_8200I)
{
s.optical_pixels = align_int_up(s.optical_pixels, 16);
s.optical_pixels = align_multiple_ceil(s.optical_pixels, 16);
}
}
@ -898,7 +862,6 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
s.output_total_bytes = s.output_line_bytes * s.output_line_count;
s.buffer_size_read = s.output_line_bytes_raw * 64;
compute_session_pipeline(dev, s);
compute_session_pixel_offsets(dev, s, sensor);
if (dev->model->asic_type == AsicType::GL124 ||

Wyświetl plik

@ -128,10 +128,7 @@ bool ScanSession::operator==(const ScanSession& other) const
output_segment_start_offset == other.output_segment_start_offset &&
buffer_size_read == other.buffer_size_read &&
enable_ledadd == other.enable_ledadd &&
use_host_side_calib == other.use_host_side_calib &&
pipeline_needs_reorder == other.pipeline_needs_reorder &&
pipeline_needs_ccd == other.pipeline_needs_ccd &&
pipeline_needs_shrink == other.pipeline_needs_shrink;
use_host_side_calib == other.use_host_side_calib;
}
std::ostream& operator<<(std::ostream& out, const ScanSession& session)
@ -167,10 +164,6 @@ std::ostream& operator<<(std::ostream& out, const ScanSession& session)
<< " buffer_size_read: " << session.buffer_size_read << '\n'
<< " enable_ledadd: " << session.enable_ledadd << '\n'
<< " use_host_side_calib: " << session.use_host_side_calib << '\n'
<< " filters: "
<< (session.pipeline_needs_reorder ? " reorder": "")
<< (session.pipeline_needs_ccd ? " ccd": "")
<< (session.pipeline_needs_shrink ? " shrink": "") << '\n'
<< " params: " << format_indent_braced_list(4, session.params) << '\n'
<< "}";
return out;

Wyświetl plik

@ -81,9 +81,6 @@ struct Genesys_Settings
// true if scan is true gray, false if monochrome scan
int true_gray = 0;
// Disable interpolation for xres<yres
int disable_interpolation = 0;
// value for contrast enhancement in the [-100..100] range
int contrast = 0;
@ -318,11 +315,6 @@ struct ScanSession {
// whether calibration should be performed host-side
bool use_host_side_calib = false;
// what pipeline modifications are needed
bool pipeline_needs_reorder = false;
bool pipeline_needs_ccd = false;
bool pipeline_needs_shrink = false;
void assert_computed() const
{
if (!computed) {
@ -373,9 +365,6 @@ void serialize(Stream& str, ScanSession& x)
serialize(str, x.buffer_size_read);
serialize(str, x.enable_ledadd);
serialize(str, x.use_host_side_calib);
serialize(str, x.pipeline_needs_reorder);
serialize(str, x.pipeline_needs_ccd);
serialize(str, x.pipeline_needs_shrink);
}
std::ostream& operator<<(std::ostream& out, const SANE_Parameters& params);