kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Deduplicate pixel count computation during calibration
rodzic
695addaafd
commit
df889c96f5
|
@ -1715,7 +1715,9 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
|
|||
|
||||
// FIXME: the current calculation is likely incorrect on non-GENESYS_GL843 implementations,
|
||||
// but this needs checking
|
||||
if (dev->model->asic_type == GENESYS_GL843) {
|
||||
if (dev->calib_total_bytes_to_read > 0) {
|
||||
size = dev->calib_total_bytes_to_read;
|
||||
} else if (dev->model->asic_type == GENESYS_GL843) {
|
||||
size = channels * 2 * pixels_per_line * dev->calib_lines;
|
||||
} else {
|
||||
size = channels * 2 * pixels_per_line * (dev->calib_lines + 1);
|
||||
|
@ -1904,7 +1906,9 @@ genesys_white_shading_calibration (Genesys_Device * dev)
|
|||
|
||||
// FIXME: the current calculation is likely incorrect on non-GENESYS_GL843 implementations,
|
||||
// but this needs checking
|
||||
if (dev->model->asic_type == GENESYS_GL843) {
|
||||
if (dev->calib_total_bytes_to_read > 0) {
|
||||
size = dev->calib_total_bytes_to_read;
|
||||
} else if (dev->model->asic_type == GENESYS_GL843) {
|
||||
size = channels * 2 * pixels_per_line * dev->calib_lines;
|
||||
} else {
|
||||
size = channels * 2 * pixels_per_line * (dev->calib_lines + 1);
|
||||
|
@ -2032,7 +2036,10 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
|
|||
dev->dark_average_data.clear();
|
||||
dev->dark_average_data.resize(channels * 2 * pixels_per_line);
|
||||
|
||||
size = channels * 2 * pixels_per_line * dev->calib_lines;
|
||||
if (dev->calib_total_bytes_to_read > 0)
|
||||
size = dev->calib_total_bytes_to_read;
|
||||
else
|
||||
size = channels * 2 * pixels_per_line * dev->calib_lines;
|
||||
|
||||
std::vector<uint8_t> calibration_data(size);
|
||||
|
||||
|
|
|
@ -2488,6 +2488,7 @@ gl124_init_regs_for_shading (Genesys_Device * dev)
|
|||
dev->calib_lines /= 2;
|
||||
}
|
||||
dev->calib_resolution = resolution;
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
factor=dev->sensor.optical_res/resolution;
|
||||
dev->calib_pixels = dev->sensor.sensor_pixels/factor;
|
||||
|
||||
|
|
|
@ -2593,7 +2593,7 @@ gl843_search_start_position (Genesys_Device * dev)
|
|||
return status;
|
||||
}
|
||||
|
||||
size = pixels * dev->model->search_lines;
|
||||
size = dev->read_bytes_left;
|
||||
|
||||
std::vector<uint8_t> data(size);
|
||||
|
||||
|
@ -2827,6 +2827,8 @@ gl843_init_regs_for_shading (Genesys_Device * dev)
|
|||
return status;
|
||||
}
|
||||
|
||||
dev->calib_total_bytes_to_read = dev->read_bytes_left;
|
||||
|
||||
dev->scanhead_position_in_steps += dev->calib_lines + move;
|
||||
sanei_genesys_get_double(dev->calib_reg,REG_STRPIXEL,&strpixel);
|
||||
DBG(DBG_info, "%s: STRPIXEL=%d\n", __func__, strpixel);
|
||||
|
@ -3032,7 +3034,7 @@ gl843_led_calibration (Genesys_Device * dev)
|
|||
(dev, dev->calib_reg, GENESYS_GL843_MAX_REGS));
|
||||
|
||||
|
||||
total_size = num_pixels * channels * (depth / 8) * 1; /* colors * bytes_per_color * scan lines */
|
||||
total_size = dev->read_bytes_left;
|
||||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
|
@ -3224,6 +3226,7 @@ gl843_offset_calibration (Genesys_Device * dev)
|
|||
DBG(DBG_io, "%s: pixels =%d\n", __func__, pixels);
|
||||
DBG(DBG_io, "%s: black_pixels=%d\n", __func__, black_pixels);
|
||||
|
||||
|
||||
status = gl843_init_scan_regs (dev,
|
||||
dev->calib_reg,
|
||||
resolution,
|
||||
|
@ -3248,7 +3251,7 @@ gl843_offset_calibration (Genesys_Device * dev)
|
|||
gl843_set_motor_power (dev->calib_reg, SANE_FALSE);
|
||||
|
||||
/* allocate memory for scans */
|
||||
total_size = pixels * channels * lines * (bpp / 8); /* colors * bytes_per_color * scan lines */
|
||||
total_size = dev->read_bytes_left;
|
||||
|
||||
std::vector<uint8_t> first_line(total_size);
|
||||
std::vector<uint8_t> second_line(total_size);
|
||||
|
@ -3456,7 +3459,7 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, int dpi)
|
|||
RIE (dev->model->cmd_set->bulk_write_register
|
||||
(dev, dev->calib_reg, GENESYS_GL843_MAX_REGS));
|
||||
|
||||
total_size = pixels * channels * (bpp/8) * lines;
|
||||
total_size = dev->read_bytes_left;
|
||||
|
||||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
|
@ -3832,8 +3835,6 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
|
|||
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
|
||||
depth = 8;
|
||||
pixels = (dev->sensor.sensor_pixels * dpi) / dev->sensor.optical_res;
|
||||
size = pixels * channels * lines * (depth / 8);
|
||||
std::vector<uint8_t> data(size);
|
||||
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
|
||||
|
@ -3860,6 +3861,9 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
|
|||
return status;
|
||||
}
|
||||
|
||||
size = dev->read_bytes_left;
|
||||
std::vector<uint8_t> data(size);
|
||||
|
||||
/* set up for reverse or forward */
|
||||
r = sanei_genesys_get_address (local_reg, REG02);
|
||||
if (forward)
|
||||
|
|
|
@ -2114,6 +2114,7 @@ gl846_init_regs_for_shading (Genesys_Device * dev)
|
|||
memcpy (dev->calib_reg, dev->reg, GENESYS_GL846_MAX_REGS * sizeof (Genesys_Register_Set));
|
||||
|
||||
dev->calib_resolution = sanei_genesys_compute_dpihw(dev,dev->settings.xres);
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
if(dev->calib_resolution==4800)
|
||||
dev->calib_lines *= 2;
|
||||
|
|
|
@ -2178,6 +2178,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev)
|
|||
memcpy (dev->calib_reg, dev->reg, GENESYS_GL847_MAX_REGS * sizeof (Genesys_Register_Set));
|
||||
|
||||
dev->calib_resolution = sanei_genesys_compute_dpihw(dev,dev->settings.xres);
|
||||
dev->calib_total_bytes_to_read = 0;
|
||||
dev->calib_lines = dev->model->shading_lines;
|
||||
if(dev->calib_resolution==4800)
|
||||
dev->calib_lines *= 2;
|
||||
|
|
|
@ -934,6 +934,8 @@ struct Genesys_Device
|
|||
size_t calib_lines = 0;
|
||||
size_t calib_channels = 0;
|
||||
size_t calib_resolution = 0;
|
||||
// bytes to read from USB when calibrating. If 0, this is not set
|
||||
size_t calib_total_bytes_to_read = 0;
|
||||
|
||||
std::vector<uint8_t> white_average_data;
|
||||
std::vector<uint8_t> dark_average_data;
|
||||
|
|
Ładowanie…
Reference in New Issue