diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 1bc44f06f..da033a7c5 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -4910,7 +4910,7 @@ static void probe_genesys_devices() of Genesys_Calibration_Cache as is. */ static const char* CALIBRATION_IDENT = "sane_genesys"; -static const int CALIBRATION_VERSION = 27; +static const int CALIBRATION_VERSION = 28; bool read_calibration(std::istream& str, Genesys_Device::Calibration& calibration, const std::string& path) diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index 934dd6c53..95137c78e 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -891,7 +891,7 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, // FIXME: take this information from motor struct std::uint8_t reg_vref = reg->get8(0x80); reg_vref = 0x50; - unsigned coeff = sensor.get_hwdpi_divisor_for_dpi(scan_yres); + unsigned coeff = sensor.optical_res / scan_yres; if (dev->model->motor_id == MotorId::KVSS080) { if (coeff >= 1) { reg_vref |= 0x05; @@ -1996,8 +1996,8 @@ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Senso // FIXME: the following is likely incorrect // start coordinate in optical dpi coordinates - startx = (sensor.dummy_pixel / sensor.ccd_pixels_per_system_pixel()) / dev->session.hwdpi_divisor; - startx *= dev->session.pixel_count_multiplier; + startx = sensor.dummy_pixel; + startx = dev->session.pixel_count_ratio.apply(startx); /* current scan coordinates */ strpixel = dev->session.pixel_startx; @@ -2008,8 +2008,8 @@ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Senso { int half_ccd_factor = dev->session.optical_resolution / sensor.get_register_hwdpi(dev->session.output_resolution); - strpixel /= half_ccd_factor * sensor.ccd_pixels_per_system_pixel(); - endpixel /= half_ccd_factor * sensor.ccd_pixels_per_system_pixel(); + strpixel = dev->session.pixel_count_ratio.apply(strpixel / half_ccd_factor); + endpixel = dev->session.pixel_count_ratio.apply(endpixel / half_ccd_factor); } /* 16 bit words, 2 words per color, 3 color channels */ diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index b145de516..19cbf2344 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -837,10 +837,6 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, } s.pixel_startx += s.params.startx * sensor.optical_res / s.params.xres; - if (sensor.stagger_config.stagger_at_resolution(s.params.xres, s.params.yres) > 0) { - s.pixel_startx |= 1; - } - s.pixel_endx = s.pixel_startx + s.optical_pixels; s.pixel_startx /= sensor.ccd_pixels_per_system_pixel() * s.ccd_size_divisor; @@ -854,10 +850,6 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, s.pixel_startx += sensor.dummy_pixel + 1; - if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) { - s.pixel_startx++; - } - /* In case of SHDAREA, we need to align start on pixel average factor, startx is different than 0 only when calling for function to setup for scan, where shading data needs to be align. @@ -876,13 +868,55 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, } else if (dev->model->asic_type == AsicType::GL843) { unsigned startx = s.params.startx * sensor.optical_res / s.params.xres; - s.pixel_startx = (startx + sensor.dummy_pixel) / ccd_pixels_per_system_pixel; - s.pixel_endx = s.pixel_startx + s.optical_pixels / ccd_pixels_per_system_pixel; + s.pixel_startx = (startx + sensor.dummy_pixel); + s.pixel_endx = s.pixel_startx + s.optical_pixels; - s.pixel_startx /= s.hwdpi_divisor; - s.pixel_endx /= s.hwdpi_divisor; + } else if (dev->model->asic_type == AsicType::GL845 || + dev->model->asic_type == AsicType::GL846 || + dev->model->asic_type == AsicType::GL847) + { + unsigned startx = s.params.startx * sensor.optical_res / s.params.xres; + s.pixel_startx = startx; + + s.pixel_startx += sensor.ccd_start_xoffset * ccd_pixels_per_system_pixel; + s.pixel_endx = s.pixel_startx + s.optical_pixels_raw; + + } else if (dev->model->asic_type == AsicType::GL124) { + unsigned startx = s.params.startx * sensor.optical_res / s.params.xres; + + s.pixel_startx = startx; + + // FIXME: should we add sensor.dummy_pxel to pixel_startx at this point? + s.pixel_endx = s.pixel_startx + s.optical_pixels; + } + + s.pixel_startx = sensor.pixel_count_ratio.apply(s.pixel_startx); + s.pixel_endx = sensor.pixel_count_ratio.apply(s.pixel_endx); + + if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I || + dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || + dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) + { + s.pixel_startx = align_multiple_floor(s.pixel_startx, sensor.pixel_count_ratio.divisor()); + s.pixel_endx = align_multiple_floor(s.pixel_endx, sensor.pixel_count_ratio.divisor()); + } + + if (dev->model->asic_type == AsicType::GL646) { + if (sensor.stagger_config.stagger_at_resolution(s.params.xres, s.params.yres) > 0 && + (s.pixel_startx & 1) == 0) + { + s.pixel_startx++; + s.pixel_endx++; + } + } else if (dev->model->asic_type == AsicType::GL841) { + if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) { + s.pixel_startx++; + s.pixel_endx++; + } + } else if (dev->model->asic_type == AsicType::GL843) { // in case of stagger we have to start at an odd coordinate + // FIXME: we should probably just configure the image pipeline accordingly bool stagger_starts_even = false; if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8400F) @@ -899,41 +933,20 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, s.pixel_endx++; } } - } else if (dev->model->asic_type == AsicType::GL845 || dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847) { - unsigned startx = s.params.startx * sensor.optical_res / s.params.xres; - - s.pixel_startx = startx; - - if (s.num_staggered_lines > 0) { - s.pixel_startx |= 1; + if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) { + s.pixel_startx++; + s.pixel_endx++; } - - s.pixel_startx += sensor.ccd_start_xoffset * ccd_pixels_per_system_pixel; - s.pixel_endx = s.pixel_startx + s.optical_pixels_raw; - - s.pixel_startx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel; - s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel; - } else if (dev->model->asic_type == AsicType::GL124) { - unsigned startx = s.params.startx * sensor.optical_res / s.params.xres; - - s.pixel_startx = startx; - - if (s.num_staggered_lines > 0) { - s.pixel_startx |= 1; + if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) { + s.pixel_startx++; + s.pixel_endx++; } - s.pixel_startx /= ccd_pixels_per_system_pixel; - // FIXME: should we add sensor.dummy_pxel to pixel_startx at this point? - s.pixel_endx = s.pixel_startx + s.optical_pixels / ccd_pixels_per_system_pixel; - - s.pixel_startx /= s.hwdpi_divisor * s.segment_count; - s.pixel_endx /= s.hwdpi_divisor * s.segment_count; - std::uint32_t segcnt = (sensor.custom_regs.get_value(gl124::REG_SEGCNT) << 16) + (sensor.custom_regs.get_value(gl124::REG_SEGCNT + 1) << 8) + sensor.custom_regs.get_value(gl124::REG_SEGCNT + 2); @@ -941,11 +954,6 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, s.pixel_endx = 0; } } - - s.pixel_count_multiplier = sensor.pixel_count_multiplier; - - s.pixel_startx *= sensor.pixel_count_multiplier; - s.pixel_endx *= sensor.pixel_count_multiplier; } void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor) @@ -959,18 +967,10 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se throw SaneException("Unsupported depth setting %d", s.params.depth); } - unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); - // compute optical and output resolutions - if (dev->model->asic_type == AsicType::GL843) { - // FIXME: this may be incorrect, but need more scanners to test - s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres); - } else { - s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres * ccd_pixels_per_system_pixel); - } - s.ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(s.params.xres); + s.pixel_count_ratio = sensor.pixel_count_ratio; if (dev->model->asic_type == AsicType::GL646) { s.optical_resolution = sensor.optical_res; @@ -1067,8 +1067,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se // the scan area unsigned extra_segment_scan_area = align_multiple_ceil(s.conseq_pixel_dist, 2); extra_segment_scan_area *= s.segment_count - 1; - extra_segment_scan_area *= s.hwdpi_divisor * s.segment_count; - extra_segment_scan_area *= ccd_pixels_per_system_pixel; + extra_segment_scan_area = s.pixel_count_ratio.apply_inverse(extra_segment_scan_area); s.optical_pixels_raw += extra_segment_scan_area; } @@ -1106,8 +1105,7 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847) { - s.output_segment_pixel_group_count = s.optical_pixels / - (s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel); + s.output_segment_pixel_group_count = s.pixel_count_ratio.apply(s.optical_pixels); } s.output_line_bytes_requested = multiply_by_depth_ceil( diff --git a/backend/genesys/sensor.cpp b/backend/genesys/sensor.cpp index c91a2cc84..7296c3400 100644 --- a/backend/genesys/sensor.cpp +++ b/backend/genesys/sensor.cpp @@ -129,7 +129,7 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor) << " logical_dpihw_override: " << sensor.logical_dpihw_override << '\n' << " dpiset_override: " << sensor.dpiset_override << '\n' << " ccd_size_divisor: " << sensor.ccd_size_divisor << '\n' - << " pixel_count_multiplier: " << sensor.pixel_count_multiplier << '\n' + << " pixel_count_ratio: " << sensor.pixel_count_ratio << '\n' << " black_pixels: " << sensor.black_pixels << '\n' << " dummy_pixel: " << sensor.dummy_pixel << '\n' << " ccd_start_xoffset: " << sensor.ccd_start_xoffset << '\n' diff --git a/backend/genesys/sensor.h b/backend/genesys/sensor.h index c11581fc0..bd73fc1dc 100644 --- a/backend/genesys/sensor.h +++ b/backend/genesys/sensor.h @@ -284,8 +284,9 @@ struct Genesys_Sensor { // CCD may present itself as half or quarter-size CCD on certain resolutions int ccd_size_divisor = 1; - // Some scanners need an additional multiplier over the scan coordinates - int pixel_count_multiplier = 1; + // This defines the ratio between logical pixel coordinates and the pixel coordinates sent to + // the scanner. + Ratio pixel_count_ratio = Ratio{1, 1}; int black_pixels = 0; // value of the dummy register @@ -327,17 +328,12 @@ struct Genesys_Sensor { std::function get_register_hwdpi_fun; std::function get_ccd_size_divisor_fun; - std::function get_hwdpi_divisor_fun; unsigned get_register_hwdpi(unsigned xres) const { return get_register_hwdpi_fun(*this, xres); } unsigned get_ccd_size_divisor_for_dpi(unsigned xres) const { return get_ccd_size_divisor_fun(*this, xres); } - unsigned get_hwdpi_divisor_for_dpi(unsigned xres) const - { - return get_hwdpi_divisor_fun(*this, xres); - } // how many CCD pixels are processed per system pixel time. This corresponds to CKSEL + 1 unsigned ccd_pixels_per_system_pixel() const @@ -366,6 +362,7 @@ struct Genesys_Sensor { resolutions == other.resolutions && method == other.method && ccd_size_divisor == other.ccd_size_divisor && + pixel_count_ratio == other.pixel_count_ratio && black_pixels == other.black_pixels && dummy_pixel == other.dummy_pixel && ccd_start_xoffset == other.ccd_start_xoffset && @@ -392,6 +389,7 @@ void serialize(Stream& str, Genesys_Sensor& x) serialize(str, x.resolutions); serialize(str, x.method); serialize(str, x.ccd_size_divisor); + serialize(str, x.pixel_count_ratio); serialize(str, x.black_pixels); serialize(str, x.dummy_pixel); serialize(str, x.ccd_start_xoffset); diff --git a/backend/genesys/settings.cpp b/backend/genesys/settings.cpp index 3fdaa88df..6a77de893 100644 --- a/backend/genesys/settings.cpp +++ b/backend/genesys/settings.cpp @@ -97,7 +97,6 @@ bool ScanSession::operator==(const ScanSession& other) const { return params == other.params && computed == other.computed && - hwdpi_divisor == other.hwdpi_divisor && ccd_size_divisor == other.ccd_size_divisor && optical_resolution == other.optical_resolution && optical_pixels == other.optical_pixels && @@ -120,7 +119,7 @@ bool ScanSession::operator==(const ScanSession& other) const segment_count == other.segment_count && pixel_startx == other.pixel_startx && pixel_endx == other.pixel_endx && - pixel_count_multiplier == other.pixel_count_multiplier && + pixel_count_ratio == other.pixel_count_ratio && conseq_pixel_dist == other.conseq_pixel_dist && output_segment_pixel_group_count == other.output_segment_pixel_group_count && output_segment_start_offset == other.output_segment_start_offset && @@ -136,7 +135,6 @@ std::ostream& operator<<(std::ostream& out, const ScanSession& session) { out << "ScanSession{\n" << " computed: " << session.computed << '\n' - << " hwdpi_divisor: " << session.hwdpi_divisor << '\n' << " ccd_size_divisor: " << session.ccd_size_divisor << '\n' << " optical_resolution: " << session.optical_resolution << '\n' << " optical_pixels: " << session.optical_pixels << '\n' diff --git a/backend/genesys/settings.h b/backend/genesys/settings.h index 914ecbde0..111939ecb 100644 --- a/backend/genesys/settings.h +++ b/backend/genesys/settings.h @@ -46,6 +46,7 @@ #include "enums.h" #include "serialize.h" +#include "utilities.h" namespace genesys { @@ -210,10 +211,6 @@ struct ScanSession { // whether the session setup has been computed via compute_session() bool computed = false; - // specifies the reduction (if any) of hardware dpi on the Genesys chip side. - // except gl646 - unsigned hwdpi_divisor = 1; - // specifies the reduction (if any) of CCD effective dpi which is performed by latching the // data coming from CCD in such a way that 1/2 or 3/4 of pixel data is ignored. unsigned ccd_size_divisor = 1; @@ -283,8 +280,18 @@ struct ScanSession { unsigned pixel_startx = 0; unsigned pixel_endx = 0; - // certain scanners require the logical pixel count to be multiplied on certain resolutions - unsigned pixel_count_multiplier = 1; + /* The following defines the ratio between logical pixel count and pixel count setting sent to + the scanner. The ratio is affected by the following: + + - Certain scanners just like to multiply the pixel number by a multiplier that depends on + the resolution. + + - The sensor may be configured to output one value per multiple physical pixels + + - The scanner will automatically average the pixels that come from the sensor using a + certain ratio. + */ + Ratio pixel_count_ratio = Ratio{1, 1}; // Distance in pixels between consecutive pixels, e.g. between odd and even pixels. Note that // the number of segments can be large. @@ -332,7 +339,6 @@ void serialize(Stream& str, ScanSession& x) serialize(str, x.params); serialize_newline(str); serialize(str, x.computed); - serialize(str, x.hwdpi_divisor); serialize(str, x.ccd_size_divisor); serialize(str, x.optical_resolution); serialize(str, x.optical_pixels); @@ -355,7 +361,7 @@ void serialize(Stream& str, ScanSession& x) serialize(str, x.segment_count); serialize(str, x.pixel_startx); serialize(str, x.pixel_endx); - serialize(str, x.pixel_count_multiplier); + serialize(str, x.pixel_count_ratio); serialize(str, x.conseq_pixel_dist); serialize(str, x.output_segment_pixel_group_count); serialize(str, x.output_segment_start_offset); diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 0cead44e6..92250c18b 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -104,11 +104,6 @@ inline unsigned get_ccd_size_divisor_gl124(const Genesys_Sensor& sensor, unsigne return 1; } -inline unsigned default_get_hwdpi_divisor_for_dpi(const Genesys_Sensor& sensor, unsigned xres) -{ - return sensor.optical_res / default_get_register_hwdpi(sensor, xres); -} - StaticInit> s_sensors; void genesys_init_sensor_tables() @@ -136,7 +131,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -160,7 +154,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -184,7 +177,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -210,7 +202,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 2.38f, 2.35f, 2.34f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { @@ -336,7 +327,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 2.1f, 2.1f, 2.1f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { @@ -433,7 +423,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 2.1f, 2.1f, 2.1f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { @@ -533,7 +522,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -565,7 +553,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 2.1f, 2.1f, 2.1f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { @@ -620,7 +607,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { @@ -744,7 +730,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -787,7 +772,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -830,7 +814,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -873,7 +856,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -916,7 +898,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -932,7 +913,6 @@ void genesys_init_sensor_tables() sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -940,6 +920,7 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; @@ -947,7 +928,8 @@ void genesys_init_sensor_tables() CustomSensorSettings custom_settings[] = { // Note: Windows driver uses 1424 lperiod and enables dummy line (0x17) - { { 75, 100, 150, 200 }, 2848, { 304, 203, 180 }, 5136, std::vector{}, { + { { 75, 100, 150, 200 }, + 2848, { 304, 203, 180 }, Ratio{1, 8}, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -958,7 +940,7 @@ void genesys_init_sensor_tables() } }, // Note: Windows driver uses 788 lperiod and enables dummy line (0x17) - { { 300, 400 }, 1424, { 304, 203, 180 }, 5136, std::vector{}, { + { { 300, 400 }, 1424, { 304, 203, 180 }, Ratio{1, 8}, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -968,7 +950,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 600 }, 1432, { 492, 326, 296 }, 5136, std::vector{}, { + { { 600 }, 1432, { 492, 326, 296 }, Ratio{1, 8}, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -978,7 +960,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 1200 }, 2712, { 935, 592, 538 }, 5136, { 0, 1 }, { + { { 1200 }, 2712, { 935, 592, 538 }, Ratio{1, 8}, 5136, { 0, 1 }, { { 0x16, 0x10 }, { 0x17, 0x08 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -988,7 +970,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 2400 }, 5280, { 1777, 1125, 979 }, 5136, { 0, 2, 1, 3 }, { + { { 2400 }, 5280, { 1777, 1125, 979 }, Ratio{1, 8}, 5136, { 0, 2, 1, 3 }, { { 0x16, 0x10 }, { 0x17, 0x06 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -998,7 +980,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 4800 }, 10416, { 3377, 2138, 1780 }, 5136, { 0, 2, 4, 6, 1, 3, 5, 7 }, { + { { 4800 }, 10416, { 3377, 2138, 1780 }, Ratio{1, 8}, 5136, { 0, 2, 4, 6, 1, 3, 5, 7 }, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1014,6 +996,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_size = setting.segment_size; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; @@ -1033,7 +1016,6 @@ void genesys_init_sensor_tables() sensor.gain_white_ref = 200; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -1041,13 +1023,15 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 200 }, 2848, { 465, 310, 239 }, 5187, std::vector{}, { + { { 75, 100, 150, 200 }, + 2848, { 465, 310, 239 }, Ratio{1, 8}, 5187, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1057,7 +1041,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 300 }, 1424, { 465, 310, 239 }, 5187, std::vector{}, { + { { 300 }, 1424, { 465, 310, 239 }, Ratio{1, 8}, 5187, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1067,7 +1051,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 600 }, 1504, { 465, 310, 239 }, 5187, std::vector{}, { + { { 600 }, 1504, { 465, 310, 239 }, Ratio{1, 8}, 5187, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1077,7 +1061,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 1200 }, 2696, { 1464, 844, 555 }, 5187, { 0, 1 }, { + { { 1200 }, 2696, { 1464, 844, 555 }, Ratio{1, 8}, 5187, { 0, 1 }, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1087,7 +1071,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 2400 }, 10576, { 2798, 1558, 972 }, 5187, { 0, 1, 2, 3 }, { + { { 2400 }, 10576, { 2798, 1558, 972 }, Ratio{1, 8}, 5187, { 0, 1, 2, 3 }, { { 0x16, 0x10 }, { 0x17, 0x08 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1097,7 +1081,8 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 4800 }, 10576, { 2798, 1558, 972 }, 5187, { 0, 1, 4, 5, 2, 3, 6, 7 }, { + { { 4800 }, 10576, { 2798, 1558, 972 }, Ratio{1, 8}, 5187, + { 0, 1, 4, 5, 2, 3, 6, 7 }, { { 0x16, 0x10 }, { 0x17, 0x06 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1113,6 +1098,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_size = setting.segment_size; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; @@ -1132,7 +1118,6 @@ void genesys_init_sensor_tables() sensor.exposure = { 0x01c1, 0x0126, 0x00e5 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -1140,13 +1125,15 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 200 }, 2304, { 423, 294, 242 }, 5136, std::vector{}, { + { { 75, 100, 150, 200 }, + 2304, { 423, 294, 242 }, Ratio{1, 4}, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1156,7 +1143,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 300 }, 1728, { 423, 294, 242 }, 5136, std::vector{}, { + { { 300 }, 1728, { 423, 294, 242 }, Ratio{1, 4}, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1166,7 +1153,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 600 }, 1432, { 423, 294, 242 }, 5136, std::vector{}, { + { { 600 }, 1432, { 423, 294, 242 }, Ratio{1, 4}, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1176,7 +1163,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, }, }, - { { 1200 }, 2712, { 791, 542, 403 }, 5136, {0, 1}, { + { { 1200 }, 2712, { 791, 542, 403 }, Ratio{1, 4}, 5136, {0, 1}, { { 0x16, 0x10 }, { 0x17, 0x08 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1186,7 +1173,7 @@ void genesys_init_sensor_tables() { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, - { { 2400 }, 5280, { 1504, 1030, 766 }, 5136, {0, 2, 1, 3}, { + { { 2400 }, 5280, { 1504, 1030, 766 }, Ratio{1, 4}, 5136, {0, 2, 1, 3}, { { 0x16, 0x10 }, { 0x17, 0x06 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, @@ -1202,6 +1189,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_size = setting.segment_size; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; @@ -1248,10 +1236,24 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + Ratio pixel_count_ratio; + }; + CustomSensorSettings custom_settings[] = { + { { 75, 100, 150, 200, 300, 600 }, Ratio{1, 1} }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.pixel_count_ratio = setting.pixel_count_ratio; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_G4050; @@ -1267,7 +1269,6 @@ void genesys_init_sensor_tables() sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -1275,11 +1276,12 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; ScanMethod method; + Ratio pixel_count_ratio; GenesysRegisterSettingSet extra_custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 100, 150, 200, 300, 400, 600 }, 8016, ScanMethod::FLATBED, { + { { 100, 150, 200, 300, 400, 600 }, 8016, ScanMethod::FLATBED, Ratio{1, 8}, { { 0x74, 0x00 }, { 0x75, 0x01 }, { 0x76, 0xff }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, @@ -1307,7 +1309,7 @@ void genesys_init_sensor_tables() { 0x5a, 0x40 }, } }, - { { 1200 }, 56064, ScanMethod::FLATBED, { + { { 1200 }, 56064, ScanMethod::FLATBED, Ratio{1, 4}, { { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x01 }, { 0x79, 0xff }, { 0x7a, 0x00 }, { 0x7b, 0x01 }, { 0x7c, 0xff }, @@ -1335,7 +1337,7 @@ void genesys_init_sensor_tables() { 0x5a, 0x40 }, } }, - { { 2400 }, 56064, ScanMethod::FLATBED, { + { { 2400 }, 56064, ScanMethod::FLATBED, Ratio{1, 2}, { { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, @@ -1363,7 +1365,7 @@ void genesys_init_sensor_tables() { 0x5a, 0x40 }, } }, - { { 4800 }, 42752, ScanMethod::FLATBED, { + { { 4800 }, 42752, ScanMethod::FLATBED, Ratio{1, 1}, { { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, @@ -1391,7 +1393,7 @@ void genesys_init_sensor_tables() { 0x5a, 0x40 }, } }, - { VALUE_FILTER_ANY, 15624, ScanMethod::TRANSPARENCY, { + { VALUE_FILTER_ANY, 15624, ScanMethod::TRANSPARENCY, Ratio{1, 1}, { { 0x74, 0x00 }, { 0x75, 0x1c }, { 0x76, 0x7f }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, @@ -1427,6 +1429,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = setting.method; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.custom_regs = base_custom_regs; sensor.custom_regs.merge(setting.extra_custom_regs); s_sensors->push_back(sensor); @@ -1446,7 +1449,6 @@ void genesys_init_sensor_tables() sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -1454,11 +1456,12 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; ScanMethod method; + Ratio pixel_count_ratio; GenesysRegisterSettingSet extra_custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 100, 150, 200, 300, 400, 600 }, 8016, ScanMethod::FLATBED, { + { { 100, 150, 200, 300, 400, 600 }, 8016, ScanMethod::FLATBED, Ratio{1, 8}, { { 0x0c, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, @@ -1472,7 +1475,7 @@ void genesys_init_sensor_tables() { 0xaa, 0x00 }, } }, - { { 1200 }, 56064, ScanMethod::FLATBED, { + { { 1200 }, 56064, ScanMethod::FLATBED, Ratio{1, 4}, { { 0x0c, 0x20 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, @@ -1486,7 +1489,7 @@ void genesys_init_sensor_tables() { 0xaa, 0x05 }, } }, - { { 2400 }, 56064, ScanMethod::FLATBED, { + { { 2400 }, 56064, ScanMethod::FLATBED, Ratio{1, 2}, { { 0x0c, 0x20 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0xc0 }, { 0x1d, 0x08 }, @@ -1500,7 +1503,7 @@ void genesys_init_sensor_tables() { 0xaa, 0x05 }, } }, - { { 4800 }, 42752, ScanMethod::FLATBED, { + { { 4800 }, 42752, ScanMethod::FLATBED, Ratio{1, 1}, { { 0x0c, 0x21 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0xc1 }, { 0x1d, 0x08 }, @@ -1514,7 +1517,7 @@ void genesys_init_sensor_tables() { 0xaa, 0x07 }, } }, - { VALUE_FILTER_ANY, 15624, ScanMethod::TRANSPARENCY, { + { VALUE_FILTER_ANY, 15624, ScanMethod::TRANSPARENCY, Ratio{1, 1}, { { 0x0c, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x4c }, { 0x18, 0x01 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, @@ -1536,6 +1539,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = setting.method; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.custom_regs = base_custom_regs; sensor.custom_regs.merge(setting.extra_custom_regs); s_sensors->push_back(sensor); @@ -1557,7 +1561,6 @@ void genesys_init_sensor_tables() sensor.stagger_config = StaggerConfig{4800, 8}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = get_sensor_optical_with_ccd_divisor; - sensor.get_hwdpi_divisor_fun = [](const Genesys_Sensor&, unsigned) { return 1; }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -1654,14 +1657,13 @@ void genesys_init_sensor_tables() sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = get_sensor_optical_with_ccd_divisor; - sensor.get_hwdpi_divisor_fun = [](const Genesys_Sensor&, unsigned) { return 1; }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ValueFilterAny resolutions; unsigned dpiset_override; - unsigned pixel_count_multiplier; + Ratio pixel_count_ratio; int exposure_lperiod; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; @@ -1669,7 +1671,7 @@ void genesys_init_sensor_tables() }; CustomSensorSettings custom_settings[] = { - { { 400 }, 2400, 1, 7200, { ScanMethod::FLATBED }, { + { { 400 }, 2400, Ratio{1, 4}, 7200, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -1681,7 +1683,7 @@ void genesys_init_sensor_tables() { 0x80, 0x2a }, }, {} }, - { { 800 }, 4800, 1, 7200, { ScanMethod::FLATBED }, { + { { 800 }, 4800, Ratio{1, 4}, 7200, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -1693,7 +1695,7 @@ void genesys_init_sensor_tables() { 0x80, 0x20 }, }, {} }, - { { 1600 }, 4800, 1, 14400, { ScanMethod::FLATBED }, { + { { 1600 }, 4800, Ratio{1, 2}, 14400, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa1 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, @@ -1707,7 +1709,7 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, } }, - { { 3200 }, 4800, 1, 28800, { ScanMethod::FLATBED }, { + { { 3200 }, 4800, Ratio{1, 1}, 28800, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x1e, 0xa1 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, @@ -1721,8 +1723,8 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, }, }, - { { 400 }, 2400, 1, 14400, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 400 }, 2400, Ratio{1, 4}, 14400, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -1734,8 +1736,8 @@ void genesys_init_sensor_tables() { 0x80, 0x20 }, }, {} }, - { { 800 }, 4800, 1, 14400, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 800 }, 4800, Ratio{1, 4}, 14400, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -1747,8 +1749,8 @@ void genesys_init_sensor_tables() { 0x80, 0x20 }, }, {} }, - { { 1600 }, 4800, 1, 28800, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 1600 }, 4800, Ratio{1, 2}, 28800, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, @@ -1762,8 +1764,8 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, }, }, - { { 3200 }, 4800, 1, 28800, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 3200 }, 4800, Ratio{1, 1}, 28800, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, @@ -1784,7 +1786,7 @@ void genesys_init_sensor_tables() for (auto method : setting.methods) { sensor.resolutions = setting.resolutions; sensor.dpiset_override = setting.dpiset_override; - sensor.pixel_count_multiplier = setting.pixel_count_multiplier; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = method; sensor.custom_regs = setting.extra_custom_regs; @@ -1810,7 +1812,6 @@ void genesys_init_sensor_tables() sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = get_sensor_optical_with_ccd_divisor; - sensor.get_hwdpi_divisor_fun = [](const Genesys_Sensor&, unsigned) { return 1; }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { @@ -1933,7 +1934,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -1950,7 +1950,6 @@ void genesys_init_sensor_tables() sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { @@ -1958,12 +1957,13 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150 }, 4608, { 462, 609, 453 }, std::vector{}, { + { { 75, 100, 150 }, 4608, { 462, 609, 453 }, Ratio{1, 4}, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0c }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, @@ -1980,7 +1980,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, } }, - { { 300 }, 4608, { 462, 609, 453 }, std::vector{}, { + { { 300 }, 4608, { 462, 609, 453 }, Ratio{1, 4}, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x0c }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, @@ -1997,7 +1997,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, } }, - { { 600 }, 5360, { 823, 1117, 805 }, std::vector{}, { + { { 600 }, 5360, { 823, 1117, 805 }, Ratio{1, 4}, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x0a }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, @@ -2014,7 +2014,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, }, }, - { { 1200 }, 10528, { 6071, 6670, 6042 }, { 0, 1 }, { + { { 1200 }, 10528, { 6071, 6670, 6042 }, Ratio{1, 4}, { 0, 1 }, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 },{ 0x20, 0x08 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, @@ -2031,7 +2031,7 @@ void genesys_init_sensor_tables() { 0x98, 0x22 }, } }, - { { 2400 }, 20864, { 7451, 8661, 7405 }, { 0, 2, 1, 3 }, { + { { 2400 }, 20864, { 7451, 8661, 7405 }, Ratio{1, 4}, { 0, 2, 1, 3 }, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x06 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, @@ -2054,6 +2054,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); @@ -2072,7 +2073,6 @@ void genesys_init_sensor_tables() sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { @@ -2080,12 +2080,14 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 300 }, 4608, { 1244, 1294, 1144 }, std::vector{}, { + { { 75, 100, 150, 300 }, + 4608, { 1244, 1294, 1144 }, Ratio{1, 4}, std::vector{}, { { 0x16, 0x15 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, @@ -2102,7 +2104,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, }, }, - { { 600 }, 5360, { 2394, 2444, 2144 }, std::vector{}, { + { { 600 }, 5360, { 2394, 2444, 2144 }, Ratio{1, 4}, std::vector{}, { { 0x16, 0x11 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, @@ -2119,7 +2121,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, }, }, - { { 1200 }, 10528, { 4694, 4644, 4094 }, std::vector{}, { + { { 1200 }, 10528, { 4694, 4644, 4094 }, Ratio{1, 2}, std::vector{}, { { 0x16, 0x15 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, @@ -2136,7 +2138,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, }, }, - { { 2400 }, 20864, { 8944, 8144, 7994 }, std::vector{}, { + { { 2400 }, 20864, { 8944, 8144, 7994 }, Ratio{1, 1}, std::vector{}, { { 0x16, 0x11 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, @@ -2159,6 +2161,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); @@ -2177,7 +2180,6 @@ void genesys_init_sensor_tables() sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { @@ -2185,12 +2187,13 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 300 }, 2768, { 388, 574, 393 }, std::vector{}, { + { { 75, 100, 150, 300 }, 2768, { 388, 574, 393 }, Ratio{1, 4}, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0c }, @@ -2208,7 +2211,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, } }, - { { 600 }, 5360, { 388, 574, 393 }, std::vector{}, { + { { 600 }, 5360, { 388, 574, 393 }, Ratio{1, 4}, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0a }, @@ -2226,7 +2229,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, } }, - { { 1200 }, 10528, { 388, 574, 393 }, {0, 1}, { + { { 1200 }, 10528, { 388, 574, 393 }, Ratio{1, 4}, {0, 1}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x08 }, @@ -2244,7 +2247,7 @@ void genesys_init_sensor_tables() { 0x98, 0x22 }, }, }, - { { 2400 }, 20864, { 6839, 8401, 6859 }, {0, 2, 1, 3}, { + { { 2400 }, 20864, { 6839, 8401, 6859 }, Ratio{1, 4}, {0, 2, 1, 3}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x06 }, @@ -2268,6 +2271,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); @@ -2286,7 +2290,6 @@ void genesys_init_sensor_tables() sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { @@ -2294,12 +2297,14 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; int exposure_lperiod; SensorExposure exposure; + Ratio pixel_count_ratio; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { - { { 75, 100, 150, 300 }, 2768, { 388, 574, 393 }, std::vector{}, { + { { 75, 100, 150, 300 }, + 2768, { 388, 574, 393 }, Ratio{1, 4}, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0c }, @@ -2317,7 +2322,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, } }, - { { 600 }, 5360, { 388, 574, 393 }, std::vector{}, { + { { 600 }, 5360, { 388, 574, 393 }, Ratio{1, 4}, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0a }, @@ -2335,7 +2340,7 @@ void genesys_init_sensor_tables() { 0x98, 0x21 }, } }, - { { 1200 }, 10528, { 388, 574, 393 }, {0, 1}, { + { { 1200 }, 10528, { 388, 574, 393 }, Ratio{1, 4}, {0, 1}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x08 }, @@ -2353,7 +2358,7 @@ void genesys_init_sensor_tables() { 0x98, 0x22 }, } }, - { { 2400 }, 20864, { 6839, 8401, 6859 }, {0, 2, 1, 3}, { + { { 2400 }, 20864, { 6839, 8401, 6859 },Ratio{1, 4}, {0, 2, 1, 3}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x06 }, @@ -2377,6 +2382,7 @@ void genesys_init_sensor_tables() sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); @@ -2422,7 +2428,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); @@ -2470,7 +2475,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings @@ -2479,26 +2483,26 @@ void genesys_init_sensor_tables() ScanMethod method; unsigned ccd_size_divisor; unsigned logical_dpihw_override; - unsigned pixel_count_multiplier; + Ratio pixel_count_ratio; unsigned exposure_lperiod; unsigned dpiset_override; GenesysRegisterSettingSet custom_fe_regs; }; CustomSensorSettings custom_settings[] = { - { { 900 }, ScanMethod::TRANSPARENCY, 1, 900, 8, 0x2538, 150, {} }, - { { 1800 }, ScanMethod::TRANSPARENCY, 1, 1800, 4, 0x2538, 300, {} }, - { { 3600 }, ScanMethod::TRANSPARENCY, 1, 3600, 2, 0x2538, 600, {} }, - { { 7200 }, ScanMethod::TRANSPARENCY, 1, 7200, 1, 0x19c8, 1200, { + { { 900 }, ScanMethod::TRANSPARENCY, 1, 900, Ratio{8, 8}, 0x2538, 150, {} }, + { { 1800 }, ScanMethod::TRANSPARENCY, 1, 1800, Ratio{4, 4}, 0x2538, 300, {} }, + { { 3600 }, ScanMethod::TRANSPARENCY, 1, 3600, Ratio{2, 2}, 0x2538, 600, {} }, + { { 7200 }, ScanMethod::TRANSPARENCY, 1, 7200, Ratio{1, 1}, 0x19c8, 1200, { { 0x02, 0x1b }, { 0x03, 0x14 }, { 0x04, 0x20 }, } }, - { { 900 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 900, 8, 0x1f54, 150, {} }, - { { 1800 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 1800, 4, 0x1f54, 300, {} }, - { { 3600 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 3600, 2, 0x1f54, 600, {} }, - { { 7200 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 7200, 1, 0x1f54, 1200, {} }, + { { 900 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 900, Ratio{8, 8}, 0x1f54, 150, {} }, + { { 1800 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 1800, Ratio{4, 4}, 0x1f54, 300, {} }, + { { 3600 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 3600, Ratio{2, 2}, 0x1f54, 600, {} }, + { { 7200 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 7200, Ratio{1, 1}, 0x1f54, 1200, {} }, }; for (const CustomSensorSettings& setting : custom_settings) { @@ -2506,7 +2510,7 @@ void genesys_init_sensor_tables() sensor.method = setting.method; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.logical_dpihw_override = setting.logical_dpihw_override; - sensor.pixel_count_multiplier = setting.pixel_count_multiplier; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.dpiset_override = setting.dpiset_override; sensor.custom_fe_regs = setting.custom_fe_regs; @@ -2560,7 +2564,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings @@ -2568,22 +2571,22 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; unsigned ccd_size_divisor; unsigned logical_dpihw_override; - unsigned pixel_count_multiplier; + Ratio pixel_count_ratio; unsigned dpiset_override; }; CustomSensorSettings custom_settings[] = { - { { 900 }, 1, 900, 8, 150 }, - { { 1800 }, 1, 1800, 4, 300 }, - { { 3600 }, 1, 3600, 2, 600 }, - { { 7200 }, 1, 7200, 1, 1200 }, + { { 900 }, 1, 900, Ratio{8, 8}, 150 }, + { { 1800 }, 1, 1800, Ratio{4, 4}, 300 }, + { { 3600 }, 1, 3600, Ratio{2, 2}, 600 }, + { { 7200 }, 1, 7200, Ratio{1, 1}, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.logical_dpihw_override = setting.logical_dpihw_override; - sensor.pixel_count_multiplier = setting.pixel_count_multiplier; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.dpiset_override = setting.dpiset_override; s_sensors->push_back(sensor); } @@ -2633,7 +2636,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings @@ -2642,20 +2644,20 @@ void genesys_init_sensor_tables() ScanMethod method; unsigned ccd_size_divisor; unsigned logical_dpihw_override; - unsigned pixel_count_multiplier; + Ratio pixel_count_ratio; unsigned exposure_lperiod; unsigned dpiset_override; }; CustomSensorSettings custom_settings[] = { - { { 900 }, ScanMethod::TRANSPARENCY, 1, 900, 8, 0x2f44, 150 }, - { { 1800 }, ScanMethod::TRANSPARENCY, 1, 1800, 4, 0x2f44, 300 }, - { { 3600 }, ScanMethod::TRANSPARENCY, 1, 3600, 2, 0x2f44, 600 }, - { { 7200 }, ScanMethod::TRANSPARENCY, 1, 7200, 1, 0x2f44, 1200 }, - { { 900 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 900, 8, 0x2af8, 150 }, - { { 1800 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 1800, 4, 0x2af8, 300 }, - { { 3600 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 3600, 2, 0x2af8, 600 }, - { { 7200 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 7200, 1, 0x2af8, 1200 }, + { { 900 }, ScanMethod::TRANSPARENCY, 1, 900, Ratio{8, 8}, 0x2f44, 150 }, + { { 1800 }, ScanMethod::TRANSPARENCY, 1, 1800, Ratio{4, 4}, 0x2f44, 300 }, + { { 3600 }, ScanMethod::TRANSPARENCY, 1, 3600, Ratio{2, 2}, 0x2f44, 600 }, + { { 7200 }, ScanMethod::TRANSPARENCY, 1, 7200, Ratio{1, 1}, 0x2f44, 1200 }, + { { 900 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 900, Ratio{8, 8}, 0x2af8, 150 }, + { { 1800 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 1800, Ratio{4, 4}, 0x2af8, 300 }, + { { 3600 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 3600, Ratio{2, 2}, 0x2af8, 600 }, + { { 7200 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 7200, Ratio{1, 1}, 0x2af8, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { @@ -2663,7 +2665,7 @@ void genesys_init_sensor_tables() sensor.method = setting.method; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.logical_dpihw_override = setting.logical_dpihw_override; - sensor.pixel_count_multiplier = setting.pixel_count_multiplier; + sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.dpiset_override = setting.dpiset_override; s_sensors->push_back(sensor); @@ -2695,9 +2697,26 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.7f, 1.7f, 1.7f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + Ratio pixel_count_ratio; + }; + + CustomSensorSettings custom_settings[] = { + { { 75, 100, 150, 300, 600 }, Ratio{1, 4} }, + { { 1200 }, Ratio{1, 2} }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.pixel_count_ratio = setting.pixel_count_ratio; + s_sensors->push_back(sensor); + } + } + sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_PLUSTEK_OPTICBOOK_3800; @@ -2721,10 +2740,25 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.7f, 1.7f, 1.7f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; - s_sensors->push_back(sensor); + { + struct CustomSensorSettings + { + ValueFilterAny resolutions; + Ratio pixel_count_ratio; + }; + CustomSensorSettings custom_settings[] = { + { { 75, 100, 150, 300, 600 }, Ratio{1, 2} }, + { { 1200 }, Ratio{1, 1} }, + }; + + for (const CustomSensorSettings& setting : custom_settings) { + sensor.resolutions = setting.resolutions; + sensor.pixel_count_ratio = setting.pixel_count_ratio; + s_sensors->push_back(sensor); + } + } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_80; @@ -2767,7 +2801,6 @@ void genesys_init_sensor_tables() }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_register_hwdpi_fun = default_get_register_hwdpi; - sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); } diff --git a/backend/genesys/utilities.h b/backend/genesys/utilities.h index aa8e82b8a..2f4ceb73e 100644 --- a/backend/genesys/utilities.h +++ b/backend/genesys/utilities.h @@ -46,6 +46,7 @@ #include "error.h" #include +#include #include #include #include @@ -108,6 +109,75 @@ void compute_array_percentile_approx(T* result, const T* data, } } +class Ratio +{ +public: + Ratio() : multiplier_{1}, divisor_{1} + { + } + + Ratio(unsigned multiplier, unsigned divisor) : multiplier_{multiplier}, divisor_{divisor} + { + } + + unsigned multiplier() const { return multiplier_; } + unsigned divisor() const { return divisor_; } + + unsigned apply(unsigned arg) const + { + return static_cast(arg) * multiplier_ / divisor_; + } + + int apply(int arg) const + { + return static_cast(arg) * multiplier_ / divisor_; + } + + float apply(float arg) const + { + return arg * multiplier_ / divisor_; + } + + unsigned apply_inverse(unsigned arg) const + { + return static_cast(arg) * divisor_ / multiplier_; + } + + int apply_inverse(int arg) const + { + return static_cast(arg) * divisor_ / multiplier_; + } + + float apply_inverse(float arg) const + { + return arg * divisor_ / multiplier_; + } + + bool operator==(const Ratio& other) const + { + return multiplier_ == other.multiplier_ && divisor_ == other.divisor_; + } +private: + unsigned multiplier_; + unsigned divisor_; + + template + friend void serialize(Stream& str, Ratio& x); +}; + +template +void serialize(Stream& str, Ratio& x) +{ + serialize(str, x.multiplier_); + serialize(str, x.divisor_); +} + +inline std::ostream& operator<<(std::ostream& out, const Ratio& ratio) +{ + out << ratio.multiplier() << "/" << ratio.divisor(); + return out; +} + template class BasicStreamStateSaver {