зеркало из https://github.com/mozilla/mozjpeg.git
Fix broken buffered I/O (to make cjpeg work)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@30 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
Родитель
d07a0a6479
Коммит
8629988742
14
jchuff.c
14
jchuff.c
|
@ -311,6 +311,8 @@ dump_buffer (working_state * state)
|
|||
{
|
||||
struct jpeg_destination_mgr * dest = state->cinfo->dest;
|
||||
|
||||
dest->free_in_buffer = state->free_in_buffer;
|
||||
|
||||
if (! (*dest->empty_output_buffer) (state->cinfo))
|
||||
return FALSE;
|
||||
/* After a successful buffer dump, must reset buffer pointers */
|
||||
|
@ -380,8 +382,10 @@ flush_bits (working_state * state)
|
|||
unsigned char *buffer;
|
||||
int put_buffer, put_bits;
|
||||
|
||||
if ((state)->free_in_buffer < DCTSIZE2 * 2)
|
||||
if ((state)->free_in_buffer < 1)
|
||||
if (! dump_buffer(state)) return FALSE;
|
||||
if ((state)->free_in_buffer < 1)
|
||||
ERREXIT(state->cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
buffer = state->next_output_byte;
|
||||
put_buffer = state->cur.put_buffer;
|
||||
|
@ -394,9 +398,6 @@ flush_bits (working_state * state)
|
|||
state->free_in_buffer -= (buffer - state->next_output_byte);
|
||||
state->next_output_byte = buffer;
|
||||
|
||||
if ((state)->free_in_buffer < DCTSIZE2 * 2)
|
||||
if (! dump_buffer(state)) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -415,6 +416,8 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||
|
||||
if ((state)->free_in_buffer < DCTSIZE2 * 2)
|
||||
if (! dump_buffer(state)) return FALSE;
|
||||
if ((state)->free_in_buffer < DCTSIZE2 * 2)
|
||||
ERREXIT(state->cinfo, JERR_BUFFER_SIZE);
|
||||
|
||||
buffer = state->next_output_byte;
|
||||
put_buffer = state->cur.put_buffer;
|
||||
|
@ -474,9 +477,6 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||
state->free_in_buffer -= (buffer - state->next_output_byte);
|
||||
state->next_output_byte = buffer;
|
||||
|
||||
if ((state)->free_in_buffer < DCTSIZE2 * 2)
|
||||
if (! dump_buffer(state)) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,9 @@ empty_output_buffer (j_compress_ptr cinfo)
|
|||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
|
||||
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
|
||||
(size_t) OUTPUT_BUF_SIZE)
|
||||
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE
|
||||
- dest->pub.free_in_buffer) !=
|
||||
(size_t) (OUTPUT_BUF_SIZE - dest->pub.free_in_buffer))
|
||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче