Added initial THP modifications

This commit is contained in:
Jack Andersen 2013-12-10 10:40:13 -06:00
parent b6fe98d896
commit 509886800f
5 changed files with 160 additions and 0 deletions

133
config.h Normal file
View File

@ -0,0 +1,133 @@
/* config.h. Generated by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Build number */
#define BUILD "20131209"
/* Support arithmetic encoding */
#define C_ARITH_CODING_SUPPORTED 1
/* Support arithmetic decoding */
#define D_ARITH_CODING_SUPPORTED 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <jni.h> header file. */
/* #undef HAVE_JNI_H */
/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define if your compiler supports prototypes */
#define HAVE_PROTOTYPES 1
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `unsigned char'. */
#define HAVE_UNSIGNED_CHAR 1
/* Define to 1 if the system has the type `unsigned short'. */
#define HAVE_UNSIGNED_SHORT 1
/* Compiler does not support pointers to undefined structures. */
/* #undef INCOMPLETE_TYPES_BROKEN */
/* How to obtain function inlining. */
#define INLINE __attribute__((always_inline))
/* libjpeg API version */
#define JPEG_LIB_VERSION 62
/* libjpeg-turbo version */
#define LIBJPEG_TURBO_VERSION 1.3.0
/* Support in-memory source/destination managers */
#define MEM_SRCDST_SUPPORTED 1
/* Define if you have BSD-like bzero and bcopy */
/* #undef NEED_BSD_STRINGS */
/* Define if you need short function names */
/* #undef NEED_SHORT_EXTERNAL_NAMES */
/* Define if you have sys/types.h */
#define NEED_SYS_TYPES_H 1
/* Name of package */
#define PACKAGE "libjpeg-turbo"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "libjpeg-turbo"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libjpeg-turbo 1.3.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libjpeg-turbo"
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.3.0"
/* Define if shift is unsigned */
/* #undef RIGHT_SHIFT_IS_UNSIGNED */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.3.0"
/* Use accelerated SIMD routines. */
/* #undef WITH_SIMD */
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
#ifndef __CHAR_UNSIGNED__
/* # undef __CHAR_UNSIGNED__ */
#endif
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */

View File

@ -102,6 +102,8 @@ 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)
{
@ -118,6 +120,9 @@ 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 */
@ -134,6 +139,9 @@ 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,6 +291,7 @@ 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,
@ -322,6 +323,9 @@ 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 (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
@ -356,6 +360,9 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
goto no_more_bytes;
}
}
#if NINTENDO_THP_STREAM
}
#endif
/* OK, load c into get_buffer */
get_buffer = (get_buffer << 8) | c;

View File

@ -314,6 +314,9 @@ 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;
@ -328,6 +331,9 @@ 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

@ -704,6 +704,12 @@ struct jpeg_decompress_struct {
struct jpeg_upsampler * upsample;
struct jpeg_color_deconverter * cconvert;
struct jpeg_color_quantizer * cquantize;
#define NINTENDO_THP_STREAM 1
#if NINTENDO_THP_STREAM
int NINTENDO_THP_FLAG;
#endif
};