kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Define SetupParams::startx in terms of xres
rodzic
1fa3086cab
commit
b54d12bc4d
|
@ -1087,7 +1087,7 @@ void scanner_move_back_home(Genesys_Device& dev, bool wait_until_home)
|
|||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.startx = 100 * resolution / sensor.optical_res;
|
||||
if (dev.model->asic_type == AsicType::GL843) {
|
||||
session.params.starty = 40000;
|
||||
} else {
|
||||
|
@ -1234,7 +1234,7 @@ void scanner_move_back_home_ta(Genesys_Device& dev)
|
|||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 100;
|
||||
session.params.startx = 100 * resolution / sensor.optical_res;
|
||||
session.params.starty = 30000;
|
||||
session.params.pixels = 100;
|
||||
session.params.lines = 100;
|
||||
|
@ -1674,7 +1674,10 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_
|
|||
}
|
||||
unsigned channels = dev->calib_session.params.channels;
|
||||
|
||||
unsigned out_pixels_per_line = pixels_per_line + dev->calib_session.params.startx;
|
||||
// BUG: we are using wrong pixel number here
|
||||
unsigned start_offset =
|
||||
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
|
||||
unsigned out_pixels_per_line = pixels_per_line + start_offset;
|
||||
|
||||
// FIXME: we set this during both dark and white calibration. A cleaner approach should
|
||||
// probably be used
|
||||
|
@ -1749,10 +1752,10 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_
|
|||
}
|
||||
|
||||
std::fill(out_average_data.begin(),
|
||||
out_average_data.begin() + dev->calib_session.params.startx * channels, 0);
|
||||
out_average_data.begin() + start_offset * channels, 0);
|
||||
|
||||
compute_array_percentile_approx(out_average_data.data() +
|
||||
dev->calib_session.params.startx * channels,
|
||||
start_offset * channels,
|
||||
calibration_data.data(),
|
||||
dev->calib_session.params.lines, pixels_per_line * channels,
|
||||
0.5f);
|
||||
|
@ -1799,7 +1802,11 @@ static void genesys_dummy_dark_shading(Genesys_Device* dev, const Genesys_Sensor
|
|||
|
||||
unsigned channels = dev->calib_session.params.channels;
|
||||
|
||||
unsigned out_pixels_per_line = pixels_per_line + dev->calib_session.params.startx;
|
||||
// BUG: we are using wrong pixel number here
|
||||
unsigned start_offset =
|
||||
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
|
||||
|
||||
unsigned out_pixels_per_line = pixels_per_line + start_offset;
|
||||
|
||||
dev->average_size = channels * out_pixels_per_line;
|
||||
dev->dark_average_data.clear();
|
||||
|
@ -1928,7 +1935,11 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
|
|||
|
||||
unsigned channels = dev->calib_session.params.channels;
|
||||
|
||||
unsigned out_pixels_per_line = pixels_per_line + dev->calib_session.params.startx;
|
||||
// BUG: we are using wrong pixel number here
|
||||
unsigned start_offset =
|
||||
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
|
||||
|
||||
unsigned out_pixels_per_line = pixels_per_line + start_offset;
|
||||
|
||||
dev->average_size = channels * out_pixels_per_line;
|
||||
|
||||
|
@ -1989,14 +2000,14 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
|
|||
|
||||
|
||||
std::fill(dev->dark_average_data.begin(),
|
||||
dev->dark_average_data.begin() + dev->calib_session.params.startx * channels, 0);
|
||||
dev->dark_average_data.begin() + start_offset * channels, 0);
|
||||
std::fill(dev->white_average_data.begin(),
|
||||
dev->white_average_data.begin() + dev->calib_session.params.startx * channels, 0);
|
||||
dev->white_average_data.begin() + start_offset * channels, 0);
|
||||
|
||||
uint16_t* average_white = dev->white_average_data.data() +
|
||||
dev->calib_session.params.startx * channels;
|
||||
start_offset * channels;
|
||||
uint16_t* average_dark = dev->dark_average_data.data() +
|
||||
dev->calib_session.params.startx * channels;
|
||||
start_offset * channels;
|
||||
|
||||
for (x = 0; x < pixels_per_line * channels; x++)
|
||||
{
|
||||
|
@ -2541,10 +2552,15 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_
|
|||
unsigned int factor;
|
||||
unsigned int coeff, target_code, words_per_color = 0;
|
||||
|
||||
|
||||
// BUG: we are using wrong pixel number here
|
||||
unsigned start_offset =
|
||||
dev->calib_session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
|
||||
|
||||
if (dev->model->asic_type == AsicType::GL843) {
|
||||
pixels_per_line = dev->calib_session.output_pixels + dev->calib_session.params.startx;
|
||||
pixels_per_line = dev->calib_session.output_pixels + start_offset;
|
||||
} else {
|
||||
pixels_per_line = dev->calib_session.params.pixels + dev->calib_session.params.startx;
|
||||
pixels_per_line = dev->calib_session.params.pixels + start_offset;
|
||||
}
|
||||
|
||||
unsigned channels = dev->calib_session.params.channels;
|
||||
|
|
|
@ -912,7 +912,7 @@ ScanSession CommandSetGl124::calculate_scan_session(const Genesys_Device* dev,
|
|||
/* start */
|
||||
start = static_cast<int>(dev->model->x_offset);
|
||||
start += static_cast<int>(settings.tl_x);
|
||||
start = static_cast<int>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<int>((start * settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
|
@ -1282,7 +1282,7 @@ void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
start = dev->model->x_offset;
|
||||
start += dev->settings.tl_x;
|
||||
start /= sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * dev->settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
|
|
|
@ -1808,7 +1808,7 @@ static ScanSession setup_for_scan(Genesys_Device* dev,
|
|||
start += dev->model->x_offset_ta;
|
||||
}
|
||||
}
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
|
@ -3381,7 +3381,7 @@ ScanSession CommandSetGl646::calculate_scan_session(const Genesys_Device* dev,
|
|||
} else {
|
||||
start += dev->model->x_offset_ta;
|
||||
}
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
|
|
|
@ -1666,7 +1666,7 @@ ScanSession CommandSetGl841::calculate_scan_session(const Genesys_Device* dev,
|
|||
|
||||
float start = dev->model->x_offset;
|
||||
start += dev->settings.tl_x;
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * dev->settings.xres) / MM_PER_INCH);
|
||||
|
||||
// we enable true gray for cis scanners only, and just when doing
|
||||
// scan since color calibration is OK for this mode
|
||||
|
|
|
@ -1313,7 +1313,7 @@ ScanSession CommandSetGl843::calculate_scan_session(const Genesys_Device* dev,
|
|||
start /= sensor.get_ccd_size_divisor_for_dpi(settings.xres);
|
||||
}
|
||||
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
|
@ -2410,7 +2410,7 @@ void CommandSetGl843::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
|
|||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = num_pixels/2;
|
||||
session.params.startx = (num_pixels / 2) * resolution / calib_sensor.optical_res;
|
||||
session.params.starty = 0;
|
||||
session.params.pixels = num_pixels;
|
||||
session.params.lines = 1;
|
||||
|
|
|
@ -760,7 +760,7 @@ ScanSession CommandSetGl846::calculate_scan_session(const Genesys_Device* dev,
|
|||
/* start */
|
||||
start = static_cast<int>(dev->model->x_offset);
|
||||
start += static_cast<int>(settings.tl_x);
|
||||
start = static_cast<int>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<int>((start * settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
|
@ -1059,7 +1059,7 @@ void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
/* start */
|
||||
start = dev->model->x_offset;
|
||||
start = start + dev->settings.tl_x;
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * dev->settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
|
|
|
@ -762,7 +762,7 @@ ScanSession CommandSetGl847::calculate_scan_session(const Genesys_Device* dev,
|
|||
/* start */
|
||||
start = static_cast<int>(dev->model->x_offset);
|
||||
start = static_cast<int>(start + settings.tl_x);
|
||||
start = static_cast<int>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<int>((start * settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = settings.xres;
|
||||
|
@ -1061,7 +1061,7 @@ void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
/* start */
|
||||
start = dev->model->x_offset;
|
||||
start = start + dev->settings.tl_x;
|
||||
start = static_cast<float>((start * sensor.optical_res) / MM_PER_INCH);
|
||||
start = static_cast<float>((start * dev->settings.xres) / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = dev->settings.xres;
|
||||
|
|
|
@ -907,7 +907,7 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
|
|||
if (has_flag(s.params.flags, ScanFlag::USE_XCORRECTION) && sensor.ccd_start_xoffset > 0) {
|
||||
s.pixel_startx = sensor.ccd_start_xoffset;
|
||||
}
|
||||
s.pixel_startx += s.params.startx;
|
||||
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;
|
||||
|
@ -919,7 +919,9 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
|
|||
s.pixel_endx /= sensor.ccd_pixels_per_system_pixel() * s.ccd_size_divisor;
|
||||
|
||||
} else if (dev->model->asic_type == AsicType::GL841) {
|
||||
s.pixel_startx = ((sensor.ccd_start_xoffset + s.params.startx) * s.optical_resolution)
|
||||
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
|
||||
|
||||
s.pixel_startx = ((sensor.ccd_start_xoffset + startx) * s.optical_resolution)
|
||||
/ sensor.optical_res;
|
||||
|
||||
s.pixel_startx += sensor.dummy_pixel + 1;
|
||||
|
@ -944,8 +946,9 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
|
|||
s.pixel_endx = s.pixel_startx + s.optical_pixels;
|
||||
|
||||
} else if (dev->model->asic_type == AsicType::GL843) {
|
||||
unsigned startx = s.params.startx * sensor.optical_res / s.params.xres;
|
||||
|
||||
s.pixel_startx = (s.params.startx + sensor.dummy_pixel) / ccd_pixels_per_system_pixel;
|
||||
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 /= s.hwdpi_divisor;
|
||||
|
@ -973,7 +976,9 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
|
|||
dev->model->asic_type == AsicType::GL846 ||
|
||||
dev->model->asic_type == AsicType::GL847)
|
||||
{
|
||||
s.pixel_startx = s.params.startx;
|
||||
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;
|
||||
|
@ -986,7 +991,9 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s,
|
|||
s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel;
|
||||
|
||||
} else if (dev->model->asic_type == AsicType::GL124) {
|
||||
s.pixel_startx = s.params.startx;
|
||||
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;
|
||||
|
@ -1362,10 +1369,10 @@ void build_image_pipeline(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
|||
!has_flag(dev->model->flags, ModelFlag::NO_CALIBRATION) &&
|
||||
!has_flag(session.params.flags, ScanFlag::DISABLE_SHADING))
|
||||
{
|
||||
unsigned pixel_shift = session.params.startx * dev->calib_session.params.xres /
|
||||
sensor.optical_res;
|
||||
unsigned pixel_shift = session.params.startx;
|
||||
if (dev->model->model_id == ModelId::CANON_4400F) {
|
||||
pixel_shift = session.params.startx;
|
||||
pixel_shift =
|
||||
session.params.startx * sensor.optical_res / dev->calib_session.params.xres;
|
||||
}
|
||||
dev->pipeline.push_node<ImagePipelineNodeCalibrate>(dev->dark_average_data,
|
||||
dev->white_average_data,
|
||||
|
|
|
@ -116,7 +116,7 @@ struct SetupParams {
|
|||
unsigned xres = NOT_SET;
|
||||
// resolution in y direction
|
||||
unsigned yres = NOT_SET;
|
||||
// start pixel in X direction, from dummy_pixel + 1
|
||||
// start pixel in X direction, from dummy_pixel + 1. Counted in terms of xres.
|
||||
unsigned startx = NOT_SET;
|
||||
// start pixel in Y direction, counted according to base_ydpi
|
||||
unsigned starty = NOT_SET;
|
||||
|
|
Ładowanie…
Reference in New Issue