genesys: Remove uses of calib_lines

merge-requests/340/head
Povilas Kanapickas 2020-02-03 00:42:04 +02:00
rodzic 53d51a6537
commit 328f39e39e
9 zmienionych plików z 34 dodań i 43 usunięć

Wyświetl plik

@ -239,7 +239,6 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Device& dev)
<< static_cast<unsigned>(dev.control[4]) << ' '
<< static_cast<unsigned>(dev.control[5]) << '\n' << std::dec
<< " average_size: " << dev.average_size << '\n'
<< " calib_lines: " << dev.calib_lines << '\n'
<< " calib_total_bytes_to_read: " << dev.calib_total_bytes_to_read << '\n'
<< " calib_session: " << format_indent_braced_list(4, dev.calib_session) << '\n'
<< " gamma_override_tables[0].size(): " << dev.gamma_override_tables[0].size() << '\n'

Wyświetl plik

@ -269,8 +269,6 @@ struct Genesys_Device
std::uint8_t control[6] = {};
size_t average_size = 0;
// number of lines used during shading calibration
size_t calib_lines = 0;
// bytes to read from USB when calibrating. If 0, this is not set
size_t calib_total_bytes_to_read = 0;

Wyświetl plik

@ -1694,9 +1694,9 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_
if (dev->calib_total_bytes_to_read > 0) {
size = dev->calib_total_bytes_to_read;
} else if (dev->model->asic_type == AsicType::GL843) {
size = channels * 2 * pixels_per_line * dev->calib_lines;
size = channels * 2 * pixels_per_line * dev->calib_session.params.lines;
} else {
size = channels * 2 * pixels_per_line * (dev->calib_lines + 1);
size = channels * 2 * pixels_per_line * (dev->calib_session.params.lines + 1);
}
std::vector<uint16_t> calibration_data(size / 2);
@ -1757,13 +1757,13 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_
compute_array_percentile_approx(out_average_data.data() +
dev->calib_session.params.startx * channels,
calibration_data.data(),
dev->calib_lines, pixels_per_line * channels,
dev->calib_session.params.lines, pixels_per_line * channels,
0.5f);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file16((log_filename_prefix + "_shading.pnm").c_str(),
calibration_data.data(),
channels, pixels_per_line, dev->calib_lines);
channels, pixels_per_line, dev->calib_session.params.lines);
sanei_genesys_write_pnm_file16((log_filename_prefix + "_average.pnm").c_str(),
out_average_data.data(),
channels, out_pixels_per_line, 1);
@ -1900,7 +1900,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
const Genesys_Sensor& sensor,
Genesys_Register_Set& local_reg)
{
DBG_HELPER_ARGS(dbg, "lines = %zu", dev->calib_lines);
DBG_HELPER(dbg);
// FIXME: remove when updating tests
dev->interface->record_progress_message("init_regs_for_shading");
@ -1941,10 +1941,11 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
dev->dark_average_data.clear();
dev->dark_average_data.resize(dev->average_size);
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;
if (dev->calib_total_bytes_to_read > 0) {
size = dev->calib_total_bytes_to_read;
} else {
size = channels * 2 * pixels_per_line * dev->calib_session.params.lines;
}
std::vector<uint8_t> calibration_data(size);
@ -1977,13 +1978,13 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
{
sanei_genesys_write_pnm_file("gl_black_white_shading.pnm", calibration_data.data(),
16, 1, pixels_per_line*channels,
dev->calib_lines);
dev->calib_session.params.lines);
}
else
{
sanei_genesys_write_pnm_file("gl_black_white_shading.pnm", calibration_data.data(),
16, channels, pixels_per_line,
dev->calib_lines);
dev->calib_session.params.lines);
}
}
@ -2003,7 +2004,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
dark = 0xffff;
white = 0;
for (std::size_t y = 0; y < dev->calib_lines; y++)
for (std::size_t y = 0; y < dev->calib_session.params.lines; y++)
{
col = calibration_data[(x + y * pixels_per_line * channels) * 2];
col |=
@ -2027,7 +2028,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
white_count = 0;
white_sum = 0;
for (std::size_t y = 0; y < dev->calib_lines; y++)
for (std::size_t y = 0; y < dev->calib_session.params.lines; y++)
{
col = calibration_data[(x + y * pixels_per_line * channels) * 2];
col |=

Wyświetl plik

@ -1179,18 +1179,18 @@ void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
int move, resolution, dpihw, factor;
unsigned channels = 3;
dev->calib_lines = dev->model->shading_lines;
unsigned calib_lines = dev->model->shading_lines;
dpihw = sensor.get_register_hwdpi(dev->settings.xres);
if(dpihw>=2400)
{
dev->calib_lines *= 2;
calib_lines *= 2;
}
resolution=dpihw;
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
resolution /= ccd_size_divisor;
dev->calib_lines /= ccd_size_divisor; // reducing just because we reduced the resolution
calib_lines /= ccd_size_divisor; // reducing just because we reduced the resolution
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
dev->settings.scan_method);
@ -1211,7 +1211,7 @@ void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
session.params.startx = 0;
session.params.starty = move;
session.params.pixels = calib_sensor.sensor_pixels / factor;
session.params.lines = dev->calib_lines;
session.params.lines = calib_lines;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;

Wyświetl plik

@ -1695,8 +1695,8 @@ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
settings.tl_y = 0;
settings.pixels = (calib_sensor.sensor_pixels * settings.xres) / calib_sensor.optical_res;
settings.requested_pixels = settings.pixels;
dev->calib_lines = dev->model->shading_lines;
settings.lines = dev->calib_lines;
unsigned calib_lines = dev->model->shading_lines;
settings.lines = calib_lines;
settings.depth = 16;
settings.color_filter = dev->settings.color_filter;
@ -1718,9 +1718,9 @@ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
/* TODO another flag to setup regs ? */
/* enforce needed LINCNT, getting rid of extra lines for color reordering */
if (!dev->model->is_cis) {
dev->reg.set24(REG_LINCNT, dev->calib_lines);
dev->reg.set24(REG_LINCNT, calib_lines);
} else {
dev->reg.set24(REG_LINCNT, dev->calib_lines * 3);
dev->reg.set24(REG_LINCNT, calib_lines * 3);
}
DBG(DBG_info, "%s:\n\tdev->settings.xres=%d\n\tdev->settings.yres=%d\n", __func__,

Wyświetl plik

@ -2431,7 +2431,7 @@ void CommandSetGl841::init_regs_for_coarse_calibration(Genesys_Device* dev,
void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const
{
DBG_HELPER_ARGS(dbg, "lines = %zu", dev->calib_lines);
DBG_HELPER(dbg);
SANE_Int ydpi;
unsigned starty = 0;
@ -2456,7 +2456,6 @@ void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
}
unsigned channels = 3;
dev->calib_lines = dev->model->shading_lines;
unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres);
unsigned factor = sensor.optical_res / resolution;
@ -2470,7 +2469,7 @@ void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
session.params.startx = 0;
session.params.starty = starty;
session.params.pixels = calib_sensor.sensor_pixels / factor;
session.params.lines = dev->calib_lines;
session.params.lines = dev->model->shading_lines;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;

Wyświetl plik

@ -1698,13 +1698,13 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
DBG_HELPER(dbg);
int move, resolution, dpihw, factor;
unsigned calib_lines = 0;
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED)
{
dev->calib_lines = dev->model->shading_ta_lines;
calib_lines = dev->model->shading_ta_lines;
} else {
dev->calib_lines = dev->model->shading_lines;
calib_lines = dev->model->shading_lines;
}
dpihw = sensor.get_logical_hwdpi(dev->settings.xres);
@ -1758,7 +1758,7 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
session.params.startx = calib_pixels_offset;
session.params.starty = move;
session.params.pixels = calib_pixels;
session.params.lines = dev->calib_lines;
session.params.lines = calib_lines;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;

Wyświetl plik

@ -964,16 +964,13 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
dev->settings.scan_method);
dev->calib_total_bytes_to_read = 0;
dev->calib_lines = dev->model->shading_lines;
unsigned calib_lines = dev->model->shading_lines;
if (resolution == 4800) {
dev->calib_lines *= 2;
calib_lines *= 2;
}
unsigned calib_pixels = (calib_sensor.sensor_pixels * resolution) /
calib_sensor.optical_res;
DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines);
DBG(DBG_io, "%s: calib_pixels = %u\n", __func__, calib_pixels);
/* this is aworkaround insufficent distance for slope
* motor acceleration TODO special motor slope for shading */
move=1;
@ -987,7 +984,7 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
session.params.startx = 0;
session.params.starty = static_cast<unsigned>(move);
session.params.pixels = calib_pixels;
session.params.lines = dev->calib_lines;
session.params.lines = calib_lines;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;

Wyświetl plik

@ -973,23 +973,20 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
dev->settings.scan_method);
dev->calib_total_bytes_to_read = 0;
dev->calib_lines = dev->model->shading_lines;
unsigned calib_lines = dev->model->shading_lines;
if (resolution == 4800) {
dev->calib_lines *= 2;
calib_lines *= 2;
}
unsigned calib_pixels = (calib_sensor.sensor_pixels * resolution) /
calib_sensor.optical_res;
DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines);
DBG(DBG_io, "%s: calib_pixels = %u\n", __func__, calib_pixels);
ScanSession session;
session.params.xres = resolution;
session.params.yres = dev->motor.base_ydpi;
session.params.startx = 0;
session.params.starty = 20;
session.params.pixels = calib_pixels;
session.params.lines = dev->calib_lines;
session.params.lines = calib_lines;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;