Working THP frame decoding

This commit is contained in:
Jack Andersen 2013-12-12 12:18:59 -06:00
parent 509886800f
commit 78083879a4
5 changed files with 16 additions and 26 deletions

View File

@ -7,6 +7,9 @@
/* libjpeg-turbo version */
#define LIBJPEG_TURBO_VERSION 1.3.0
/* RWK Nintendo THP fork */
#define NINTENDO_THP_STREAM 1
/* Support arithmetic encoding */
#define C_ARITH_CODING_SUPPORTED 1

View File

@ -102,8 +102,6 @@ get_byte (j_decompress_ptr cinfo)
* derived from Markus Kuhn's JBIG implementation.
*/
#define NINTENDO_THP_STREAM 1
LOCAL(int)
arith_decode (j_decompress_ptr cinfo, unsigned char *st)
{
@ -120,9 +118,6 @@ arith_decode (j_decompress_ptr cinfo, unsigned char *st)
data = 0; /* stuff zero data */
else {
data = get_byte(cinfo); /* read next input byte */
#if NINTENDO_THP_STREAM
if (!cinfo->NINTENDO_THP_FLAG) {
#endif
if (data == 0xFF) { /* zero stuff or marker code */
do data = get_byte(cinfo);
while (data == 0xFF); /* swallow extra 0xFF bytes */
@ -139,9 +134,6 @@ arith_decode (j_decompress_ptr cinfo, unsigned char *st)
data = 0;
}
}
#if NINTENDO_THP_STREAM
}
#endif
}
e->c = (e->c << 8) | data; /* insert data into C register */
if ((e->ct += 8) < 0) /* update bit shift counter */

View File

@ -291,8 +291,6 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
#define MIN_GET_BITS (BIT_BUF_SIZE-7)
#endif
#define NINTENDO_THP_STREAM 1
GLOBAL(boolean)
jpeg_fill_bit_buffer (bitread_working_state * state,
register bit_buf_type get_buffer, register int bits_left,
@ -323,9 +321,7 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
c = GETJOCTET(*next_input_byte++);
/* If it's 0xFF, check and discard stuffed zero byte */
#if NINTENDO_THP_STREAM
if (!cinfo->NINTENDO_THP_FLAG) {
#endif
#if !NINTENDO_THP_STREAM
if (c == 0xFF) {
/* Loop here to discard any padding FF's on terminating marker,
* so that we can save a valid unread_marker value. NOTE: we will
@ -360,8 +356,6 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
goto no_more_bytes;
}
}
#if NINTENDO_THP_STREAM
}
#endif
/* OK, load c into get_buffer */
@ -404,6 +398,17 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
handle markers. We have to hand off any blocks with markers to the
slower routines. */
#if NINTENDO_THP_STREAM
#define GET_BYTE \
{ \
register int c0, c1; \
c0 = GETJOCTET(*buffer++); \
c1 = GETJOCTET(*buffer); \
/* Pre-execute most common case */ \
get_buffer = (get_buffer << 8) | c0; \
bits_left += 8; \
}
#else
#define GET_BYTE \
{ \
register int c0, c1; \
@ -424,6 +429,7 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
} \
} \
}
#endif
#if __WORDSIZE == 64 || defined(_WIN64)

View File

@ -314,9 +314,6 @@ consume_markers (j_decompress_ptr cinfo)
switch (val) {
case JPEG_REACHED_SOS: /* Found SOS */
#if NINTENDO_THP_STREAM
cinfo->NINTENDO_THP_FLAG = 1;
#endif
if (inputctl->inheaders) { /* 1st SOS */
initial_setup(cinfo);
inputctl->inheaders = FALSE;
@ -331,9 +328,6 @@ consume_markers (j_decompress_ptr cinfo)
}
break;
case JPEG_REACHED_EOI: /* Found EOI */
#if NINTENDO_THP_STREAM
cinfo->NINTENDO_THP_FLAG = 0;
#endif
inputctl->pub.eoi_reached = TRUE;
if (inputctl->inheaders) { /* Tables-only datastream, apparently */
if (cinfo->marker->saw_SOF)

View File

@ -705,11 +705,6 @@ struct jpeg_decompress_struct {
struct jpeg_color_deconverter * cconvert;
struct jpeg_color_quantizer * cquantize;
#define NINTENDO_THP_STREAM 1
#if NINTENDO_THP_STREAM
int NINTENDO_THP_FLAG;
#endif
};