Fixed bug in fix_line_distance_block that resulted in too much data transfered

to the frontend. New version: 1.0-110.
Henning Meier-Geinitz <henning@meier-geinitz.de>
DEVEL_2_0_BRANCH-1
Henning Geinitz 2001-07-11 21:41:25 +00:00
rodzic b1365ef2de
commit 6b51ef9908
2 zmienionych plików z 32 dodań i 7 usunięć

Wyświetl plik

@ -46,7 +46,7 @@
/**************************************************************************/ /**************************************************************************/
/* Mustek backend version */ /* Mustek backend version */
#define BUILD 109 #define BUILD 110
/**************************************************************************/ /**************************************************************************/
#include "../include/sane/config.h" #include "../include/sane/config.h"
@ -2754,6 +2754,15 @@ do_stop (Mustek_Scanner *s)
DBG(2, "Scanning time was %ld seconds, %ld kB/s\n", scan_time, DBG(2, "Scanning time was %ld seconds, %ld kB/s\n", scan_time,
scan_size / scan_time); scan_size / scan_time);
if (s->total_bytes == s->params.lines * s->params.bytes_per_line)
DBG(3, "Scanned %d bytes as expected\n", s->total_bytes);
else if (s->total_bytes < s->params.lines * s->params.bytes_per_line)
DBG(3, "Scanned %d bytes, expected %d bytes\n", s->total_bytes,
s->params.lines * s->params.bytes_per_line);
else
DBG(1, "Warning: Scanned %d bytes, but expected only %d bytes\n",
s->total_bytes, s->params.lines * s->params.bytes_per_line);
/* ensure child knows it's time to stop: */ /* ensure child knows it's time to stop: */
DBG(5, "do_stop: terminating reader process\n"); DBG(5, "do_stop: terminating reader process\n");
kill (s->reader_pid, SIGTERM); kill (s->reader_pid, SIGTERM);
@ -3750,7 +3759,8 @@ fix_line_distance_normal (Mustek_Scanner *s, SANE_Int num_lines, SANE_Int bpl,
/* Paragon series I + II. */ /* Paragon series I + II. */
static SANE_Int static SANE_Int
fix_line_distance_block (Mustek_Scanner *s, SANE_Int num_lines, SANE_Int bpl, fix_line_distance_block (Mustek_Scanner *s, SANE_Int num_lines, SANE_Int bpl,
SANE_Byte *raw, SANE_Byte *out, SANE_Int num_lines_total) SANE_Byte *raw, SANE_Byte *out,
SANE_Int num_lines_total)
{ {
SANE_Byte *out_end, *out_ptr, *raw_end = raw + num_lines * bpl; SANE_Byte *out_end, *out_ptr, *raw_end = raw + num_lines * bpl;
SANE_Int c, num_saved_lines, line, max_index, min_index; SANE_Int c, num_saved_lines, line, max_index, min_index;
@ -3823,6 +3833,9 @@ fix_line_distance_block (Mustek_Scanner *s, SANE_Int num_lines, SANE_Int bpl,
num_lines = min_index - s->ld.ld_line; num_lines = min_index - s->ld.ld_line;
if (num_lines < 0) if (num_lines < 0)
num_lines = 0; num_lines = 0;
if ((s->total_lines + num_lines) > s->params.lines)
num_lines = s->params.lines - s->total_lines;
s->total_lines += num_lines;
/* copy away the lines with at least one missing /* copy away the lines with at least one missing
color component, so that we can interleave them color component, so that we can interleave them
@ -4556,6 +4569,7 @@ reader_process (Mustek_Scanner *s, SANE_Int fd)
if (!fp) if (!fp)
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
s->total_lines = 0;
bpl = s->hw->bpl; bpl = s->hw->bpl;
/* buffer size is scanner dependant */ /* buffer size is scanner dependant */
@ -5819,6 +5833,8 @@ sane_start (SANE_Handle handle)
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
return status; return status;
s->total_bytes = 0;
if (s->fd < 0) if (s->fd < 0)
{ {
/* this is the first (and maybe only) pass... */ /* this is the first (and maybe only) pass... */
@ -6167,7 +6183,8 @@ sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len)
if (*len == 0) if (*len == 0)
DBG(5, "sane_read: no more data at the moment--try again\n"); DBG(5, "sane_read: no more data at the moment--try again\n");
else else
DBG(5, "sane_read: read buffer of %d bytes\n", *len); DBG(5, "sane_read: read buffer of %d bytes "
"(%d bytes total)\n", *len, s->total_bytes);
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
else else
@ -6180,7 +6197,8 @@ sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len)
} }
*len += nread; *len += nread;
s->total_bytes += nread;
if (nread == 0) if (nread == 0)
{ {
if (*len == 0) if (*len == 0)
@ -6204,13 +6222,14 @@ sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len)
} }
else else
{ {
DBG(5, "sane_read: read last buffer of %d bytes\n", DBG(5, "sane_read: read last buffer of %d bytes "
*len); "(%d bytes total)\n", *len, s->total_bytes);
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
} }
} }
DBG(5, "sane_read: read full buffer of %d bytes\n", *len); DBG(5, "sane_read: read full buffer of %d bytes (%d total bytes)\n",
*len, s->total_bytes);
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }

Wyświetl plik

@ -1,5 +1,11 @@
CHANGES for the SANE Mustek backend CHANGES for the SANE Mustek backend
2001-07-10
* Added debug output for the total amount of data transfered to the
frontend.
* Fixed bug in fix_line_distance_block which lead to too much data
transferred to sane_read.
2001-07-09 2001-07-09
* Released Mustek backend 1.0-109. * Released Mustek backend 1.0-109.