genesys: Simplify setup of session depth parameter

merge-requests/212/head
Povilas Kanapickas 2019-10-01 18:11:47 +03:00
rodzic 9581f29f13
commit 158cc81e20
5 zmienionych plików z 94 dodań i 123 usunięć

Wyświetl plik

@ -1922,7 +1922,7 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
int dpihw;
int i, j;
int val;
int channels, depth;
int channels;
int avg[3];
int turn;
uint16_t exp[3],target;
@ -1932,7 +1932,6 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
/* offset calibration is always done in 16 bit depth color mode */
channels = 3;
depth=16;
dpihw = sensor.get_register_hwdpi(dev->settings.xres);
resolution = dpihw;
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
@ -1952,7 +1951,7 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -1965,7 +1964,7 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
gl124_init_scan_regs(dev, sensor, &regs, session);
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
total_size = num_pixels * channels * (session.params.depth / 8) * 1;
std::vector<uint8_t> line(total_size);
// initial loop values and boundaries
@ -2000,7 +1999,8 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
{
char fn[30];
snprintf(fn, 30, "gl124_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line.data(), depth, channels, num_pixels, 1);
sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth, channels, num_pixels,
1);
}
/* compute average */
@ -2093,7 +2093,7 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
unsigned channels;
int pass = 0, avg, total_size;
int topavg, bottomavg, lines;
int top, bottom, black_pixels, pixels;
@ -2109,7 +2109,6 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
channels = 3;
dev->calib_pixels = sensor.sensor_pixels;
lines=1;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
@ -2121,7 +2120,7 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2137,7 +2136,7 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
sanei_genesys_set_motor_power(regs, false);
/* allocate memory for scans */
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
total_size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> first_line(total_size);
std::vector<uint8_t> second_line(total_size);
@ -2162,7 +2161,8 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char title[30];
snprintf(title, 30, "gl124_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(title, first_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, first_line.data(), session.params.depth,
channels, pixels, lines);
}
bottomavg = dark_average(first_line.data(), pixels, lines, channels, black_pixels);
@ -2203,7 +2203,8 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char title[30];
snprintf(title, 30, "gl124_offset%03d.pnm", dev->frontend.get_offset(1));
sanei_genesys_write_pnm_file(title, second_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, second_line.data(), session.params.depth,
channels, pixels, lines);
}
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
@ -2247,7 +2248,6 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
int max[3];
float gain[3],coeff;
int val, code, lines;
int bpp;
// no gain nor offset for TI AFE
uint8_t reg0a = dev->read_register(REG0A);
@ -2266,7 +2266,6 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
coeff=1.0;
}
lines=10;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
ScanSession session;
@ -2276,7 +2275,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2298,7 +2297,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
dev->write_registers(regs);
total_size = pixels * channels * (16/bpp) * lines;
total_size = pixels * channels * (16 / session.params.depth) * lines;
std::vector<uint8_t> line(total_size);
@ -2306,8 +2305,10 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
begin_scan(dev, sensor, &regs, true);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl124_gain.pnm", line.data(), bpp, channels, pixels, lines);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl124_gain.pnm", line.data(), session.params.depth,
channels, pixels, lines);
}
/* average value on each channel */
for (j = 0; j < channels; j++)
@ -2315,23 +2316,10 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
max[j] = 0;
for (i = pixels/4; i < (pixels*3/4); i++)
{
if(bpp==16)
{
if (dev->model->is_cis)
val =
line[i * 2 + j * 2 * pixels + 1] * 256 +
line[i * 2 + j * 2 * pixels];
else
val =
line[i * 2 * channels + 2 * j + 1] * 256 +
line[i * 2 * channels + 2 * j];
}
else
{
if (dev->model->is_cis)
val = line[i + j * pixels];
else
val = line[i * channels + j];
if (dev->model->is_cis) {
val = line[i + j * pixels];
} else {
val = line[i * channels + j];
}
max[j] += val;

Wyświetl plik

@ -3952,7 +3952,6 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
size_t size;
int depth;
unsigned int pass, count, found, x, y, length;
char title[80];
GenesysRegister *r;
@ -3980,10 +3979,7 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; */
lines = (10*dpi)/MM_PER_INCH;
depth = 8;
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
size = pixels * channels * lines * (depth / 8);
std::vector<uint8_t> data(size);
/* 20 cm max length for calibration sheet */
length = ((200 * dpi) / MM_PER_INCH)/lines;
@ -3999,7 +3995,7 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
@ -4007,6 +4003,9 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA;
gl841_compute_session(dev, session, sensor);
size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> data(size);
gl841_init_scan_regs(dev, sensor, &local_reg, session);
/* set up for reverse or forward */
@ -4034,7 +4033,8 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
sprintf(title, "gl841_search_strip_%s_%s%02u.pnm", black ? "black" : "white",
forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
@ -4058,7 +4058,8 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
sprintf(title, "gl841_search_strip_%s_%s%02u.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* search data to find black strip */

Wyświetl plik

@ -2452,14 +2452,12 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
{
DBG_HELPER(dbg);
int num_pixels;
int depth;
int avg[3], avga, avge;
int turn;
uint16_t expr, expg, expb;
// offset calibration is always done in color mode
unsigned channels = 3;
depth = 16;
// take a copy, as we're going to modify exposure
auto calib_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res, channels,
@ -2477,7 +2475,7 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2640,7 +2638,7 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
if (dev->frontend.layout.type != FrontendType::WOLFSON)
return;
unsigned int channels, bpp;
unsigned channels;
int pass, resolution, lines;
int topavg[3], bottomavg[3], avg[3];
int top[3], bottom[3], black_pixels, pixels, factor, dpihw;
@ -2648,7 +2646,6 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
/* offset calibration is always done in color mode */
channels = 3;
lines = 8;
bpp = 8;
// compute divider factor to compute final pixels number
dpihw = sensor.get_logical_hwdpi(dev->settings.xres);
@ -2694,7 +2691,7 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = target_pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2832,7 +2829,8 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
reinterpret_cast<const std::uint8_t*>(debug_image_info.data()),
debug_image_info.size());
sanei_genesys_write_pnm_file("gl843_offset_all.pnm",
debug_image.data(), bpp, channels, pixels, debug_image_lines);
debug_image.data(), session.params.depth, channels, pixels,
debug_image_lines);
}
DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__,
@ -2859,7 +2857,6 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
float coeff;
int lines;
int resolution;
int bpp;
if (dev->frontend.layout.type != FrontendType::WOLFSON)
return;
@ -2887,7 +2884,6 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
}
resolution=dpihw;
lines=10;
bpp=8;
int target_pixels = sensor.sensor_pixels / factor;
int flags = SCAN_FLAG_DISABLE_SHADING |
@ -2911,7 +2907,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = target_pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2954,9 +2950,6 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
// in transparency scans for example
std::sort(values.begin(), values.end());
uint16_t curr_output = values[unsigned((values.size() - 1) * 0.95)];
if (bpp == 16) {
curr_output /= 256;
}
float target_value = calib_sensor.gain_white_ref * coeff;
int code = compute_frontend_gain(curr_output, target_value, dev->frontend.layout.type);
@ -3233,7 +3226,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse");
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
int depth, dpi;
int dpi;
unsigned int pass, count, found, x, y;
GenesysRegister *r;
@ -3251,7 +3244,6 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (10 * dpi) / MM_PER_INCH; */
/* shading calibation is done with dev->motor.base_ydpi */
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
depth = 8;
pixels = (calib_sensor.sensor_pixels * dpi) / calib_sensor.optical_res;
dev->scanhead_position_in_steps = 0;
@ -3265,7 +3257,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;

Wyświetl plik

@ -1589,7 +1589,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
int used_res;
int i, j;
int val;
int channels, depth;
int channels;
int avg[3], top[3], bottom[3];
int turn;
uint16_t exp[3];
@ -1605,7 +1605,6 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
/* offset calibration is always done in color mode */
channels = 3;
depth=16;
used_res = sensor.get_register_hwdpi(dev->settings.xres);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, used_res, 1);
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
@ -1620,7 +1619,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -1633,7 +1632,7 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
gl846_init_scan_regs(dev, sensor, &regs, session);
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
total_size = num_pixels * channels * (session.params.depth / 8) * 1;
std::vector<uint8_t> line(total_size);
/* initial loop values and boundaries */
@ -1675,7 +1674,8 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
{
char fn[30];
snprintf(fn, 30, "gl846_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line.data(), depth, channels, num_pixels, 1);
sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth,
channels, num_pixels, 1);
}
/* compute average */
@ -1916,7 +1916,6 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
size_t size;
int depth;
unsigned int pass, count, found, x, y;
char title[80];
GenesysRegister *r;
@ -1933,10 +1932,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (10 * dpi) / MM_PER_INCH; */
/* shading calibation is done with dev->motor.base_ydpi */
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
depth = 8;
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
size = pixels * channels * lines * (depth / 8);
std::vector<uint8_t> data(size);
dev->scanhead_position_in_steps = 0;
@ -1949,7 +1945,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::RED;
@ -1959,6 +1955,9 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
gl846_init_scan_regs(dev, sensor, &local_reg, session);
size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> data(size);
/* set up for reverse or forward */
r = sanei_genesys_get_address (&local_reg, REG02);
if (forward) {
@ -1983,7 +1982,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
@ -2006,7 +2006,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* search data to find black strip */
@ -2138,7 +2139,7 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
unsigned channels;
int pass = 0, avg, total_size;
int topavg, bottomavg, lines;
int top, bottom, black_pixels, pixels;
@ -2154,7 +2155,6 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
channels = 3;
dev->calib_pixels = sensor.sensor_pixels;
lines=1;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
@ -2166,7 +2166,7 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2181,8 +2181,7 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
sanei_genesys_set_motor_power(regs, false);
/* allocate memory for scans */
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
total_size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> first_line(total_size);
std::vector<uint8_t> second_line(total_size);
@ -2207,7 +2206,8 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl846_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(fn, first_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, first_line.data(), session.params.depth,
channels, pixels, lines);
}
bottomavg = dark_average(first_line.data(), pixels, lines, channels, black_pixels);
@ -2248,7 +2248,8 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl846_offset%03d.pnm", dev->frontend.get_offset(1));
sanei_genesys_write_pnm_file(fn, second_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, second_line.data(), session.params.depth,
channels, pixels, lines);
}
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
@ -2282,7 +2283,6 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
int max[3];
float gain[3],coeff;
int val, code, lines;
int bpp;
DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi);
@ -2306,7 +2306,6 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
coeff=1.0;
}
lines=10;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
ScanSession session;
@ -2316,7 +2315,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2338,7 +2337,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
dev->write_registers(regs);
total_size = pixels * channels * (16/bpp) * lines;
total_size = pixels * channels * (16 / session.params.depth) * lines;
std::vector<uint8_t> line(total_size);
@ -2346,8 +2345,10 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
begin_scan(dev, sensor, &regs, true);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl846_gain.pnm", line.data(), bpp, channels, pixels, lines);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl846_gain.pnm", line.data(), session.params.depth,
channels, pixels, lines);
}
/* average value on each channel */
for (j = 0; j < channels; j++)

Wyświetl plik

@ -1628,7 +1628,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
int used_res;
int i, j;
int val;
int channels, depth;
int channels;
int avg[3], top[3], bottom[3];
int turn;
uint16_t exp[3];
@ -1644,7 +1644,6 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
/* offset calibration is always done in color mode */
channels = 3;
depth=16;
used_res = sensor.get_register_hwdpi(dev->settings.xres);
const auto& sensor_profile = get_sensor_profile(dev->model->asic_type, sensor, used_res, 1);
num_pixels = (sensor.sensor_pixels*used_res)/sensor.optical_res;
@ -1659,7 +1658,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
session.params.starty = 0;
session.params.pixels = num_pixels;
session.params.lines = 1;
session.params.depth = depth;
session.params.depth = 16;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -1672,7 +1671,7 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
gl847_init_scan_regs(dev, sensor, &regs, session);
total_size = num_pixels * channels * (depth/8) * 1; /* colors * bytes_per_color * scan lines */
total_size = num_pixels * channels * (session.params.depth/8) * 1;
std::vector<uint8_t> line(total_size);
// initial loop values and boundaries
@ -1714,7 +1713,8 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
{
char fn[30];
snprintf(fn, 30, "gl847_led_%02d.pnm", turn);
sanei_genesys_write_pnm_file(fn, line.data(), depth, channels, num_pixels, 1);
sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth,
channels, num_pixels, 1);
}
/* compute average */
@ -1992,7 +1992,6 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
unsigned int pixels, lines, channels;
Genesys_Register_Set local_reg;
size_t size;
int depth;
unsigned int pass, count, found, x, y;
char title[80];
GenesysRegister *r;
@ -2008,10 +2007,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
/* lines = (10 * dpi) / MM_PER_INCH; */
/* shading calibation is done with dev->motor.base_ydpi */
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
depth = 8;
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
size = pixels * channels * lines * (depth / 8);
std::vector<uint8_t> data(size);
dev->scanhead_position_in_steps = 0;
local_reg = dev->reg;
@ -2023,7 +2019,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = depth;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
@ -2032,6 +2028,9 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
SCAN_FLAG_DISABLE_GAMMA;
gl847_compute_session(dev, session, sensor);
size = pixels * channels * lines * (session.params.depth / 8);
std::vector<uint8_t> data(size);
gl847_init_scan_regs(dev, sensor, &local_reg, session);
/* set up for reverse or forward */
@ -2058,7 +2057,8 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
std::sprintf(title, "gl847_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* loop until strip is found or maximum pass number done */
@ -2081,7 +2081,8 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
{
sprintf(title, "gl847_search_strip_%s_%s%02d.pnm",
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
sanei_genesys_write_pnm_file(title, data.data(), session.params.depth,
channels, pixels, lines);
}
/* search data to find black strip */
@ -2213,7 +2214,7 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
Genesys_Register_Set& regs) const
{
DBG_HELPER(dbg);
unsigned int channels, bpp;
unsigned channels;
int pass = 0, avg, total_size;
int topavg, bottomavg, lines;
int top, bottom, black_pixels, pixels;
@ -2229,7 +2230,6 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
channels = 3;
dev->calib_pixels = sensor.sensor_pixels;
lines=1;
bpp=8;
pixels= (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res;
DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels);
@ -2241,7 +2241,7 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2257,7 +2257,7 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
sanei_genesys_set_motor_power(regs, false);
/* allocate memory for scans */
total_size = pixels * channels * lines * (bpp/8); /* colors * bytes_per_color * scan lines */
total_size = pixels * channels * lines * (session.params.depth / 8); /* colors * bytes_per_color * scan lines */
std::vector<uint8_t> first_line(total_size);
std::vector<uint8_t> second_line(total_size);
@ -2282,7 +2282,8 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl847_offset%03d.pnm", bottom);
sanei_genesys_write_pnm_file(fn, first_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, first_line.data(), session.params.depth,
channels, pixels, lines);
}
bottomavg = dark_average (first_line.data(), pixels, lines, channels, black_pixels);
@ -2323,7 +2324,8 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
{
char fn[30];
snprintf(fn, 30, "gl847_offset%03d.pnm", dev->frontend.get_offset(1));
sanei_genesys_write_pnm_file(fn, second_line.data(), bpp, channels, pixels, lines);
sanei_genesys_write_pnm_file(fn, second_line.data(), session.params.depth,
channels, pixels, lines);
}
avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels);
@ -2357,7 +2359,6 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
int max[3];
float gain[3],coeff;
int val, code, lines;
int bpp;
// no gain nor offset for AKM AFE
uint8_t reg04 = dev->read_register(REG04);
@ -2379,7 +2380,6 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
coeff=1.0;
}
lines=10;
bpp=8;
pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res;
ScanSession session;
@ -2389,7 +2389,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
session.params.starty = 0;
session.params.pixels = pixels;
session.params.lines = lines;
session.params.depth = bpp;
session.params.depth = 8;
session.params.channels = channels;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
@ -2411,7 +2411,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
dev->write_registers(regs);
total_size = pixels * channels * (16/bpp) * lines;
total_size = pixels * channels * (16 / session.params.depth) * lines;
std::vector<uint8_t> line(total_size);
@ -2419,8 +2419,10 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
begin_scan(dev, sensor, &regs, true);
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl847_gain.pnm", line.data(), bpp, channels, pixels, lines);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl847_gain.pnm", line.data(), session.params.depth,
channels, pixels, lines);
}
/* average value on each channel */
for (j = 0; j < channels; j++)
@ -2428,23 +2430,10 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
max[j] = 0;
for (i = pixels/4; i < (pixels*3/4); i++)
{
if(bpp==16)
{
if (dev->model->is_cis)
val =
line[i * 2 + j * 2 * pixels + 1] * 256 +
line[i * 2 + j * 2 * pixels];
else
val =
line[i * 2 * channels + 2 * j + 1] * 256 +
line[i * 2 * channels + 2 * j];
}
else
{
if (dev->model->is_cis)
val = line[i + j * pixels];
else
val = line[i * channels + j];
if (dev->model->is_cis) {
val = line[i + j * pixels];
} else {
val = line[i * channels + j];
}
max[j] += val;