From 509886800f5b9a9c15cf3569644741458f3a18e3 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 10 Dec 2013 10:40:13 -0600 Subject: [PATCH] Added initial THP modifications --- config.h | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ jdarith.c | 8 ++++ jdhuff.c | 7 +++ jdinput.c | 6 +++ jpeglib.h | 6 +++ 5 files changed, 160 insertions(+) create mode 100644 config.h diff --git a/config.h b/config.h new file mode 100644 index 0000000..2eade3d --- /dev/null +++ b/config.h @@ -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 header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the 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 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 header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the 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 does not define. */ +/* #undef size_t */ diff --git a/jdarith.c b/jdarith.c index d556733..6126eea 100644 --- a/jdarith.c +++ b/jdarith.c @@ -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 */ diff --git a/jdhuff.c b/jdhuff.c index 36fd03b..744e964 100644 --- a/jdhuff.c +++ b/jdhuff.c @@ -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; diff --git a/jdinput.c b/jdinput.c index 0d3ae10..2ec9dd3 100644 --- a/jdinput.c +++ b/jdinput.c @@ -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) diff --git a/jpeglib.h b/jpeglib.h index 91668ed..e039f70 100644 --- a/jpeglib.h +++ b/jpeglib.h @@ -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 + };