From 2ff8e8473a4bacbe071ea75bfc933a0d29f3edd7 Mon Sep 17 00:00:00 2001 From: dcommander Date: Sun, 18 May 2014 18:33:44 +0000 Subject: Remove MS-DOS code and information, and adjust copyright headers to reflect the removal of features in r1307 and r1308. libjpeg-turbo has never supported MS-DOS, nor is it even possible for us to do so. git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1312 632fc199-4ca6-4c93-a231-07263d6284db --- ChangeLog.txt | 5 +++++ cdjpeg.c | 44 +++---------------------------------- cdjpeg.h | 4 +++- cjpeg.c | 5 ----- coderules.txt | 4 +--- djpeg.c | 5 ----- jcapimin.c | 4 +++- jccoefct.c | 19 ++++++++-------- jchuff.h | 4 +++- jcmainct.c | 4 +++- jconfig.txt | 18 +++------------ jcphuff.c | 4 +++- jctrans.c | 6 +++-- jdcoefct.c | 5 +---- jdct.h | 4 +++- jdmarker.c | 12 +++++----- jdmaster.c | 4 ---- jdphuff.c | 4 +++- jdpostct.c | 4 +++- jdtrans.c | 4 +++- jerror.c | 4 +++- jmemmgr.c | 35 +++++++++++++++-------------- jmemnobs.c | 13 +++++------ jmemsys.h | 28 +++++++++++------------- jmorecfg.h | 16 -------------- jpegint.h | 6 +++-- jpeglib.h | 16 ++++++-------- jpegtran.c | 7 ------ jquant1.c | 21 +++++++----------- jquant2.c | 28 ++++++++++-------------- jutils.c | 63 +++++++---------------------------------------------- libjpeg.txt | 62 ---------------------------------------------------- rdppm.c | 21 +++++------------- rdrle.c | 7 +++--- rdtarga.c | 4 +++- simd/jsimdcfg.inc.h | 4 ++-- structure.txt | 58 +++++++----------------------------------------- transupp.c | 12 +--------- transupp.h | 4 +++- wrppm.c | 14 +++++------- wrrle.c | 7 +++--- wrtarga.c | 15 ++++--------- 42 files changed, 177 insertions(+), 431 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e59939f..c8476df 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -65,6 +65,11 @@ slower. [8] Added a new output colorspace (JCS_RGB565) to the libjpeg API that allows for decompressing JPEG images into RGB565 (16-bit) pixels. +[9] Numerous obsolete features, such as support for compilers that can't +handle prototypes and support for the MS-DOS memory model, were removed from +the libjpeg code, greatly improving its readability and making it easier to +maintain and extend. + 1.3.1 ===== diff --git a/cdjpeg.c b/cdjpeg.c index 17f1de7..7cc0d6e 100644 --- a/cdjpeg.c +++ b/cdjpeg.c @@ -1,8 +1,10 @@ /* * cdjpeg.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains common support routines used by the IJG application @@ -11,9 +13,6 @@ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include /* to declare signal() */ -#endif #ifdef USE_SETMODE #include /* to declare setmode()'s parameter macros */ /* If you have setmode() but not , just delete this line: */ @@ -21,43 +20,6 @@ #endif -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (int signum) -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (j_common_ptr cinfo) -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - /* * Optional progress monitor: display a percent-done figure on stderr. */ diff --git a/cdjpeg.h b/cdjpeg.h index 400cb69..c633f3f 100644 --- a/cdjpeg.h +++ b/cdjpeg.h @@ -1,8 +1,10 @@ /* * cdjpeg.h * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains common declarations for the sample applications diff --git a/cjpeg.c b/cjpeg.c index 4429c49..a7d2504 100644 --- a/cjpeg.c +++ b/cjpeg.c @@ -510,11 +510,6 @@ main (int argc, char **argv) jerr.first_addon_message = JMSG_FIRSTADDONCODE; jerr.last_addon_message = JMSG_LASTADDONCODE; - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - /* Initialize JPEG parameters. * Much of this may be overridden later. * In particular, we don't yet know the input file's color space, diff --git a/coderules.txt b/coderules.txt index f36d5f8..c87e6d2 100644 --- a/coderules.txt +++ b/coderules.txt @@ -1,9 +1,7 @@ - - IJG JPEG LIBRARY: CODING RULES +This file was part of the Independent JPEG Group's software: Copyright (C) 1991-1996, Thomas G. Lane. -This file was part of the Independent JPEG Group's software. It was modified by The libjpeg-turbo Project to include only information relevant to libjpeg-turbo. For conditions of distribution and use, see the accompanying README file. diff --git a/djpeg.c b/djpeg.c index 9b95e3c..7c63f25 100644 --- a/djpeg.c +++ b/djpeg.c @@ -495,11 +495,6 @@ main (int argc, char **argv) jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - /* Scan command line to find file names. */ /* It is convenient to use just one switch-parsing routine, but the switch * values read here are ignored; we will rescan the switches after opening diff --git a/jcapimin.c b/jcapimin.c index cbd9bd2..60f5737 100644 --- a/jcapimin.c +++ b/jcapimin.c @@ -1,9 +1,11 @@ /* * jcapimin.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1998, Thomas G. Lane. * Modified 2003-2010 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains application interface code for the compression half diff --git a/jccoefct.c b/jccoefct.c index faca94e..d17b75c 100644 --- a/jccoefct.c +++ b/jccoefct.c @@ -1,8 +1,10 @@ /* * jccoefct.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code and + * information relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains the coefficient buffer controller for compression. @@ -42,11 +44,8 @@ typedef struct { /* For single-pass compression, it's sufficient to buffer just one MCU * (although this may prove a bit slow in practice). We allocate a * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each - * MCU constructed and sent. (On 80x86, the workspace is FAR even though - * it's not really very big; this is to keep the module interfaces unchanged - * when a large coefficient buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays. + * MCU constructed and sent. In multi-pass modes, this array points to the + * current MCU's blocks within the virtual arrays. */ JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; @@ -180,7 +179,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) ypos, xpos, (JDIMENSION) blockcnt); if (blockcnt < compptr->MCU_width) { /* Create some dummy blocks at the right edge of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], + jzero_far((void *) coef->MCU_buffer[blkn + blockcnt], (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); for (bi = blockcnt; bi < compptr->MCU_width; bi++) { coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; @@ -188,7 +187,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) } } else { /* Create a row of dummy blocks at the bottom of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn], + jzero_far((void *) coef->MCU_buffer[blkn], compptr->MCU_width * SIZEOF(JBLOCK)); for (bi = 0; bi < compptr->MCU_width; bi++) { coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; @@ -286,7 +285,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) if (ndummy > 0) { /* Create dummy blocks at the right edge of the image. */ thisblockrow += blocks_across; /* => first dummy block */ - jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); + jzero_far((void *) thisblockrow, ndummy * SIZEOF(JBLOCK)); lastDC = thisblockrow[-1][0]; for (bi = 0; bi < ndummy; bi++) { thisblockrow[bi][0] = lastDC; @@ -305,7 +304,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) block_row++) { thisblockrow = buffer[block_row]; lastblockrow = buffer[block_row-1]; - jzero_far((void FAR *) thisblockrow, + jzero_far((void *) thisblockrow, (size_t) (blocks_across * SIZEOF(JBLOCK))); for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { lastDC = lastblockrow[h_samp_factor-1][0]; diff --git a/jchuff.h b/jchuff.h index c247e6f..d49a992 100644 --- a/jchuff.h +++ b/jchuff.h @@ -1,8 +1,10 @@ /* * jchuff.h * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains declarations for Huffman entropy encoding routines diff --git a/jcmainct.c b/jcmainct.c index 62f13c9..20ef398 100644 --- a/jcmainct.c +++ b/jcmainct.c @@ -1,8 +1,10 @@ /* * jcmainct.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains the main buffer controller for compression. diff --git a/jconfig.txt b/jconfig.txt index bf89a83..8acd8dd 100644 --- a/jconfig.txt +++ b/jconfig.txt @@ -1,8 +1,10 @@ /* * jconfig.txt * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file documents the configuration options that are required to @@ -64,14 +66,6 @@ */ #undef NEED_SYS_TYPES_H -/* For 80x86 machines, you need to define NEED_FAR_POINTERS, - * unless you are using a large-data memory model or 80386 flat-memory mode. - * On less brain-damaged CPUs this symbol must not be defined. - * (Defining this symbol causes large data structures to be referenced through - * "far" pointers and to be allocated with a special version of malloc.) - */ -#undef NEED_FAR_POINTERS - /* Although a real ANSI C compiler can deal perfectly well with pointers to * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI * and pseudo-ANSI compilers get confused. To keep one of these bozos happy, @@ -133,12 +127,6 @@ typedef unsigned char boolean; */ #undef TWO_FILE_COMMANDLINE -/* Define this if your system needs explicit cleanup of temporary files. - * This is crucial under MS-DOS, where the temporary "files" may be areas - * of extended memory; on most other systems it's not as important. - */ -#undef NEED_SIGNAL_CATCHER - /* By default, we open image files with fopen(...,"rb") or fopen(...,"wb"). * This is necessary on systems that distinguish text files from binary files, * and is harmless on most systems that don't. If you have one of the rare diff --git a/jcphuff.c b/jcphuff.c index a95e94c..85d8904 100644 --- a/jcphuff.c +++ b/jcphuff.c @@ -1,8 +1,10 @@ /* * jcphuff.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains Huffman entropy encoding routines for progressive JPEG. diff --git a/jctrans.c b/jctrans.c index 62d4396..85725a9 100644 --- a/jctrans.c +++ b/jctrans.c @@ -1,9 +1,11 @@ /* * jctrans.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1995-1998, Thomas G. Lane. * Modified 2000-2009 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains library routines for transcoding compression, @@ -392,7 +394,7 @@ transencode_coef_controller (j_compress_ptr cinfo, buffer = (JBLOCKROW) (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); + jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { coef->dummy_buffer[i] = buffer + i; } diff --git a/jdcoefct.c b/jdcoefct.c index 775bcdf..c1a168a 100644 --- a/jdcoefct.c +++ b/jdcoefct.c @@ -42,9 +42,6 @@ typedef struct { /* In single-pass modes, it's sufficient to buffer just one MCU. * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, * and let the entropy decoder write into that workspace each time. - * (On 80x86, the workspace is FAR even though it's not really very big; - * this is to keep the module interfaces unchanged when a large coefficient - * buffer is necessary.) * In multi-pass modes, this array points to the current MCU's blocks * within the virtual arrays; it is used only by the input side. */ @@ -168,7 +165,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; MCU_col_num++) { /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ - jzero_far((void FAR *) coef->MCU_buffer[0], + jzero_far((void *) coef->MCU_buffer[0], (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { /* Suspension forced; update state counters and exit */ diff --git a/jdct.h b/jdct.h index 0c70c5b..c06bf9d 100644 --- a/jdct.h +++ b/jdct.h @@ -1,8 +1,10 @@ /* * jdct.h * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This include file contains common declarations for the forward and diff --git a/jdmarker.c b/jdmarker.c index d996f6b..fbcf554 100644 --- a/jdmarker.c +++ b/jdmarker.c @@ -597,7 +597,7 @@ get_dri (j_decompress_ptr cinfo) LOCAL(void) -examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, +examine_app0 (j_decompress_ptr cinfo, JOCTET * data, unsigned int datalen, INT32 remaining) /* Examine first few bytes from an APP0. * Take appropriate action if it is a JFIF marker. @@ -673,7 +673,7 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, LOCAL(void) -examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, +examine_app14 (j_decompress_ptr cinfo, JOCTET * data, unsigned int datalen, INT32 remaining) /* Examine first few bytes from an APP14. * Take appropriate action if it is an Adobe marker. @@ -729,10 +729,10 @@ get_interesting_appn (j_decompress_ptr cinfo) /* process it */ switch (cinfo->unread_marker) { case M_APP0: - examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); + examine_app0(cinfo, (JOCTET *) b, numtoread, length); break; case M_APP14: - examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); + examine_app14(cinfo, (JOCTET *) b, numtoread, length); break; default: /* can't get here unless jpeg_save_markers chooses wrong processor */ @@ -758,7 +758,7 @@ save_marker (j_decompress_ptr cinfo) my_marker_ptr marker = (my_marker_ptr) cinfo->marker; jpeg_saved_marker_ptr cur_marker = marker->cur_marker; unsigned int bytes_read, data_length; - JOCTET FAR * data; + JOCTET * data; INT32 length = 0; INPUT_VARS(cinfo); @@ -784,7 +784,7 @@ save_marker (j_decompress_ptr cinfo) cur_marker->original_length = (unsigned int) length; cur_marker->data_length = limit; /* data area is just beyond the jpeg_marker_struct */ - data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); + data = cur_marker->data = (JOCTET *) (cur_marker + 1); marker->cur_marker = cur_marker; marker->bytes_read = 0; bytes_read = 0; diff --git a/jdmaster.c b/jdmaster.c index 30be6cf..e1f0290 100644 --- a/jdmaster.c +++ b/jdmaster.c @@ -7,7 +7,6 @@ * libjpeg-turbo Modifications: * Copyright (C) 2009-2011, D. R. Commander. * Copyright (C) 2013, Linaro Limited. - * For conditions of distribution and use, see the accompanying README file. * * This file contains master control logic for the JPEG decompressor. @@ -419,9 +418,6 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo) * We can save some space by overlapping the start of the post-IDCT table * with the simpler range limiting table. The post-IDCT table begins at * sample_range_limit + CENTERJSAMPLE. - * - * Note that the table is allocated in near data space on PCs; it's small - * enough and used often enough to justify this. */ LOCAL(void) diff --git a/jdphuff.c b/jdphuff.c index cd8f0b2..e52aa7b 100644 --- a/jdphuff.c +++ b/jdphuff.c @@ -1,8 +1,10 @@ /* * jdphuff.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains Huffman entropy decoding routines for progressive JPEG. diff --git a/jdpostct.c b/jdpostct.c index 2e8f28c..3843831 100644 --- a/jdpostct.c +++ b/jdpostct.c @@ -1,8 +1,10 @@ /* * jdpostct.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains the decompression postprocessing controller. diff --git a/jdtrans.c b/jdtrans.c index 85b60b8..86fda3b 100644 --- a/jdtrans.c +++ b/jdtrans.c @@ -1,8 +1,10 @@ /* * jdtrans.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains library routines for transcoding decompression, diff --git a/jerror.c b/jerror.c index ca4f3a5..cd3098d 100644 --- a/jerror.c +++ b/jerror.c @@ -1,8 +1,10 @@ /* * jerror.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains simple error-reporting and trace-message routines. diff --git a/jmemmgr.c b/jmemmgr.c index 8e33318..c721c46 100644 --- a/jmemmgr.c +++ b/jmemmgr.c @@ -1,8 +1,10 @@ /* * jmemmgr.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code and + * information relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains the JPEG system-independent memory management @@ -91,8 +93,7 @@ round_up_pow2 (size_t a, size_t b) * request to jpeg_get_small() or jpeg_get_large(). There is no per-object * overhead within a pool, except for alignment padding. Each pool has a * header with a link to the next pool of the same class. - * Small and large pool headers are identical except that the latter's - * link pointer must be FAR on 80x86 machines. + * Small and large pool headers are identical. */ typedef struct small_pool_struct * small_pool_ptr; @@ -103,7 +104,7 @@ typedef struct small_pool_struct { size_t bytes_left; /* bytes still available in this pool */ } small_pool_hdr; -typedef struct large_pool_struct FAR * large_pool_ptr; +typedef struct large_pool_struct * large_pool_ptr; typedef struct large_pool_struct { large_pool_ptr next; /* next in list of pools */ @@ -339,9 +340,8 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) /* * Allocation of "large" objects. * - * The external semantics of these are the same as "small" objects, - * except that FAR pointers are used on 80x86. However the pool - * management heuristics are quite different. We assume that each + * The external semantics of these are the same as "small" objects. However, + * the pool management heuristics are quite different. We assume that each * request is large enough that it may as well be passed directly to * jpeg_get_large; the pool management just links everything together * so that we can free it all on demand. @@ -350,13 +350,13 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) * deliberately bunch rows together to ensure a large request size. */ -METHODDEF(void FAR *) +METHODDEF(void *) alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) /* Allocate a "large" object */ { my_mem_ptr mem = (my_mem_ptr) cinfo->mem; large_pool_ptr hdr_ptr; - char FAR * data_ptr; + char * data_ptr; /* * Round up the requested size to a multiple of ALIGN_SIZE so that @@ -394,13 +394,12 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */ data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE; - return (void FAR *) data_ptr; + return (void *) data_ptr; } /* * Creation of 2-D sample arrays. - * The pointers are in near heap, the samples themselves in FAR heap. * * To minimize allocation overhead and to allow I/O of large contiguous * blocks, we allocate the sample rows in groups of as many rows as possible @@ -741,11 +740,11 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) byte_count = rows * bytesperrow; if (writing) (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], + (void *) ptr->mem_buffer[i], file_offset, byte_count); else (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], + (void *) ptr->mem_buffer[i], file_offset, byte_count); file_offset += byte_count; } @@ -774,11 +773,11 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) byte_count = rows * bytesperrow; if (writing) (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], + (void *) ptr->mem_buffer[i], file_offset, byte_count); else (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], + (void *) ptr->mem_buffer[i], file_offset, byte_count); file_offset += byte_count; } @@ -854,7 +853,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ end_row -= ptr->cur_start_row; while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow); undef_row++; } } else { @@ -939,7 +938,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ end_row -= ptr->cur_start_row; while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); + jzero_far((void *) ptr->mem_buffer[undef_row], bytesperrow); undef_row++; } } else { @@ -1005,7 +1004,7 @@ free_pool (j_common_ptr cinfo, int pool_id) space_freed = lhdr_ptr->bytes_used + lhdr_ptr->bytes_left + SIZEOF(large_pool_hdr); - jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); + jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed); mem->total_space_allocated -= space_freed; lhdr_ptr = next_lhdr_ptr; } diff --git a/jmemnobs.c b/jmemnobs.c index e81b016..6282832 100644 --- a/jmemnobs.c +++ b/jmemnobs.c @@ -1,8 +1,10 @@ /* * jmemnobs.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code and + * information relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file provides a really simple implementation of the system- @@ -46,19 +48,16 @@ jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) /* * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. */ -GLOBAL(void FAR *) +GLOBAL(void *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) { - return (void FAR *) malloc(sizeofobject); + return (void *) malloc(sizeofobject); } GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) +jpeg_free_large (j_common_ptr cinfo, void * object, size_t sizeofobject) { free(object); } diff --git a/jmemsys.h b/jmemsys.h index b32f80c..5026c7c 100644 --- a/jmemsys.h +++ b/jmemsys.h @@ -1,8 +1,10 @@ /* * jmemsys.h * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code and + * information relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This include file defines the interface between the system-independent @@ -14,8 +16,7 @@ * in the IJG distribution. You may need to modify it if you write a * custom memory manager. If system-dependent changes are needed in * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR - * and USE_MAC_MEMMGR. + * symbol supplied in jconfig.h. */ @@ -27,7 +28,6 @@ * and free; in particular, jpeg_get_small must return NULL on failure. * On most systems, these ARE malloc and free. jpeg_free_small is passed the * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. */ EXTERN(void *) jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject); @@ -37,23 +37,21 @@ EXTERN(void) jpeg_free_small (j_common_ptr cinfo, void * object, /* * These two functions are used to allocate and release large chunks of * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. + * These are identical to the jpeg_get/free_small routines; but we keep them + * separate anyway, in case a different allocation strategy is desirable for + * large chunks. */ -EXTERN(void FAR *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject); -EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void FAR * object, +EXTERN(void *) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject); +EXTERN(void) jpeg_free_large (j_common_ptr cinfo, void * object, size_t sizeofobject); /* * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed + * matter, but that case should never come into play). This macro was needed * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. + * On machines with flat address spaces, any large constant may be used. * * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type * size_t and will be a multiple of sizeof(align_type). @@ -123,10 +121,10 @@ typedef struct backing_store_struct * backing_store_ptr; typedef struct backing_store_struct { /* Methods for reading/writing/closing this backing-store object */ void (*read_backing_store) (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, long file_offset, + void * buffer_address, long file_offset, long byte_count); void (*write_backing_store) (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, long file_offset, + void * buffer_address, long file_offset, long byte_count); void (*close_backing_store) (j_common_ptr cinfo, backing_store_ptr info); diff --git a/jmorecfg.h b/jmorecfg.h index 4776757..91fbd15 100644 --- a/jmorecfg.h +++ b/jmorecfg.h @@ -192,22 +192,6 @@ typedef unsigned int JDIMENSION; #define EXTERN(type) extern type -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifdef NEED_FAR_POINTERS -#ifndef FAR -#define FAR far -#endif -#else -#undef FAR -#define FAR -#endif - - /* * On a few systems, type boolean and/or its values FALSE, TRUE may appear * in standard header files. Or you may have conflicts with application- diff --git a/jpegint.h b/jpegint.h index 51c11c3..025accd 100644 --- a/jpegint.h +++ b/jpegint.h @@ -1,9 +1,11 @@ /* * jpegint.h * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1997, Thomas G. Lane. * Modified 1997-2009 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file provides common declarations for the various JPEG modules. @@ -325,7 +327,7 @@ EXTERN(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row, int num_rows, JDIMENSION num_cols); EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks); -EXTERN(void) jzero_far (void FAR * target, size_t bytestozero); +EXTERN(void) jzero_far (void * target, size_t bytestozero); /* Constant tables in jutils.c */ #if 0 /* This table is not actually needed in v6a */ extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ diff --git a/jpeglib.h b/jpeglib.h index 484c78a..27045a4 100644 --- a/jpeglib.h +++ b/jpeglib.h @@ -62,20 +62,18 @@ extern "C" { /* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. */ -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */ typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */ typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ +typedef JCOEF *JCOEFPTR; /* useful in a couple of places */ /* Types for JPEG compression parameters and working tables. */ @@ -198,14 +196,14 @@ typedef struct { /* The decompressor can save APPn and COM markers in a list of these: */ -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; +typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr; struct jpeg_marker_struct { jpeg_saved_marker_ptr next; /* next in list, or NULL */ UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ unsigned int original_length; /* # bytes of data in the file */ unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ + JOCTET * data; /* the data contained in the marker */ /* the marker length word is not counted in data_length or original_length */ }; @@ -833,8 +831,8 @@ typedef struct jvirt_barray_control * jvirt_barray_ptr; struct jpeg_memory_mgr { /* Method pointers */ void * (*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject); - void FAR * (*alloc_large) (j_common_ptr cinfo, int pool_id, - size_t sizeofobject); + void * (*alloc_large) (j_common_ptr cinfo, int pool_id, + size_t sizeofobject); JSAMPARRAY (*alloc_sarray) (j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow, JDIMENSION numrows); JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id, diff --git a/jpegtran.c b/jpegtran.c index c7906f4..6b40de3 100644 --- a/jpegtran.c +++ b/jpegtran.c @@ -395,13 +395,6 @@ main (int argc, char **argv) dstinfo.err = jpeg_std_error(&jdsterr); jpeg_create_compress(&dstinfo); - /* Now safe to enable signal catcher. - * Note: we assume only the decompression object will have virtual arrays. - */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &srcinfo); -#endif - /* Scan command line to find file names. * It is convenient to use just one switch-parsing routine, but the switch * values read here are mostly ignored; we will rescan the switches after diff --git a/jquant1.c b/jquant1.c index dbcdd27..2fd3037 100644 --- a/jquant1.c +++ b/jquant1.c @@ -121,9 +121,6 @@ static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { * The fserrors[] array is indexed [component#][position]. * We provide (#columns + 2) entries per component; the extra entry at each * end saves us from special-casing the first and last pixels. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. */ #if BITS_IN_JSAMPLE == 8 @@ -134,7 +131,7 @@ typedef INT32 FSERROR; /* may need more than 16 bits */ typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ #endif -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ +typedef FSERROR *FSERRPTR; /* pointer to error array */ /* Private subobject */ @@ -535,8 +532,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, for (row = 0; row < num_rows; row++) { /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); + jzero_far((void *) output_buf[row], (size_t) (width * SIZEOF(JSAMPLE))); row_index = cquantize->row_index; for (ci = 0; ci < nc; ci++) { input_ptr = input_buf[row] + ci; @@ -640,8 +636,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, for (row = 0; row < num_rows; row++) { /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); + jzero_far((void *) output_buf[row], (size_t) (width * SIZEOF(JSAMPLE))); for (ci = 0; ci < nc; ci++) { input_ptr = input_buf[row] + ci; output_ptr = output_buf[row]; @@ -786,7 +781,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) /* Initialize the propagated errors to zero. */ arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); for (i = 0; i < cinfo->out_color_components; i++) - jzero_far((void FAR *) cquantize->fserrors[i], arraysize); + jzero_far((void *) cquantize->fserrors[i], arraysize); break; default: ERREXIT(cinfo, JERR_NOT_COMPILED); @@ -849,10 +844,10 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo) create_colorindex(cinfo); /* Allocate Floyd-Steinberg workspace now if requested. - * We do this now since it is FAR storage and may affect the memory - * manager's space calculations. If the user changes to FS dither - * mode in a later pass, we will allocate the space then, and will - * possibly overrun the max_memory_to_use setting. + * We do this now since it may affect the memory manager's space + * calculations. If the user changes to FS dither mode in a later pass, we + * will allocate the space then, and will possibly overrun the + * max_memory_to_use setting. */ if (cinfo->dither_mode == JDITHER_FS) alloc_fs_workspace(cinfo); diff --git a/jquant2.c b/jquant2.c index 0fdb197..a9c7845 100644 --- a/jquant2.c +++ b/jquant2.c @@ -102,9 +102,7 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE}; * machines, we can't just allocate the histogram in one chunk. Instead * of a true 3-D array, we use a row of pointers to 2-D arrays. Each * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and - * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that - * on 80x86 machines, the pointer row is in near memory but the actual - * arrays are in far memory (same arrangement as we use for image arrays). + * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. */ #define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ @@ -129,10 +127,10 @@ static const int c_scales[3]={R_SCALE, G_SCALE, B_SCALE}; typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */ -typedef histcell FAR * histptr; /* for pointers to histogram cells */ +typedef histcell * histptr; /* for pointers to histogram cells */ typedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */ -typedef hist1d FAR * hist2d; /* type for the 2nd-level pointers */ +typedef hist1d * hist2d; /* type for the 2nd-level pointers */ typedef hist2d * hist3d; /* type for top-level pointer */ @@ -155,9 +153,6 @@ typedef hist2d * hist3d; /* type for top-level pointer */ * The fserrors[] array has (#columns + 2) entries; the extra entry at * each end saves us from special-casing the first and last pixels. * Each entry is three values long, one value for each color component. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. */ #if BITS_IN_JSAMPLE == 8 @@ -168,7 +163,7 @@ typedef INT32 FSERROR; /* may need more than 16 bits */ typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ #endif -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ +typedef FSERROR *FSERRPTR; /* pointer to error array */ /* Private subobject */ @@ -1178,7 +1173,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); /* Initialize the propagated errors to zero. */ - jzero_far((void FAR *) cquantize->fserrors, arraysize); + jzero_far((void *) cquantize->fserrors, arraysize); /* Make the error-limit table if we didn't already. */ if (cquantize->error_limiter == NULL) init_error_limit(cinfo); @@ -1189,7 +1184,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) /* Zero the histogram or inverse color map, if necessary */ if (cquantize->needs_zeroed) { for (i = 0; i < HIST_C0_ELEMS; i++) { - jzero_far((void FAR *) histogram[i], + jzero_far((void *) histogram[i], HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); } cquantize->needs_zeroed = FALSE; @@ -1245,8 +1240,8 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo) cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ /* Allocate storage for the completed colormap, if required. - * We do this now since it is FAR storage and may affect - * the memory manager's space calculations. + * We do this now since it may affect the memory manager's space + * calculations. */ if (cinfo->enable_2pass_quant) { /* Make sure color count is acceptable */ @@ -1269,9 +1264,10 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo) cinfo->dither_mode = JDITHER_FS; /* Allocate Floyd-Steinberg workspace if necessary. - * This isn't really needed until pass 2, but again it is FAR storage. - * Although we will cope with a later change in dither_mode, - * we do not promise to honor max_memory_to_use if dither_mode changes. + * This isn't really needed until pass 2, but again it may affect the memory + * manager's space calculations. Although we will cope with a later change + * in dither_mode, we do not promise to honor max_memory_to_use if + * dither_mode changes. */ if (cinfo->dither_mode == JDITHER_FS) { cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) diff --git a/jutils.c b/jutils.c index b9997a3..7955d23 100644 --- a/jutils.c +++ b/jutils.c @@ -1,8 +1,10 @@ /* * jutils.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code + * relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains tables and miscellaneous utility routines needed @@ -87,26 +89,6 @@ jround_up (long a, long b) } -/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays - * and coefficient-block arrays. This won't work on 80x86 because the arrays - * are FAR and we're assuming a small-pointer memory model. However, some - * DOS compilers provide far-pointer versions of memcpy() and memset() even - * in the small-model libraries. These will be used if USE_FMEM is defined. - * Otherwise, the routines below do it the hard way. (The performance cost - * is not all that great, because these routines aren't very heavily used.) - */ - -#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ -#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) -#define FMEMZERO(target,size) MEMZERO(target,size) -#else /* 80x86 case, define if we can */ -#ifdef USE_FMEM -#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) -#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) -#endif -#endif - - GLOBAL(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row, JSAMPARRAY output_array, int dest_row, @@ -118,11 +100,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row, */ { register JSAMPROW inptr, outptr; -#ifdef FMEMCOPY register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); -#else - register JDIMENSION count; -#endif register int row; input_array += source_row; @@ -131,12 +109,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row, for (row = num_rows; row > 0; row--) { inptr = *input_array++; outptr = *output_array++; -#ifdef FMEMCOPY - FMEMCOPY(outptr, inptr, count); -#else - for (count = num_cols; count > 0; count--) - *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ -#endif + MEMCOPY(outptr, inptr, count); } } @@ -146,34 +119,14 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks) /* Copy a row of coefficient blocks from one place to another. */ { -#ifdef FMEMCOPY - FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); -#else - register JCOEFPTR inptr, outptr; - register long count; - - inptr = (JCOEFPTR) input_row; - outptr = (JCOEFPTR) output_row; - for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { - *outptr++ = *inptr++; - } -#endif + MEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); } GLOBAL(void) -jzero_far (void FAR * target, size_t bytestozero) -/* Zero out a chunk of FAR memory. */ +jzero_far (void * target, size_t bytestozero) +/* Zero out a chunk of memory. */ /* This might be sample-array data, block-array data, or alloc_large data. */ { -#ifdef FMEMZERO - FMEMZERO(target, bytestozero); -#else - register char FAR * ptr = (char FAR *) target; - register size_t count; - - for (count = bytestozero; count > 0; count--) { - *ptr++ = 0; - } -#endif + MEMZERO(target, bytestozero); } diff --git a/libjpeg.txt b/libjpeg.txt index 84965fc..edc61b7 100644 --- a/libjpeg.txt +++ b/libjpeg.txt @@ -52,7 +52,6 @@ Advanced features: Memory usage Library compile-time options Portability considerations - Notes for MS-DOS implementors You should read at least the overview and basic usage sections before trying to program with the library. The sections on advanced features can be read @@ -764,12 +763,6 @@ compatible across versions; we only try to ensure source-code compatibility. applications and introduce a ton of access functions instead. Too late now, however.) -On some systems your application may need to set up a signal handler to ensure -that temporary files are deleted if the program is interrupted. This is most -critical if you are on MS-DOS and use the jmemdos.c memory manager back end; -it will try to grab extended memory for temp files, and that space will NOT be -freed automatically. See cjpeg.c or djpeg.c for an example signal handler. - It may be worth pointing out that the core JPEG library does not actually require the stdio library: only the default source/destination managers and error handler need it. You can use the library in a stdio-less environment @@ -2877,18 +2870,6 @@ that space allocated with alloc_small() is ignored, on the assumption that it's too small to be worth worrying about; so a reasonable safety margin should be left when setting max_memory_to_use. -If you use the jmemname.c or jmemdos.c memory manager back end, it is -important to clean up the JPEG object properly to ensure that the temporary -files get deleted. (This is especially crucial with jmemdos.c, where the -"temporary files" may be extended-memory segments; if they are not freed, -DOS will require a reboot to recover the memory.) Thus, with these memory -managers, it's a good idea to provide a signal handler that will trap any -early exit from your program. The handler should call either jpeg_abort() -or jpeg_destroy() for any active JPEG objects. A handler is not needed with -jmemnobs.c, and shouldn't be necessary with jmemansi.c or jmemmac.c either, -since the C library is supposed to take care of deleting files made with -tmpfile(). - Memory usage ------------ @@ -3033,46 +3014,3 @@ replacing that one file. More info about porting the code may be gleaned by reading jconfig.txt, jmorecfg.h, and jinclude.h. - - -Notes for MS-DOS implementors ------------------------------ - -The IJG code is designed to work efficiently in 80x86 "small" or "medium" -memory models (i.e., data pointers are 16 bits unless explicitly declared -"far"; code pointers can be either size). You may be able to use small -model to compile cjpeg or djpeg by itself, but you will probably have to use -medium model for any larger application. This won't make much difference in -performance. You *will* take a noticeable performance hit if you use a -large-data memory model (perhaps 10%-25%), and you should avoid "huge" model -if at all possible. - -The JPEG library typically needs 2Kb-3Kb of stack space. It will also -malloc about 20K-30K of near heap space while executing (and lots of far -heap, but that doesn't count in this calculation). This figure will vary -depending on selected operating mode, and to a lesser extent on image size. -There is also about 5Kb-6Kb of constant data which will be allocated in the -near data segment (about 4Kb of this is the error message table). -Thus you have perhaps 20K available for other modules' static data and near -heap space before you need to go to a larger memory model. The C library's -static data will account for several K of this, but that still leaves a good -deal for your needs. (If you are tight on space, you could reduce the sizes -of the I/O buffers allocated by jdatasrc.c and jdatadst.c, say from 4K to -1K. Another possibility is to move the error message table to far memory; -this should be doable with only localized hacking on jerror.c.) - -About 2K of the near heap space is "permanent" memory that will not be -released until you destroy the JPEG object. This is only an issue if you -save a JPEG object between compression or decompression operations. - -Far data space may also be a tight resource when you are dealing with large -images. The most memory-intensive case is decompression with two-pass color -quantization, or single-pass quantization to an externally supplied color -map. This requires a 128Kb color lookup table plus strip buffers amounting -to about 40 bytes per column for typical sampling ratios (eg, about 25600 -bytes for a 640-pixel-wide image). You may not be able to process wide -images if you have large data structures of your own. - -Of course, all of these concerns vanish if you use a 32-bit flat-memory-model -compiler, such as DJGPP or Watcom C. We highly recommend flat model if you -can use it; the JPEG library is significantly faster in flat model. diff --git a/rdppm.c b/rdppm.c index c55ab2b..0bc6d35 100644 --- a/rdppm.c +++ b/rdppm.c @@ -1,9 +1,11 @@ /* * rdppm.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1997, Thomas G. Lane. * Modified 2009 by Bill Allombert, Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code and + * information relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains routines to read input images in PPM/PGM format. @@ -56,24 +58,14 @@ typedef char U_CHAR; #define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) -/* - * On most systems, reading individual bytes with getc() is drastically less - * efficient than buffering a row at a time with fread(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fread() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fread() with a getc() loop --- which will be much - * slower. - */ - - /* Private version of data source object */ typedef struct { struct cjpeg_source_struct pub; /* public fields */ - U_CHAR *iobuffer; /* non-FAR pointer to I/O buffer */ - JSAMPROW pixrow; /* FAR pointer to same */ + /* Usually these two pointers point to the same place: */ + U_CHAR *iobuffer; /* fread's I/O buffer */ + JSAMPROW pixrow; /* compressor input buffer */ size_t buffer_width; /* width of I/O buffer */ JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ } ppm_source_struct; @@ -396,7 +388,6 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) if (use_raw_buffer) { /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ source->pixrow = (JSAMPROW) source->iobuffer; source->pub.buffer = & source->pixrow; source->pub.buffer_height = 1; diff --git a/rdrle.c b/rdrle.c index f8b3587..a82cc3a 100644 --- a/rdrle.c +++ b/rdrle.c @@ -1,8 +1,10 @@ /* * rdrle.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only information + * relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains routines to read input images in Utah RLE format. @@ -254,8 +256,7 @@ load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) rle_row = source->rle_row; /* Read the RLE data into our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. + * We assume here that rle_pixel is represented the same as JSAMPLE. */ RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ diff --git a/rdtarga.c b/rdtarga.c index 38c8514..3f35d3d 100644 --- a/rdtarga.c +++ b/rdtarga.c @@ -1,8 +1,10 @@ /* * rdtarga.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains routines to read input images in Targa format. diff --git a/simd/jsimdcfg.inc.h b/simd/jsimdcfg.inc.h index a3450aa..d2b499f 100644 --- a/simd/jsimdcfg.inc.h +++ b/simd/jsimdcfg.inc.h @@ -84,10 +84,10 @@ %define JDIMENSION dword ; unsigned int %define SIZEOF_JDIMENSION SIZEOF_DWORD ; sizeof(JDIMENSION) -%define JSAMPROW POINTER ; JSAMPLE FAR * (jpeglib.h) +%define JSAMPROW POINTER ; JSAMPLE * (jpeglib.h) %define JSAMPARRAY POINTER ; JSAMPROW * (jpeglib.h) %define JSAMPIMAGE POINTER ; JSAMPARRAY * (jpeglib.h) -%define JCOEFPTR POINTER ; JCOEF FAR * (jpeglib.h) +%define JCOEFPTR POINTER ; JCOEF * (jpeglib.h) %define SIZEOF_JSAMPROW SIZEOF_POINTER ; sizeof(JSAMPROW) %define SIZEOF_JSAMPARRAY SIZEOF_POINTER ; sizeof(JSAMPARRAY) %define SIZEOF_JSAMPIMAGE SIZEOF_POINTER ; sizeof(JSAMPIMAGE) diff --git a/structure.txt b/structure.txt index 6045784..4c9fe39 100644 --- a/structure.txt +++ b/structure.txt @@ -84,36 +84,6 @@ low-quality modes may not meet the JPEG standard's accuracy requirements; nonetheless, they are useful for viewers. -*** Portability issues *** - -Portability is an essential requirement for the library. The key portability -issues that show up at the level of system architecture are: - -1. Memory usage. We want the code to be able to run on PC-class machines -with limited memory. Images should therefore be processed sequentially (in -strips), to avoid holding the whole image in memory at once. Where a -full-image buffer is necessary, we should be able to use either virtual memory -or temporary files. - -2. Near/far pointer distinction. To run efficiently on 80x86 machines, the -code should distinguish "small" objects (kept in near data space) from -"large" ones (kept in far data space). This is an annoying restriction, but -fortunately it does not impact code quality for less brain-damaged machines, -and the source code clutter turns out to be minimal with sufficient use of -pointer typedefs. - -3. Data precision. We assume that "char" is at least 8 bits, "short" and -"int" at least 16, "long" at least 32. The code will work fine with larger -data sizes, although memory may be used inefficiently in some cases. However, -the JPEG compressed datastream must ultimately appear on external storage as a -sequence of 8-bit bytes if it is to conform to the standard. This may pose a -problem on machines where char is wider than 8 bits. The library represents -compressed data as an array of values of typedef JOCTET. If no data type -exactly 8 bits wide is available, custom data source and data destination -modules must be written to unpack and pack the chosen JOCTET datatype into -8-bit external representation. - - *** System overview *** The compressor and decompressor are each divided into two main sections: @@ -661,17 +631,6 @@ Notice that the allocation unit is now a row of 8x8 blocks, corresponding to eight rows of samples. Otherwise the structure is much the same as for samples, and for the same reasons. -On machines where malloc() can't handle a request bigger than 64Kb, this data -structure limits us to rows of less than 512 JBLOCKs, or a picture width of -4000+ pixels. This seems an acceptable restriction. - - -On 80x86 machines, the bottom-level pointer types (JSAMPROW and JBLOCKROW) -must be declared as "far" pointers, but the upper levels can be "near" -(implying that the pointer lists are allocated in the DS segment). -We use a #define symbol FAR, which expands to the "far" keyword when -compiling on 80x86 machines and to nothing elsewhere. - *** Suspendable processing *** @@ -773,12 +732,11 @@ The memory manager deals with three kinds of object: 1. "Small" objects. Typically these require no more than 10K-20K total. 2. "Large" objects. These may require tens to hundreds of K depending on image size. Semantically they behave the same as small objects, but we - distinguish them for two reasons: - * On MS-DOS machines, large objects are referenced by FAR pointers, - small objects by NEAR pointers. - * Pool allocation heuristics may differ for large and small objects. - Note that individual "large" objects cannot exceed the size allowed by - type size_t, which may be 64K or less on some machines. + distinguish them because pool allocation heuristics may differ for large and + small objects (historically, large objects were also referenced by far + pointers on MS-DOS machines.) Note that individual "large" objects cannot + exceed the size allowed by type size_t, which may be 64K or less on some + machines. 3. "Virtual" objects. These are large 2-D arrays of JSAMPLEs or JBLOCKs (typically large enough for the entire image being processed). The memory manager provides stripwise access to these arrays. On machines @@ -862,9 +820,9 @@ jpeg_mem_init, jpeg_mem_term system-dependent initialization/shutdown jpeg_get_small, jpeg_free_small interface to malloc and free library routines (or their equivalents) -jpeg_get_large, jpeg_free_large interface to FAR malloc/free in MSDOS machines; - else usually the same as - jpeg_get_small/jpeg_free_small +jpeg_get_large, jpeg_free_large historically was used to interface with + FAR malloc/free on MS-DOS machines; now the + same as jpeg_get_small/jpeg_free_small jpeg_mem_available estimate available memory diff --git a/transupp.c b/transupp.c index 72ef8d8..20c8d59 100644 --- a/transupp.c +++ b/transupp.c @@ -1178,7 +1178,7 @@ transpose_critical_parameters (j_compress_ptr dstinfo) #if JPEG_LIB_VERSION >= 70 LOCAL(void) -adjust_exif_parameters (JOCTET FAR * data, unsigned int length, +adjust_exif_parameters (JOCTET * data, unsigned int length, JDIMENSION new_width, JDIMENSION new_height) { boolean is_motorola; /* Flag for byte order */ @@ -1614,17 +1614,7 @@ jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, GETJOCTET(marker->data[3]) == 0x62 && GETJOCTET(marker->data[4]) == 0x65) continue; /* reject duplicate Adobe */ -#ifdef NEED_FAR_POINTERS - /* We could use jpeg_write_marker if the data weren't FAR... */ - { - unsigned int i; - jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); - for (i = 0; i < marker->data_length; i++) - jpeg_write_m_byte(dstinfo, marker->data[i]); - } -#else jpeg_write_marker(dstinfo, marker->marker, marker->data, marker->data_length); -#endif } } diff --git a/transupp.h b/transupp.h index c5bfa91..8fe9071 100644 --- a/transupp.h +++ b/transupp.h @@ -1,8 +1,10 @@ /* * transupp.h * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code relevant + * to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains declarations for image transformation routines and diff --git a/wrppm.c b/wrppm.c index 6b7ebf4..6acf204 100644 --- a/wrppm.c +++ b/wrppm.c @@ -1,9 +1,11 @@ /* * wrppm.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1996, Thomas G. Lane. * Modified 2009 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only information + * relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains routines to write output images in PPM/PGM format. @@ -55,12 +57,7 @@ /* * When JSAMPLE is the same size as char, we can just fwrite() the - * decompressed data to the PPM or PGM file. On PCs, in order to make this - * work the output buffer must be allocated in near data space, because we are - * assuming small-data memory model wherein fwrite() can't reach far memory. - * If you need to process very wide images on a PC, you might have to compile - * in large-memory model, or else replace fwrite() with a putc() loop --- - * which will be much slower. + * decompressed data to the PPM or PGM file. */ @@ -231,7 +228,7 @@ jinit_write_ppm (j_decompress_ptr cinfo) /* Calculate output image dimensions so we can allocate space */ jpeg_calc_output_dimensions(cinfo); - /* Create physical I/O buffer. Note we make this near on a PC. */ + /* Create physical I/O buffer */ dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); dest->iobuffer = (char *) (*cinfo->mem->alloc_small) @@ -256,7 +253,6 @@ jinit_write_ppm (j_decompress_ptr cinfo) } else { /* We will fwrite() directly from decompressor output buffer. */ /* Synthesize a JSAMPARRAY pointer structure */ - /* Cast here implies near->far pointer conversion on PCs */ dest->pixrow = (JSAMPROW) dest->iobuffer; dest->pub.buffer = & dest->pixrow; dest->pub.buffer_height = 1; diff --git a/wrrle.c b/wrrle.c index fbc2fb0..7560d16 100644 --- a/wrrle.c +++ b/wrrle.c @@ -1,8 +1,10 @@ /* * wrrle.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only code and + * information relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains routines to write output images in RLE format. @@ -207,8 +209,7 @@ finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) rle_put_setup(&header); /* Now output the RLE data from our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. + * We assume here that rle_pixel is represented the same as JSAMPLE. */ #ifdef PROGRESS_REPORT diff --git a/wrtarga.c b/wrtarga.c index ffdce63..0ee26b5 100644 --- a/wrtarga.c +++ b/wrtarga.c @@ -1,8 +1,10 @@ /* * wrtarga.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. + * It was modified by The libjpeg-turbo Project to include only information + * relevant to libjpeg-turbo. * For conditions of distribution and use, see the accompanying README file. * * This file contains routines to write output images in Targa format. @@ -28,15 +30,6 @@ Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ #endif -/* - * The output buffer needs to be writable by fwrite(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fwrite() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fwrite() with a putc() loop --- which will be much - * slower. - */ - /* Private version of data destination object */ @@ -236,7 +229,7 @@ jinit_write_targa (j_decompress_ptr cinfo) /* Calculate output image dimensions so we can allocate space */ jpeg_calc_output_dimensions(cinfo); - /* Create I/O buffer. Note we make this near on a PC. */ + /* Create I/O buffer. */ dest->buffer_width = cinfo->output_width * cinfo->output_components; dest->iobuffer = (char *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, -- cgit v1.2.3