reverted libjpeg to an earlier version
This commit is contained in:
74
3rdparty/libjpeg/jdmarker.c
vendored
74
3rdparty/libjpeg/jdmarker.c
vendored
@@ -2,7 +2,6 @@
|
||||
* jdmarker.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2009 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -235,8 +234,7 @@ get_soi (j_decompress_ptr cinfo)
|
||||
|
||||
|
||||
LOCAL(boolean)
|
||||
get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
|
||||
boolean is_arith)
|
||||
get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
|
||||
/* Process a SOFn marker */
|
||||
{
|
||||
INT32 length;
|
||||
@@ -244,7 +242,6 @@ get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
|
||||
jpeg_component_info * compptr;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
cinfo->is_baseline = is_baseline;
|
||||
cinfo->progressive_mode = is_prog;
|
||||
cinfo->arith_code = is_arith;
|
||||
|
||||
@@ -318,9 +315,7 @@ get_sos (j_decompress_ptr cinfo)
|
||||
|
||||
TRACEMS1(cinfo, 1, JTRC_SOS, n);
|
||||
|
||||
if (length != (n * 2 + 6) || n > MAX_COMPS_IN_SCAN ||
|
||||
(n == 0 && !cinfo->progressive_mode))
|
||||
/* pseudo SOS marker only allowed in progressive mode */
|
||||
if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
|
||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||
|
||||
cinfo->comps_in_scan = n;
|
||||
@@ -364,8 +359,8 @@ get_sos (j_decompress_ptr cinfo)
|
||||
/* Prepare to scan data & restart markers */
|
||||
cinfo->marker->next_restart_num = 0;
|
||||
|
||||
/* Count another (non-pseudo) SOS marker */
|
||||
if (n) cinfo->input_scan_number++;
|
||||
/* Count another SOS marker */
|
||||
cinfo->input_scan_number++;
|
||||
|
||||
INPUT_SYNC(cinfo);
|
||||
return TRUE;
|
||||
@@ -495,18 +490,16 @@ LOCAL(boolean)
|
||||
get_dqt (j_decompress_ptr cinfo)
|
||||
/* Process a DQT marker */
|
||||
{
|
||||
INT32 length, count, i;
|
||||
int n, prec;
|
||||
INT32 length;
|
||||
int n, i, prec;
|
||||
unsigned int tmp;
|
||||
JQUANT_TBL *quant_ptr;
|
||||
const int *natural_order;
|
||||
INPUT_VARS(cinfo);
|
||||
|
||||
INPUT_2BYTES(cinfo, length, return FALSE);
|
||||
length -= 2;
|
||||
|
||||
while (length > 0) {
|
||||
length--;
|
||||
INPUT_BYTE(cinfo, n, return FALSE);
|
||||
prec = n >> 4;
|
||||
n &= 0x0F;
|
||||
@@ -520,43 +513,13 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
|
||||
quant_ptr = cinfo->quant_tbl_ptrs[n];
|
||||
|
||||
if (prec) {
|
||||
if (length < DCTSIZE2 * 2) {
|
||||
/* Initialize full table for safety. */
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
quant_ptr->quantval[i] = 1;
|
||||
}
|
||||
count = length >> 1;
|
||||
} else
|
||||
count = DCTSIZE2;
|
||||
} else {
|
||||
if (length < DCTSIZE2) {
|
||||
/* Initialize full table for safety. */
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
quant_ptr->quantval[i] = 1;
|
||||
}
|
||||
count = length;
|
||||
} else
|
||||
count = DCTSIZE2;
|
||||
}
|
||||
|
||||
switch (count) {
|
||||
case (2*2): natural_order = jpeg_natural_order2; break;
|
||||
case (3*3): natural_order = jpeg_natural_order3; break;
|
||||
case (4*4): natural_order = jpeg_natural_order4; break;
|
||||
case (5*5): natural_order = jpeg_natural_order5; break;
|
||||
case (6*6): natural_order = jpeg_natural_order6; break;
|
||||
case (7*7): natural_order = jpeg_natural_order7; break;
|
||||
default: natural_order = jpeg_natural_order; break;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
for (i = 0; i < DCTSIZE2; i++) {
|
||||
if (prec)
|
||||
INPUT_2BYTES(cinfo, tmp, return FALSE);
|
||||
else
|
||||
INPUT_BYTE(cinfo, tmp, return FALSE);
|
||||
/* We convert the zigzag-order table to natural array order. */
|
||||
quant_ptr->quantval[natural_order[i]] = (UINT16) tmp;
|
||||
quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp;
|
||||
}
|
||||
|
||||
if (cinfo->err->trace_level >= 2) {
|
||||
@@ -569,8 +532,8 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
}
|
||||
}
|
||||
|
||||
length -= count;
|
||||
if (prec) length -= count;
|
||||
length -= DCTSIZE2+1;
|
||||
if (prec) length -= DCTSIZE2;
|
||||
}
|
||||
|
||||
if (length != 0)
|
||||
@@ -983,11 +946,6 @@ first_marker (j_decompress_ptr cinfo)
|
||||
*
|
||||
* Returns same codes as are defined for jpeg_consume_input:
|
||||
* JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
|
||||
*
|
||||
* Note: This function may return a pseudo SOS marker (with zero
|
||||
* component number) for treat by input controller's consume_input.
|
||||
* consume_input itself should filter out (skip) the pseudo marker
|
||||
* after processing for the caller.
|
||||
*/
|
||||
|
||||
METHODDEF(int)
|
||||
@@ -1017,27 +975,23 @@ read_markers (j_decompress_ptr cinfo)
|
||||
break;
|
||||
|
||||
case M_SOF0: /* Baseline */
|
||||
if (! get_sof(cinfo, TRUE, FALSE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF1: /* Extended sequential, Huffman */
|
||||
if (! get_sof(cinfo, FALSE, FALSE, FALSE))
|
||||
if (! get_sof(cinfo, FALSE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF2: /* Progressive, Huffman */
|
||||
if (! get_sof(cinfo, FALSE, TRUE, FALSE))
|
||||
if (! get_sof(cinfo, TRUE, FALSE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF9: /* Extended sequential, arithmetic */
|
||||
if (! get_sof(cinfo, FALSE, FALSE, TRUE))
|
||||
if (! get_sof(cinfo, FALSE, TRUE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
case M_SOF10: /* Progressive, arithmetic */
|
||||
if (! get_sof(cinfo, FALSE, TRUE, TRUE))
|
||||
if (! get_sof(cinfo, TRUE, TRUE))
|
||||
return JPEG_SUSPENDED;
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user