kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'genesys-session-line-sizes' into 'master'
genesys: Use common code path to compute session line sizes See merge request sane-project/backends!159merge-requests/160/merge
commit
f44c0bb680
|
@ -1066,7 +1066,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
session.assert_computed();
|
||||
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int mflags;
|
||||
int exposure_time;
|
||||
|
@ -1145,18 +1144,13 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = session.output_pixels;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
/* since we don't have sheetfed scanners to handle,
|
||||
* use huge read buffer */
|
||||
/* TODO find the best size according to settings */
|
||||
requested_buffer_size = 16 * bytes_per_line;
|
||||
requested_buffer_size = 16 * session.output_line_bytes;
|
||||
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels *
|
||||
session.params.channels * session.params.depth) / 8;
|
||||
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1170,7 +1164,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
||||
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
@ -1185,14 +1179,10 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->current_setup.stagger = session.num_staggered_lines;
|
||||
dev->current_setup.max_shift = session.max_color_shift_lines + session.num_staggered_lines;
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines *
|
||||
session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read =
|
||||
multiply_by_depth_ceil(session.params.get_requested_pixels() * session.params.lines,
|
||||
session.params.depth) * session.params.channels;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send to frontend = %lu\n", __func__,
|
||||
(u_long) dev->total_bytes_to_read);
|
||||
|
|
|
@ -357,11 +357,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
int i, nb;
|
||||
Motor_Master *motor = NULL;
|
||||
unsigned int used1, used2, vfinal;
|
||||
unsigned int bpp; /**> bytes per pixel */
|
||||
uint32_t z1, z2;
|
||||
uint16_t ex, sx;
|
||||
int words_per_line;
|
||||
size_t requested_buffer_size;
|
||||
size_t read_buffer_size;
|
||||
int feedl;
|
||||
|
||||
|
@ -567,24 +564,10 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
DBG(DBG_info, "%s: startx=%d, endx=%d, ccd_size_divisor=%d\n", __func__, sx, ex,
|
||||
session.ccd_size_divisor);
|
||||
|
||||
/* words_per_line must be computed according to the scan's resolution */
|
||||
/* in fact, words_per_line _gives_ the actual scan resolution */
|
||||
words_per_line = session.output_pixels;
|
||||
bpp = session.params.depth/8;
|
||||
if (session.params.depth == 1) {
|
||||
words_per_line = (words_per_line+7)/8 ;
|
||||
bpp=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
words_per_line *= bpp;
|
||||
}
|
||||
dev->bpl = words_per_line;
|
||||
words_per_line *= session.params.channels;
|
||||
dev->wpl = words_per_line;
|
||||
dev->bpl = session.output_line_channel_bytes;
|
||||
dev->wpl = session.output_line_bytes;
|
||||
|
||||
DBG(DBG_info, "%s: wpl=%d\n", __func__, words_per_line);
|
||||
regs->set24(REG_MAXWD, words_per_line);
|
||||
regs->set24(REG_MAXWD, session.output_line_bytes);
|
||||
|
||||
regs->set16(REG_DPISET, session.output_resolution * session.ccd_size_divisor *
|
||||
sensor.ccd_pixels_per_system_pixel());
|
||||
|
@ -739,9 +722,8 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
/* now we're done with registers setup values used by data transfer */
|
||||
/* we setup values needed for the data transfer */
|
||||
|
||||
/* we must use a round number of words_per_line */
|
||||
requested_buffer_size = 8 * words_per_line;
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
// we must use a round number of words_per_line
|
||||
read_buffer_size = 16 * session.output_line_bytes +
|
||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.params.pixels *
|
||||
session.params.channels * session.params.depth) / 8;
|
||||
|
||||
|
@ -752,15 +734,15 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
dev->lines_buffer.alloc(read_buffer_size);
|
||||
|
||||
dev->shrink_buffer.clear();
|
||||
dev->shrink_buffer.alloc(requested_buffer_size);
|
||||
dev->shrink_buffer.alloc(8 * session.output_line_bytes);
|
||||
|
||||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc(8 * session.params.pixels * session.params.channels * bpp);
|
||||
dev->out_buffer.alloc(8 * session.output_line_bytes);
|
||||
|
||||
/* scan bytes to read */
|
||||
unsigned cis_channel_multiplier = dev->model->is_cis ? session.params.channels : 1;
|
||||
|
||||
dev->read_bytes_left = words_per_line * session.output_line_count * cis_channel_multiplier;
|
||||
dev->read_bytes_left = session.output_line_bytes * session.output_line_count * cis_channel_multiplier;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
@ -774,17 +756,10 @@ static void gl646_setup_registers(Genesys_Device* dev,
|
|||
dev->current_setup.stagger = session.num_staggered_lines;
|
||||
dev->current_setup.max_shift = session.max_color_shift_lines + session.num_staggered_lines;
|
||||
|
||||
/* total_bytes_to_read is the number of byte to send to frontend
|
||||
* total_bytes_read is the number of bytes sent to frontend
|
||||
* read_bytes_left is the number of bytes to read from the scanner
|
||||
*/
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.requested_pixels * session.params.lines) / 8 +
|
||||
(((session.params.requested_pixels * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.requested_pixels * session.params.lines * session.params.channels * bpp;
|
||||
}
|
||||
dev->total_bytes_to_read =
|
||||
multiply_by_depth_ceil(session.params.get_requested_pixels() * session.params.lines,
|
||||
session.params.depth) * session.params.channels;
|
||||
|
||||
/* select color filter based on settings */
|
||||
regs->find_reg(0x04).value &= ~REG04_FILTER;
|
||||
|
|
|
@ -1763,7 +1763,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
session.assert_computed();
|
||||
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
int exposure_time;
|
||||
int avg;
|
||||
|
@ -1920,19 +1919,14 @@ dummy \ scanned lines
|
|||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = session.output_pixels;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
/* we must use a round number of bytes_per_line */
|
||||
requested_buffer_size = 8 * session.output_line_bytes;
|
||||
// we must use a multiple of session.output_line_bytes
|
||||
if (requested_buffer_size > sanei_genesys_get_bulk_max_size(dev)) {
|
||||
requested_buffer_size = (sanei_genesys_get_bulk_max_size(dev) / bytes_per_line) * bytes_per_line;
|
||||
requested_buffer_size = (sanei_genesys_get_bulk_max_size(dev) / session.output_line_bytes) * session.output_line_bytes;
|
||||
}
|
||||
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels *
|
||||
session.params.channels * session.params.depth) / 8;
|
||||
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1946,7 +1940,7 @@ dummy \ scanned lines
|
|||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * dev->settings.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
||||
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
@ -1960,32 +1954,12 @@ dummy \ scanned lines
|
|||
dev->current_setup.stagger = session.num_staggered_lines;
|
||||
dev->current_setup.max_shift = session.max_color_shift_lines + session.num_staggered_lines;
|
||||
|
||||
/* TODO: should this be done elsewhere? */
|
||||
/* scan bytes to send to the frontend */
|
||||
/* theory :
|
||||
target_size =
|
||||
(dev->settings.pixels * dev->settings.lines * channels * depth) / 8;
|
||||
but it suffers from integer overflow so we do the following:
|
||||
|
||||
1 bit color images store color data byte-wise, eg byte 0 contains
|
||||
8 bits of red data, byte 1 contains 8 bits of green, byte 2 contains
|
||||
8 bits of blue.
|
||||
This does not fix the overflow, though.
|
||||
644mp*16 = 10gp, leading to an overflow
|
||||
-- pierre
|
||||
*/
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines)%8)?1:0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read =
|
||||
session.params.get_requested_pixels() * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read =
|
||||
multiply_by_depth_ceil(session.params.get_requested_pixels() * session.params.lines,
|
||||
session.params.depth) * session.params.channels;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
}
|
||||
|
||||
static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor)
|
||||
|
|
|
@ -1157,12 +1157,8 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
reg->set16(REG_STRPIXEL, session.pixel_startx);
|
||||
reg->set16(REG_ENDPIXEL, session.pixel_endx);
|
||||
|
||||
// words(16bit) before gamma, conversion to 8 bit or lineart */
|
||||
// FIXME: this computation differs from session.output_line_bytes
|
||||
unsigned words_per_line = (session.output_pixels / session.ccd_size_divisor) * (session.params.depth / 8);
|
||||
|
||||
dev->wpl = words_per_line; // FIXME: this is not currently used
|
||||
dev->bpl = words_per_line; // FIXME: this is not currently used
|
||||
dev->wpl = session.output_line_channel_bytes; // FIXME: this is not currently used
|
||||
dev->bpl = session.output_line_channel_bytes; // FIXME: this is not currently used
|
||||
|
||||
DBG(DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
|
||||
DBG(DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
|
||||
|
@ -1170,12 +1166,10 @@ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
|
|||
DBG(DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len);
|
||||
DBG(DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist);
|
||||
|
||||
words_per_line *= session.params.channels;
|
||||
|
||||
/* MAXWD is expressed in 2 words unit */
|
||||
/* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */
|
||||
reg->set24(REG_MAXWD, (words_per_line) >> 1);
|
||||
DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line);
|
||||
// BUG: the division by ccd_size_divisor likely does not make sense
|
||||
reg->set24(REG_MAXWD, (session.output_line_bytes / session.ccd_size_divisor) >> 1);
|
||||
|
||||
reg->set16(REG_LPERIOD, exposure / tgtime);
|
||||
DBG(DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime);
|
||||
|
@ -1193,8 +1187,6 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s,
|
|||
// compute optical and output resolutions
|
||||
s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres);
|
||||
|
||||
s.optical_line_bytes = (s.optical_pixels * s.params.channels * s.params.depth) / 8;
|
||||
s.output_line_bytes = (s.output_pixels * s.params.channels * s.params.depth) / 8;
|
||||
|
||||
// compute physical pixel positions
|
||||
unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel();
|
||||
|
@ -1346,14 +1338,9 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->current_setup.max_shift = session.max_color_shift_lines + session.num_staggered_lines;
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) *
|
||||
session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines *
|
||||
session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
dev->total_bytes_to_read =
|
||||
multiply_by_depth_ceil(session.params.get_requested_pixels() * session.params.lines,
|
||||
session.params.depth) * session.params.channels;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
}
|
||||
|
|
|
@ -951,7 +951,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
session.assert_computed();
|
||||
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int mflags; /**> motor flags */
|
||||
int exposure_time;
|
||||
|
@ -1027,15 +1026,10 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = session.output_pixels;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
requested_buffer_size = 8 * session.output_line_bytes;
|
||||
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels * session.params.channels *
|
||||
session.params.depth) / 8;
|
||||
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1049,7 +1043,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
||||
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
@ -1063,32 +1057,12 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->current_setup.stagger = session.num_staggered_lines;
|
||||
dev->current_setup.max_shift = session.max_color_shift_lines + session.num_staggered_lines;
|
||||
|
||||
/* TODO: should this be done elsewhere? */
|
||||
/* scan bytes to send to the frontend */
|
||||
/* theory :
|
||||
target_size =
|
||||
(params.pixels * params.lines * channels * depth) / 8;
|
||||
but it suffers from integer overflow so we do the following:
|
||||
|
||||
1 bit color images store color data byte-wise, eg byte 0 contains
|
||||
8 bits of red data, byte 1 contains 8 bits of green, byte 2 contains
|
||||
8 bits of blue.
|
||||
This does not fix the overflow, though.
|
||||
644mp*16 = 10gp, leading to an overflow
|
||||
-- pierre
|
||||
*/
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) *
|
||||
session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read =
|
||||
multiply_by_depth_ceil(session.params.get_requested_pixels() * session.params.lines,
|
||||
session.params.depth) * session.params.channels;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -970,7 +970,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
session.assert_computed();
|
||||
|
||||
int start;
|
||||
int bytes_per_line;
|
||||
int move;
|
||||
unsigned int mflags; /**> motor flags */
|
||||
int exposure_time;
|
||||
|
@ -1043,15 +1042,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
|
||||
/*** prepares data reordering ***/
|
||||
|
||||
/* words_per_line */
|
||||
bytes_per_line = session.output_pixels;
|
||||
bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8;
|
||||
|
||||
requested_buffer_size = 8 * bytes_per_line;
|
||||
requested_buffer_size = 8 * session.output_line_bytes;
|
||||
|
||||
read_buffer_size = 2 * requested_buffer_size +
|
||||
((session.max_color_shift_lines + session.num_staggered_lines) * session.optical_pixels *
|
||||
session.params.channels * session.params.depth) / 8;
|
||||
(session.max_color_shift_lines + session.num_staggered_lines) * session.optical_line_bytes;
|
||||
|
||||
dev->read_buffer.clear();
|
||||
dev->read_buffer.alloc(read_buffer_size);
|
||||
|
@ -1065,7 +1059,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->out_buffer.clear();
|
||||
dev->out_buffer.alloc((8 * session.params.pixels * session.params.channels * session.params.depth) / 8);
|
||||
|
||||
dev->read_bytes_left = bytes_per_line * session.output_line_count;
|
||||
dev->read_bytes_left = session.output_line_bytes * session.output_line_count;
|
||||
|
||||
DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left);
|
||||
dev->read_active = SANE_TRUE;
|
||||
|
@ -1079,28 +1073,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->current_setup.stagger = session.num_staggered_lines;
|
||||
dev->current_setup.max_shift = session.max_color_shift_lines + session.num_staggered_lines;
|
||||
|
||||
/* TODO: should this be done elsewhere? */
|
||||
/* scan bytes to send to the frontend */
|
||||
/* theory :
|
||||
target_size =
|
||||
(session.params.pixels * session.params.lines * channels * depth) / 8;
|
||||
but it suffers from integer overflow so we do the following:
|
||||
|
||||
1 bit color images store color data byte-wise, eg byte 0 contains
|
||||
8 bits of red data, byte 1 contains 8 bits of green, byte 2 contains
|
||||
8 bits of blue.
|
||||
This does not fix the overflow, though.
|
||||
644mp*16 = 10gp, leading to an overflow
|
||||
-- pierre
|
||||
*/
|
||||
|
||||
dev->total_bytes_read = 0;
|
||||
if (session.params.depth == 1) {
|
||||
dev->total_bytes_to_read = ((session.params.get_requested_pixels() * session.params.lines) / 8 +
|
||||
(((session.params.get_requested_pixels() * session.params.lines) % 8) ? 1 : 0)) * session.params.channels;
|
||||
} else {
|
||||
dev->total_bytes_to_read = session.params.get_requested_pixels() * session.params.lines * session.params.channels * (session.params.depth / 8);
|
||||
}
|
||||
dev->total_bytes_to_read =
|
||||
multiply_by_depth_ceil(session.params.get_requested_pixels() * session.params.lines,
|
||||
session.params.depth) * session.params.channels;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
|
|
|
@ -1223,6 +1223,10 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
|
|||
s.params.yres, s.params.flags);
|
||||
|
||||
s.output_line_count = s.params.lines + s.max_color_shift_lines + s.num_staggered_lines;
|
||||
|
||||
s.optical_line_bytes = multiply_by_depth_ceil(s.optical_pixels, s.params.depth) * s.params.channels;
|
||||
s.output_line_channel_bytes = multiply_by_depth_ceil(s.output_pixels, s.params.depth);
|
||||
s.output_line_bytes = s.output_line_channel_bytes * s.params.channels;
|
||||
}
|
||||
|
||||
/** @brief initialize device
|
||||
|
|
|
@ -646,6 +646,15 @@ inline T abs_diff(T a, T b)
|
|||
}
|
||||
}
|
||||
|
||||
inline unsigned multiply_by_depth_ceil(unsigned pixels, unsigned depth)
|
||||
{
|
||||
if (depth == 1) {
|
||||
return (pixels / 8) + ((pixels % 8) ? 1 : 0);
|
||||
} else {
|
||||
return pixels * (depth / 8);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ASIC specific functions declarations */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -231,7 +231,6 @@ struct ScanSession {
|
|||
unsigned optical_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a single line directly from scanner
|
||||
// gl843-only
|
||||
unsigned optical_line_bytes = 0;
|
||||
|
||||
// the resolution of the output data.
|
||||
|
@ -241,8 +240,10 @@ struct ScanSession {
|
|||
// the number of pixels in output data
|
||||
unsigned output_pixels = 0;
|
||||
|
||||
// the number of bytes in the output of a channel of a single line
|
||||
unsigned output_line_channel_bytes;
|
||||
|
||||
// the number of bytes in the output of a single line
|
||||
// gl843-only
|
||||
unsigned output_line_bytes = 0;
|
||||
|
||||
// the number of lines in the output of the scanner. This must be larger than the user
|
||||
|
|
Ładowanie…
Reference in New Issue