compiles on OSX (10.4.10 Intel)
authorTTimo <ttimo@ttimo.net>
Sat, 3 Nov 2007 15:00:38 +0000 (15:00 +0000)
committerTTimo <ttimo@ttimo.net>
Sat, 3 Nov 2007 15:00:38 +0000 (15:00 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant@181 8a3a26a2-13c4-0310-b231-cf6edde360e5

38 files changed:
config.py
libs/jpeg6/.cvsignore [deleted file]
libs/jpeg6/.cvswrappers [deleted file]
libs/jpeg6/jchuff.h [deleted file]
libs/jpeg6/jcomapi.cpp [deleted file]
libs/jpeg6/jconfig.h [deleted file]
libs/jpeg6/jdapimin.cpp [deleted file]
libs/jpeg6/jdapistd.cpp [deleted file]
libs/jpeg6/jdatasrc.cpp [deleted file]
libs/jpeg6/jdcoefct.cpp [deleted file]
libs/jpeg6/jdcolor.cpp [deleted file]
libs/jpeg6/jdct.h [deleted file]
libs/jpeg6/jddctmgr.cpp [deleted file]
libs/jpeg6/jdhuff.cpp [deleted file]
libs/jpeg6/jdhuff.h [deleted file]
libs/jpeg6/jdinput.cpp [deleted file]
libs/jpeg6/jdmainct.cpp [deleted file]
libs/jpeg6/jdmarker.cpp [deleted file]
libs/jpeg6/jdmaster.cpp [deleted file]
libs/jpeg6/jdpostct.cpp [deleted file]
libs/jpeg6/jdsample.cpp [deleted file]
libs/jpeg6/jdtrans.cpp [deleted file]
libs/jpeg6/jerror.cpp [deleted file]
libs/jpeg6/jerror.h [deleted file]
libs/jpeg6/jfdctflt.cpp [deleted file]
libs/jpeg6/jidctflt.cpp [deleted file]
libs/jpeg6/jinclude.h [deleted file]
libs/jpeg6/jmemmgr.cpp [deleted file]
libs/jpeg6/jmemnobs.cpp [deleted file]
libs/jpeg6/jmemsys.h [deleted file]
libs/jpeg6/jmorecfg.h [deleted file]
libs/jpeg6/jpeg6.vcproj [deleted file]
libs/jpeg6/jpegint.h [deleted file]
libs/jpeg6/jpgload.cpp [deleted file]
libs/jpeg6/jutils.cpp [deleted file]
libs/jpeg6/jversion.h [deleted file]
libs/radiant_jpeglib.h [deleted file]
utils.py

index fb9c34fe1c4951373cff7adb18f934cb644d7ffe..9b7e370db6f944b32b04540b8942448c0041e80d 100644 (file)
--- a/config.py
+++ b/config.py
@@ -1,4 +1,4 @@
-import sys, traceback, platform, re, commands
+import sys, traceback, platform, re, commands, platform
 
 if __name__ != '__main__':
        from SCons.Script import *
 
 if __name__ != '__main__':
        from SCons.Script import *
@@ -25,8 +25,13 @@ class Config:
                self.target_selected = [ 'radiant' ]
                self.config_selected = [ 'release' ]
                # those are global to each config
                self.target_selected = [ 'radiant' ]
                self.config_selected = [ 'release' ]
                # those are global to each config
-               self.cc = 'gcc-4.1'
-               self.cxx = 'g++-4.1'
+               self.platform = platform.system()
+               if ( self.platform == 'Darwin' ):
+                       self.cc = 'gcc'
+                       self.cxx = 'g++'
+               else:
+                       self.cc = 'gcc-4.1'
+                       self.cxx = 'g++-4.1'
 
        def __repr__( self ):
                return 'config: target=%s config=%s' % ( self.target_selected, self.config_selected )
 
        def __repr__( self ):
                return 'config: target=%s config=%s' % ( self.target_selected, self.config_selected )
@@ -108,6 +113,10 @@ class Config:
                env.Append( LINKFLAGS = xml2libs.split( ' ' ) )
                baseflags = [ '-pipe', '-Wall', '-fmessage-length=0', '-fvisibility=hidden', xml2.split( ' ' ) ]
 #              baseflags += [ '-m32' ]
                env.Append( LINKFLAGS = xml2libs.split( ' ' ) )
                baseflags = [ '-pipe', '-Wall', '-fmessage-length=0', '-fvisibility=hidden', xml2.split( ' ' ) ]
 #              baseflags += [ '-m32' ]
+
+               if ( self.platform == 'Darwin' ):
+                       env.Append( CPPPATH = [ '/Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/include' ] )
+
                if ( useGtk ):
                        ( ret, gtk2 ) = commands.getstatusoutput( 'pkg-config gtk+-2.0 --cflags' )
                        if ( ret != 0 ):
                if ( useGtk ):
                        ( ret, gtk2 ) = commands.getstatusoutput( 'pkg-config gtk+-2.0 --cflags' )
                        if ( ret != 0 ):
@@ -125,6 +134,7 @@ class Config:
                        baseflags += glib.split( ' ' )
                        gliblibs = commands.getoutput( 'pkg-config glib-2.0 --libs' )
                        env.Append( LINKFLAGS = gliblibs.split( ' ' ) )
                        baseflags += glib.split( ' ' )
                        gliblibs = commands.getoutput( 'pkg-config glib-2.0 --libs' )
                        env.Append( LINKFLAGS = gliblibs.split( ' ' ) )
+
                if ( useGtkGL ):
                        ( ret, gtkgl ) = commands.getstatusoutput( 'pkg-config gtkglext-1.0 --cflags' )
                        if ( ret != 0 ):
                if ( useGtkGL ):
                        ( ret, gtkgl ) = commands.getstatusoutput( 'pkg-config gtkglext-1.0 --cflags' )
                        if ( ret != 0 ):
diff --git a/libs/jpeg6/.cvsignore b/libs/jpeg6/.cvsignore
deleted file mode 100644 (file)
index face6ad..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Debug
-Release
-*.ncb
-*.opt
-*.plg
-*.001
-*.BAK
-.consign
diff --git a/libs/jpeg6/.cvswrappers b/libs/jpeg6/.cvswrappers
deleted file mode 100644 (file)
index cdfd6d4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.dsp  -m 'COPY' -k 'b'\r
-*.dsw  -m 'COPY' -k 'b'\r
-*.scc  -m 'COPY' -k 'b'\r
diff --git a/libs/jpeg6/jchuff.h b/libs/jpeg6/jchuff.h
deleted file mode 100644 (file)
index 7ae05e8..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*\r
-\r
- * jchuff.h\r
-\r
- *\r
-\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains declarations for Huffman entropy encoding routines\r
-\r
- * that are shared between the sequential encoder (jchuff.c) and the\r
-\r
- * progressive encoder (jcphuff.c).  No other modules need to see these.\r
-\r
- */\r
-\r
-\r
-\r
-/* Derived data constructed for each Huffman table */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  unsigned int ehufco[256];    /* code for each symbol */\r
-\r
-  char ehufsi[256];            /* length of code for each symbol */\r
-\r
-  /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */\r
-\r
-} c_derived_tbl;\r
-\r
-\r
-\r
-/* Short forms of external names for systems with brain-damaged linkers. */\r
-\r
-\r
-\r
-#ifdef NEED_SHORT_EXTERNAL_NAMES\r
-\r
-#define jpeg_make_c_derived_tbl        jMkCDerived\r
-\r
-#define jpeg_gen_optimal_table jGenOptTbl\r
-\r
-#endif /* NEED_SHORT_EXTERNAL_NAMES */\r
-\r
-\r
-\r
-/* Expand a Huffman table definition into the derived format */\r
-\r
-EXTERN void jpeg_make_c_derived_tbl JPP((j_compress_ptr cinfo,\r
-\r
-                               JHUFF_TBL * htbl, c_derived_tbl ** pdtbl));\r
-\r
-\r
-\r
-/* Generate an optimal table definition given the specified counts */\r
-\r
-EXTERN void jpeg_gen_optimal_table JPP((j_compress_ptr cinfo,\r
-\r
-                                       JHUFF_TBL * htbl, long freq[]));\r
-\r
diff --git a/libs/jpeg6/jcomapi.cpp b/libs/jpeg6/jcomapi.cpp
deleted file mode 100644 (file)
index ebf2d79..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*\r
-\r
- * jcomapi.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains application interface routines that are used for both\r
-\r
- * compression and decompression.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Abort processing of a JPEG compression or decompression operation,\r
-\r
- * but don't destroy the object itself.\r
-\r
- *\r
-\r
- * For this, we merely clean up all the nonpermanent memory pools.\r
-\r
- * Note that temp files (virtual arrays) are not allowed to belong to\r
-\r
- * the permanent pool, so we will be able to close all temp files here.\r
-\r
- * Closing a data source or destination, if necessary, is the application's\r
-\r
- * responsibility.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jpeg_abort (j_common_ptr cinfo)\r
-\r
-{\r
-\r
-  int pool;\r
-\r
-\r
-\r
-  /* Releasing pools in reverse order might help avoid fragmentation\r
-\r
-   * with some (brain-damaged) malloc libraries.\r
-\r
-   */\r
-\r
-  for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {\r
-\r
-    (*cinfo->mem->free_pool) (cinfo, pool);\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Reset overall state for possible reuse of object */\r
-\r
-  cinfo->global_state = (cinfo->is_decompressor ? DSTATE_START : CSTATE_START);\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Destruction of a JPEG object.\r
-\r
- *\r
-\r
- * Everything gets deallocated except the master jpeg_compress_struct itself\r
-\r
- * and the error manager struct.  Both of these are supplied by the application\r
-\r
- * and must be freed, if necessary, by the application.  (Often they are on\r
-\r
- * the stack and so don't need to be freed anyway.)\r
-\r
- * Closing a data source or destination, if necessary, is the application's\r
-\r
- * responsibility.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jpeg_destroy (j_common_ptr cinfo)\r
-\r
-{\r
-\r
-  /* We need only tell the memory manager to release everything. */\r
-\r
-  /* NB: mem pointer is NULL if memory mgr failed to initialize. */\r
-\r
-  if (cinfo->mem != NULL)\r
-\r
-    (*cinfo->mem->self_destruct) (cinfo);\r
-\r
-  cinfo->mem = NULL;           /* be safe if jpeg_destroy is called twice */\r
-\r
-  cinfo->global_state = 0;     /* mark it destroyed */\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Convenience routines for allocating quantization and Huffman tables.\r
-\r
- * (Would jutils.c be a more reasonable place to put these?)\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL JQUANT_TBL *\r
-\r
-jpeg_alloc_quant_table (j_common_ptr cinfo)\r
-\r
-{\r
-\r
-  JQUANT_TBL *tbl;\r
-\r
-\r
-\r
-  tbl = (JQUANT_TBL *)\r
-\r
-    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));\r
-\r
-  tbl->sent_table = FALSE;     /* make sure this is false in any new table */\r
-\r
-  return tbl;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-GLOBAL JHUFF_TBL *\r
-\r
-jpeg_alloc_huff_table (j_common_ptr cinfo)\r
-\r
-{\r
-\r
-  JHUFF_TBL *tbl;\r
-\r
-\r
-\r
-  tbl = (JHUFF_TBL *)\r
-\r
-    (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));\r
-\r
-  tbl->sent_table = FALSE;     /* make sure this is false in any new table */\r
-\r
-  return tbl;\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jconfig.h b/libs/jpeg6/jconfig.h
deleted file mode 100644 (file)
index c727519..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */\r
-\r
-/* see jconfig.doc for explanations */\r
-\r
-\r
-\r
-#define HAVE_PROTOTYPES\r
-\r
-#define HAVE_UNSIGNED_CHAR\r
-\r
-#define HAVE_UNSIGNED_SHORT\r
-\r
-/* #define void char */\r
-\r
-/* #define const */\r
-\r
-#define CHAR_IS_UNSIGNED\r
-\r
-#define HAVE_STDDEF_H\r
-\r
-#define HAVE_STDLIB_H\r
-\r
-#undef NEED_BSD_STRINGS\r
-\r
-#undef NEED_SYS_TYPES_H\r
-\r
-#undef NEED_FAR_POINTERS       /* Watcom uses flat 32-bit addressing */\r
-\r
-#undef NEED_SHORT_EXTERNAL_NAMES\r
-\r
-#undef INCOMPLETE_TYPES_BROKEN\r
-\r
-\r
-\r
-#define JDCT_DEFAULT  JDCT_FLOAT\r
-\r
-#define JDCT_FASTEST  JDCT_FLOAT\r
-\r
-\r
-\r
-#ifdef JPEG_INTERNALS\r
-\r
-\r
-\r
-#undef RIGHT_SHIFT_IS_UNSIGNED\r
-\r
-\r
-\r
-#endif /* JPEG_INTERNALS */\r
-\r
-\r
-\r
-#ifdef JPEG_CJPEG_DJPEG\r
-\r
-\r
-\r
-#define BMP_SUPPORTED          /* BMP image file format */\r
-\r
-#define GIF_SUPPORTED          /* GIF image file format */\r
-\r
-#define PPM_SUPPORTED          /* PBMPLUS PPM/PGM image file format */\r
-\r
-#undef RLE_SUPPORTED           /* Utah RLE image file format */\r
-\r
-#define TARGA_SUPPORTED                /* Targa image file format */\r
-\r
-\r
-\r
-#undef TWO_FILE_COMMANDLINE    /* optional */\r
-\r
-#define USE_SETMODE            /* Needed to make one-file style work in Watcom */\r
-\r
-#undef NEED_SIGNAL_CATCHER     /* Define this if you use jmemname.c */\r
-\r
-#undef DONT_USE_B_MODE\r
-\r
-#undef PROGRESS_REPORT         /* optional */\r
-\r
-\r
-\r
-#endif /* JPEG_CJPEG_DJPEG */\r
-\r
diff --git a/libs/jpeg6/jdapimin.cpp b/libs/jpeg6/jdapimin.cpp
deleted file mode 100644 (file)
index 9086b49..0000000
+++ /dev/null
@@ -1,800 +0,0 @@
-/*\r
-\r
- * jdapimin.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains application interface code for the decompression half\r
-\r
- * of the JPEG library.  These are the "minimum" API routines that may be\r
-\r
- * needed in either the normal full-decompression case or the\r
-\r
- * transcoding-only case.\r
-\r
- *\r
-\r
- * Most of the routines intended to be called directly by an application\r
-\r
- * are in this file or in jdapistd.c.  But also see jcomapi.c for routines\r
-\r
- * shared by compression and decompression, and jdtrans.c for the transcoding\r
-\r
- * case.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialization of a JPEG decompression object.\r
-\r
- * The error manager must already be set up (in case memory manager fails).\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jpeg_create_decompress (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  int i;\r
-\r
-\r
-\r
-  /* For debugging purposes, zero the whole master structure.\r
-\r
-   * But error manager pointer is already there, so save and restore it.\r
-\r
-   */\r
-\r
-  {\r
-\r
-    struct jpeg_error_mgr * err = cinfo->err;\r
-\r
-    i = sizeof(struct jpeg_decompress_struct);\r
-\r
-    i = SIZEOF(struct jpeg_decompress_struct);\r
-\r
-    MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));\r
-\r
-    cinfo->err = err;\r
-\r
-  }\r
-\r
-  cinfo->is_decompressor = TRUE;\r
-\r
-\r
-\r
-  /* Initialize a memory manager instance for this object */\r
-\r
-  jinit_memory_mgr((j_common_ptr) cinfo);\r
-\r
-\r
-\r
-  /* Zero out pointers to permanent structures. */\r
-\r
-  cinfo->progress = NULL;\r
-\r
-  cinfo->src = NULL;\r
-\r
-\r
-\r
-  for (i = 0; i < NUM_QUANT_TBLS; i++)\r
-\r
-    cinfo->quant_tbl_ptrs[i] = NULL;\r
-\r
-\r
-\r
-  for (i = 0; i < NUM_HUFF_TBLS; i++) {\r
-\r
-    cinfo->dc_huff_tbl_ptrs[i] = NULL;\r
-\r
-    cinfo->ac_huff_tbl_ptrs[i] = NULL;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Initialize marker processor so application can override methods\r
-\r
-   * for COM, APPn markers before calling jpeg_read_header.\r
-\r
-   */\r
-\r
-  jinit_marker_reader(cinfo);\r
-\r
-\r
-\r
-  /* And initialize the overall input controller. */\r
-\r
-  jinit_input_controller(cinfo);\r
-\r
-\r
-\r
-  /* OK, I'm ready */\r
-\r
-  cinfo->global_state = DSTATE_START;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Destruction of a JPEG decompression object\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jpeg_destroy_decompress (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Abort processing of a JPEG decompression operation,\r
-\r
- * but don't destroy the object itself.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jpeg_abort_decompress (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  jpeg_abort((j_common_ptr) cinfo); /* use common routine */\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Install a special processing method for COM or APPn markers.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,\r
-\r
-                          jpeg_marker_parser_method routine)\r
-\r
-{\r
-\r
-  if (marker_code == JPEG_COM)\r
-\r
-    cinfo->marker->process_COM = routine;\r
-\r
-  else if (marker_code >= JPEG_APP0 && marker_code <= JPEG_APP0+15)\r
-\r
-    cinfo->marker->process_APPn[marker_code-JPEG_APP0] = routine;\r
-\r
-  else\r
-\r
-    ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Set default decompression parameters.\r
-\r
- */\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-default_decompress_parms (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  /* Guess the input colorspace, and set output colorspace accordingly. */\r
-\r
-  /* (Wish JPEG committee had provided a real way to specify this...) */\r
-\r
-  /* Note application may override our guesses. */\r
-\r
-  switch (cinfo->num_components) {\r
-\r
-  case 1:\r
-\r
-    cinfo->jpeg_color_space = JCS_GRAYSCALE;\r
-\r
-    cinfo->out_color_space = JCS_GRAYSCALE;\r
-\r
-    break;\r
-\r
-    \r
-\r
-  case 3:\r
-\r
-    if (cinfo->saw_JFIF_marker) {\r
-\r
-      cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */\r
-\r
-    } else if (cinfo->saw_Adobe_marker) {\r
-\r
-      switch (cinfo->Adobe_transform) {\r
-\r
-      case 0:\r
-\r
-       cinfo->jpeg_color_space = JCS_RGB;\r
-\r
-       break;\r
-\r
-      case 1:\r
-\r
-       cinfo->jpeg_color_space = JCS_YCbCr;\r
-\r
-       break;\r
-\r
-      default:\r
-\r
-       WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);\r
-\r
-       cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */\r
-\r
-       break;\r
-\r
-      }\r
-\r
-    } else {\r
-\r
-      /* Saw no special markers, try to guess from the component IDs */\r
-\r
-      int cid0 = cinfo->comp_info[0].component_id;\r
-\r
-      int cid1 = cinfo->comp_info[1].component_id;\r
-\r
-      int cid2 = cinfo->comp_info[2].component_id;\r
-\r
-\r
-\r
-      if (cid0 == 1 && cid1 == 2 && cid2 == 3)\r
-\r
-       cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */\r
-\r
-      else if (cid0 == 82 && cid1 == 71 && cid2 == 66)\r
-\r
-       cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */\r
-\r
-      else {\r
-\r
-       TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);\r
-\r
-       cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */\r
-\r
-      }\r
-\r
-    }\r
-\r
-    /* Always guess RGB is proper output colorspace. */\r
-\r
-    cinfo->out_color_space = JCS_RGB;\r
-\r
-    break;\r
-\r
-    \r
-\r
-  case 4:\r
-\r
-    if (cinfo->saw_Adobe_marker) {\r
-\r
-      switch (cinfo->Adobe_transform) {\r
-\r
-      case 0:\r
-\r
-       cinfo->jpeg_color_space = JCS_CMYK;\r
-\r
-       break;\r
-\r
-      case 2:\r
-\r
-       cinfo->jpeg_color_space = JCS_YCCK;\r
-\r
-       break;\r
-\r
-      default:\r
-\r
-       WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);\r
-\r
-       cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */\r
-\r
-       break;\r
-\r
-      }\r
-\r
-    } else {\r
-\r
-      /* No special markers, assume straight CMYK. */\r
-\r
-      cinfo->jpeg_color_space = JCS_CMYK;\r
-\r
-    }\r
-\r
-    cinfo->out_color_space = JCS_CMYK;\r
-\r
-    break;\r
-\r
-    \r
-\r
-  default:\r
-\r
-    cinfo->jpeg_color_space = JCS_UNKNOWN;\r
-\r
-    cinfo->out_color_space = JCS_UNKNOWN;\r
-\r
-    break;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Set defaults for other decompression parameters. */\r
-\r
-  cinfo->scale_num = 1;                /* 1:1 scaling */\r
-\r
-  cinfo->scale_denom = 1;\r
-\r
-  cinfo->output_gamma = 1.0;\r
-\r
-  cinfo->buffered_image = FALSE;\r
-\r
-  cinfo->raw_data_out = FALSE;\r
-\r
-  cinfo->dct_method = JDCT_DEFAULT;\r
-\r
-  cinfo->do_fancy_upsampling = TRUE;\r
-\r
-  cinfo->do_block_smoothing = TRUE;\r
-\r
-  cinfo->quantize_colors = FALSE;\r
-\r
-  /* We set these in case application only sets quantize_colors. */\r
-\r
-  cinfo->dither_mode = JDITHER_FS;\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-  cinfo->two_pass_quantize = TRUE;\r
-\r
-#else\r
-\r
-  cinfo->two_pass_quantize = FALSE;\r
-\r
-#endif\r
-\r
-  cinfo->desired_number_of_colors = 256;\r
-\r
-  cinfo->colormap = NULL;\r
-\r
-  /* Initialize for no mode change in buffered-image mode. */\r
-\r
-  cinfo->enable_1pass_quant = FALSE;\r
-\r
-  cinfo->enable_external_quant = FALSE;\r
-\r
-  cinfo->enable_2pass_quant = FALSE;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Decompression startup: read start of JPEG datastream to see what's there.\r
-\r
- * Need only initialize JPEG object and supply a data source before calling.\r
-\r
- *\r
-\r
- * This routine will read as far as the first SOS marker (ie, actual start of\r
-\r
- * compressed data), and will save all tables and parameters in the JPEG\r
-\r
- * object.  It will also initialize the decompression parameters to default\r
-\r
- * values, and finally return JPEG_HEADER_OK.  On return, the application may\r
-\r
- * adjust the decompression parameters and then call jpeg_start_decompress.\r
-\r
- * (Or, if the application only wanted to determine the image parameters,\r
-\r
- * the data need not be decompressed.  In that case, call jpeg_abort or\r
-\r
- * jpeg_destroy to release any temporary space.)\r
-\r
- * If an abbreviated (tables only) datastream is presented, the routine will\r
-\r
- * return JPEG_HEADER_TABLES_ONLY upon reaching EOI.  The application may then\r
-\r
- * re-use the JPEG object to read the abbreviated image datastream(s).\r
-\r
- * It is unnecessary (but OK) to call jpeg_abort in this case.\r
-\r
- * The JPEG_SUSPENDED return code only occurs if the data source module\r
-\r
- * requests suspension of the decompressor.  In this case the application\r
-\r
- * should load more source data and then re-call jpeg_read_header to resume\r
-\r
- * processing.\r
-\r
- * If a non-suspending data source is used and require_image is TRUE, then the\r
-\r
- * return code need not be inspected since only JPEG_HEADER_OK is possible.\r
-\r
- *\r
-\r
- * This routine is now just a front end to jpeg_consume_input, with some\r
-\r
- * extra error checking.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL int\r
-\r
-jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)\r
-\r
-{\r
-\r
-  int retcode;\r
-\r
-\r
-\r
-  if (cinfo->global_state != DSTATE_START &&\r
-\r
-      cinfo->global_state != DSTATE_INHEADER)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-\r
-\r
-  retcode = jpeg_consume_input(cinfo);\r
-\r
-\r
-\r
-  switch (retcode) {\r
-\r
-  case JPEG_REACHED_SOS:\r
-\r
-    retcode = JPEG_HEADER_OK;\r
-\r
-    break;\r
-\r
-  case JPEG_REACHED_EOI:\r
-\r
-    if (require_image)         /* Complain if application wanted an image */\r
-\r
-      ERREXIT(cinfo, JERR_NO_IMAGE);\r
-\r
-    /* Reset to start state; it would be safer to require the application to\r
-\r
-     * call jpeg_abort, but we can't change it now for compatibility reasons.\r
-\r
-     * A side effect is to free any temporary memory (there shouldn't be any).\r
-\r
-     */\r
-\r
-    jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */\r
-\r
-    retcode = JPEG_HEADER_TABLES_ONLY;\r
-\r
-    break;\r
-\r
-  case JPEG_SUSPENDED:\r
-\r
-    /* no work */\r
-\r
-    break;\r
-\r
-  }\r
-\r
-\r
-\r
-  return retcode;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Consume data in advance of what the decompressor requires.\r
-\r
- * This can be called at any time once the decompressor object has\r
-\r
- * been created and a data source has been set up.\r
-\r
- *\r
-\r
- * This routine is essentially a state machine that handles a couple\r
-\r
- * of critical state-transition actions, namely initial setup and\r
-\r
- * transition from header scanning to ready-for-start_decompress.\r
-\r
- * All the actual input is done via the input controller's consume_input\r
-\r
- * method.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL int\r
-\r
-jpeg_consume_input (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  int retcode = JPEG_SUSPENDED;\r
-\r
-\r
-\r
-  /* NB: every possible DSTATE value should be listed in this switch */\r
-\r
-  switch (cinfo->global_state) {\r
-\r
-  case DSTATE_START:\r
-\r
-    /* Start-of-datastream actions: reset appropriate modules */\r
-\r
-    (*cinfo->inputctl->reset_input_controller) (cinfo);\r
-\r
-    /* Initialize application's data source module */\r
-\r
-    (*cinfo->src->init_source) (cinfo);\r
-\r
-    cinfo->global_state = DSTATE_INHEADER;\r
-\r
-    /*FALLTHROUGH*/\r
-\r
-  case DSTATE_INHEADER:\r
-\r
-    retcode = (*cinfo->inputctl->consume_input) (cinfo);\r
-\r
-    if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */\r
-\r
-      /* Set up default parameters based on header data */\r
-\r
-      default_decompress_parms(cinfo);\r
-\r
-      /* Set global state: ready for start_decompress */\r
-\r
-      cinfo->global_state = DSTATE_READY;\r
-\r
-    }\r
-\r
-    break;\r
-\r
-  case DSTATE_READY:\r
-\r
-    /* Can't advance past first SOS until start_decompress is called */\r
-\r
-    retcode = JPEG_REACHED_SOS;\r
-\r
-    break;\r
-\r
-  case DSTATE_PRELOAD:\r
-\r
-  case DSTATE_PRESCAN:\r
-\r
-  case DSTATE_SCANNING:\r
-\r
-  case DSTATE_RAW_OK:\r
-\r
-  case DSTATE_BUFIMAGE:\r
-\r
-  case DSTATE_BUFPOST:\r
-\r
-  case DSTATE_STOPPING:\r
-\r
-    retcode = (*cinfo->inputctl->consume_input) (cinfo);\r
-\r
-    break;\r
-\r
-  default:\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  }\r
-\r
-  return retcode;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Have we finished reading the input file?\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL boolean\r
-\r
-jpeg_input_complete (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  /* Check for valid jpeg object */\r
-\r
-  if (cinfo->global_state < DSTATE_START ||\r
-\r
-      cinfo->global_state > DSTATE_STOPPING)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  return cinfo->inputctl->eoi_reached;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Is there more than one scan?\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL boolean\r
-\r
-jpeg_has_multiple_scans (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  /* Only valid after jpeg_read_header completes */\r
-\r
-  if (cinfo->global_state < DSTATE_READY ||\r
-\r
-      cinfo->global_state > DSTATE_STOPPING)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  return cinfo->inputctl->has_multiple_scans;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Finish JPEG decompression.\r
-\r
- *\r
-\r
- * This will normally just verify the file trailer and release temp storage.\r
-\r
- *\r
-\r
- * Returns FALSE if suspended.  The return value need be inspected only if\r
-\r
- * a suspending data source is used.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL boolean\r
-\r
-jpeg_finish_decompress (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  if ((cinfo->global_state == DSTATE_SCANNING ||\r
-\r
-       cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {\r
-\r
-    /* Terminate final pass of non-buffered mode */\r
-\r
-    if (cinfo->output_scanline < cinfo->output_height)\r
-\r
-      ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);\r
-\r
-    (*cinfo->master->finish_output_pass) (cinfo);\r
-\r
-    cinfo->global_state = DSTATE_STOPPING;\r
-\r
-  } else if (cinfo->global_state == DSTATE_BUFIMAGE) {\r
-\r
-    /* Finishing after a buffered-image operation */\r
-\r
-    cinfo->global_state = DSTATE_STOPPING;\r
-\r
-  } else if (cinfo->global_state != DSTATE_STOPPING) {\r
-\r
-    /* STOPPING = repeat call after a suspension, anything else is error */\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  }\r
-\r
-  /* Read until EOI */\r
-\r
-  while (! cinfo->inputctl->eoi_reached) {\r
-\r
-    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)\r
-\r
-      return FALSE;            /* Suspend, come back later */\r
-\r
-  }\r
-\r
-  /* Do final cleanup */\r
-\r
-  (*cinfo->src->term_source) (cinfo);\r
-\r
-  /* We can use jpeg_abort to release memory and reset global_state */\r
-\r
-  jpeg_abort((j_common_ptr) cinfo);\r
-\r
-  return TRUE;\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jdapistd.cpp b/libs/jpeg6/jdapistd.cpp
deleted file mode 100644 (file)
index 0718fb3..0000000
+++ /dev/null
@@ -1,550 +0,0 @@
-/*\r
-\r
- * jdapistd.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains application interface code for the decompression half\r
-\r
- * of the JPEG library.  These are the "standard" API routines that are\r
-\r
- * used in the normal full-decompression case.  They are not used by a\r
-\r
- * transcoding-only application.  Note that if an application links in\r
-\r
- * jpeg_start_decompress, it will end up linking in the entire decompressor.\r
-\r
- * We thus must separate this file from jdapimin.c to avoid linking the\r
-\r
- * whole decompression library into a transcoder.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/* Forward declarations */\r
-\r
-LOCAL boolean output_pass_setup JPP((j_decompress_ptr cinfo));\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Decompression initialization.\r
-\r
- * jpeg_read_header must be completed before calling this.\r
-\r
- *\r
-\r
- * If a multipass operating mode was selected, this will do all but the\r
-\r
- * last pass, and thus may take a great deal of time.\r
-\r
- *\r
-\r
- * Returns FALSE if suspended.  The return value need be inspected only if\r
-\r
- * a suspending data source is used.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL boolean\r
-\r
-jpeg_start_decompress (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  if (cinfo->global_state == DSTATE_READY) {\r
-\r
-    /* First call: initialize master control, select active modules */\r
-\r
-    jinit_master_decompress(cinfo);\r
-\r
-    if (cinfo->buffered_image) {\r
-\r
-      /* No more work here; expecting jpeg_start_output next */\r
-\r
-      cinfo->global_state = DSTATE_BUFIMAGE;\r
-\r
-      return TRUE;\r
-\r
-    }\r
-\r
-    cinfo->global_state = DSTATE_PRELOAD;\r
-\r
-  }\r
-\r
-  if (cinfo->global_state == DSTATE_PRELOAD) {\r
-\r
-    /* If file has multiple scans, absorb them all into the coef buffer */\r
-\r
-    if (cinfo->inputctl->has_multiple_scans) {\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-      for (;;) {\r
-\r
-       int retcode;\r
-\r
-       /* Call progress monitor hook if present */\r
-\r
-       if (cinfo->progress != NULL)\r
-\r
-         (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\r
-\r
-       /* Absorb some more input */\r
-\r
-       retcode = (*cinfo->inputctl->consume_input) (cinfo);\r
-\r
-       if (retcode == JPEG_SUSPENDED)\r
-\r
-         return FALSE;\r
-\r
-       if (retcode == JPEG_REACHED_EOI)\r
-\r
-         break;\r
-\r
-       /* Advance progress counter if appropriate */\r
-\r
-       if (cinfo->progress != NULL &&\r
-\r
-           (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {\r
-\r
-         if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {\r
-\r
-           /* jdmaster underestimated number of scans; ratchet up one scan */\r
-\r
-           cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;\r
-\r
-         }\r
-\r
-       }\r
-\r
-      }\r
-\r
-#else\r
-\r
-      ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-\r
-#endif /* D_MULTISCAN_FILES_SUPPORTED */\r
-\r
-    }\r
-\r
-    cinfo->output_scan_number = cinfo->input_scan_number;\r
-\r
-  } else if (cinfo->global_state != DSTATE_PRESCAN)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  /* Perform any dummy output passes, and set up for the final pass */\r
-\r
-  return output_pass_setup(cinfo);\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Set up for an output pass, and perform any dummy pass(es) needed.\r
-\r
- * Common subroutine for jpeg_start_decompress and jpeg_start_output.\r
-\r
- * Entry: global_state = DSTATE_PRESCAN only if previously suspended.\r
-\r
- * Exit: If done, returns TRUE and sets global_state for proper output mode.\r
-\r
- *       If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN.\r
-\r
- */\r
-\r
-\r
-\r
-LOCAL boolean\r
-\r
-output_pass_setup (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  if (cinfo->global_state != DSTATE_PRESCAN) {\r
-\r
-    /* First call: do pass setup */\r
-\r
-    (*cinfo->master->prepare_for_output_pass) (cinfo);\r
-\r
-    cinfo->output_scanline = 0;\r
-\r
-    cinfo->global_state = DSTATE_PRESCAN;\r
-\r
-  }\r
-\r
-  /* Loop over any required dummy passes */\r
-\r
-  while (cinfo->master->is_dummy_pass) {\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-    /* Crank through the dummy pass */\r
-\r
-    while (cinfo->output_scanline < cinfo->output_height) {\r
-\r
-      JDIMENSION last_scanline;\r
-\r
-      /* Call progress monitor hook if present */\r
-\r
-      if (cinfo->progress != NULL) {\r
-\r
-       cinfo->progress->pass_counter = (long) cinfo->output_scanline;\r
-\r
-       cinfo->progress->pass_limit = (long) cinfo->output_height;\r
-\r
-       (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\r
-\r
-      }\r
-\r
-      /* Process some data */\r
-\r
-      last_scanline = cinfo->output_scanline;\r
-\r
-      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,\r
-\r
-                                   &cinfo->output_scanline, (JDIMENSION) 0);\r
-\r
-      if (cinfo->output_scanline == last_scanline)\r
-\r
-       return FALSE;           /* No progress made, must suspend */\r
-\r
-    }\r
-\r
-    /* Finish up dummy pass, and set up for another one */\r
-\r
-    (*cinfo->master->finish_output_pass) (cinfo);\r
-\r
-    (*cinfo->master->prepare_for_output_pass) (cinfo);\r
-\r
-    cinfo->output_scanline = 0;\r
-\r
-#else\r
-\r
-    ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-\r
-#endif /* QUANT_2PASS_SUPPORTED */\r
-\r
-  }\r
-\r
-  /* Ready for application to drive output pass through\r
-\r
-   * jpeg_read_scanlines or jpeg_read_raw_data.\r
-\r
-   */\r
-\r
-  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;\r
-\r
-  return TRUE;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Read some scanlines of data from the JPEG decompressor.\r
-\r
- *\r
-\r
- * The return value will be the number of lines actually read.\r
-\r
- * This may be less than the number requested in several cases,\r
-\r
- * including bottom of image, data source suspension, and operating\r
-\r
- * modes that emit multiple scanlines at a time.\r
-\r
- *\r
-\r
- * Note: we warn about excess calls to jpeg_read_scanlines() since\r
-\r
- * this likely signals an application programmer error.  However,\r
-\r
- * an oversize buffer (max_lines > scanlines remaining) is not an error.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL JDIMENSION\r
-\r
-jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,\r
-\r
-                    JDIMENSION max_lines)\r
-\r
-{\r
-\r
-  JDIMENSION row_ctr;\r
-\r
-\r
-\r
-  if (cinfo->global_state != DSTATE_SCANNING)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  if (cinfo->output_scanline >= cinfo->output_height) {\r
-\r
-    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\r
-\r
-    return 0;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Call progress monitor hook if present */\r
-\r
-  if (cinfo->progress != NULL) {\r
-\r
-    cinfo->progress->pass_counter = (long) cinfo->output_scanline;\r
-\r
-    cinfo->progress->pass_limit = (long) cinfo->output_height;\r
-\r
-    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Process some data */\r
-\r
-  row_ctr = 0;\r
-\r
-  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);\r
-\r
-  cinfo->output_scanline += row_ctr;\r
-\r
-  return row_ctr;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Alternate entry point to read raw data.\r
-\r
- * Processes exactly one iMCU row per call, unless suspended.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL JDIMENSION\r
-\r
-jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,\r
-\r
-                   JDIMENSION max_lines)\r
-\r
-{\r
-\r
-  JDIMENSION lines_per_iMCU_row;\r
-\r
-\r
-\r
-  if (cinfo->global_state != DSTATE_RAW_OK)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  if (cinfo->output_scanline >= cinfo->output_height) {\r
-\r
-    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);\r
-\r
-    return 0;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Call progress monitor hook if present */\r
-\r
-  if (cinfo->progress != NULL) {\r
-\r
-    cinfo->progress->pass_counter = (long) cinfo->output_scanline;\r
-\r
-    cinfo->progress->pass_limit = (long) cinfo->output_height;\r
-\r
-    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Verify that at least one iMCU row can be returned. */\r
-\r
-  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;\r
-\r
-  if (max_lines < lines_per_iMCU_row)\r
-\r
-    ERREXIT(cinfo, JERR_BUFFER_SIZE);\r
-\r
-\r
-\r
-  /* Decompress directly into user's buffer. */\r
-\r
-  if (! (*cinfo->coef->decompress_data) (cinfo, data))\r
-\r
-    return 0;                  /* suspension forced, can do nothing more */\r
-\r
-\r
-\r
-  /* OK, we processed one iMCU row. */\r
-\r
-  cinfo->output_scanline += lines_per_iMCU_row;\r
-\r
-  return lines_per_iMCU_row;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/* Additional entry points for buffered-image mode. */\r
-\r
-\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize for an output pass in buffered-image mode.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL boolean\r
-\r
-jpeg_start_output (j_decompress_ptr cinfo, int scan_number)\r
-\r
-{\r
-\r
-  if (cinfo->global_state != DSTATE_BUFIMAGE &&\r
-\r
-      cinfo->global_state != DSTATE_PRESCAN)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  /* Limit scan number to valid range */\r
-\r
-  if (scan_number <= 0)\r
-\r
-    scan_number = 1;\r
-\r
-  if (cinfo->inputctl->eoi_reached &&\r
-\r
-      scan_number > cinfo->input_scan_number)\r
-\r
-    scan_number = cinfo->input_scan_number;\r
-\r
-  cinfo->output_scan_number = scan_number;\r
-\r
-  /* Perform any dummy output passes, and set up for the real pass */\r
-\r
-  return output_pass_setup(cinfo);\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Finish up after an output pass in buffered-image mode.\r
-\r
- *\r
-\r
- * Returns FALSE if suspended.  The return value need be inspected only if\r
-\r
- * a suspending data source is used.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL boolean\r
-\r
-jpeg_finish_output (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  if ((cinfo->global_state == DSTATE_SCANNING ||\r
-\r
-       cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {\r
-\r
-    /* Terminate this pass. */\r
-\r
-    /* We do not require the whole pass to have been completed. */\r
-\r
-    (*cinfo->master->finish_output_pass) (cinfo);\r
-\r
-    cinfo->global_state = DSTATE_BUFPOST;\r
-\r
-  } else if (cinfo->global_state != DSTATE_BUFPOST) {\r
-\r
-    /* BUFPOST = repeat call after a suspension, anything else is error */\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  }\r
-\r
-  /* Read markers looking for SOS or EOI */\r
-\r
-  while (cinfo->input_scan_number <= cinfo->output_scan_number &&\r
-\r
-        ! cinfo->inputctl->eoi_reached) {\r
-\r
-    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)\r
-\r
-      return FALSE;            /* Suspend, come back later */\r
-\r
-  }\r
-\r
-  cinfo->global_state = DSTATE_BUFIMAGE;\r
-\r
-  return TRUE;\r
-\r
-}\r
-\r
-\r
-\r
-#endif /* D_MULTISCAN_FILES_SUPPORTED */\r
-\r
diff --git a/libs/jpeg6/jdatasrc.cpp b/libs/jpeg6/jdatasrc.cpp
deleted file mode 100644 (file)
index ae95d21..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*\r
- * jdatasrc.c\r
- *\r
- * Copyright (C) 1994, Thomas G. Lane.\r
- * This file is part of the Independent JPEG Group's software.\r
- * For conditions of distribution and use, see the accompanying README file.\r
- *\r
- * This file contains decompression data source routines for the case of\r
- * reading JPEG data from a file (or any stdio stream).  While these routines\r
- * are sufficient for most applications, some will want to use a different\r
- * source manager.\r
- * IMPORTANT: we assume that fread() will correctly transcribe an array of\r
- * JOCTETs from 8-bit-wide elements on external storage.  If char is wider\r
- * than 8 bits on your machine, you may need to do some tweaking.\r
- */\r
-\r
-\r
-/* this is not a core library module, so it doesn't define JPEG_INTERNALS */\r
-#include "jinclude.h"\r
-#include "radiant_jpeglib.h"\r
-#include "jerror.h"\r
-\r
-//extern int leo_buf_size; // FIXME ? merged in from Alpha - replaced by my_source_mgr->src_size\r
-\r
-/* Expanded data source object for stdio input */\r
-\r
-typedef struct {\r
-  struct jpeg_source_mgr pub;  /* public fields */\r
-  int src_size; // FIXME ? merged from Alpha\r
-  unsigned char *infile;               /* source stream */\r
-  JOCTET * buffer;             /* start of buffer */\r
-  boolean start_of_file;       /* have we gotten any data yet? */\r
-} my_source_mgr;\r
-\r
-typedef my_source_mgr * my_src_ptr;\r
-\r
-#define INPUT_BUF_SIZE  4096   /* choose an efficiently fread'able size */\r
-\r
-\r
-/*\r
- * Initialize source --- called by jpeg_read_header\r
- * before any data is actually read.\r
- */\r
-\r
-METHODDEF void\r
-init_source (j_decompress_ptr cinfo)\r
-{\r
-  my_src_ptr src = (my_src_ptr) cinfo->src;\r
-\r
-  /* We reset the empty-input-file flag for each image,\r
-   * but we don't clear the input buffer.\r
-   * This is correct behavior for reading a series of images from one source.\r
-   */\r
-  src->start_of_file = TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Fill the input buffer --- called whenever buffer is emptied.\r
- *\r
- * In typical applications, this should read fresh data into the buffer\r
- * (ignoring the current state of next_input_byte & bytes_in_buffer),\r
- * reset the pointer & count to the start of the buffer, and return TRUE\r
- * indicating that the buffer has been reloaded.  It is not necessary to\r
- * fill the buffer entirely, only to obtain at least one more byte.\r
- *\r
- * There is no such thing as an EOF return.  If the end of the file has been\r
- * reached, the routine has a choice of ERREXIT() or inserting fake data into\r
- * the buffer.  In most cases, generating a warning message and inserting a\r
- * fake EOI marker is the best course of action --- this will allow the\r
- * decompressor to output however much of the image is there.  However,\r
- * the resulting error message is misleading if the real problem is an empty\r
- * input file, so we handle that case specially.\r
- *\r
- * In applications that need to be able to suspend compression due to input\r
- * not being available yet, a FALSE return indicates that no more data can be\r
- * obtained right now, but more may be forthcoming later.  In this situation,\r
- * the decompressor will return to its caller (with an indication of the\r
- * number of scanlines it has read, if any).  The application should resume\r
- * decompression after it has loaded more data into the input buffer.  Note\r
- * that there are substantial restrictions on the use of suspension --- see\r
- * the documentation.\r
- *\r
- * When suspending, the decompressor will back up to a convenient restart point\r
- * (typically the start of the current MCU). next_input_byte & bytes_in_buffer\r
- * indicate where the restart point will be if the current call returns FALSE.\r
- * Data beyond this point must be rescanned after resumption, so move it to\r
- * the front of the buffer rather than discarding it.\r
- */\r
-\r
-METHODDEF boolean\r
-// FIXME ? merged in from Alpha\r
-fill_input_buffer (j_decompress_ptr cinfo)\r
-{\r
-  my_src_ptr src = (my_src_ptr) cinfo->src;\r
-  size_t nbytes;\r
\r
-  if (src->src_size > INPUT_BUF_SIZE)\r
-    nbytes = INPUT_BUF_SIZE;\r
-  else\r
-    nbytes = src->src_size;\r
-\r
-  memcpy (src->buffer, src->infile, nbytes);\r
-\r
-  src->infile += nbytes;\r
-  src->src_size -= nbytes;\r
-\r
-  src->pub.next_input_byte = src->buffer;\r
-  src->pub.bytes_in_buffer = nbytes;\r
-  src->start_of_file = FALSE;\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Skip data --- used to skip over a potentially large amount of\r
- * uninteresting data (such as an APPn marker).\r
- *\r
- * Writers of suspendable-input applications must note that skip_input_data\r
- * is not granted the right to give a suspension return.  If the skip extends\r
- * beyond the data currently in the buffer, the buffer can be marked empty so\r
- * that the next read will cause a fill_input_buffer call that can suspend.\r
- * Arranging for additional bytes to be discarded before reloading the input\r
- * buffer is the application writer's problem.\r
- */\r
-\r
-METHODDEF void\r
-skip_input_data (j_decompress_ptr cinfo, long num_bytes)\r
-{\r
-  my_src_ptr src = (my_src_ptr) cinfo->src;\r
-\r
-  /* Just a dumb implementation for now.  Could use fseek() except\r
-   * it doesn't work on pipes.  Not clear that being smart is worth\r
-   * any trouble anyway --- large skips are infrequent.\r
-   */\r
-  if (num_bytes > 0) {\r
-    while (num_bytes > (long) src->pub.bytes_in_buffer) {\r
-      num_bytes -= (long) src->pub.bytes_in_buffer;\r
-      (void) fill_input_buffer(cinfo);\r
-      /* note we assume that fill_input_buffer will never return FALSE,\r
-       * so suspension need not be handled.\r
-       */\r
-    }\r
-    src->pub.next_input_byte += (size_t) num_bytes;\r
-    src->pub.bytes_in_buffer -= (size_t) num_bytes;\r
-  }\r
-}\r
-\r
-\r
-/*\r
- * An additional method that can be provided by data source modules is the\r
- * resync_to_restart method for error recovery in the presence of RST markers.\r
- * For the moment, this source module just uses the default resync method\r
- * provided by the JPEG library.  That method assumes that no backtracking\r
- * is possible.\r
- */\r
-\r
-\r
-/*\r
- * Terminate source --- called by jpeg_finish_decompress\r
- * after all data has been read.  Often a no-op.\r
- *\r
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding\r
- * application must deal with any cleanup that should happen even\r
- * for error exit.\r
- */\r
-\r
-METHODDEF void\r
-term_source (j_decompress_ptr cinfo)\r
-{\r
-  /* no work necessary here */\r
-}\r
-\r
-\r
-/*\r
- * Prepare for input from a stdio stream.\r
- * The caller must have already opened the stream, and is responsible\r
- * for closing it after finishing decompression.\r
- */\r
-\r
-GLOBAL void\r
-jpeg_stdio_src (j_decompress_ptr cinfo, unsigned char *infile, int bufsize)\r
-{\r
-  my_src_ptr src;\r
-\r
-  /* The source object and input buffer are made permanent so that a series\r
-   * of JPEG images can be read from the same file by calling jpeg_stdio_src\r
-   * only before the first one.  (If we discarded the buffer at the end of\r
-   * one image, we'd likely lose the start of the next one.)\r
-   * This makes it unsafe to use this manager and a different source\r
-   * manager serially with the same JPEG object.  Caveat programmer.\r
-   */\r
-  if (cinfo->src == NULL) {    /* first time for this JPEG object? */\r
-    cinfo->src = (struct jpeg_source_mgr *)\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\r
-                                 SIZEOF(my_source_mgr));\r
-    src = (my_src_ptr) cinfo->src;\r
-    src->buffer = (JOCTET *)\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\r
-                                 INPUT_BUF_SIZE * SIZEOF(JOCTET));\r
-  }\r
-\r
-  src = (my_src_ptr) cinfo->src;\r
-  src->pub.init_source = init_source;\r
-  src->pub.fill_input_buffer = fill_input_buffer;\r
-  src->pub.skip_input_data = skip_input_data;\r
-  src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */\r
-  src->pub.term_source = term_source;\r
-  src->infile = infile;\r
-  src->src_size = bufsize; // FIXME ? merged from Alpha\r
-  src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */\r
-  src->pub.next_input_byte = NULL; /* until buffer loaded */\r
-}\r
-\r
diff --git a/libs/jpeg6/jdcoefct.cpp b/libs/jpeg6/jdcoefct.cpp
deleted file mode 100644 (file)
index f9a1f7e..0000000
+++ /dev/null
@@ -1,1450 +0,0 @@
-/*\r
-\r
- * jdcoefct.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains the coefficient buffer controller for decompression.\r
-\r
- * This controller is the top level of the JPEG decompressor proper.\r
-\r
- * The coefficient buffer lies between entropy decoding and inverse-DCT steps.\r
-\r
- *\r
-\r
- * In buffered-image mode, this controller is the interface between\r
-\r
- * input-oriented processing and output-oriented processing.\r
-\r
- * Also, the input side (only) is used when reading a file for transcoding.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-/* Block smoothing is only applicable for progressive JPEG, so: */\r
-\r
-#ifndef D_PROGRESSIVE_SUPPORTED\r
-\r
-#undef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-#endif\r
-\r
-\r
-\r
-/* Private buffer controller object */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  struct jpeg_d_coef_controller pub; /* public fields */\r
-\r
-\r
-\r
-  /* These variables keep track of the current location of the input side. */\r
-\r
-  /* cinfo->input_iMCU_row is also used for this. */\r
-\r
-  JDIMENSION MCU_ctr;          /* counts MCUs processed in current row */\r
-\r
-  int MCU_vert_offset;         /* counts MCU rows within iMCU row */\r
-\r
-  int MCU_rows_per_iMCU_row;   /* number of such rows needed */\r
-\r
-\r
-\r
-  /* The output side's location is represented by cinfo->output_iMCU_row. */\r
-\r
-\r
-\r
-  /* In single-pass modes, it's sufficient to buffer just one MCU.\r
-\r
-   * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,\r
-\r
-   * and let the entropy decoder write into that workspace each time.\r
-\r
-   * (On 80x86, the workspace is FAR even though it's not really very big;\r
-\r
-   * this is to keep the module interfaces unchanged when a large coefficient\r
-\r
-   * buffer is necessary.)\r
-\r
-   * In multi-pass modes, this array points to the current MCU's blocks\r
-\r
-   * within the virtual arrays; it is used only by the input side.\r
-\r
-   */\r
-\r
-  JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];\r
-\r
-\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-  /* In multi-pass modes, we need a virtual block array for each component. */\r
-\r
-  jvirt_barray_ptr whole_image[MAX_COMPONENTS];\r
-\r
-#endif\r
-\r
-\r
-\r
-#ifdef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-  /* When doing block smoothing, we latch coefficient Al values here */\r
-\r
-  int * coef_bits_latch;\r
-\r
-#define SAVED_COEFS  6         /* we save coef_bits[0..5] */\r
-\r
-#endif\r
-\r
-} my_coef_controller;\r
-\r
-\r
-\r
-typedef my_coef_controller * my_coef_ptr;\r
-\r
-\r
-\r
-/* Forward declarations */\r
-\r
-METHODDEF int decompress_onepass\r
-\r
-       JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-METHODDEF int decompress_data\r
-\r
-       JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\r
-\r
-#endif\r
-\r
-#ifdef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-LOCAL boolean smoothing_ok JPP((j_decompress_ptr cinfo));\r
-\r
-METHODDEF int decompress_smooth_data\r
-\r
-       JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));\r
-\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-start_iMCU_row (j_decompress_ptr cinfo)\r
-\r
-/* Reset within-iMCU-row counters for a new row (input side) */\r
-\r
-{\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-\r
-\r
-  /* In an interleaved scan, an MCU row is the same as an iMCU row.\r
-\r
-   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.\r
-\r
-   * But at the bottom of the image, process only what's left.\r
-\r
-   */\r
-\r
-  if (cinfo->comps_in_scan > 1) {\r
-\r
-    coef->MCU_rows_per_iMCU_row = 1;\r
-\r
-  } else {\r
-\r
-    if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))\r
-\r
-      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;\r
-\r
-    else\r
-\r
-      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;\r
-\r
-  }\r
-\r
-\r
-\r
-  coef->MCU_ctr = 0;\r
-\r
-  coef->MCU_vert_offset = 0;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize for an input processing pass.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_input_pass (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  cinfo->input_iMCU_row = 0;\r
-\r
-  start_iMCU_row(cinfo);\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize for an output processing pass.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_output_pass (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-#ifdef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-\r
-\r
-  /* If multipass, check to see whether to use block smoothing on this pass */\r
-\r
-  if (coef->pub.coef_arrays != NULL) {\r
-\r
-    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))\r
-\r
-      coef->pub.decompress_data = decompress_smooth_data;\r
-\r
-    else\r
-\r
-      coef->pub.decompress_data = decompress_data;\r
-\r
-  }\r
-\r
-#endif\r
-\r
-  cinfo->output_iMCU_row = 0;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Decompress and return some data in the single-pass case.\r
-\r
- * Always attempts to emit one fully interleaved MCU row ("iMCU" row).\r
-\r
- * Input and output must run in lockstep since we have only a one-MCU buffer.\r
-\r
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\r
-\r
- *\r
-\r
- * NB: output_buf contains a plane for each component in image.\r
-\r
- * For single pass, this is the same as the components in the scan.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF int\r
-\r
-decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\r
-\r
-{\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-  JDIMENSION MCU_col_num;      /* index of current MCU within row */\r
-\r
-  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;\r
-\r
-  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\r
-\r
-  int blkn, ci, xindex, yindex, yoffset, useful_width;\r
-\r
-  JSAMPARRAY output_ptr;\r
-\r
-  JDIMENSION start_col, output_col;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  inverse_DCT_method_ptr inverse_DCT;\r
-\r
-\r
-\r
-  /* Loop to process as much as one whole iMCU row */\r
-\r
-  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\r
-\r
-       yoffset++) {\r
-\r
-    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;\r
-\r
-        MCU_col_num++) {\r
-\r
-      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */\r
-\r
-      jzero_far((void FAR *) coef->MCU_buffer[0],\r
-\r
-               (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));\r
-\r
-      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {\r
-\r
-       /* Suspension forced; update state counters and exit */\r
-\r
-       coef->MCU_vert_offset = yoffset;\r
-\r
-       coef->MCU_ctr = MCU_col_num;\r
-\r
-       return JPEG_SUSPENDED;\r
-\r
-      }\r
-\r
-      /* Determine where data should go in output_buf and do the IDCT thing.\r
-\r
-       * We skip dummy blocks at the right and bottom edges (but blkn gets\r
-\r
-       * incremented past them!).  Note the inner loop relies on having\r
-\r
-       * allocated the MCU_buffer[] blocks sequentially.\r
-\r
-       */\r
-\r
-      blkn = 0;                        /* index of current DCT block within MCU */\r
-\r
-      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\r
-\r
-       compptr = cinfo->cur_comp_info[ci];\r
-\r
-       /* Don't bother to IDCT an uninteresting component. */\r
-\r
-       if (! compptr->component_needed) {\r
-\r
-         blkn += compptr->MCU_blocks;\r
-\r
-         continue;\r
-\r
-       }\r
-\r
-       inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];\r
-\r
-       useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width\r
-\r
-                                                   : compptr->last_col_width;\r
-\r
-       output_ptr = output_buf[ci] + yoffset * compptr->DCT_scaled_size;\r
-\r
-       start_col = MCU_col_num * compptr->MCU_sample_width;\r
-\r
-       for (yindex = 0; yindex < compptr->MCU_height; yindex++) {\r
-\r
-         if (cinfo->input_iMCU_row < last_iMCU_row ||\r
-\r
-             yoffset+yindex < compptr->last_row_height) {\r
-\r
-           output_col = start_col;\r
-\r
-           for (xindex = 0; xindex < useful_width; xindex++) {\r
-\r
-             (*inverse_DCT) (cinfo, compptr,\r
-\r
-                             (JCOEFPTR) coef->MCU_buffer[blkn+xindex],\r
-\r
-                             output_ptr, output_col);\r
-\r
-             output_col += compptr->DCT_scaled_size;\r
-\r
-           }\r
-\r
-         }\r
-\r
-         blkn += compptr->MCU_width;\r
-\r
-         output_ptr += compptr->DCT_scaled_size;\r
-\r
-       }\r
-\r
-      }\r
-\r
-    }\r
-\r
-    /* Completed an MCU row, but perhaps not an iMCU row */\r
-\r
-    coef->MCU_ctr = 0;\r
-\r
-  }\r
-\r
-  /* Completed the iMCU row, advance counters for next one */\r
-\r
-  cinfo->output_iMCU_row++;\r
-\r
-  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {\r
-\r
-    start_iMCU_row(cinfo);\r
-\r
-    return JPEG_ROW_COMPLETED;\r
-\r
-  }\r
-\r
-  /* Completed the scan */\r
-\r
-  (*cinfo->inputctl->finish_input_pass) (cinfo);\r
-\r
-  return JPEG_SCAN_COMPLETED;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Dummy consume-input routine for single-pass operation.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF int\r
-\r
-dummy_consume_data (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  return JPEG_SUSPENDED;       /* Always indicate nothing was done */\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-\r
-\r
-/*\r
-\r
- * Consume input data and store it in the full-image coefficient buffer.\r
-\r
- * We read as much as one fully interleaved MCU row ("iMCU" row) per call,\r
-\r
- * ie, v_samp_factor block rows for each component in the scan.\r
-\r
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF int\r
-\r
-consume_data (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-  JDIMENSION MCU_col_num;      /* index of current MCU within row */\r
-\r
-  int blkn, ci, xindex, yindex, yoffset;\r
-\r
-  JDIMENSION start_col;\r
-\r
-  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];\r
-\r
-  JBLOCKROW buffer_ptr;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-\r
-\r
-  /* Align the virtual buffers for the components used in this scan. */\r
-\r
-  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\r
-\r
-    compptr = cinfo->cur_comp_info[ci];\r
-\r
-    buffer[ci] = (*cinfo->mem->access_virt_barray)\r
-\r
-      ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],\r
-\r
-       cinfo->input_iMCU_row * compptr->v_samp_factor,\r
-\r
-       (JDIMENSION) compptr->v_samp_factor, TRUE);\r
-\r
-    /* Note: entropy decoder expects buffer to be zeroed,\r
-\r
-     * but this is handled automatically by the memory manager\r
-\r
-     * because we requested a pre-zeroed array.\r
-\r
-     */\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Loop to process one whole iMCU row */\r
-\r
-  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;\r
-\r
-       yoffset++) {\r
-\r
-    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;\r
-\r
-        MCU_col_num++) {\r
-\r
-      /* Construct list of pointers to DCT blocks belonging to this MCU */\r
-\r
-      blkn = 0;                        /* index of current DCT block within MCU */\r
-\r
-      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\r
-\r
-       compptr = cinfo->cur_comp_info[ci];\r
-\r
-       start_col = MCU_col_num * compptr->MCU_width;\r
-\r
-       for (yindex = 0; yindex < compptr->MCU_height; yindex++) {\r
-\r
-         buffer_ptr = buffer[ci][yindex+yoffset] + start_col;\r
-\r
-         for (xindex = 0; xindex < compptr->MCU_width; xindex++) {\r
-\r
-           coef->MCU_buffer[blkn++] = buffer_ptr++;\r
-\r
-         }\r
-\r
-       }\r
-\r
-      }\r
-\r
-      /* Try to fetch the MCU. */\r
-\r
-      if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {\r
-\r
-       /* Suspension forced; update state counters and exit */\r
-\r
-       coef->MCU_vert_offset = yoffset;\r
-\r
-       coef->MCU_ctr = MCU_col_num;\r
-\r
-       return JPEG_SUSPENDED;\r
-\r
-      }\r
-\r
-    }\r
-\r
-    /* Completed an MCU row, but perhaps not an iMCU row */\r
-\r
-    coef->MCU_ctr = 0;\r
-\r
-  }\r
-\r
-  /* Completed the iMCU row, advance counters for next one */\r
-\r
-  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {\r
-\r
-    start_iMCU_row(cinfo);\r
-\r
-    return JPEG_ROW_COMPLETED;\r
-\r
-  }\r
-\r
-  /* Completed the scan */\r
-\r
-  (*cinfo->inputctl->finish_input_pass) (cinfo);\r
-\r
-  return JPEG_SCAN_COMPLETED;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Decompress and return some data in the multi-pass case.\r
-\r
- * Always attempts to emit one fully interleaved MCU row ("iMCU" row).\r
-\r
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.\r
-\r
- *\r
-\r
- * NB: output_buf contains a plane for each component in image.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF int\r
-\r
-decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\r
-\r
-{\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\r
-\r
-  JDIMENSION block_num;\r
-\r
-  int ci, block_row, block_rows;\r
-\r
-  JBLOCKARRAY buffer;\r
-\r
-  JBLOCKROW buffer_ptr;\r
-\r
-  JSAMPARRAY output_ptr;\r
-\r
-  JDIMENSION output_col;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  inverse_DCT_method_ptr inverse_DCT;\r
-\r
-\r
-\r
-  /* Force some input to be done if we are getting ahead of the input. */\r
-\r
-  while (cinfo->input_scan_number < cinfo->output_scan_number ||\r
-\r
-        (cinfo->input_scan_number == cinfo->output_scan_number &&\r
-\r
-         cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {\r
-\r
-    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)\r
-\r
-      return JPEG_SUSPENDED;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* OK, output from the virtual arrays. */\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    /* Don't bother to IDCT an uninteresting component. */\r
-\r
-    if (! compptr->component_needed)\r
-\r
-      continue;\r
-\r
-    /* Align the virtual buffer for this component. */\r
-\r
-    buffer = (*cinfo->mem->access_virt_barray)\r
-\r
-      ((j_common_ptr) cinfo, coef->whole_image[ci],\r
-\r
-       cinfo->output_iMCU_row * compptr->v_samp_factor,\r
-\r
-       (JDIMENSION) compptr->v_samp_factor, FALSE);\r
-\r
-    /* Count non-dummy DCT block rows in this iMCU row. */\r
-\r
-    if (cinfo->output_iMCU_row < last_iMCU_row)\r
-\r
-      block_rows = compptr->v_samp_factor;\r
-\r
-    else {\r
-\r
-      /* NB: can't use last_row_height here; it is input-side-dependent! */\r
-\r
-      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\r
-\r
-      if (block_rows == 0) block_rows = compptr->v_samp_factor;\r
-\r
-    }\r
-\r
-    inverse_DCT = cinfo->idct->inverse_DCT[ci];\r
-\r
-    output_ptr = output_buf[ci];\r
-\r
-    /* Loop over all DCT blocks to be processed. */\r
-\r
-    for (block_row = 0; block_row < block_rows; block_row++) {\r
-\r
-      buffer_ptr = buffer[block_row];\r
-\r
-      output_col = 0;\r
-\r
-      for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {\r
-\r
-       (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,\r
-\r
-                       output_ptr, output_col);\r
-\r
-       buffer_ptr++;\r
-\r
-       output_col += compptr->DCT_scaled_size;\r
-\r
-      }\r
-\r
-      output_ptr += compptr->DCT_scaled_size;\r
-\r
-    }\r
-\r
-  }\r
-\r
-\r
-\r
-  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)\r
-\r
-    return JPEG_ROW_COMPLETED;\r
-\r
-  return JPEG_SCAN_COMPLETED;\r
-\r
-}\r
-\r
-\r
-\r
-#endif /* D_MULTISCAN_FILES_SUPPORTED */\r
-\r
-\r
-\r
-\r
-\r
-#ifdef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-\r
-\r
-/*\r
-\r
- * This code applies interblock smoothing as described by section K.8\r
-\r
- * of the JPEG standard: the first 5 AC coefficients are estimated from\r
-\r
- * the DC values of a DCT block and its 8 neighboring blocks.\r
-\r
- * We apply smoothing only for progressive JPEG decoding, and only if\r
-\r
- * the coefficients it can estimate are not yet known to full precision.\r
-\r
- */\r
-\r
-\r
-\r
-/*\r
-\r
- * Determine whether block smoothing is applicable and safe.\r
-\r
- * We also latch the current states of the coef_bits[] entries for the\r
-\r
- * AC coefficients; otherwise, if the input side of the decompressor\r
-\r
- * advances into a new scan, we might think the coefficients are known\r
-\r
- * more accurately than they really are.\r
-\r
- */\r
-\r
-\r
-\r
-LOCAL boolean\r
-\r
-smoothing_ok (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-  boolean smoothing_useful = FALSE;\r
-\r
-  int ci, coefi;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  JQUANT_TBL * qtable;\r
-\r
-  int * coef_bits;\r
-\r
-  int * coef_bits_latch;\r
-\r
-\r
-\r
-  if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)\r
-\r
-    return FALSE;\r
-\r
-\r
-\r
-  /* Allocate latch area if not already done */\r
-\r
-  if (coef->coef_bits_latch == NULL)\r
-\r
-    coef->coef_bits_latch = (int *)\r
-\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                                 cinfo->num_components *\r
-\r
-                                 (SAVED_COEFS * SIZEOF(int)));\r
-\r
-  coef_bits_latch = coef->coef_bits_latch;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    /* All components' quantization values must already be latched. */\r
-\r
-    if ((qtable = compptr->quant_table) == NULL)\r
-\r
-      return FALSE;\r
-\r
-    /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */\r
-\r
-    for (coefi = 0; coefi <= 5; coefi++) {\r
-\r
-      if (qtable->quantval[coefi] == 0)\r
-\r
-       return FALSE;\r
-\r
-    }\r
-\r
-    /* DC values must be at least partly known for all components. */\r
-\r
-    coef_bits = cinfo->coef_bits[ci];\r
-\r
-    if (coef_bits[0] < 0)\r
-\r
-      return FALSE;\r
-\r
-    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */\r
-\r
-    for (coefi = 1; coefi <= 5; coefi++) {\r
-\r
-      coef_bits_latch[coefi] = coef_bits[coefi];\r
-\r
-      if (coef_bits[coefi] != 0)\r
-\r
-       smoothing_useful = TRUE;\r
-\r
-    }\r
-\r
-    coef_bits_latch += SAVED_COEFS;\r
-\r
-  }\r
-\r
-\r
-\r
-  return smoothing_useful;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Variant of decompress_data for use when doing block smoothing.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF int\r
-\r
-decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)\r
-\r
-{\r
-\r
-  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;\r
-\r
-  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;\r
-\r
-  JDIMENSION block_num, last_block_column;\r
-\r
-  int ci, block_row, block_rows, access_rows;\r
-\r
-  JBLOCKARRAY buffer;\r
-\r
-  JBLOCKROW buffer_ptr, prev_block_row, next_block_row;\r
-\r
-  JSAMPARRAY output_ptr;\r
-\r
-  JDIMENSION output_col;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  inverse_DCT_method_ptr inverse_DCT;\r
-\r
-  boolean first_row, last_row;\r
-\r
-  JBLOCK workspace;\r
-\r
-  int *coef_bits;\r
-\r
-  JQUANT_TBL *quanttbl;\r
-\r
-  INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;\r
-\r
-  int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;\r
-\r
-  int Al, pred;\r
-\r
-\r
-\r
-  /* Force some input to be done if we are getting ahead of the input. */\r
-\r
-  while (cinfo->input_scan_number <= cinfo->output_scan_number &&\r
-\r
-        ! cinfo->inputctl->eoi_reached) {\r
-\r
-    if (cinfo->input_scan_number == cinfo->output_scan_number) {\r
-\r
-      /* If input is working on current scan, we ordinarily want it to\r
-\r
-       * have completed the current row.  But if input scan is DC,\r
-\r
-       * we want it to keep one row ahead so that next block row's DC\r
-\r
-       * values are up to date.\r
-\r
-       */\r
-\r
-      JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;\r
-\r
-      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)\r
-\r
-       break;\r
-\r
-    }\r
-\r
-    if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)\r
-\r
-      return JPEG_SUSPENDED;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* OK, output from the virtual arrays. */\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    /* Don't bother to IDCT an uninteresting component. */\r
-\r
-    if (! compptr->component_needed)\r
-\r
-      continue;\r
-\r
-    /* Count non-dummy DCT block rows in this iMCU row. */\r
-\r
-    if (cinfo->output_iMCU_row < last_iMCU_row) {\r
-\r
-      block_rows = compptr->v_samp_factor;\r
-\r
-      access_rows = block_rows * 2; /* this and next iMCU row */\r
-\r
-      last_row = FALSE;\r
-\r
-    } else {\r
-\r
-      /* NB: can't use last_row_height here; it is input-side-dependent! */\r
-\r
-      block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\r
-\r
-      if (block_rows == 0) block_rows = compptr->v_samp_factor;\r
-\r
-      access_rows = block_rows; /* this iMCU row only */\r
-\r
-      last_row = TRUE;\r
-\r
-    }\r
-\r
-    /* Align the virtual buffer for this component. */\r
-\r
-    if (cinfo->output_iMCU_row > 0) {\r
-\r
-      access_rows += compptr->v_samp_factor; /* prior iMCU row too */\r
-\r
-      buffer = (*cinfo->mem->access_virt_barray)\r
-\r
-       ((j_common_ptr) cinfo, coef->whole_image[ci],\r
-\r
-        (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,\r
-\r
-        (JDIMENSION) access_rows, FALSE);\r
-\r
-      buffer += compptr->v_samp_factor;        /* point to current iMCU row */\r
-\r
-      first_row = FALSE;\r
-\r
-    } else {\r
-\r
-      buffer = (*cinfo->mem->access_virt_barray)\r
-\r
-       ((j_common_ptr) cinfo, coef->whole_image[ci],\r
-\r
-        (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);\r
-\r
-      first_row = TRUE;\r
-\r
-    }\r
-\r
-    /* Fetch component-dependent info */\r
-\r
-    coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);\r
-\r
-    quanttbl = compptr->quant_table;\r
-\r
-    Q00 = quanttbl->quantval[0];\r
-\r
-    Q01 = quanttbl->quantval[1];\r
-\r
-    Q10 = quanttbl->quantval[2];\r
-\r
-    Q20 = quanttbl->quantval[3];\r
-\r
-    Q11 = quanttbl->quantval[4];\r
-\r
-    Q02 = quanttbl->quantval[5];\r
-\r
-    inverse_DCT = cinfo->idct->inverse_DCT[ci];\r
-\r
-    output_ptr = output_buf[ci];\r
-\r
-    /* Loop over all DCT blocks to be processed. */\r
-\r
-    for (block_row = 0; block_row < block_rows; block_row++) {\r
-\r
-      buffer_ptr = buffer[block_row];\r
-\r
-      if (first_row && block_row == 0)\r
-\r
-       prev_block_row = buffer_ptr;\r
-\r
-      else\r
-\r
-       prev_block_row = buffer[block_row-1];\r
-\r
-      if (last_row && block_row == block_rows-1)\r
-\r
-       next_block_row = buffer_ptr;\r
-\r
-      else\r
-\r
-       next_block_row = buffer[block_row+1];\r
-\r
-      /* We fetch the surrounding DC values using a sliding-register approach.\r
-\r
-       * Initialize all nine here so as to do the right thing on narrow pics.\r
-\r
-       */\r
-\r
-      DC1 = DC2 = DC3 = (int) prev_block_row[0][0];\r
-\r
-      DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];\r
-\r
-      DC7 = DC8 = DC9 = (int) next_block_row[0][0];\r
-\r
-      output_col = 0;\r
-\r
-      last_block_column = compptr->width_in_blocks - 1;\r
-\r
-      for (block_num = 0; block_num <= last_block_column; block_num++) {\r
-\r
-       /* Fetch current DCT block into workspace so we can modify it. */\r
-\r
-       jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);\r
-\r
-       /* Update DC values */\r
-\r
-       if (block_num < last_block_column) {\r
-\r
-         DC3 = (int) prev_block_row[1][0];\r
-\r
-         DC6 = (int) buffer_ptr[1][0];\r
-\r
-         DC9 = (int) next_block_row[1][0];\r
-\r
-       }\r
-\r
-       /* Compute coefficient estimates per K.8.\r
-\r
-        * An estimate is applied only if coefficient is still zero,\r
-\r
-        * and is not known to be fully accurate.\r
-\r
-        */\r
-\r
-       /* AC01 */\r
-\r
-       if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {\r
-\r
-         num = 36 * Q00 * (DC4 - DC6);\r
-\r
-         if (num >= 0) {\r
-\r
-           pred = (int) (((Q01<<7) + num) / (Q01<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-         } else {\r
-\r
-           pred = (int) (((Q01<<7) - num) / (Q01<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-           pred = -pred;\r
-\r
-         }\r
-\r
-         workspace[1] = (JCOEF) pred;\r
-\r
-       }\r
-\r
-       /* AC10 */\r
-\r
-       if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {\r
-\r
-         num = 36 * Q00 * (DC2 - DC8);\r
-\r
-         if (num >= 0) {\r
-\r
-           pred = (int) (((Q10<<7) + num) / (Q10<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-         } else {\r
-\r
-           pred = (int) (((Q10<<7) - num) / (Q10<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-           pred = -pred;\r
-\r
-         }\r
-\r
-         workspace[8] = (JCOEF) pred;\r
-\r
-       }\r
-\r
-       /* AC20 */\r
-\r
-       if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {\r
-\r
-         num = 9 * Q00 * (DC2 + DC8 - 2*DC5);\r
-\r
-         if (num >= 0) {\r
-\r
-           pred = (int) (((Q20<<7) + num) / (Q20<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-         } else {\r
-\r
-           pred = (int) (((Q20<<7) - num) / (Q20<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-           pred = -pred;\r
-\r
-         }\r
-\r
-         workspace[16] = (JCOEF) pred;\r
-\r
-       }\r
-\r
-       /* AC11 */\r
-\r
-       if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {\r
-\r
-         num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);\r
-\r
-         if (num >= 0) {\r
-\r
-           pred = (int) (((Q11<<7) + num) / (Q11<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-         } else {\r
-\r
-           pred = (int) (((Q11<<7) - num) / (Q11<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-           pred = -pred;\r
-\r
-         }\r
-\r
-         workspace[9] = (JCOEF) pred;\r
-\r
-       }\r
-\r
-       /* AC02 */\r
-\r
-       if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {\r
-\r
-         num = 9 * Q00 * (DC4 + DC6 - 2*DC5);\r
-\r
-         if (num >= 0) {\r
-\r
-           pred = (int) (((Q02<<7) + num) / (Q02<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-         } else {\r
-\r
-           pred = (int) (((Q02<<7) - num) / (Q02<<8));\r
-\r
-           if (Al > 0 && pred >= (1<<Al))\r
-\r
-             pred = (1<<Al)-1;\r
-\r
-           pred = -pred;\r
-\r
-         }\r
-\r
-         workspace[2] = (JCOEF) pred;\r
-\r
-       }\r
-\r
-       /* OK, do the IDCT */\r
-\r
-       (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,\r
-\r
-                       output_ptr, output_col);\r
-\r
-       /* Advance for next column */\r
-\r
-       DC1 = DC2; DC2 = DC3;\r
-\r
-       DC4 = DC5; DC5 = DC6;\r
-\r
-       DC7 = DC8; DC8 = DC9;\r
-\r
-       buffer_ptr++, prev_block_row++, next_block_row++;\r
-\r
-       output_col += compptr->DCT_scaled_size;\r
-\r
-      }\r
-\r
-      output_ptr += compptr->DCT_scaled_size;\r
-\r
-    }\r
-\r
-  }\r
-\r
-\r
-\r
-  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)\r
-\r
-    return JPEG_ROW_COMPLETED;\r
-\r
-  return JPEG_SCAN_COMPLETED;\r
-\r
-}\r
-\r
-\r
-\r
-#endif /* BLOCK_SMOOTHING_SUPPORTED */\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize coefficient buffer controller.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\r
-\r
-{\r
-\r
-  my_coef_ptr coef;\r
-\r
-\r
-\r
-  coef = (my_coef_ptr)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               SIZEOF(my_coef_controller));\r
-\r
-  cinfo->coef = (struct jpeg_d_coef_controller *) coef;\r
-\r
-  coef->pub.start_input_pass = start_input_pass;\r
-\r
-  coef->pub.start_output_pass = start_output_pass;\r
-\r
-#ifdef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-  coef->coef_bits_latch = NULL;\r
-\r
-#endif\r
-\r
-\r
-\r
-  /* Create the coefficient buffer. */\r
-\r
-  if (need_full_buffer) {\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-    /* Allocate a full-image virtual array for each component, */\r
-\r
-    /* padded to a multiple of samp_factor DCT blocks in each direction. */\r
-\r
-    /* Note we ask for a pre-zeroed array. */\r
-\r
-    int ci, access_rows;\r
-\r
-    jpeg_component_info *compptr;\r
-\r
-\r
-\r
-    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-        ci++, compptr++) {\r
-\r
-      access_rows = compptr->v_samp_factor;\r
-\r
-#ifdef BLOCK_SMOOTHING_SUPPORTED\r
-\r
-      /* If block smoothing could be used, need a bigger window */\r
-\r
-      if (cinfo->progressive_mode)\r
-\r
-       access_rows *= 3;\r
-\r
-#endif\r
-\r
-      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)\r
-\r
-       ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,\r
-\r
-        (JDIMENSION) jround_up((long) compptr->width_in_blocks,\r
-\r
-                               (long) compptr->h_samp_factor),\r
-\r
-        (JDIMENSION) jround_up((long) compptr->height_in_blocks,\r
-\r
-                               (long) compptr->v_samp_factor),\r
-\r
-        (JDIMENSION) access_rows);\r
-\r
-    }\r
-\r
-    coef->pub.consume_data = consume_data;\r
-\r
-    coef->pub.decompress_data = decompress_data;\r
-\r
-    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */\r
-\r
-#else\r
-\r
-    ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-\r
-#endif\r
-\r
-  } else {\r
-\r
-    /* We only need a single-MCU buffer. */\r
-\r
-    JBLOCKROW buffer;\r
-\r
-    int i;\r
-\r
-\r
-\r
-    buffer = (JBLOCKROW)\r
-\r
-      (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                                 D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));\r
-\r
-    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {\r
-\r
-      coef->MCU_buffer[i] = buffer + i;\r
-\r
-    }\r
-\r
-    coef->pub.consume_data = dummy_consume_data;\r
-\r
-    coef->pub.decompress_data = decompress_onepass;\r
-\r
-    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */\r
-\r
-  }\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jdcolor.cpp b/libs/jpeg6/jdcolor.cpp
deleted file mode 100644 (file)
index 5c17359..0000000
+++ /dev/null
@@ -1,734 +0,0 @@
-/*\r
-\r
- * jdcolor.c\r
-\r
- *\r
-\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains output colorspace conversion routines.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/* Private subobject */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  struct jpeg_color_deconverter pub; /* public fields */\r
-\r
-\r
-\r
-  /* Private state for YCC->RGB conversion */\r
-\r
-  int * Cr_r_tab;              /* => table for Cr to R conversion */\r
-\r
-  int * Cb_b_tab;              /* => table for Cb to B conversion */\r
-\r
-  INT32 * Cr_g_tab;            /* => table for Cr to G conversion */\r
-\r
-  INT32 * Cb_g_tab;            /* => table for Cb to G conversion */\r
-\r
-} my_color_deconverter;\r
-\r
-\r
-\r
-typedef my_color_deconverter * my_cconvert_ptr;\r
-\r
-\r
-\r
-\r
-\r
-/**************** YCbCr -> RGB conversion: most common case **************/\r
-\r
-\r
-\r
-/*\r
-\r
- * YCbCr is defined per CCIR 601-1, except that Cb and Cr are\r
-\r
- * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.\r
-\r
- * The conversion equations to be implemented are therefore\r
-\r
- *     R = Y                + 1.40200 * Cr\r
-\r
- *     G = Y - 0.34414 * Cb - 0.71414 * Cr\r
-\r
- *     B = Y + 1.77200 * Cb\r
-\r
- * where Cb and Cr represent the incoming values less CENTERJSAMPLE.\r
-\r
- * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)\r
-\r
- *\r
-\r
- * To avoid floating-point arithmetic, we represent the fractional constants\r
-\r
- * as integers scaled up by 2^16 (about 4 digits precision); we have to divide\r
-\r
- * the products by 2^16, with appropriate rounding, to get the correct answer.\r
-\r
- * Notice that Y, being an integral input, does not contribute any fraction\r
-\r
- * so it need not participate in the rounding.\r
-\r
- *\r
-\r
- * For even more speed, we avoid doing any multiplications in the inner loop\r
-\r
- * by precalculating the constants times Cb and Cr for all possible values.\r
-\r
- * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);\r
-\r
- * for 12-bit samples it is still acceptable.  It's not very reasonable for\r
-\r
- * 16-bit samples, but if you want lossless storage you shouldn't be changing\r
-\r
- * colorspace anyway.\r
-\r
- * The Cr=>R and Cb=>B values can be rounded to integers in advance; the\r
-\r
- * values for the G calculation are left scaled up, since we must add them\r
-\r
- * together before rounding.\r
-\r
- */\r
-\r
-\r
-\r
-#define SCALEBITS      16      /* speediest right-shift on some machines */\r
-\r
-#define ONE_HALF       ((INT32) 1 << (SCALEBITS-1))\r
-\r
-#define FIX(x)         ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize tables for YCC->RGB colorspace conversion.\r
-\r
- */\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-build_ycc_rgb_table (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\r
-\r
-  int i;\r
-\r
-  INT32 x;\r
-\r
-  SHIFT_TEMPS\r
-\r
-\r
-\r
-  cconvert->Cr_r_tab = (int *)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               (MAXJSAMPLE+1) * SIZEOF(int));\r
-\r
-  cconvert->Cb_b_tab = (int *)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               (MAXJSAMPLE+1) * SIZEOF(int));\r
-\r
-  cconvert->Cr_g_tab = (INT32 *)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               (MAXJSAMPLE+1) * SIZEOF(INT32));\r
-\r
-  cconvert->Cb_g_tab = (INT32 *)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               (MAXJSAMPLE+1) * SIZEOF(INT32));\r
-\r
-\r
-\r
-  for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {\r
-\r
-    /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */\r
-\r
-    /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */\r
-\r
-    /* Cr=>R value is nearest int to 1.40200 * x */\r
-\r
-    cconvert->Cr_r_tab[i] = (int)\r
-\r
-                   RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);\r
-\r
-    /* Cb=>B value is nearest int to 1.77200 * x */\r
-\r
-    cconvert->Cb_b_tab[i] = (int)\r
-\r
-                   RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);\r
-\r
-    /* Cr=>G value is scaled-up -0.71414 * x */\r
-\r
-    cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;\r
-\r
-    /* Cb=>G value is scaled-up -0.34414 * x */\r
-\r
-    /* We also add in ONE_HALF so that need not do it in inner loop */\r
-\r
-    cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Convert some rows of samples to the output colorspace.\r
-\r
- *\r
-\r
- * Note that we change from noninterleaved, one-plane-per-component format\r
-\r
- * to interleaved-pixel format.  The output buffer is therefore three times\r
-\r
- * as wide as the input buffer.\r
-\r
- * A starting row offset is provided only for the input buffer.  The caller\r
-\r
- * can easily adjust the passed output_buf value to accommodate any row\r
-\r
- * offset required on that side.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-ycc_rgb_convert (j_decompress_ptr cinfo,\r
-\r
-                JSAMPIMAGE input_buf, JDIMENSION input_row,\r
-\r
-                JSAMPARRAY output_buf, int num_rows)\r
-\r
-{\r
-\r
-  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\r
-\r
-  register int y, cb, cr;\r
-\r
-  register JSAMPROW outptr;\r
-\r
-  register JSAMPROW inptr0, inptr1, inptr2;\r
-\r
-  register JDIMENSION col;\r
-\r
-  JDIMENSION num_cols = cinfo->output_width;\r
-\r
-  /* copy these pointers into registers if possible */\r
-\r
-  register JSAMPLE * range_limit = cinfo->sample_range_limit;\r
-\r
-  register int * Crrtab = cconvert->Cr_r_tab;\r
-\r
-  register int * Cbbtab = cconvert->Cb_b_tab;\r
-\r
-  register INT32 * Crgtab = cconvert->Cr_g_tab;\r
-\r
-  register INT32 * Cbgtab = cconvert->Cb_g_tab;\r
-\r
-  SHIFT_TEMPS\r
-\r
-\r
-\r
-  while (--num_rows >= 0) {\r
-\r
-    inptr0 = input_buf[0][input_row];\r
-\r
-    inptr1 = input_buf[1][input_row];\r
-\r
-    inptr2 = input_buf[2][input_row];\r
-\r
-    input_row++;\r
-\r
-    outptr = *output_buf++;\r
-\r
-    for (col = 0; col < num_cols; col++) {\r
-\r
-      y  = GETJSAMPLE(inptr0[col]);\r
-\r
-      cb = GETJSAMPLE(inptr1[col]);\r
-\r
-      cr = GETJSAMPLE(inptr2[col]);\r
-\r
-      /* Range-limiting is essential due to noise introduced by DCT losses. */\r
-\r
-      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];\r
-\r
-      outptr[RGB_GREEN] = range_limit[y +\r
-\r
-                             ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\r
-\r
-                                                SCALEBITS))];\r
-\r
-      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];\r
-\r
-      outptr += RGB_PIXELSIZE;\r
-\r
-    }\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/**************** Cases other than YCbCr -> RGB **************/\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Color conversion for no colorspace change: just copy the data,\r
-\r
- * converting from separate-planes to interleaved representation.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-null_convert (j_decompress_ptr cinfo,\r
-\r
-             JSAMPIMAGE input_buf, JDIMENSION input_row,\r
-\r
-             JSAMPARRAY output_buf, int num_rows)\r
-\r
-{\r
-\r
-  register JSAMPROW inptr, outptr;\r
-\r
-  register JDIMENSION count;\r
-\r
-  register int num_components = cinfo->num_components;\r
-\r
-  JDIMENSION num_cols = cinfo->output_width;\r
-\r
-  int ci;\r
-\r
-\r
-\r
-  while (--num_rows >= 0) {\r
-\r
-    for (ci = 0; ci < num_components; ci++) {\r
-\r
-      inptr = input_buf[ci][input_row];\r
-\r
-      outptr = output_buf[0] + ci;\r
-\r
-      for (count = num_cols; count > 0; count--) {\r
-\r
-       *outptr = *inptr++;     /* needn't bother with GETJSAMPLE() here */\r
-\r
-       outptr += num_components;\r
-\r
-      }\r
-\r
-    }\r
-\r
-    input_row++;\r
-\r
-    output_buf++;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Color conversion for grayscale: just copy the data.\r
-\r
- * This also works for YCbCr -> grayscale conversion, in which\r
-\r
- * we just copy the Y (luminance) component and ignore chrominance.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-grayscale_convert (j_decompress_ptr cinfo,\r
-\r
-                  JSAMPIMAGE input_buf, JDIMENSION input_row,\r
-\r
-                  JSAMPARRAY output_buf, int num_rows)\r
-\r
-{\r
-\r
-  jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,\r
-\r
-                   num_rows, cinfo->output_width);\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Adobe-style YCCK->CMYK conversion.\r
-\r
- * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same\r
-\r
- * conversion as above, while passing K (black) unchanged.\r
-\r
- * We assume build_ycc_rgb_table has been called.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-ycck_cmyk_convert (j_decompress_ptr cinfo,\r
-\r
-                  JSAMPIMAGE input_buf, JDIMENSION input_row,\r
-\r
-                  JSAMPARRAY output_buf, int num_rows)\r
-\r
-{\r
-\r
-  my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\r
-\r
-  register int y, cb, cr;\r
-\r
-  register JSAMPROW outptr;\r
-\r
-  register JSAMPROW inptr0, inptr1, inptr2, inptr3;\r
-\r
-  register JDIMENSION col;\r
-\r
-  JDIMENSION num_cols = cinfo->output_width;\r
-\r
-  /* copy these pointers into registers if possible */\r
-\r
-  register JSAMPLE * range_limit = cinfo->sample_range_limit;\r
-\r
-  register int * Crrtab = cconvert->Cr_r_tab;\r
-\r
-  register int * Cbbtab = cconvert->Cb_b_tab;\r
-\r
-  register INT32 * Crgtab = cconvert->Cr_g_tab;\r
-\r
-  register INT32 * Cbgtab = cconvert->Cb_g_tab;\r
-\r
-  SHIFT_TEMPS\r
-\r
-\r
-\r
-  while (--num_rows >= 0) {\r
-\r
-    inptr0 = input_buf[0][input_row];\r
-\r
-    inptr1 = input_buf[1][input_row];\r
-\r
-    inptr2 = input_buf[2][input_row];\r
-\r
-    inptr3 = input_buf[3][input_row];\r
-\r
-    input_row++;\r
-\r
-    outptr = *output_buf++;\r
-\r
-    for (col = 0; col < num_cols; col++) {\r
-\r
-      y  = GETJSAMPLE(inptr0[col]);\r
-\r
-      cb = GETJSAMPLE(inptr1[col]);\r
-\r
-      cr = GETJSAMPLE(inptr2[col]);\r
-\r
-      /* Range-limiting is essential due to noise introduced by DCT losses. */\r
-\r
-      outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];  /* red */\r
-\r
-      outptr[1] = range_limit[MAXJSAMPLE - (y +                        /* green */\r
-\r
-                             ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\r
-\r
-                                                SCALEBITS)))];\r
-\r
-      outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];  /* blue */\r
-\r
-      /* K passes through unchanged */\r
-\r
-      outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */\r
-\r
-      outptr += 4;\r
-\r
-    }\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Empty method for start_pass.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_pass_dcolor (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  /* no work needed */\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Module initialization routine for output colorspace conversion.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jinit_color_deconverter (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_cconvert_ptr cconvert;\r
-\r
-  int ci;\r
-\r
-\r
-\r
-  cconvert = (my_cconvert_ptr)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               SIZEOF(my_color_deconverter));\r
-\r
-  cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;\r
-\r
-  cconvert->pub.start_pass = start_pass_dcolor;\r
-\r
-\r
-\r
-  /* Make sure num_components agrees with jpeg_color_space */\r
-\r
-  switch (cinfo->jpeg_color_space) {\r
-\r
-  case JCS_GRAYSCALE:\r
-\r
-    if (cinfo->num_components != 1)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\r
-\r
-    break;\r
-\r
-\r
-\r
-  case JCS_RGB:\r
-\r
-  case JCS_YCbCr:\r
-\r
-    if (cinfo->num_components != 3)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\r
-\r
-    break;\r
-\r
-\r
-\r
-  case JCS_CMYK:\r
-\r
-  case JCS_YCCK:\r
-\r
-    if (cinfo->num_components != 4)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\r
-\r
-    break;\r
-\r
-\r
-\r
-  default:                     /* JCS_UNKNOWN can be anything */\r
-\r
-    if (cinfo->num_components < 1)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);\r
-\r
-    break;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Set out_color_components and conversion method based on requested space.\r
-\r
-   * Also clear the component_needed flags for any unused components,\r
-\r
-   * so that earlier pipeline stages can avoid useless computation.\r
-\r
-   */\r
-\r
-\r
-\r
-  switch (cinfo->out_color_space) {\r
-\r
-  case JCS_GRAYSCALE:\r
-\r
-    cinfo->out_color_components = 1;\r
-\r
-    if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||\r
-\r
-       cinfo->jpeg_color_space == JCS_YCbCr) {\r
-\r
-      cconvert->pub.color_convert = grayscale_convert;\r
-\r
-      /* For color->grayscale conversion, only the Y (0) component is needed */\r
-\r
-      for (ci = 1; ci < cinfo->num_components; ci++)\r
-\r
-       cinfo->comp_info[ci].component_needed = FALSE;\r
-\r
-    } else\r
-\r
-      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\r
-\r
-    break;\r
-\r
-\r
-\r
-  case JCS_RGB:\r
-\r
-    cinfo->out_color_components = RGB_PIXELSIZE;\r
-\r
-    if (cinfo->jpeg_color_space == JCS_YCbCr) {\r
-\r
-      cconvert->pub.color_convert = ycc_rgb_convert;\r
-\r
-      build_ycc_rgb_table(cinfo);\r
-\r
-    } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) {\r
-\r
-      cconvert->pub.color_convert = null_convert;\r
-\r
-    } else\r
-\r
-      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\r
-\r
-    break;\r
-\r
-\r
-\r
-  case JCS_CMYK:\r
-\r
-    cinfo->out_color_components = 4;\r
-\r
-    if (cinfo->jpeg_color_space == JCS_YCCK) {\r
-\r
-      cconvert->pub.color_convert = ycck_cmyk_convert;\r
-\r
-      build_ycc_rgb_table(cinfo);\r
-\r
-    } else if (cinfo->jpeg_color_space == JCS_CMYK) {\r
-\r
-      cconvert->pub.color_convert = null_convert;\r
-\r
-    } else\r
-\r
-      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\r
-\r
-    break;\r
-\r
-\r
-\r
-  default:\r
-\r
-    /* Permit null conversion to same output space */\r
-\r
-    if (cinfo->out_color_space == cinfo->jpeg_color_space) {\r
-\r
-      cinfo->out_color_components = cinfo->num_components;\r
-\r
-      cconvert->pub.color_convert = null_convert;\r
-\r
-    } else                     /* unsupported non-null conversion */\r
-\r
-      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);\r
-\r
-    break;\r
-\r
-  }\r
-\r
-\r
-\r
-  if (cinfo->quantize_colors)\r
-\r
-    cinfo->output_components = 1; /* single colormapped output component */\r
-\r
-  else\r
-\r
-    cinfo->output_components = cinfo->out_color_components;\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jdct.h b/libs/jpeg6/jdct.h
deleted file mode 100644 (file)
index cebb118..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*\r
-\r
- * jdct.h\r
-\r
- *\r
-\r
- * Copyright (C) 1994, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This include file contains common declarations for the forward and\r
-\r
- * inverse DCT modules.  These declarations are private to the DCT managers\r
-\r
- * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.\r
-\r
- * The individual DCT algorithms are kept in separate files to ease \r
-\r
- * machine-dependent tuning (e.g., assembly coding).\r
-\r
- */\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * A forward DCT routine is given a pointer to a work area of type DCTELEM[];\r
-\r
- * the DCT is to be performed in-place in that buffer.  Type DCTELEM is int\r
-\r
- * for 8-bit samples, INT32 for 12-bit samples.  (NOTE: Floating-point DCT\r
-\r
- * implementations use an array of type FAST_FLOAT, instead.)\r
-\r
- * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).\r
-\r
- * The DCT outputs are returned scaled up by a factor of 8; they therefore\r
-\r
- * have a range of +-8K for 8-bit data, +-128K for 12-bit data.  This\r
-\r
- * convention improves accuracy in integer implementations and saves some\r
-\r
- * work in floating-point ones.\r
-\r
- * Quantization of the output coefficients is done by jcdctmgr.c.\r
-\r
- */\r
-\r
-\r
-\r
-#if BITS_IN_JSAMPLE == 8\r
-\r
-typedef int DCTELEM;           /* 16 or 32 bits is fine */\r
-\r
-#else\r
-\r
-typedef INT32 DCTELEM;         /* must have 32 bits */\r
-\r
-#endif\r
-\r
-\r
-\r
-typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data));\r
-\r
-typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data));\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer\r
-\r
- * to an output sample array.  The routine must dequantize the input data as\r
-\r
- * well as perform the IDCT; for dequantization, it uses the multiplier table\r
-\r
- * pointed to by compptr->dct_table.  The output data is to be placed into the\r
-\r
- * sample array starting at a specified column.  (Any row offset needed will\r
-\r
- * be applied to the array pointer before it is passed to the IDCT code.)\r
-\r
- * Note that the number of samples emitted by the IDCT routine is\r
-\r
- * DCT_scaled_size * DCT_scaled_size.\r
-\r
- */\r
-\r
-\r
-\r
-/* typedef inverse_DCT_method_ptr is declared in jpegint.h */\r
-\r
-\r
-\r
-/*\r
-\r
- * Each IDCT routine has its own ideas about the best dct_table element type.\r
-\r
- */\r
-\r
-\r
-\r
-typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */\r
-\r
-#if BITS_IN_JSAMPLE == 8\r
-\r
-typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */\r
-\r
-#define IFAST_SCALE_BITS  2    /* fractional bits in scale factors */\r
-\r
-#else\r
-\r
-typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */\r
-\r
-#define IFAST_SCALE_BITS  13   /* fractional bits in scale factors */\r
-\r
-#endif\r
-\r
-typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Each IDCT routine is responsible for range-limiting its results and\r
-\r
- * converting them to unsigned form (0..MAXJSAMPLE).  The raw outputs could\r
-\r
- * be quite far out of range if the input data is corrupt, so a bulletproof\r
-\r
- * range-limiting step is required.  We use a mask-and-table-lookup method\r
-\r
- * to do the combined operations quickly.  See the comments with\r
-\r
- * prepare_range_limit_table (in jdmaster.c) for more info.\r
-\r
- */\r
-\r
-\r
-\r
-#define IDCT_range_limit(cinfo)  ((cinfo)->sample_range_limit + CENTERJSAMPLE)\r
-\r
-\r
-\r
-#define RANGE_MASK  (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */\r
-\r
-\r
-\r
-\r
-\r
-/* Short forms of external names for systems with brain-damaged linkers. */\r
-\r
-\r
-\r
-#ifdef NEED_SHORT_EXTERNAL_NAMES\r
-\r
-#define jpeg_fdct_islow                jFDislow\r
-\r
-#define jpeg_fdct_ifast                jFDifast\r
-\r
-#define jpeg_fdct_float                jFDfloat\r
-\r
-#define jpeg_idct_islow                jRDislow\r
-\r
-#define jpeg_idct_ifast                jRDifast\r
-\r
-#define jpeg_idct_float                jRDfloat\r
-\r
-#define jpeg_idct_4x4          jRD4x4\r
-\r
-#define jpeg_idct_2x2          jRD2x2\r
-\r
-#define jpeg_idct_1x1          jRD1x1\r
-\r
-#endif /* NEED_SHORT_EXTERNAL_NAMES */\r
-\r
-\r
-\r
-/* Extern declarations for the forward and inverse DCT routines. */\r
-\r
-\r
-\r
-EXTERN void jpeg_fdct_islow JPP((DCTELEM * data));\r
-\r
-EXTERN void jpeg_fdct_ifast JPP((DCTELEM * data));\r
-\r
-EXTERN void jpeg_fdct_float JPP((FAST_FLOAT * data));\r
-\r
-\r
-\r
-EXTERN void jpeg_idct_islow\r
-\r
-    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\r
-\r
-        JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\r
-\r
-EXTERN void jpeg_idct_ifast\r
-\r
-    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\r
-\r
-        JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\r
-\r
-EXTERN void jpeg_idct_float\r
-\r
-    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\r
-\r
-        JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\r
-\r
-EXTERN void jpeg_idct_4x4\r
-\r
-    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\r
-\r
-        JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\r
-\r
-EXTERN void jpeg_idct_2x2\r
-\r
-    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\r
-\r
-        JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\r
-\r
-EXTERN void jpeg_idct_1x1\r
-\r
-    JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,\r
-\r
-        JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Macros for handling fixed-point arithmetic; these are used by many\r
-\r
- * but not all of the DCT/IDCT modules.\r
-\r
- *\r
-\r
- * All values are expected to be of type INT32.\r
-\r
- * Fractional constants are scaled left by CONST_BITS bits.\r
-\r
- * CONST_BITS is defined within each module using these macros,\r
-\r
- * and may differ from one module to the next.\r
-\r
- */\r
-\r
-\r
-\r
-#define ONE    ((INT32) 1)\r
-\r
-#define CONST_SCALE (ONE << CONST_BITS)\r
-\r
-\r
-\r
-/* Convert a positive real constant to an integer scaled by CONST_SCALE.\r
-\r
- * Caution: some C compilers fail to reduce "FIX(constant)" at compile time,\r
-\r
- * thus causing a lot of useless floating-point operations at run time.\r
-\r
- */\r
-\r
-\r
-\r
-#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))\r
-\r
-\r
-\r
-/* Descale and correctly round an INT32 value that's scaled by N bits.\r
-\r
- * We assume RIGHT_SHIFT rounds towards minus infinity, so adding\r
-\r
- * the fudge factor is correct for either sign of X.\r
-\r
- */\r
-\r
-\r
-\r
-#define DESCALE(x,n)  RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)\r
-\r
-\r
-\r
-/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.\r
-\r
- * This macro is used only when the two inputs will actually be no more than\r
-\r
- * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a\r
-\r
- * full 32x32 multiply.  This provides a useful speedup on many machines.\r
-\r
- * Unfortunately there is no way to specify a 16x16->32 multiply portably\r
-\r
- * in C, but some C compilers will do the right thing if you provide the\r
-\r
- * correct combination of casts.\r
-\r
- */\r
-\r
-\r
-\r
-#ifdef SHORTxSHORT_32          /* may work if 'int' is 32 bits */\r
-\r
-#define MULTIPLY16C16(var,const)  (((INT16) (var)) * ((INT16) (const)))\r
-\r
-#endif\r
-\r
-#ifdef SHORTxLCONST_32         /* known to work with Microsoft C 6.0 */\r
-\r
-#define MULTIPLY16C16(var,const)  (((INT16) (var)) * ((INT32) (const)))\r
-\r
-#endif\r
-\r
-\r
-\r
-#ifndef MULTIPLY16C16          /* default definition */\r
-\r
-#define MULTIPLY16C16(var,const)  ((var) * (const))\r
-\r
-#endif\r
-\r
-\r
-\r
-/* Same except both inputs are variables. */\r
-\r
-\r
-\r
-#ifdef SHORTxSHORT_32          /* may work if 'int' is 32 bits */\r
-\r
-#define MULTIPLY16V16(var1,var2)  (((INT16) (var1)) * ((INT16) (var2)))\r
-\r
-#endif\r
-\r
-\r
-\r
-#ifndef MULTIPLY16V16          /* default definition */\r
-\r
-#define MULTIPLY16V16(var1,var2)  ((var1) * (var2))\r
-\r
-#endif\r
-\r
diff --git a/libs/jpeg6/jddctmgr.cpp b/libs/jpeg6/jddctmgr.cpp
deleted file mode 100644 (file)
index cdf107e..0000000
+++ /dev/null
@@ -1,540 +0,0 @@
-/*\r
-\r
- * jddctmgr.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains the inverse-DCT management logic.\r
-\r
- * This code selects a particular IDCT implementation to be used,\r
-\r
- * and it performs related housekeeping chores.  No code in this file\r
-\r
- * is executed per IDCT step, only during output pass setup.\r
-\r
- *\r
-\r
- * Note that the IDCT routines are responsible for performing coefficient\r
-\r
- * dequantization as well as the IDCT proper.  This module sets up the\r
-\r
- * dequantization multiplier table needed by the IDCT routine.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-#include "jdct.h"              /* Private declarations for DCT subsystem */\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * The decompressor input side (jdinput.c) saves away the appropriate\r
-\r
- * quantization table for each component at the start of the first scan\r
-\r
- * involving that component.  (This is necessary in order to correctly\r
-\r
- * decode files that reuse Q-table slots.)\r
-\r
- * When we are ready to make an output pass, the saved Q-table is converted\r
-\r
- * to a multiplier table that will actually be used by the IDCT routine.\r
-\r
- * The multiplier table contents are IDCT-method-dependent.  To support\r
-\r
- * application changes in IDCT method between scans, we can remake the\r
-\r
- * multiplier tables if necessary.\r
-\r
- * In buffered-image mode, the first output pass may occur before any data\r
-\r
- * has been seen for some components, and thus before their Q-tables have\r
-\r
- * been saved away.  To handle this case, multiplier tables are preset\r
-\r
- * to zeroes; the result of the IDCT will be a neutral gray level.\r
-\r
- */\r
-\r
-\r
-\r
-\r
-\r
-/* Private subobject for this module */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  struct jpeg_inverse_dct pub; /* public fields */\r
-\r
-\r
-\r
-  /* This array contains the IDCT method code that each multiplier table\r
-\r
-   * is currently set up for, or -1 if it's not yet set up.\r
-\r
-   * The actual multiplier tables are pointed to by dct_table in the\r
-\r
-   * per-component comp_info structures.\r
-\r
-   */\r
-\r
-  int cur_method[MAX_COMPONENTS];\r
-\r
-} my_idct_controller;\r
-\r
-\r
-\r
-typedef my_idct_controller * my_idct_ptr;\r
-\r
-\r
-\r
-\r
-\r
-/* Allocated multiplier tables: big enough for any supported variant */\r
-\r
-\r
-\r
-typedef union {\r
-\r
-  ISLOW_MULT_TYPE islow_array[DCTSIZE2];\r
-\r
-#ifdef DCT_IFAST_SUPPORTED\r
-\r
-  IFAST_MULT_TYPE ifast_array[DCTSIZE2];\r
-\r
-#endif\r
-\r
-#ifdef DCT_FLOAT_SUPPORTED\r
-\r
-  FLOAT_MULT_TYPE float_array[DCTSIZE2];\r
-\r
-#endif\r
-\r
-} multiplier_table;\r
-\r
-\r
-\r
-\r
-\r
-/* The current scaled-IDCT routines require ISLOW-style multiplier tables,\r
-\r
- * so be sure to compile that code if either ISLOW or SCALING is requested.\r
-\r
- */\r
-\r
-#ifdef DCT_ISLOW_SUPPORTED\r
-\r
-#define PROVIDE_ISLOW_TABLES\r
-\r
-#else\r
-\r
-#ifdef IDCT_SCALING_SUPPORTED\r
-\r
-#define PROVIDE_ISLOW_TABLES\r
-\r
-#endif\r
-\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Prepare for an output pass.\r
-\r
- * Here we select the proper IDCT routine for each component and build\r
-\r
- * a matching multiplier table.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_pass (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_idct_ptr idct = (my_idct_ptr) cinfo->idct;\r
-\r
-  int ci, i;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  int method = 0;\r
-\r
-  inverse_DCT_method_ptr method_ptr = NULL;\r
-\r
-  JQUANT_TBL * qtbl;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    /* Select the proper IDCT routine for this component's scaling */\r
-\r
-    switch (compptr->DCT_scaled_size) {\r
-\r
-#ifdef IDCT_SCALING_SUPPORTED\r
-\r
-    case 1:\r
-\r
-      method_ptr = jpeg_idct_1x1;\r
-\r
-      method = JDCT_ISLOW;     /* jidctred uses islow-style table */\r
-\r
-      break;\r
-\r
-    case 2:\r
-\r
-      method_ptr = jpeg_idct_2x2;\r
-\r
-      method = JDCT_ISLOW;     /* jidctred uses islow-style table */\r
-\r
-      break;\r
-\r
-    case 4:\r
-\r
-      method_ptr = jpeg_idct_4x4;\r
-\r
-      method = JDCT_ISLOW;     /* jidctred uses islow-style table */\r
-\r
-      break;\r
-\r
-#endif\r
-\r
-    case DCTSIZE:\r
-\r
-      switch (cinfo->dct_method) {\r
-\r
-#ifdef DCT_ISLOW_SUPPORTED\r
-\r
-      case JDCT_ISLOW:\r
-\r
-       method_ptr = jpeg_idct_islow;\r
-\r
-       method = JDCT_ISLOW;\r
-\r
-       break;\r
-\r
-#endif\r
-\r
-#ifdef DCT_IFAST_SUPPORTED\r
-\r
-      case JDCT_IFAST:\r
-\r
-       method_ptr = jpeg_idct_ifast;\r
-\r
-       method = JDCT_IFAST;\r
-\r
-       break;\r
-\r
-#endif\r
-\r
-#ifdef DCT_FLOAT_SUPPORTED\r
-\r
-      case JDCT_FLOAT:\r
-\r
-       method_ptr = jpeg_idct_float;\r
-\r
-       method = JDCT_FLOAT;\r
-\r
-       break;\r
-\r
-#endif\r
-\r
-      default:\r
-\r
-       ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-\r
-       break;\r
-\r
-      }\r
-\r
-      break;\r
-\r
-    default:\r
-\r
-      ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size);\r
-\r
-      break;\r
-\r
-    }\r
-\r
-    idct->pub.inverse_DCT[ci] = method_ptr;\r
-\r
-    /* Create multiplier table from quant table.\r
-\r
-     * However, we can skip this if the component is uninteresting\r
-\r
-     * or if we already built the table.  Also, if no quant table\r
-\r
-     * has yet been saved for the component, we leave the\r
-\r
-     * multiplier table all-zero; we'll be reading zeroes from the\r
-\r
-     * coefficient controller's buffer anyway.\r
-\r
-     */\r
-\r
-    if (! compptr->component_needed || idct->cur_method[ci] == method)\r
-\r
-      continue;\r
-\r
-    qtbl = compptr->quant_table;\r
-\r
-    if (qtbl == NULL)          /* happens if no data yet for component */\r
-\r
-      continue;\r
-\r
-    idct->cur_method[ci] = method;\r
-\r
-    switch (method) {\r
-\r
-#ifdef PROVIDE_ISLOW_TABLES\r
-\r
-    case JDCT_ISLOW:\r
-\r
-      {\r
-\r
-       /* For LL&M IDCT method, multipliers are equal to raw quantization\r
-\r
-        * coefficients, but are stored in natural order as ints.\r
-\r
-        */\r
-\r
-       ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table;\r
-\r
-       for (i = 0; i < DCTSIZE2; i++) {\r
-\r
-         ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[jpeg_zigzag_order[i]];\r
-\r
-       }\r
-\r
-      }\r
-\r
-      break;\r
-\r
-#endif\r
-\r
-#ifdef DCT_IFAST_SUPPORTED\r
-\r
-    case JDCT_IFAST:\r
-\r
-      {\r
-\r
-       /* For AA&N IDCT method, multipliers are equal to quantization\r
-\r
-        * coefficients scaled by scalefactor[row]*scalefactor[col], where\r
-\r
-        *   scalefactor[0] = 1\r
-\r
-        *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\r
-\r
-        * For integer operation, the multiplier table is to be scaled by\r
-\r
-        * IFAST_SCALE_BITS.  The multipliers are stored in natural order.\r
-\r
-        */\r
-\r
-       IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table;\r
-\r
-#define CONST_BITS 14\r
-\r
-       static const INT16 aanscales[DCTSIZE2] = {\r
-\r
-         /* precomputed values scaled up by 14 bits */\r
-\r
-         16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\r
-\r
-         22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,\r
-\r
-         21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,\r
-\r
-         19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,\r
-\r
-         16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,\r
-\r
-         12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,\r
-\r
-          8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,\r
-\r
-          4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247\r
-\r
-       };\r
-\r
-       SHIFT_TEMPS\r
-\r
-\r
-\r
-       for (i = 0; i < DCTSIZE2; i++) {\r
-\r
-         ifmtbl[i] = (IFAST_MULT_TYPE)\r
-\r
-           DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[jpeg_zigzag_order[i]],\r
-\r
-                                 (INT32) aanscales[i]),\r
-\r
-                   CONST_BITS-IFAST_SCALE_BITS);\r
-\r
-       }\r
-\r
-      }\r
-\r
-      break;\r
-\r
-#endif\r
-\r
-#ifdef DCT_FLOAT_SUPPORTED\r
-\r
-    case JDCT_FLOAT:\r
-\r
-      {\r
-\r
-       /* For float AA&N IDCT method, multipliers are equal to quantization\r
-\r
-        * coefficients scaled by scalefactor[row]*scalefactor[col], where\r
-\r
-        *   scalefactor[0] = 1\r
-\r
-        *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7\r
-\r
-        * The multipliers are stored in natural order.\r
-\r
-        */\r
-\r
-       FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;\r
-\r
-       int row, col;\r
-\r
-       static const double aanscalefactor[DCTSIZE] = {\r
-\r
-         1.0, 1.387039845, 1.306562965, 1.175875602,\r
-\r
-         1.0, 0.785694958, 0.541196100, 0.275899379\r
-\r
-       };\r
-\r
-\r
-\r
-       i = 0;\r
-\r
-       for (row = 0; row < DCTSIZE; row++) {\r
-\r
-         for (col = 0; col < DCTSIZE; col++) {\r
-\r
-           fmtbl[i] = (FLOAT_MULT_TYPE)\r
-\r
-             ((double) qtbl->quantval[jpeg_zigzag_order[i]] *\r
-\r
-              aanscalefactor[row] * aanscalefactor[col]);\r
-\r
-           i++;\r
-\r
-         }\r
-\r
-       }\r
-\r
-      }\r
-\r
-      break;\r
-\r
-#endif\r
-\r
-    default:\r
-\r
-      ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-\r
-      break;\r
-\r
-    }\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize IDCT manager.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jinit_inverse_dct (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_idct_ptr idct;\r
-\r
-  int ci;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-\r
-\r
-  idct = (my_idct_ptr)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               SIZEOF(my_idct_controller));\r
-\r
-  cinfo->idct = (struct jpeg_inverse_dct *) idct;\r
-\r
-  idct->pub.start_pass = start_pass;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    /* Allocate and pre-zero a multiplier table for each component */\r
-\r
-    compptr->dct_table =\r
-\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                                 SIZEOF(multiplier_table));\r
-\r
-    MEMZERO(compptr->dct_table, SIZEOF(multiplier_table));\r
-\r
-    /* Mark multiplier table not yet set up for any method */\r
-\r
-    idct->cur_method[ci] = -1;\r
-\r
-  }\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jdhuff.cpp b/libs/jpeg6/jdhuff.cpp
deleted file mode 100644 (file)
index 4ed8bc3..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-/*\r
- * jdhuff.c\r
- *\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
- * This file is part of the Independent JPEG Group's software.\r
- * For conditions of distribution and use, see the accompanying README file.\r
- *\r
- * This file contains Huffman entropy decoding routines.\r
- *\r
- * Much of the complexity here has to do with supporting input suspension.\r
- * If the data source module demands suspension, we want to be able to back\r
- * up to the start of the current MCU.  To do this, we copy state variables\r
- * into local working storage, and update them back to the permanent\r
- * storage only upon successful completion of an MCU.\r
- */\r
-\r
-#define JPEG_INTERNALS\r
-#include "jinclude.h"\r
-#include "radiant_jpeglib.h"\r
-#include "jdhuff.h"            /* Declarations shared with jdphuff.c */\r
-\r
-\r
-/*\r
- * Expanded entropy decoder object for Huffman decoding.\r
- *\r
- * The savable_state subrecord contains fields that change within an MCU,\r
- * but must not be updated permanently until we complete the MCU.\r
- */\r
-\r
-typedef struct {\r
-  int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */\r
-} savable_state;\r
-\r
-/* This macro is to work around compilers with missing or broken\r
- * structure assignment.  You'll need to fix this code if you have\r
- * such a compiler and you change MAX_COMPS_IN_SCAN.\r
- */\r
-\r
-#ifndef NO_STRUCT_ASSIGN\r
-#define ASSIGN_STATE(dest,src)  ((dest) = (src))\r
-#else\r
-#if MAX_COMPS_IN_SCAN == 4\r
-#define ASSIGN_STATE(dest,src)  \\r
-       ((dest).last_dc_val[0] = (src).last_dc_val[0], \\r
-        (dest).last_dc_val[1] = (src).last_dc_val[1], \\r
-        (dest).last_dc_val[2] = (src).last_dc_val[2], \\r
-        (dest).last_dc_val[3] = (src).last_dc_val[3])\r
-#endif\r
-#endif\r
-\r
-\r
-typedef struct {\r
-  struct jpeg_entropy_decoder pub; /* public fields */\r
-\r
-  /* These fields are loaded into local variables at start of each MCU.\r
-   * In case of suspension, we exit WITHOUT updating them.\r
-   */\r
-  bitread_perm_state bitstate; /* Bit buffer at start of MCU */\r
-  savable_state saved;         /* Other state at start of MCU */\r
-\r
-  /* These fields are NOT loaded into local working state. */\r
-  unsigned int restarts_to_go; /* MCUs left in this restart interval */\r
-\r
-  /* Pointers to derived tables (these workspaces have image lifespan) */\r
-  d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];\r
-  d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];\r
-} huff_entropy_decoder;\r
-\r
-typedef huff_entropy_decoder * huff_entropy_ptr;\r
-\r
-\r
-/*\r
- * Initialize for a Huffman-compressed scan.\r
- */\r
-\r
-METHODDEF void\r
-start_pass_huff_decoder (j_decompress_ptr cinfo)\r
-{\r
-  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\r
-  int ci, dctbl, actbl;\r
-  jpeg_component_info * compptr;\r
-\r
-  /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.\r
-   * This ought to be an error condition, but we make it a warning because\r
-   * there are some baseline files out there with all zeroes in these bytes.\r
-   */\r
-  if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 ||\r
-      cinfo->Ah != 0 || cinfo->Al != 0)\r
-    WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);\r
-\r
-  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\r
-    compptr = cinfo->cur_comp_info[ci];\r
-    dctbl = compptr->dc_tbl_no;\r
-    actbl = compptr->ac_tbl_no;\r
-    /* Make sure requested tables are present */\r
-    if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS ||\r
-       cinfo->dc_huff_tbl_ptrs[dctbl] == NULL)\r
-      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);\r
-    if (actbl < 0 || actbl >= NUM_HUFF_TBLS ||\r
-       cinfo->ac_huff_tbl_ptrs[actbl] == NULL)\r
-      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl);\r
-    /* Compute derived values for Huffman tables */\r
-    /* We may do this more than once for a table, but it's not expensive */\r
-    jpeg_make_d_derived_tbl(cinfo, cinfo->dc_huff_tbl_ptrs[dctbl],\r
-                           & entropy->dc_derived_tbls[dctbl]);\r
-    jpeg_make_d_derived_tbl(cinfo, cinfo->ac_huff_tbl_ptrs[actbl],\r
-                           & entropy->ac_derived_tbls[actbl]);\r
-    /* Initialize DC predictions to 0 */\r
-    entropy->saved.last_dc_val[ci] = 0;\r
-  }\r
-\r
-  /* Initialize bitread state variables */\r
-  entropy->bitstate.bits_left = 0;\r
-  entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */\r
-  entropy->bitstate.printed_eod = FALSE;\r
-\r
-  /* Initialize restart counter */\r
-  entropy->restarts_to_go = cinfo->restart_interval;\r
-}\r
-\r
-\r
-/*\r
- * Compute the derived values for a Huffman table.\r
- * Note this is also used by jdphuff.c.\r
- */\r
-\r
-GLOBAL void\r
-jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, JHUFF_TBL * htbl,\r
-                        d_derived_tbl ** pdtbl)\r
-{\r
-  d_derived_tbl *dtbl;\r
-  int p, i, l, si;\r
-  int lookbits, ctr;\r
-  char huffsize[257];\r
-  unsigned int huffcode[257];\r
-  unsigned int code;\r
-\r
-  /* Allocate a workspace if we haven't already done so. */\r
-  if (*pdtbl == NULL)\r
-    *pdtbl = (d_derived_tbl *)\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-                                 SIZEOF(d_derived_tbl));\r
-  dtbl = *pdtbl;\r
-  dtbl->pub = htbl;            /* fill in back link */\r
-  \r
-  /* Figure C.1: make table of Huffman code length for each symbol */\r
-  /* Note that this is in code-length order. */\r
-\r
-  p = 0;\r
-  for (l = 1; l <= 16; l++) {\r
-    for (i = 1; i <= (int) htbl->bits[l]; i++)\r
-      huffsize[p++] = (char) l;\r
-  }\r
-  huffsize[p] = 0;\r
-  \r
-  /* Figure C.2: generate the codes themselves */\r
-  /* Note that this is in code-length order. */\r
-  \r
-  code = 0;\r
-  si = huffsize[0];\r
-  p = 0;\r
-  while (huffsize[p]) {\r
-    while (((int) huffsize[p]) == si) {\r
-      huffcode[p++] = code;\r
-      code++;\r
-    }\r
-    code <<= 1;\r
-    si++;\r
-  }\r
-\r
-  /* Figure F.15: generate decoding tables for bit-sequential decoding */\r
-\r
-  p = 0;\r
-  for (l = 1; l <= 16; l++) {\r
-    if (htbl->bits[l]) {\r
-      dtbl->valptr[l] = p; /* huffval[] index of 1st symbol of code length l */\r
-      dtbl->mincode[l] = huffcode[p]; /* minimum code of length l */\r
-      p += htbl->bits[l];\r
-      dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */\r
-    } else {\r
-      dtbl->maxcode[l] = -1;   /* -1 if no codes of this length */\r
-    }\r
-  }\r
-  dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */\r
-\r
-  /* Compute lookahead tables to speed up decoding.\r
-   * First we set all the table entries to 0, indicating "too long";\r
-   * then we iterate through the Huffman codes that are short enough and\r
-   * fill in all the entries that correspond to bit sequences starting\r
-   * with that code.\r
-   */\r
-\r
-  MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits));\r
-\r
-  p = 0;\r
-  for (l = 1; l <= HUFF_LOOKAHEAD; l++) {\r
-    for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {\r
-      /* l = current code's length, p = its index in huffcode[] & huffval[]. */\r
-      /* Generate left-justified code followed by all possible bit sequences */\r
-      lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);\r
-      for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {\r
-       dtbl->look_nbits[lookbits] = l;\r
-       dtbl->look_sym[lookbits] = htbl->huffval[p];\r
-       lookbits++;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/*\r
- * Out-of-line code for bit fetching (shared with jdphuff.c).\r
- * See jdhuff.h for info about usage.\r
- * Note: current values of get_buffer and bits_left are passed as parameters,\r
- * but are returned in the corresponding fields of the state struct.\r
- *\r
- * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width\r
- * of get_buffer to be used.  (On machines with wider words, an even larger\r
- * buffer could be used.)  However, on some machines 32-bit shifts are\r
- * quite slow and take time proportional to the number of places shifted.\r
- * (This is true with most PC compilers, for instance.)  In this case it may\r
- * be a win to set MIN_GET_BITS to the minimum value of 15.  This reduces the\r
- * average shift distance at the cost of more calls to jpeg_fill_bit_buffer.\r
- */\r
-\r
-#ifdef SLOW_SHIFT_32\r
-#define MIN_GET_BITS  15       /* minimum allowable value */\r
-#else\r
-#define MIN_GET_BITS  (BIT_BUF_SIZE-7)\r
-#endif\r
-\r
-\r
-GLOBAL boolean\r
-jpeg_fill_bit_buffer (bitread_working_state * state,\r
-                     register bit_buf_type get_buffer, register int bits_left,\r
-                     int nbits)\r
-/* Load up the bit buffer to a depth of at least nbits */\r
-{\r
-  /* Copy heavily used state fields into locals (hopefully registers) */\r
-  register const JOCTET * next_input_byte = state->next_input_byte;\r
-  register size_t bytes_in_buffer = state->bytes_in_buffer;\r
-  register int c;\r
-\r
-  /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */\r
-  /* (It is assumed that no request will be for more than that many bits.) */\r
-\r
-  while (bits_left < MIN_GET_BITS) {\r
-    /* Attempt to read a byte */\r
-    if (state->unread_marker != 0)\r
-      goto no_more_data;       /* can't advance past a marker */\r
-\r
-    if (bytes_in_buffer == 0) {\r
-      if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo))\r
-       return FALSE;\r
-      next_input_byte = state->cinfo->src->next_input_byte;\r
-      bytes_in_buffer = state->cinfo->src->bytes_in_buffer;\r
-    }\r
-    bytes_in_buffer--;\r
-    c = GETJOCTET(*next_input_byte++);\r
-\r
-    /* If it's 0xFF, check and discard stuffed zero byte */\r
-    if (c == 0xFF) {\r
-      do {\r
-       if (bytes_in_buffer == 0) {\r
-         if (! (*state->cinfo->src->fill_input_buffer) (state->cinfo))\r
-           return FALSE;\r
-         next_input_byte = state->cinfo->src->next_input_byte;\r
-         bytes_in_buffer = state->cinfo->src->bytes_in_buffer;\r
-       }\r
-       bytes_in_buffer--;\r
-       c = GETJOCTET(*next_input_byte++);\r
-      } while (c == 0xFF);\r
-\r
-      if (c == 0) {\r
-       /* Found FF/00, which represents an FF data byte */\r
-       c = 0xFF;\r
-      } else {\r
-       /* Oops, it's actually a marker indicating end of compressed data. */\r
-       /* Better put it back for use later */\r
-       state->unread_marker = c;\r
-\r
-      no_more_data:\r
-       /* There should be enough bits still left in the data segment; */\r
-       /* if so, just break out of the outer while loop. */\r
-       if (bits_left >= nbits)\r
-         break;\r
-       /* Uh-oh.  Report corrupted data to user and stuff zeroes into\r
-        * the data stream, so that we can produce some kind of image.\r
-        * Note that this code will be repeated for each byte demanded\r
-        * for the rest of the segment.  We use a nonvolatile flag to ensure\r
-        * that only one warning message appears.\r
-        */\r
-       if (! *(state->printed_eod_ptr)) {\r
-         WARNMS(state->cinfo, JWRN_HIT_MARKER);\r
-         *(state->printed_eod_ptr) = TRUE;\r
-       }\r
-       c = 0;                  /* insert a zero byte into bit buffer */\r
-      }\r
-    }\r
-\r
-    /* OK, load c into get_buffer */\r
-    get_buffer = (get_buffer << 8) | c;\r
-    bits_left += 8;\r
-  }\r
-\r
-  /* Unload the local registers */\r
-  state->next_input_byte = next_input_byte;\r
-  state->bytes_in_buffer = bytes_in_buffer;\r
-  state->get_buffer = get_buffer;\r
-  state->bits_left = bits_left;\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Out-of-line code for Huffman code decoding.\r
- * See jdhuff.h for info about usage.\r
- */\r
-\r
-GLOBAL int\r
-jpeg_huff_decode (bitread_working_state * state,\r
-                 register bit_buf_type get_buffer, register int bits_left,\r
-                 d_derived_tbl * htbl, int min_bits)\r
-{\r
-  register int l = min_bits;\r
-  register INT32 code;\r
-\r
-  /* HUFF_DECODE has determined that the code is at least min_bits */\r
-  /* bits long, so fetch that many bits in one swoop. */\r
-\r
-  CHECK_BIT_BUFFER(*state, l, return -1);\r
-  code = GET_BITS(l);\r
-\r
-  /* Collect the rest of the Huffman code one bit at a time. */\r
-  /* This is per Figure F.16 in the JPEG spec. */\r
-\r
-  while (code > htbl->maxcode[l]) {\r
-    code <<= 1;\r
-    CHECK_BIT_BUFFER(*state, 1, return -1);\r
-    code |= GET_BITS(1);\r
-    l++;\r
-  }\r
-\r
-  /* Unload the local registers */\r
-  state->get_buffer = get_buffer;\r
-  state->bits_left = bits_left;\r
-\r
-  /* With garbage input we may reach the sentinel value l = 17. */\r
-\r
-  if (l > 16) {\r
-    WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);\r
-    return 0;                  /* fake a zero as the safest result */\r
-  }\r
-\r
-  return htbl->pub->huffval[ htbl->valptr[l] +\r
-                           ((int) (code - htbl->mincode[l])) ];\r
-}\r
-\r
-\r
-/*\r
- * Figure F.12: extend sign bit.\r
- * On some machines, a shift and add will be faster than a table lookup.\r
- */\r
-\r
-#ifdef AVOID_TABLES\r
-\r
-#define HUFF_EXTEND(x,s)  ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))\r
-\r
-#else\r
-\r
-#define HUFF_EXTEND(x,s)  ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))\r
-\r
-static const int extend_test[16] =   /* entry n is 2**(n-1) */\r
-  { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,\r
-    0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };\r
-\r
-static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */\r
-  { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,\r
-    ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,\r
-    ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,\r
-    ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };\r
-\r
-#endif /* AVOID_TABLES */\r
-\r
-\r
-/*\r
- * Check for a restart marker & resynchronize decoder.\r
- * Returns FALSE if must suspend.\r
- */\r
-\r
-LOCAL boolean\r
-process_restart (j_decompress_ptr cinfo)\r
-{\r
-  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\r
-  int ci;\r
-\r
-  /* Throw away any unused bits remaining in bit buffer; */\r
-  /* include any full bytes in next_marker's count of discarded bytes */\r
-  cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;\r
-  entropy->bitstate.bits_left = 0;\r
-\r
-  /* Advance past the RSTn marker */\r
-  if (! (*cinfo->marker->read_restart_marker) (cinfo))\r
-    return FALSE;\r
-\r
-  /* Re-initialize DC predictions to 0 */\r
-  for (ci = 0; ci < cinfo->comps_in_scan; ci++)\r
-    entropy->saved.last_dc_val[ci] = 0;\r
-\r
-  /* Reset restart counter */\r
-  entropy->restarts_to_go = cinfo->restart_interval;\r
-\r
-  /* Next segment can get another out-of-data warning */\r
-  entropy->bitstate.printed_eod = FALSE;\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Decode and return one MCU's worth of Huffman-compressed coefficients.\r
- * The coefficients are reordered from zigzag order into natural array order,\r
- * but are not dequantized.\r
- *\r
- * The i'th block of the MCU is stored into the block pointed to by\r
- * MCU_data[i].  WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER.\r
- * (Wholesale zeroing is usually a little faster than retail...)\r
- *\r
- * Returns FALSE if data source requested suspension.  In that case no\r
- * changes have been made to permanent state.  (Exception: some output\r
- * coefficients may already have been assigned.  This is harmless for\r
- * this module, since we'll just re-assign them on the next call.)\r
- */\r
-\r
-METHODDEF boolean\r
-decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)\r
-{\r
-  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;\r
-  register int s, k, r;\r
-  int blkn, ci;\r
-  JBLOCKROW block;\r
-  BITREAD_STATE_VARS;\r
-  savable_state state;\r
-  d_derived_tbl * dctbl;\r
-  d_derived_tbl * actbl;\r
-  jpeg_component_info * compptr;\r
-\r
-  /* Process restart marker if needed; may have to suspend */\r
-  if (cinfo->restart_interval) {\r
-    if (entropy->restarts_to_go == 0)\r
-      if (! process_restart(cinfo))\r
-       return FALSE;\r
-  }\r
-\r
-  /* Load up working state */\r
-  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);\r
-  ASSIGN_STATE(state, entropy->saved);\r
-\r
-  /* Outer loop handles each block in the MCU */\r
-\r
-  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {\r
-    block = MCU_data[blkn];\r
-    ci = cinfo->MCU_membership[blkn];\r
-    compptr = cinfo->cur_comp_info[ci];\r
-    dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no];\r
-    actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no];\r
-\r
-    /* Decode a single block's worth of coefficients */\r
-\r
-    /* Section F.2.2.1: decode the DC coefficient difference */\r
-    HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);\r
-    if (s) {\r
-      CHECK_BIT_BUFFER(br_state, s, return FALSE);\r
-      r = GET_BITS(s);\r
-      s = HUFF_EXTEND(r, s);\r
-    }\r
-\r
-    /* Shortcut if component's values are not interesting */\r
-    if (! compptr->component_needed)\r
-      goto skip_ACs;\r
-\r
-    /* Convert DC difference to actual value, update last_dc_val */\r
-    s += state.last_dc_val[ci];\r
-    state.last_dc_val[ci] = s;\r
-    /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */\r
-    (*block)[0] = (JCOEF) s;\r
-\r
-    /* Do we need to decode the AC coefficients for this component? */\r
-    if (compptr->DCT_scaled_size > 1) {\r
-\r
-      /* Section F.2.2.2: decode the AC coefficients */\r
-      /* Since zeroes are skipped, output area must be cleared beforehand */\r
-      for (k = 1; k < DCTSIZE2; k++) {\r
-       HUFF_DECODE(s, br_state, actbl, return FALSE, label2);\r
-      \r
-       r = s >> 4;\r
-       s &= 15;\r
-      \r
-       if (s) {\r
-         k += r;\r
-         CHECK_BIT_BUFFER(br_state, s, return FALSE);\r
-         r = GET_BITS(s);\r
-         s = HUFF_EXTEND(r, s);\r
-         /* Output coefficient in natural (dezigzagged) order.\r
-          * Note: the extra entries in jpeg_natural_order[] will save us\r
-          * if k >= DCTSIZE2, which could happen if the data is corrupted.\r
-          */\r
-         (*block)[jpeg_natural_order[k]] = (JCOEF) s;\r
-       } else {\r
-         if (r != 15)\r
-           break;\r
-         k += 15;\r
-       }\r
-      }\r
-\r
-    } else {\r
-skip_ACs:\r
-\r
-      /* Section F.2.2.2: decode the AC coefficients */\r
-      /* In this path we just discard the values */\r
-      for (k = 1; k < DCTSIZE2; k++) {\r
-       HUFF_DECODE(s, br_state, actbl, return FALSE, label3);\r
-      \r
-       r = s >> 4;\r
-       s &= 15;\r
-      \r
-       if (s) {\r
-         k += r;\r
-         CHECK_BIT_BUFFER(br_state, s, return FALSE);\r
-         DROP_BITS(s);\r
-       } else {\r
-         if (r != 15)\r
-           break;\r
-         k += 15;\r
-       }\r
-      }\r
-\r
-    }\r
-  }\r
-\r
-  /* Completed MCU, so update state */\r
-  BITREAD_SAVE_STATE(cinfo,entropy->bitstate);\r
-  ASSIGN_STATE(entropy->saved, state);\r
-\r
-  /* Account for restart interval (no-op if not using restarts) */\r
-  entropy->restarts_to_go--;\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Module initialization routine for Huffman entropy decoding.\r
- */\r
-\r
-GLOBAL void\r
-jinit_huff_decoder (j_decompress_ptr cinfo)\r
-{\r
-  huff_entropy_ptr entropy;\r
-  int i;\r
-\r
-  entropy = (huff_entropy_ptr)\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-                               SIZEOF(huff_entropy_decoder));\r
-  cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;\r
-  entropy->pub.start_pass = start_pass_huff_decoder;\r
-  entropy->pub.decode_mcu = decode_mcu;\r
-\r
-  /* Mark tables unallocated */\r
-  for (i = 0; i < NUM_HUFF_TBLS; i++) {\r
-    entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;\r
-  }\r
-}\r
diff --git a/libs/jpeg6/jdhuff.h b/libs/jpeg6/jdhuff.h
deleted file mode 100644 (file)
index 65f3054..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*\r
- * jdhuff.h\r
- *\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
- * This file is part of the Independent JPEG Group's software.\r
- * For conditions of distribution and use, see the accompanying README file.\r
- *\r
- * This file contains declarations for Huffman entropy decoding routines\r
- * that are shared between the sequential decoder (jdhuff.c) and the\r
- * progressive decoder (jdphuff.c).  No other modules need to see these.\r
- */\r
-\r
-/* Short forms of external names for systems with brain-damaged linkers. */\r
-\r
-#ifdef NEED_SHORT_EXTERNAL_NAMES\r
-#define jpeg_make_d_derived_tbl        jMkDDerived\r
-#define jpeg_fill_bit_buffer   jFilBitBuf\r
-#define jpeg_huff_decode       jHufDecode\r
-#endif /* NEED_SHORT_EXTERNAL_NAMES */\r
-\r
-\r
-/* Derived data constructed for each Huffman table */\r
-\r
-#define HUFF_LOOKAHEAD 8       /* # of bits of lookahead */\r
-\r
-typedef struct {\r
-  /* Basic tables: (element [0] of each array is unused) */\r
-  INT32 mincode[17];           /* smallest code of length k */\r
-  INT32 maxcode[18];           /* largest code of length k (-1 if none) */\r
-  /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */\r
-  int valptr[17];              /* huffval[] index of 1st symbol of length k */\r
-\r
-  /* Link to public Huffman table (needed only in jpeg_huff_decode) */\r
-  JHUFF_TBL *pub;\r
-\r
-  /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of\r
-   * the input data stream.  If the next Huffman code is no more\r
-   * than HUFF_LOOKAHEAD bits long, we can obtain its length and\r
-   * the corresponding symbol directly from these tables.\r
-   */\r
-  int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */\r
-  UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */\r
-} d_derived_tbl;\r
-\r
-/* Expand a Huffman table definition into the derived format */\r
-EXTERN void jpeg_make_d_derived_tbl JPP((j_decompress_ptr cinfo,\r
-                               JHUFF_TBL * htbl, d_derived_tbl ** pdtbl));\r
-\r
-\r
-/*\r
- * Fetching the next N bits from the input stream is a time-critical operation\r
- * for the Huffman decoders.  We implement it with a combination of inline\r
- * macros and out-of-line subroutines.  Note that N (the number of bits\r
- * demanded at one time) never exceeds 15 for JPEG use.\r
- *\r
- * We read source bytes into get_buffer and dole out bits as needed.\r
- * If get_buffer already contains enough bits, they are fetched in-line\r
- * by the macros CHECK_BIT_BUFFER and GET_BITS.  When there aren't enough\r
- * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer\r
- * as full as possible (not just to the number of bits needed; this\r
- * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).\r
- * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.\r
- * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains\r
- * at least the requested number of bits --- dummy zeroes are inserted if\r
- * necessary.\r
- */\r
-\r
-typedef INT32 bit_buf_type;    /* type of bit-extraction buffer */\r
-#define BIT_BUF_SIZE  32       /* size of buffer in bits */\r
-\r
-/* If long is > 32 bits on your machine, and shifting/masking longs is\r
- * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE\r
- * appropriately should be a win.  Unfortunately we can't do this with\r
- * something like  #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)\r
- * because not all machines measure sizeof in 8-bit bytes.\r
- */\r
-\r
-typedef struct {               /* Bitreading state saved across MCUs */\r
-  bit_buf_type get_buffer;     /* current bit-extraction buffer */\r
-  int bits_left;               /* # of unused bits in it */\r
-  boolean printed_eod;         /* flag to suppress multiple warning msgs */\r
-} bitread_perm_state;\r
-\r
-typedef struct {               /* Bitreading working state within an MCU */\r
-  /* current data source state */\r
-  const JOCTET * next_input_byte; /* => next byte to read from source */\r
-  size_t bytes_in_buffer;      /* # of bytes remaining in source buffer */\r
-  int unread_marker;           /* nonzero if we have hit a marker */\r
-  /* bit input buffer --- note these values are kept in register variables,\r
-   * not in this struct, inside the inner loops.\r
-   */\r
-  bit_buf_type get_buffer;     /* current bit-extraction buffer */\r
-  int bits_left;               /* # of unused bits in it */\r
-  /* pointers needed by jpeg_fill_bit_buffer */\r
-  j_decompress_ptr cinfo;      /* back link to decompress master record */\r
-  boolean * printed_eod_ptr;   /* => flag in permanent state */\r
-} bitread_working_state;\r
-\r
-/* Macros to declare and load/save bitread local variables. */\r
-#define BITREAD_STATE_VARS  \\r
-       register bit_buf_type get_buffer;  \\r
-       register int bits_left;  \\r
-       bitread_working_state br_state\r
-\r
-#define BITREAD_LOAD_STATE(cinfop,permstate)  \\r
-       br_state.cinfo = cinfop; \\r
-       br_state.next_input_byte = cinfop->src->next_input_byte; \\r
-       br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \\r
-       br_state.unread_marker = cinfop->unread_marker; \\r
-       get_buffer = permstate.get_buffer; \\r
-       bits_left = permstate.bits_left; \\r
-       br_state.printed_eod_ptr = & permstate.printed_eod\r
-\r
-#define BITREAD_SAVE_STATE(cinfop,permstate)  \\r
-       cinfop->src->next_input_byte = br_state.next_input_byte; \\r
-       cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \\r
-       cinfop->unread_marker = br_state.unread_marker; \\r
-       permstate.get_buffer = get_buffer; \\r
-       permstate.bits_left = bits_left\r
-\r
-/*\r
- * These macros provide the in-line portion of bit fetching.\r
- * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer\r
- * before using GET_BITS, PEEK_BITS, or DROP_BITS.\r
- * The variables get_buffer and bits_left are assumed to be locals,\r
- * but the state struct might not be (jpeg_huff_decode needs this).\r
- *     CHECK_BIT_BUFFER(state,n,action);\r
- *             Ensure there are N bits in get_buffer; if suspend, take action.\r
- *      val = GET_BITS(n);\r
- *             Fetch next N bits.\r
- *      val = PEEK_BITS(n);\r
- *             Fetch next N bits without removing them from the buffer.\r
- *     DROP_BITS(n);\r
- *             Discard next N bits.\r
- * The value N should be a simple variable, not an expression, because it\r
- * is evaluated multiple times.\r
- */\r
-\r
-#define CHECK_BIT_BUFFER(state,nbits,action) \\r
-       { if (bits_left < (nbits)) {  \\r
-           if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits))  \\r
-             { action; }  \\r
-           get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }\r
-\r
-#define GET_BITS(nbits) \\r
-       (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1))\r
-\r
-#define PEEK_BITS(nbits) \\r
-       (((int) (get_buffer >> (bits_left -  (nbits)))) & ((1<<(nbits))-1))\r
-\r
-#define DROP_BITS(nbits) \\r
-       (bits_left -= (nbits))\r
-\r
-/* Load up the bit buffer to a depth of at least nbits */\r
-EXTERN boolean jpeg_fill_bit_buffer JPP((bitread_working_state * state,\r
-               register bit_buf_type get_buffer, register int bits_left,\r
-               int nbits));\r
-\r
-\r
-/*\r
- * Code for extracting next Huffman-coded symbol from input bit stream.\r
- * Again, this is time-critical and we make the main paths be macros.\r
- *\r
- * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits\r
- * without looping.  Usually, more than 95% of the Huffman codes will be 8\r
- * or fewer bits long.  The few overlength codes are handled with a loop,\r
- * which need not be inline code.\r
- *\r
- * Notes about the HUFF_DECODE macro:\r
- * 1. Near the end of the data segment, we may fail to get enough bits\r
- *    for a lookahead.  In that case, we do it the hard way.\r
- * 2. If the lookahead table contains no entry, the next code must be\r
- *    more than HUFF_LOOKAHEAD bits long.\r
- * 3. jpeg_huff_decode returns -1 if forced to suspend.\r
- */\r
-\r
-#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \\r
-{ register int nb, look; \\r
-  if (bits_left < HUFF_LOOKAHEAD) { \\r
-    if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \\r
-    get_buffer = state.get_buffer; bits_left = state.bits_left; \\r
-    if (bits_left < HUFF_LOOKAHEAD) { \\r
-      nb = 1; goto slowlabel; \\r
-    } \\r
-  } \\r
-  look = PEEK_BITS(HUFF_LOOKAHEAD); \\r
-  if ((nb = htbl->look_nbits[look]) != 0) { \\r
-    DROP_BITS(nb); \\r
-    result = htbl->look_sym[look]; \\r
-  } else { \\r
-    nb = HUFF_LOOKAHEAD+1; \\r
-slowlabel: \\r
-    if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \\r
-       { failaction; } \\r
-    get_buffer = state.get_buffer; bits_left = state.bits_left; \\r
-  } \\r
-}\r
-\r
-/* Out-of-line case for Huffman code fetching */\r
-EXTERN int jpeg_huff_decode JPP((bitread_working_state * state,\r
-               register bit_buf_type get_buffer, register int bits_left,\r
-               d_derived_tbl * htbl, int min_bits));\r
diff --git a/libs/jpeg6/jdinput.cpp b/libs/jpeg6/jdinput.cpp
deleted file mode 100644 (file)
index 4def216..0000000
+++ /dev/null
@@ -1,762 +0,0 @@
-/*\r
-\r
- * jdinput.c\r
-\r
- *\r
-\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains input control logic for the JPEG decompressor.\r
-\r
- * These routines are concerned with controlling the decompressor's input\r
-\r
- * processing (marker reading and coefficient decoding).  The actual input\r
-\r
- * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/* Private state */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  struct jpeg_input_controller pub; /* public fields */\r
-\r
-\r
-\r
-  boolean inheaders;           /* TRUE until first SOS is reached */\r
-\r
-} my_input_controller;\r
-\r
-\r
-\r
-typedef my_input_controller * my_inputctl_ptr;\r
-\r
-\r
-\r
-\r
-\r
-/* Forward declarations */\r
-\r
-METHODDEF int consume_markers JPP((j_decompress_ptr cinfo));\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Routines to calculate various quantities related to the size of the image.\r
-\r
- */\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-initial_setup (j_decompress_ptr cinfo)\r
-\r
-/* Called once, when first SOS marker is reached */\r
-\r
-{\r
-\r
-  int ci;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-\r
-\r
-  /* Make sure image isn't bigger than I can handle */\r
-\r
-  if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||\r
-\r
-      (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)\r
-\r
-    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);\r
-\r
-\r
-\r
-  /* For now, precision must match compiled-in value... */\r
-\r
-  if (cinfo->data_precision != BITS_IN_JSAMPLE)\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);\r
-\r
-\r
-\r
-  /* Check that number of components won't exceed internal array sizes */\r
-\r
-  if (cinfo->num_components > MAX_COMPONENTS)\r
-\r
-    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,\r
-\r
-            MAX_COMPONENTS);\r
-\r
-\r
-\r
-  /* Compute maximum sampling factors; check factor validity */\r
-\r
-  cinfo->max_h_samp_factor = 1;\r
-\r
-  cinfo->max_v_samp_factor = 1;\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||\r
-\r
-       compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_SAMPLING);\r
-\r
-    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,\r
-\r
-                                  compptr->h_samp_factor);\r
-\r
-    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,\r
-\r
-                                  compptr->v_samp_factor);\r
-\r
-  }\r
-\r
-\r
-\r
-  /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.\r
-\r
-   * In the full decompressor, this will be overridden by jdmaster.c;\r
-\r
-   * but in the transcoder, jdmaster.c is not used, so we must do it here.\r
-\r
-   */\r
-\r
-  cinfo->min_DCT_scaled_size = DCTSIZE;\r
-\r
-\r
-\r
-  /* Compute dimensions of components */\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    compptr->DCT_scaled_size = DCTSIZE;\r
-\r
-    /* Size in DCT blocks */\r
-\r
-    compptr->width_in_blocks = (JDIMENSION)\r
-\r
-      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\r
-\r
-                   (long) (cinfo->max_h_samp_factor * DCTSIZE));\r
-\r
-    compptr->height_in_blocks = (JDIMENSION)\r
-\r
-      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\r
-\r
-                   (long) (cinfo->max_v_samp_factor * DCTSIZE));\r
-\r
-    /* downsampled_width and downsampled_height will also be overridden by\r
-\r
-     * jdmaster.c if we are doing full decompression.  The transcoder library\r
-\r
-     * doesn't use these values, but the calling application might.\r
-\r
-     */\r
-\r
-    /* Size in samples */\r
-\r
-    compptr->downsampled_width = (JDIMENSION)\r
-\r
-      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,\r
-\r
-                   (long) cinfo->max_h_samp_factor);\r
-\r
-    compptr->downsampled_height = (JDIMENSION)\r
-\r
-      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,\r
-\r
-                   (long) cinfo->max_v_samp_factor);\r
-\r
-    /* Mark component needed, until color conversion says otherwise */\r
-\r
-    compptr->component_needed = TRUE;\r
-\r
-    /* Mark no quantization table yet saved for component */\r
-\r
-    compptr->quant_table = NULL;\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Compute number of fully interleaved MCU rows. */\r
-\r
-  cinfo->total_iMCU_rows = (JDIMENSION)\r
-\r
-    jdiv_round_up((long) cinfo->image_height,\r
-\r
-                 (long) (cinfo->max_v_samp_factor*DCTSIZE));\r
-\r
-\r
-\r
-  /* Decide whether file contains multiple scans */\r
-\r
-  if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)\r
-\r
-    cinfo->inputctl->has_multiple_scans = TRUE;\r
-\r
-  else\r
-\r
-    cinfo->inputctl->has_multiple_scans = FALSE;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-per_scan_setup (j_decompress_ptr cinfo)\r
-\r
-/* Do computations that are needed before processing a JPEG scan */\r
-\r
-/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */\r
-\r
-{\r
-\r
-  int ci, mcublks, tmp;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  \r
-\r
-  if (cinfo->comps_in_scan == 1) {\r
-\r
-    \r
-\r
-    /* Noninterleaved (single-component) scan */\r
-\r
-    compptr = cinfo->cur_comp_info[0];\r
-\r
-    \r
-\r
-    /* Overall image size in MCUs */\r
-\r
-    cinfo->MCUs_per_row = compptr->width_in_blocks;\r
-\r
-    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;\r
-\r
-    \r
-\r
-    /* For noninterleaved scan, always one block per MCU */\r
-\r
-    compptr->MCU_width = 1;\r
-\r
-    compptr->MCU_height = 1;\r
-\r
-    compptr->MCU_blocks = 1;\r
-\r
-    compptr->MCU_sample_width = compptr->DCT_scaled_size;\r
-\r
-    compptr->last_col_width = 1;\r
-\r
-    /* For noninterleaved scans, it is convenient to define last_row_height\r
-\r
-     * as the number of block rows present in the last iMCU row.\r
-\r
-     */\r
-\r
-    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);\r
-\r
-    if (tmp == 0) tmp = compptr->v_samp_factor;\r
-\r
-    compptr->last_row_height = tmp;\r
-\r
-    \r
-\r
-    /* Prepare array describing MCU composition */\r
-\r
-    cinfo->blocks_in_MCU = 1;\r
-\r
-    cinfo->MCU_membership[0] = 0;\r
-\r
-    \r
-\r
-  } else {\r
-\r
-    \r
-\r
-    /* Interleaved (multi-component) scan */\r
-\r
-    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)\r
-\r
-      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,\r
-\r
-              MAX_COMPS_IN_SCAN);\r
-\r
-    \r
-\r
-    /* Overall image size in MCUs */\r
-\r
-    cinfo->MCUs_per_row = (JDIMENSION)\r
-\r
-      jdiv_round_up((long) cinfo->image_width,\r
-\r
-                   (long) (cinfo->max_h_samp_factor*DCTSIZE));\r
-\r
-    cinfo->MCU_rows_in_scan = (JDIMENSION)\r
-\r
-      jdiv_round_up((long) cinfo->image_height,\r
-\r
-                   (long) (cinfo->max_v_samp_factor*DCTSIZE));\r
-\r
-    \r
-\r
-    cinfo->blocks_in_MCU = 0;\r
-\r
-    \r
-\r
-    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\r
-\r
-      compptr = cinfo->cur_comp_info[ci];\r
-\r
-      /* Sampling factors give # of blocks of component in each MCU */\r
-\r
-      compptr->MCU_width = compptr->h_samp_factor;\r
-\r
-      compptr->MCU_height = compptr->v_samp_factor;\r
-\r
-      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;\r
-\r
-      compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size;\r
-\r
-      /* Figure number of non-dummy blocks in last MCU column & row */\r
-\r
-      tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);\r
-\r
-      if (tmp == 0) tmp = compptr->MCU_width;\r
-\r
-      compptr->last_col_width = tmp;\r
-\r
-      tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);\r
-\r
-      if (tmp == 0) tmp = compptr->MCU_height;\r
-\r
-      compptr->last_row_height = tmp;\r
-\r
-      /* Prepare array describing MCU composition */\r
-\r
-      mcublks = compptr->MCU_blocks;\r
-\r
-      if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)\r
-\r
-       ERREXIT(cinfo, JERR_BAD_MCU_SIZE);\r
-\r
-      while (mcublks-- > 0) {\r
-\r
-       cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;\r
-\r
-      }\r
-\r
-    }\r
-\r
-    \r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Save away a copy of the Q-table referenced by each component present\r
-\r
- * in the current scan, unless already saved during a prior scan.\r
-\r
- *\r
-\r
- * In a multiple-scan JPEG file, the encoder could assign different components\r
-\r
- * the same Q-table slot number, but change table definitions between scans\r
-\r
- * so that each component uses a different Q-table.  (The IJG encoder is not\r
-\r
- * currently capable of doing this, but other encoders might.)  Since we want\r
-\r
- * to be able to dequantize all the components at the end of the file, this\r
-\r
- * means that we have to save away the table actually used for each component.\r
-\r
- * We do this by copying the table at the start of the first scan containing\r
-\r
- * the component.\r
-\r
- * The JPEG spec prohibits the encoder from changing the contents of a Q-table\r
-\r
- * slot between scans of a component using that slot.  If the encoder does so\r
-\r
- * anyway, this decoder will simply use the Q-table values that were current\r
-\r
- * at the start of the first scan for the component.\r
-\r
- *\r
-\r
- * The decompressor output side looks only at the saved quant tables,\r
-\r
- * not at the current Q-table slots.\r
-\r
- */\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-latch_quant_tables (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  int ci, qtblno;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  JQUANT_TBL * qtbl;\r
-\r
-\r
-\r
-  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {\r
-\r
-    compptr = cinfo->cur_comp_info[ci];\r
-\r
-    /* No work if we already saved Q-table for this component */\r
-\r
-    if (compptr->quant_table != NULL)\r
-\r
-      continue;\r
-\r
-    /* Make sure specified quantization table is present */\r
-\r
-    qtblno = compptr->quant_tbl_no;\r
-\r
-    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||\r
-\r
-       cinfo->quant_tbl_ptrs[qtblno] == NULL)\r
-\r
-      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);\r
-\r
-    /* OK, save away the quantization table */\r
-\r
-    qtbl = (JQUANT_TBL *)\r
-\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                                 SIZEOF(JQUANT_TBL));\r
-\r
-    MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));\r
-\r
-    compptr->quant_table = qtbl;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize the input modules to read a scan of compressed data.\r
-\r
- * The first call to this is done by jdmaster.c after initializing\r
-\r
- * the entire decompressor (during jpeg_start_decompress).\r
-\r
- * Subsequent calls come from consume_markers, below.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_input_pass (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  per_scan_setup(cinfo);\r
-\r
-  latch_quant_tables(cinfo);\r
-\r
-  (*cinfo->entropy->start_pass) (cinfo);\r
-\r
-  (*cinfo->coef->start_input_pass) (cinfo);\r
-\r
-  cinfo->inputctl->consume_input = cinfo->coef->consume_data;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Finish up after inputting a compressed-data scan.\r
-\r
- * This is called by the coefficient controller after it's read all\r
-\r
- * the expected data of the scan.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-finish_input_pass (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  cinfo->inputctl->consume_input = consume_markers;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Read JPEG markers before, between, or after compressed-data scans.\r
-\r
- * Change state as necessary when a new scan is reached.\r
-\r
- * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\r
-\r
- *\r
-\r
- * The consume_input method pointer points either here or to the\r
-\r
- * coefficient controller's consume_data routine, depending on whether\r
-\r
- * we are reading a compressed data segment or inter-segment markers.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF int\r
-\r
-consume_markers (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;\r
-\r
-  int val;\r
-\r
-\r
-\r
-  if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */\r
-\r
-    return JPEG_REACHED_EOI;\r
-\r
-\r
-\r
-  val = (*cinfo->marker->read_markers) (cinfo);\r
-\r
-\r
-\r
-  switch (val) {\r
-\r
-  case JPEG_REACHED_SOS:       /* Found SOS */\r
-\r
-    if (inputctl->inheaders) { /* 1st SOS */\r
-\r
-      initial_setup(cinfo);\r
-\r
-      inputctl->inheaders = FALSE;\r
-\r
-      /* Note: start_input_pass must be called by jdmaster.c\r
-\r
-       * before any more input can be consumed.  jdapi.c is\r
-\r
-       * responsible for enforcing this sequencing.\r
-\r
-       */\r
-\r
-    } else {                   /* 2nd or later SOS marker */\r
-\r
-      if (! inputctl->pub.has_multiple_scans)\r
-\r
-       ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */\r
-\r
-      start_input_pass(cinfo);\r
-\r
-    }\r
-\r
-    break;\r
-\r
-  case JPEG_REACHED_EOI:       /* Found EOI */\r
-\r
-    inputctl->pub.eoi_reached = TRUE;\r
-\r
-    if (inputctl->inheaders) { /* Tables-only datastream, apparently */\r
-\r
-      if (cinfo->marker->saw_SOF)\r
-\r
-       ERREXIT(cinfo, JERR_SOF_NO_SOS);\r
-\r
-    } else {\r
-\r
-      /* Prevent infinite loop in coef ctlr's decompress_data routine\r
-\r
-       * if user set output_scan_number larger than number of scans.\r
-\r
-       */\r
-\r
-      if (cinfo->output_scan_number > cinfo->input_scan_number)\r
-\r
-       cinfo->output_scan_number = cinfo->input_scan_number;\r
-\r
-    }\r
-\r
-    break;\r
-\r
-  case JPEG_SUSPENDED:\r
-\r
-    break;\r
-\r
-  }\r
-\r
-\r
-\r
-  return val;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Reset state to begin a fresh datastream.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-reset_input_controller (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;\r
-\r
-\r
-\r
-  inputctl->pub.consume_input = consume_markers;\r
-\r
-  inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */\r
-\r
-  inputctl->pub.eoi_reached = FALSE;\r
-\r
-  inputctl->inheaders = TRUE;\r
-\r
-  /* Reset other modules */\r
-\r
-  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);\r
-\r
-  (*cinfo->marker->reset_marker_reader) (cinfo);\r
-\r
-  /* Reset progression state -- would be cleaner if entropy decoder did this */\r
-\r
-  cinfo->coef_bits = NULL;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize the input controller module.\r
-\r
- * This is called only once, when the decompression object is created.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jinit_input_controller (j_decompress_ptr cinfo)\r
-\r
-{\r
-\r
-  my_inputctl_ptr inputctl;\r
-\r
-\r
-\r
-  /* Create subobject in permanent pool */\r
-\r
-  inputctl = (my_inputctl_ptr)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\r
-\r
-                               SIZEOF(my_input_controller));\r
-\r
-  cinfo->inputctl = (struct jpeg_input_controller *) inputctl;\r
-\r
-  /* Initialize method pointers */\r
-\r
-  inputctl->pub.consume_input = consume_markers;\r
-\r
-  inputctl->pub.reset_input_controller = reset_input_controller;\r
-\r
-  inputctl->pub.start_input_pass = start_input_pass;\r
-\r
-  inputctl->pub.finish_input_pass = finish_input_pass;\r
-\r
-  /* Initialize state: can't use reset_input_controller since we don't\r
-\r
-   * want to try to reset other modules yet.\r
-\r
-   */\r
-\r
-  inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */\r
-\r
-  inputctl->pub.eoi_reached = FALSE;\r
-\r
-  inputctl->inheaders = TRUE;\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jdmainct.cpp b/libs/jpeg6/jdmainct.cpp
deleted file mode 100644 (file)
index 7b4c255..0000000
+++ /dev/null
@@ -1,1024 +0,0 @@
-/*\r
-\r
- * jdmainct.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains the main buffer controller for decompression.\r
-\r
- * The main buffer lies between the JPEG decompressor proper and the\r
-\r
- * post-processor; it holds downsampled data in the JPEG colorspace.\r
-\r
- *\r
-\r
- * Note that this code is bypassed in raw-data mode, since the application\r
-\r
- * supplies the equivalent of the main buffer in that case.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * In the current system design, the main buffer need never be a full-image\r
-\r
- * buffer; any full-height buffers will be found inside the coefficient or\r
-\r
- * postprocessing controllers.  Nonetheless, the main controller is not\r
-\r
- * trivial.  Its responsibility is to provide context rows for upsampling/\r
-\r
- * rescaling, and doing this in an efficient fashion is a bit tricky.\r
-\r
- *\r
-\r
- * Postprocessor input data is counted in "row groups".  A row group\r
-\r
- * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)\r
-\r
- * sample rows of each component.  (We require DCT_scaled_size values to be\r
-\r
- * chosen such that these numbers are integers.  In practice DCT_scaled_size\r
-\r
- * values will likely be powers of two, so we actually have the stronger\r
-\r
- * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.)\r
-\r
- * Upsampling will typically produce max_v_samp_factor pixel rows from each\r
-\r
- * row group (times any additional scale factor that the upsampler is\r
-\r
- * applying).\r
-\r
- *\r
-\r
- * The coefficient controller will deliver data to us one iMCU row at a time;\r
-\r
- * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or\r
-\r
- * exactly min_DCT_scaled_size row groups.  (This amount of data corresponds\r
-\r
- * to one row of MCUs when the image is fully interleaved.)  Note that the\r
-\r
- * number of sample rows varies across components, but the number of row\r
-\r
- * groups does not.  Some garbage sample rows may be included in the last iMCU\r
-\r
- * row at the bottom of the image.\r
-\r
- *\r
-\r
- * Depending on the vertical scaling algorithm used, the upsampler may need\r
-\r
- * access to the sample row(s) above and below its current input row group.\r
-\r
- * The upsampler is required to set need_context_rows TRUE at global selection\r
-\r
- * time if so.  When need_context_rows is FALSE, this controller can simply\r
-\r
- * obtain one iMCU row at a time from the coefficient controller and dole it\r
-\r
- * out as row groups to the postprocessor.\r
-\r
- *\r
-\r
- * When need_context_rows is TRUE, this controller guarantees that the buffer\r
-\r
- * passed to postprocessing contains at least one row group's worth of samples\r
-\r
- * above and below the row group(s) being processed.  Note that the context\r
-\r
- * rows "above" the first passed row group appear at negative row offsets in\r
-\r
- * the passed buffer.  At the top and bottom of the image, the required\r
-\r
- * context rows are manufactured by duplicating the first or last real sample\r
-\r
- * row; this avoids having special cases in the upsampling inner loops.\r
-\r
- *\r
-\r
- * The amount of context is fixed at one row group just because that's a\r
-\r
- * convenient number for this controller to work with.  The existing\r
-\r
- * upsamplers really only need one sample row of context.  An upsampler\r
-\r
- * supporting arbitrary output rescaling might wish for more than one row\r
-\r
- * group of context when shrinking the image; tough, we don't handle that.\r
-\r
- * (This is justified by the assumption that downsizing will be handled mostly\r
-\r
- * by adjusting the DCT_scaled_size values, so that the actual scale factor at\r
-\r
- * the upsample step needn't be much less than one.)\r
-\r
- *\r
-\r
- * To provide the desired context, we have to retain the last two row groups\r
-\r
- * of one iMCU row while reading in the next iMCU row.  (The last row group\r
-\r
- * can't be processed until we have another row group for its below-context,\r
-\r
- * and so we have to save the next-to-last group too for its above-context.)\r
-\r
- * We could do this most simply by copying data around in our buffer, but\r
-\r
- * that'd be very slow.  We can avoid copying any data by creating a rather\r
-\r
- * strange pointer structure.  Here's how it works.  We allocate a workspace\r
-\r
- * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number\r
-\r
- * of row groups per iMCU row).  We create two sets of redundant pointers to\r
-\r
- * the workspace.  Labeling the physical row groups 0 to M+1, the synthesized\r
-\r
- * pointer lists look like this:\r
-\r
- *                   M+1                          M-1\r
-\r
- * master pointer --> 0         master pointer --> 0\r
-\r
- *                    1                            1\r
-\r
- *                   ...                          ...\r
-\r
- *                   M-3                          M-3\r
-\r
- *                   M-2                           M\r
-\r
- *                   M-1                          M+1\r
-\r
- *                    M                           M-2\r
-\r
- *                   M+1                          M-1\r
-\r
- *                    0                            0\r
-\r
- * We read alternate iMCU rows using each master pointer; thus the last two\r
-\r
- * row groups of the previous iMCU row remain un-overwritten in the workspace.\r
-\r
- * The pointer lists are set up so that the required context rows appear to\r
-\r
- * be adjacent to the proper places when we pass the pointer lists to the\r
-\r
- * upsampler.\r
-\r
- *\r
-\r
- * The above pictures describe the normal state of the pointer lists.\r
-\r
- * At top and bottom of the image, we diddle the pointer lists to duplicate\r
-\r
- * the first or last sample row as necessary (this is cheaper than copying\r
-\r
- * sample rows around).\r
-\r
- *\r
-\r
- * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1.  In that\r
-\r
- * situation each iMCU row provides only one row group so the buffering logic\r
-\r
- * must be different (eg, we must read two iMCU rows before we can emit the\r
-\r
- * first row group).  For now, we simply do not support providing context\r
-\r
- * rows when min_DCT_scaled_size is 1.  That combination seems unlikely to\r
-\r
- * be worth providing --- if someone wants a 1/8th-size preview, they probably\r
-\r
- * want it quick and dirty, so a context-free upsampler is sufficient.\r
-\r
- */\r
-\r
-\r
-\r
-\r
-\r
-/* Private buffer controller object */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  struct jpeg_d_main_controller pub; /* public fields */\r
-\r
-\r
-\r
-  /* Pointer to allocated workspace (M or M+2 row groups). */\r
-\r
-  JSAMPARRAY buffer[MAX_COMPONENTS];\r
-\r
-\r
-\r
-  boolean buffer_full;         /* Have we gotten an iMCU row from decoder? */\r
-\r
-  JDIMENSION rowgroup_ctr;     /* counts row groups output to postprocessor */\r
-\r
-\r
-\r
-  /* Remaining fields are only used in the context case. */\r
-\r
-\r
-\r
-  /* These are the master pointers to the funny-order pointer lists. */\r
-\r
-  JSAMPIMAGE xbuffer[2];       /* pointers to weird pointer lists */\r
-\r
-\r
-\r
-  int whichptr;                        /* indicates which pointer set is now in use */\r
-\r
-  int context_state;           /* process_data state machine status */\r
-\r
-  JDIMENSION rowgroups_avail;  /* row groups available to postprocessor */\r
-\r
-  JDIMENSION iMCU_row_ctr;     /* counts iMCU rows to detect image top/bot */\r
-\r
-} my_main_controller;\r
-\r
-\r
-\r
-typedef my_main_controller * my_main_ptr;\r
-\r
-\r
-\r
-/* context_state values: */\r
-\r
-#define CTX_PREPARE_FOR_IMCU   0       /* need to prepare for MCU row */\r
-\r
-#define CTX_PROCESS_IMCU       1       /* feeding iMCU to postprocessor */\r
-\r
-#define CTX_POSTPONED_ROW      2       /* feeding postponed row group */\r
-\r
-\r
-\r
-\r
-\r
-/* Forward declarations */\r
-\r
-METHODDEF void process_data_simple_main\r
-\r
-       JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\r
-\r
-            JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\r
-\r
-METHODDEF void process_data_context_main\r
-\r
-       JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\r
-\r
-            JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-METHODDEF void process_data_crank_post\r
-\r
-       JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,\r
-\r
-            JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));\r
-\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-alloc_funny_pointers (j_decompress_ptr cinfo)\r
-\r
-/* Allocate space for the funny pointer lists.\r
-\r
- * This is done only once, not once per pass.\r
-\r
- */\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-  int ci, rgroup;\r
-\r
-  int M = cinfo->min_DCT_scaled_size;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  JSAMPARRAY xbuf;\r
-\r
-\r
-\r
-  /* Get top-level space for component array pointers.\r
-\r
-   * We alloc both arrays with one call to save a few cycles.\r
-\r
-   */\r
-\r
-  main->xbuffer[0] = (JSAMPIMAGE)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));\r
-\r
-  main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\r
-\r
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */\r
-\r
-    /* Get space for pointer lists --- M+4 row groups in each list.\r
-\r
-     * We alloc both pointer lists with one call to save a few cycles.\r
-\r
-     */\r
-\r
-    xbuf = (JSAMPARRAY)\r
-\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                                 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));\r
-\r
-    xbuf += rgroup;            /* want one row group at negative offsets */\r
-\r
-    main->xbuffer[0][ci] = xbuf;\r
-\r
-    xbuf += rgroup * (M + 4);\r
-\r
-    main->xbuffer[1][ci] = xbuf;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-make_funny_pointers (j_decompress_ptr cinfo)\r
-\r
-/* Create the funny pointer lists discussed in the comments above.\r
-\r
- * The actual workspace is already allocated (in main->buffer),\r
-\r
- * and the space for the pointer lists is allocated too.\r
-\r
- * This routine just fills in the curiously ordered lists.\r
-\r
- * This will be repeated at the beginning of each pass.\r
-\r
- */\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-  int ci, i, rgroup;\r
-\r
-  int M = cinfo->min_DCT_scaled_size;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  JSAMPARRAY buf, xbuf0, xbuf1;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\r
-\r
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */\r
-\r
-    xbuf0 = main->xbuffer[0][ci];\r
-\r
-    xbuf1 = main->xbuffer[1][ci];\r
-\r
-    /* First copy the workspace pointers as-is */\r
-\r
-    buf = main->buffer[ci];\r
-\r
-    for (i = 0; i < rgroup * (M + 2); i++) {\r
-\r
-      xbuf0[i] = xbuf1[i] = buf[i];\r
-\r
-    }\r
-\r
-    /* In the second list, put the last four row groups in swapped order */\r
-\r
-    for (i = 0; i < rgroup * 2; i++) {\r
-\r
-      xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];\r
-\r
-      xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];\r
-\r
-    }\r
-\r
-    /* The wraparound pointers at top and bottom will be filled later\r
-\r
-     * (see set_wraparound_pointers, below).  Initially we want the "above"\r
-\r
-     * pointers to duplicate the first actual data line.  This only needs\r
-\r
-     * to happen in xbuffer[0].\r
-\r
-     */\r
-\r
-    for (i = 0; i < rgroup; i++) {\r
-\r
-      xbuf0[i - rgroup] = xbuf0[0];\r
-\r
-    }\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-set_wraparound_pointers (j_decompress_ptr cinfo)\r
-\r
-/* Set up the "wraparound" pointers at top and bottom of the pointer lists.\r
-\r
- * This changes the pointer list state from top-of-image to the normal state.\r
-\r
- */\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-  int ci, i, rgroup;\r
-\r
-  int M = cinfo->min_DCT_scaled_size;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  JSAMPARRAY xbuf0, xbuf1;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\r
-\r
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */\r
-\r
-    xbuf0 = main->xbuffer[0][ci];\r
-\r
-    xbuf1 = main->xbuffer[1][ci];\r
-\r
-    for (i = 0; i < rgroup; i++) {\r
-\r
-      xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];\r
-\r
-      xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];\r
-\r
-      xbuf0[rgroup*(M+2) + i] = xbuf0[i];\r
-\r
-      xbuf1[rgroup*(M+2) + i] = xbuf1[i];\r
-\r
-    }\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-LOCAL void\r
-\r
-set_bottom_pointers (j_decompress_ptr cinfo)\r
-\r
-/* Change the pointer lists to duplicate the last sample row at the bottom\r
-\r
- * of the image.  whichptr indicates which xbuffer holds the final iMCU row.\r
-\r
- * Also sets rowgroups_avail to indicate number of nondummy row groups in row.\r
-\r
- */\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-  int ci, i, rgroup, iMCUheight, rows_left;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-  JSAMPARRAY xbuf;\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    /* Count sample rows in one iMCU row and in one row group */\r
-\r
-    iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size;\r
-\r
-    rgroup = iMCUheight / cinfo->min_DCT_scaled_size;\r
-\r
-    /* Count nondummy sample rows remaining for this component */\r
-\r
-    rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);\r
-\r
-    if (rows_left == 0) rows_left = iMCUheight;\r
-\r
-    /* Count nondummy row groups.  Should get same answer for each component,\r
-\r
-     * so we need only do it once.\r
-\r
-     */\r
-\r
-    if (ci == 0) {\r
-\r
-      main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);\r
-\r
-    }\r
-\r
-    /* Duplicate the last real sample row rgroup*2 times; this pads out the\r
-\r
-     * last partial rowgroup and ensures at least one full rowgroup of context.\r
-\r
-     */\r
-\r
-    xbuf = main->xbuffer[main->whichptr][ci];\r
-\r
-    for (i = 0; i < rgroup * 2; i++) {\r
-\r
-      xbuf[rows_left + i] = xbuf[rows_left-1];\r
-\r
-    }\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize for a processing pass.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-\r
-\r
-  switch (pass_mode) {\r
-\r
-  case JBUF_PASS_THRU:\r
-\r
-    if (cinfo->upsample->need_context_rows) {\r
-\r
-      main->pub.process_data = process_data_context_main;\r
-\r
-      make_funny_pointers(cinfo); /* Create the xbuffer[] lists */\r
-\r
-      main->whichptr = 0;      /* Read first iMCU row into xbuffer[0] */\r
-\r
-      main->context_state = CTX_PREPARE_FOR_IMCU;\r
-\r
-      main->iMCU_row_ctr = 0;\r
-\r
-    } else {\r
-\r
-      /* Simple case with no context needed */\r
-\r
-      main->pub.process_data = process_data_simple_main;\r
-\r
-    }\r
-\r
-    main->buffer_full = FALSE; /* Mark buffer empty */\r
-\r
-    main->rowgroup_ctr = 0;\r
-\r
-    break;\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-  case JBUF_CRANK_DEST:\r
-\r
-    /* For last pass of 2-pass quantization, just crank the postprocessor */\r
-\r
-    main->pub.process_data = process_data_crank_post;\r
-\r
-    break;\r
-\r
-#endif\r
-\r
-  default:\r
-\r
-    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\r
-\r
-    break;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Process some data.\r
-\r
- * This handles the simple case where no context is required.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-process_data_simple_main (j_decompress_ptr cinfo,\r
-\r
-                         JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-                         JDIMENSION out_rows_avail)\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-  JDIMENSION rowgroups_avail;\r
-\r
-\r
-\r
-  /* Read input data if we haven't filled the main buffer yet */\r
-\r
-  if (! main->buffer_full) {\r
-\r
-    if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer))\r
-\r
-      return;                  /* suspension forced, can do nothing more */\r
-\r
-    main->buffer_full = TRUE;  /* OK, we have an iMCU row to work with */\r
-\r
-  }\r
-\r
-\r
-\r
-  /* There are always min_DCT_scaled_size row groups in an iMCU row. */\r
-\r
-  rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;\r
-\r
-  /* Note: at the bottom of the image, we may pass extra garbage row groups\r
-\r
-   * to the postprocessor.  The postprocessor has to check for bottom\r
-\r
-   * of image anyway (at row resolution), so no point in us doing it too.\r
-\r
-   */\r
-\r
-\r
-\r
-  /* Feed the postprocessor */\r
-\r
-  (*cinfo->post->post_process_data) (cinfo, main->buffer,\r
-\r
-                                    &main->rowgroup_ctr, rowgroups_avail,\r
-\r
-                                    output_buf, out_row_ctr, out_rows_avail);\r
-\r
-\r
-\r
-  /* Has postprocessor consumed all the data yet? If so, mark buffer empty */\r
-\r
-  if (main->rowgroup_ctr >= rowgroups_avail) {\r
-\r
-    main->buffer_full = FALSE;\r
-\r
-    main->rowgroup_ctr = 0;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Process some data.\r
-\r
- * This handles the case where context rows must be provided.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-process_data_context_main (j_decompress_ptr cinfo,\r
-\r
-                          JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-                          JDIMENSION out_rows_avail)\r
-\r
-{\r
-\r
-  my_main_ptr main = (my_main_ptr) cinfo->main;\r
-\r
-\r
-\r
-  /* Read input data if we haven't filled the main buffer yet */\r
-\r
-  if (! main->buffer_full) {\r
-\r
-    if (! (*cinfo->coef->decompress_data) (cinfo,\r
-\r
-                                          main->xbuffer[main->whichptr]))\r
-\r
-      return;                  /* suspension forced, can do nothing more */\r
-\r
-    main->buffer_full = TRUE;  /* OK, we have an iMCU row to work with */\r
-\r
-    main->iMCU_row_ctr++;      /* count rows received */\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Postprocessor typically will not swallow all the input data it is handed\r
-\r
-   * in one call (due to filling the output buffer first).  Must be prepared\r
-\r
-   * to exit and restart.  This switch lets us keep track of how far we got.\r
-\r
-   * Note that each case falls through to the next on successful completion.\r
-\r
-   */\r
-\r
-  switch (main->context_state) {\r
-\r
-  case CTX_POSTPONED_ROW:\r
-\r
-    /* Call postprocessor using previously set pointers for postponed row */\r
-\r
-    (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],\r
-\r
-                       &main->rowgroup_ctr, main->rowgroups_avail,\r
-\r
-                       output_buf, out_row_ctr, out_rows_avail);\r
-\r
-    if (main->rowgroup_ctr < main->rowgroups_avail)\r
-\r
-      return;                  /* Need to suspend */\r
-\r
-    main->context_state = CTX_PREPARE_FOR_IMCU;\r
-\r
-    if (*out_row_ctr >= out_rows_avail)\r
-\r
-      return;                  /* Postprocessor exactly filled output buf */\r
-\r
-    /*FALLTHROUGH*/\r
-\r
-  case CTX_PREPARE_FOR_IMCU:\r
-\r
-    /* Prepare to process first M-1 row groups of this iMCU row */\r
-\r
-    main->rowgroup_ctr = 0;\r
-\r
-    main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);\r
-\r
-    /* Check for bottom of image: if so, tweak pointers to "duplicate"\r
-\r
-     * the last sample row, and adjust rowgroups_avail to ignore padding rows.\r
-\r
-     */\r
-\r
-    if (main->iMCU_row_ctr == cinfo->total_iMCU_rows)\r
-\r
-      set_bottom_pointers(cinfo);\r
-\r
-    main->context_state = CTX_PROCESS_IMCU;\r
-\r
-    /*FALLTHROUGH*/\r
-\r
-  case CTX_PROCESS_IMCU:\r
-\r
-    /* Call postprocessor using previously set pointers */\r
-\r
-    (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],\r
-\r
-                       &main->rowgroup_ctr, main->rowgroups_avail,\r
-\r
-                       output_buf, out_row_ctr, out_rows_avail);\r
-\r
-    if (main->rowgroup_ctr < main->rowgroups_avail)\r
-\r
-      return;                  /* Need to suspend */\r
-\r
-    /* After the first iMCU, change wraparound pointers to normal state */\r
-\r
-    if (main->iMCU_row_ctr == 1)\r
-\r
-      set_wraparound_pointers(cinfo);\r
-\r
-    /* Prepare to load new iMCU row using other xbuffer list */\r
-\r
-    main->whichptr ^= 1;       /* 0=>1 or 1=>0 */\r
-\r
-    main->buffer_full = FALSE;\r
-\r
-    /* Still need to process last row group of this iMCU row, */\r
-\r
-    /* which is saved at index M+1 of the other xbuffer */\r
-\r
-    main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);\r
-\r
-    main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);\r
-\r
-    main->context_state = CTX_POSTPONED_ROW;\r
-\r
-  }\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Process some data.\r
-\r
- * Final pass of two-pass quantization: just call the postprocessor.\r
-\r
- * Source data will be the postprocessor controller's internal buffer.\r
-\r
- */\r
-\r
-\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-process_data_crank_post (j_decompress_ptr cinfo,\r
-\r
-                        JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-                        JDIMENSION out_rows_avail)\r
-\r
-{\r
-\r
-  (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,\r
-\r
-                                    (JDIMENSION *) NULL, (JDIMENSION) 0,\r
-\r
-                                    output_buf, out_row_ctr, out_rows_avail);\r
-\r
-}\r
-\r
-\r
-\r
-#endif /* QUANT_2PASS_SUPPORTED */\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize main buffer controller.\r
-\r
- */\r
-\r
-\r
-\r
-GLOBAL void\r
-\r
-jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)\r
-\r
-{\r
-\r
-  my_main_ptr main;\r
-\r
-  int ci, rgroup, ngroups;\r
-\r
-  jpeg_component_info *compptr;\r
-\r
-\r
-\r
-  main = (my_main_ptr)\r
-\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                               SIZEOF(my_main_controller));\r
-\r
-  cinfo->main = (struct jpeg_d_main_controller *) main;\r
-\r
-  main->pub.start_pass = start_pass_main;\r
-\r
-\r
-\r
-  if (need_full_buffer)                /* shouldn't happen */\r
-\r
-    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\r
-\r
-\r
-\r
-  /* Allocate the workspace.\r
-\r
-   * ngroups is the number of row groups we need.\r
-\r
-   */\r
-\r
-  if (cinfo->upsample->need_context_rows) {\r
-\r
-    if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */\r
-\r
-      ERREXIT(cinfo, JERR_NOTIMPL);\r
-\r
-    alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */\r
-\r
-    ngroups = cinfo->min_DCT_scaled_size + 2;\r
-\r
-  } else {\r
-\r
-    ngroups = cinfo->min_DCT_scaled_size;\r
-\r
-  }\r
-\r
-\r
-\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-\r
-       ci++, compptr++) {\r
-\r
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /\r
-\r
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */\r
-\r
-    main->buffer[ci] = (*cinfo->mem->alloc_sarray)\r
-\r
-                       ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-\r
-                        compptr->width_in_blocks * compptr->DCT_scaled_size,\r
-\r
-                        (JDIMENSION) (rgroup * ngroups));\r
-\r
-  }\r
-\r
-}\r
-\r
diff --git a/libs/jpeg6/jdmarker.cpp b/libs/jpeg6/jdmarker.cpp
deleted file mode 100644 (file)
index 1576098..0000000
+++ /dev/null
@@ -1,1052 +0,0 @@
-/*\r
- * jdmarker.c\r
- *\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
- * This file is part of the Independent JPEG Group's software.\r
- * For conditions of distribution and use, see the accompanying README file.\r
- *\r
- * This file contains routines to decode JPEG datastream markers.\r
- * Most of the complexity arises from our desire to support input\r
- * suspension: if not all of the data for a marker is available,\r
- * we must exit back to the application.  On resumption, we reprocess\r
- * the marker.\r
- */\r
-\r
-#define JPEG_INTERNALS\r
-#include "jinclude.h"\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-typedef enum {                 /* JPEG marker codes */\r
-  M_SOF0  = 0xc0,\r
-  M_SOF1  = 0xc1,\r
-  M_SOF2  = 0xc2,\r
-  M_SOF3  = 0xc3,\r
-  \r
-  M_SOF5  = 0xc5,\r
-  M_SOF6  = 0xc6,\r
-  M_SOF7  = 0xc7,\r
-  \r
-  M_JPG   = 0xc8,\r
-  M_SOF9  = 0xc9,\r
-  M_SOF10 = 0xca,\r
-  M_SOF11 = 0xcb,\r
-  \r
-  M_SOF13 = 0xcd,\r
-  M_SOF14 = 0xce,\r
-  M_SOF15 = 0xcf,\r
-  \r
-  M_DHT   = 0xc4,\r
-  \r
-  M_DAC   = 0xcc,\r
-  \r
-  M_RST0  = 0xd0,\r
-  M_RST1  = 0xd1,\r
-  M_RST2  = 0xd2,\r
-  M_RST3  = 0xd3,\r
-  M_RST4  = 0xd4,\r
-  M_RST5  = 0xd5,\r
-  M_RST6  = 0xd6,\r
-  M_RST7  = 0xd7,\r
-  \r
-  M_SOI   = 0xd8,\r
-  M_EOI   = 0xd9,\r
-  M_SOS   = 0xda,\r
-  M_DQT   = 0xdb,\r
-  M_DNL   = 0xdc,\r
-  M_DRI   = 0xdd,\r
-  M_DHP   = 0xde,\r
-  M_EXP   = 0xdf,\r
-  \r
-  M_APP0  = 0xe0,\r
-  M_APP1  = 0xe1,\r
-  M_APP2  = 0xe2,\r
-  M_APP3  = 0xe3,\r
-  M_APP4  = 0xe4,\r
-  M_APP5  = 0xe5,\r
-  M_APP6  = 0xe6,\r
-  M_APP7  = 0xe7,\r
-  M_APP8  = 0xe8,\r
-  M_APP9  = 0xe9,\r
-  M_APP10 = 0xea,\r
-  M_APP11 = 0xeb,\r
-  M_APP12 = 0xec,\r
-  M_APP13 = 0xed,\r
-  M_APP14 = 0xee,\r
-  M_APP15 = 0xef,\r
-  \r
-  M_JPG0  = 0xf0,\r
-  M_JPG13 = 0xfd,\r
-  M_COM   = 0xfe,\r
-  \r
-  M_TEM   = 0x01,\r
-  \r
-  M_ERROR = 0x100\r
-} JPEG_MARKER;\r
-\r
-\r
-/*\r
- * Macros for fetching data from the data source module.\r
- *\r
- * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect\r
- * the current restart point; we update them only when we have reached a\r
- * suitable place to restart if a suspension occurs.\r
- */\r
-\r
-/* Declare and initialize local copies of input pointer/count */\r
-#define INPUT_VARS(cinfo)  \\r
-       struct jpeg_source_mgr * datasrc = (cinfo)->src;  \\r
-       const JOCTET * next_input_byte = datasrc->next_input_byte;  \\r
-       size_t bytes_in_buffer = datasrc->bytes_in_buffer\r
-\r
-/* Unload the local copies --- do this only at a restart boundary */\r
-#define INPUT_SYNC(cinfo)  \\r
-       ( datasrc->next_input_byte = next_input_byte,  \\r
-         datasrc->bytes_in_buffer = bytes_in_buffer )\r
-\r
-/* Reload the local copies --- seldom used except in MAKE_BYTE_AVAIL */\r
-#define INPUT_RELOAD(cinfo)  \\r
-       ( next_input_byte = datasrc->next_input_byte,  \\r
-         bytes_in_buffer = datasrc->bytes_in_buffer )\r
-\r
-/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available.\r
- * Note we do *not* do INPUT_SYNC before calling fill_input_buffer,\r
- * but we must reload the local copies after a successful fill.\r
- */\r
-#define MAKE_BYTE_AVAIL(cinfo,action)  \\r
-       if (bytes_in_buffer == 0) {  \\r
-         if (! (*datasrc->fill_input_buffer) (cinfo))  \\r
-           { action; }  \\r
-         INPUT_RELOAD(cinfo);  \\r
-       }  \\r
-       bytes_in_buffer--\r
-\r
-/* Read a byte into variable V.\r
- * If must suspend, take the specified action (typically "return FALSE").\r
- */\r
-#define INPUT_BYTE(cinfo,V,action)  \\r
-       MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \\r
-                 V = GETJOCTET(*next_input_byte++); )\r
-\r
-/* As above, but read two bytes interpreted as an unsigned 16-bit integer.\r
- * V should be declared unsigned int or perhaps INT32.\r
- */\r
-#define INPUT_2BYTES(cinfo,V,action)  \\r
-       MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \\r
-                 V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \\r
-                 MAKE_BYTE_AVAIL(cinfo,action); \\r
-                 V += GETJOCTET(*next_input_byte++); )\r
-\r
-\r
-/*\r
- * Routines to process JPEG markers.\r
- *\r
- * Entry condition: JPEG marker itself has been read and its code saved\r
- *   in cinfo->unread_marker; input restart point is just after the marker.\r
- *\r
- * Exit: if return TRUE, have read and processed any parameters, and have\r
- *   updated the restart point to point after the parameters.\r
- *   If return FALSE, was forced to suspend before reaching end of\r
- *   marker parameters; restart point has not been moved.  Same routine\r
- *   will be called again after application supplies more input data.\r
- *\r
- * This approach to suspension assumes that all of a marker's parameters can\r
- * fit into a single input bufferload.  This should hold for "normal"\r
- * markers.  Some COM/APPn markers might have large parameter segments,\r
- * but we use skip_input_data to get past those, and thereby put the problem\r
- * on the source manager's shoulders.\r
- *\r
- * Note that we don't bother to avoid duplicate trace messages if a\r
- * suspension occurs within marker parameters.  Other side effects\r
- * require more care.\r
- */\r
-\r
-\r
-LOCAL boolean\r
-get_soi (j_decompress_ptr cinfo)\r
-/* Process an SOI marker */\r
-{\r
-  int i;\r
-  \r
-  TRACEMS(cinfo, 1, JTRC_SOI);\r
-\r
-  if (cinfo->marker->saw_SOI)\r
-    ERREXIT(cinfo, JERR_SOI_DUPLICATE);\r
-\r
-  /* Reset all parameters that are defined to be reset by SOI */\r
-\r
-  for (i = 0; i < NUM_ARITH_TBLS; i++) {\r
-    cinfo->arith_dc_L[i] = 0;\r
-    cinfo->arith_dc_U[i] = 1;\r
-    cinfo->arith_ac_K[i] = 5;\r
-  }\r
-  cinfo->restart_interval = 0;\r
-\r
-  /* Set initial assumptions for colorspace etc */\r
-\r
-  cinfo->jpeg_color_space = JCS_UNKNOWN;\r
-  cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */\r
-\r
-  cinfo->saw_JFIF_marker = FALSE;\r
-  cinfo->density_unit = 0;     /* set default JFIF APP0 values */\r
-  cinfo->X_density = 1;\r
-  cinfo->Y_density = 1;\r
-  cinfo->saw_Adobe_marker = FALSE;\r
-  cinfo->Adobe_transform = 0;\r
-\r
-  cinfo->marker->saw_SOI = TRUE;\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)\r
-/* Process a SOFn marker */\r
-{\r
-  INT32 length;\r
-  int c, ci;\r
-  jpeg_component_info * compptr;\r
-  INPUT_VARS(cinfo);\r
-\r
-  cinfo->progressive_mode = is_prog;\r
-  cinfo->arith_code = is_arith;\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-\r
-  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);\r
-  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);\r
-  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);\r
-  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);\r
-\r
-  length -= 8;\r
-\r
-  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,\r
-          (int) cinfo->image_width, (int) cinfo->image_height,\r
-          cinfo->num_components);\r
-\r
-  if (cinfo->marker->saw_SOF)\r
-    ERREXIT(cinfo, JERR_SOF_DUPLICATE);\r
-\r
-  /* We don't support files in which the image height is initially specified */\r
-  /* as 0 and is later redefined by DNL.  As long as we have to check that,  */\r
-  /* might as well have a general sanity check. */\r
-  if (cinfo->image_height <= 0 || cinfo->image_width <= 0\r
-      || cinfo->num_components <= 0)\r
-    ERREXIT(cinfo, JERR_EMPTY_IMAGE);\r
-\r
-  if (length != (cinfo->num_components * 3))\r
-    ERREXIT(cinfo, JERR_BAD_LENGTH);\r
-\r
-  if (cinfo->comp_info == NULL)        /* do only once, even if suspend */\r
-    cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)\r
-                       ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-                        cinfo->num_components * SIZEOF(jpeg_component_info));\r
-  \r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-       ci++, compptr++) {\r
-    compptr->component_index = ci;\r
-    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);\r
-    INPUT_BYTE(cinfo, c, return FALSE);\r
-    compptr->h_samp_factor = (c >> 4) & 15;\r
-    compptr->v_samp_factor = (c     ) & 15;\r
-    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);\r
-\r
-    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,\r
-            compptr->component_id, compptr->h_samp_factor,\r
-            compptr->v_samp_factor, compptr->quant_tbl_no);\r
-  }\r
-\r
-  cinfo->marker->saw_SOF = TRUE;\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-get_sos (j_decompress_ptr cinfo)\r
-/* Process a SOS marker */\r
-{\r
-  INT32 length;\r
-  int i, ci, n, c, cc;\r
-  jpeg_component_info * compptr;\r
-  INPUT_VARS(cinfo);\r
-\r
-  if (! cinfo->marker->saw_SOF)\r
-    ERREXIT(cinfo, JERR_SOS_NO_SOF);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-\r
-  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */\r
-\r
-  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)\r
-    ERREXIT(cinfo, JERR_BAD_LENGTH);\r
-\r
-  TRACEMS1(cinfo, 1, JTRC_SOS, n);\r
-\r
-  cinfo->comps_in_scan = n;\r
-\r
-  /* Collect the component-spec parameters */\r
-\r
-  for (i = 0; i < n; i++) {\r
-    INPUT_BYTE(cinfo, cc, return FALSE);\r
-    INPUT_BYTE(cinfo, c, return FALSE);\r
-    \r
-    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-        ci++, compptr++) {\r
-      if (cc == compptr->component_id)\r
-       goto id_found;\r
-    }\r
-\r
-    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);\r
-\r
-  id_found:\r
-\r
-    cinfo->cur_comp_info[i] = compptr;\r
-    compptr->dc_tbl_no = (c >> 4) & 15;\r
-    compptr->ac_tbl_no = (c     ) & 15;\r
-    \r
-    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,\r
-            compptr->dc_tbl_no, compptr->ac_tbl_no);\r
-  }\r
-\r
-  /* Collect the additional scan parameters Ss, Se, Ah/Al. */\r
-  INPUT_BYTE(cinfo, c, return FALSE);\r
-  cinfo->Ss = c;\r
-  INPUT_BYTE(cinfo, c, return FALSE);\r
-  cinfo->Se = c;\r
-  INPUT_BYTE(cinfo, c, return FALSE);\r
-  cinfo->Ah = (c >> 4) & 15;\r
-  cinfo->Al = (c     ) & 15;\r
-\r
-  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,\r
-          cinfo->Ah, cinfo->Al);\r
-\r
-  /* Prepare to scan data & restart markers */\r
-  cinfo->marker->next_restart_num = 0;\r
-\r
-  /* Count another SOS marker */\r
-  cinfo->input_scan_number++;\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-METHODDEF boolean\r
-get_app0 (j_decompress_ptr cinfo)\r
-/* Process an APP0 marker */\r
-{\r
-#define JFIF_LEN 14\r
-  INT32 length;\r
-  UINT8 b[JFIF_LEN];\r
-  int buffp;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  length -= 2;\r
-\r
-  /* See if a JFIF APP0 marker is present */\r
-\r
-  if (length >= JFIF_LEN) {\r
-    for (buffp = 0; buffp < JFIF_LEN; buffp++)\r
-      INPUT_BYTE(cinfo, b[buffp], return FALSE);\r
-    length -= JFIF_LEN;\r
-\r
-    if (b[0]==0x4A && b[1]==0x46 && b[2]==0x49 && b[3]==0x46 && b[4]==0) {\r
-      /* Found JFIF APP0 marker: check version */\r
-      /* Major version must be 1, anything else signals an incompatible change.\r
-       * We used to treat this as an error, but now it's a nonfatal warning,\r
-       * because some bozo at Hijaak couldn't read the spec.\r
-       * Minor version should be 0..2, but process anyway if newer.\r
-       */\r
-      if (b[5] != 1)\r
-       WARNMS2(cinfo, JWRN_JFIF_MAJOR, b[5], b[6]);\r
-      else if (b[6] > 2)\r
-       TRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]);\r
-      /* Save info */\r
-      cinfo->saw_JFIF_marker = TRUE;\r
-      cinfo->density_unit = b[7];\r
-      cinfo->X_density = (b[8] << 8) + b[9];\r
-      cinfo->Y_density = (b[10] << 8) + b[11];\r
-      TRACEMS3(cinfo, 1, JTRC_JFIF,\r
-              cinfo->X_density, cinfo->Y_density, cinfo->density_unit);\r
-      if (b[12] | b[13])\r
-       TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]);\r
-      if (length != ((INT32) b[12] * (INT32) b[13] * (INT32) 3))\r
-       TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) length);\r
-    } else {\r
-      /* Start of APP0 does not match "JFIF" */\r
-      TRACEMS1(cinfo, 1, JTRC_APP0, (int) length + JFIF_LEN);\r
-    }\r
-  } else {\r
-    /* Too short to be JFIF marker */\r
-    TRACEMS1(cinfo, 1, JTRC_APP0, (int) length);\r
-  }\r
-\r
-  INPUT_SYNC(cinfo);\r
-  if (length > 0)              /* skip any remaining data -- could be lots */\r
-    (*cinfo->src->skip_input_data) (cinfo, (long) length);\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-METHODDEF boolean\r
-get_app14 (j_decompress_ptr cinfo)\r
-/* Process an APP14 marker */\r
-{\r
-#define ADOBE_LEN 12\r
-  INT32 length;\r
-  UINT8 b[ADOBE_LEN];\r
-  int buffp;\r
-  unsigned int version, flags0, flags1, transform;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  length -= 2;\r
-\r
-  /* See if an Adobe APP14 marker is present */\r
-\r
-  if (length >= ADOBE_LEN) {\r
-    for (buffp = 0; buffp < ADOBE_LEN; buffp++)\r
-      INPUT_BYTE(cinfo, b[buffp], return FALSE);\r
-    length -= ADOBE_LEN;\r
-\r
-    if (b[0]==0x41 && b[1]==0x64 && b[2]==0x6F && b[3]==0x62 && b[4]==0x65) {\r
-      /* Found Adobe APP14 marker */\r
-      version = (b[5] << 8) + b[6];\r
-      flags0 = (b[7] << 8) + b[8];\r
-      flags1 = (b[9] << 8) + b[10];\r
-      transform = b[11];\r
-      TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);\r
-      cinfo->saw_Adobe_marker = TRUE;\r
-      cinfo->Adobe_transform = (UINT8) transform;\r
-    } else {\r
-      /* Start of APP14 does not match "Adobe" */\r
-      TRACEMS1(cinfo, 1, JTRC_APP14, (int) length + ADOBE_LEN);\r
-    }\r
-  } else {\r
-    /* Too short to be Adobe marker */\r
-    TRACEMS1(cinfo, 1, JTRC_APP14, (int) length);\r
-  }\r
-\r
-  INPUT_SYNC(cinfo);\r
-  if (length > 0)              /* skip any remaining data -- could be lots */\r
-    (*cinfo->src->skip_input_data) (cinfo, (long) length);\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-get_dac (j_decompress_ptr cinfo)\r
-/* Process a DAC marker */\r
-{\r
-  INT32 length;\r
-  int index, val;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  length -= 2;\r
-  \r
-  while (length > 0) {\r
-    INPUT_BYTE(cinfo, index, return FALSE);\r
-    INPUT_BYTE(cinfo, val, return FALSE);\r
-\r
-    length -= 2;\r
-\r
-    TRACEMS2(cinfo, 1, JTRC_DAC, index, val);\r
-\r
-    if (index < 0 || index >= (2*NUM_ARITH_TBLS))\r
-      ERREXIT1(cinfo, JERR_DAC_INDEX, index);\r
-\r
-    if (index >= NUM_ARITH_TBLS) { /* define AC table */\r
-      cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;\r
-    } else {                   /* define DC table */\r
-      cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);\r
-      cinfo->arith_dc_U[index] = (UINT8) (val >> 4);\r
-      if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])\r
-       ERREXIT1(cinfo, JERR_DAC_VALUE, val);\r
-    }\r
-  }\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-get_dht (j_decompress_ptr cinfo)\r
-/* Process a DHT marker */\r
-{\r
-  INT32 length;\r
-  UINT8 bits[17];\r
-  UINT8 huffval[256];\r
-  int i, index, count;\r
-  JHUFF_TBL **htblptr;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  length -= 2;\r
-  \r
-  while (length > 0) {\r
-    INPUT_BYTE(cinfo, index, return FALSE);\r
-\r
-    TRACEMS1(cinfo, 1, JTRC_DHT, index);\r
-      \r
-    bits[0] = 0;\r
-    count = 0;\r
-    for (i = 1; i <= 16; i++) {\r
-      INPUT_BYTE(cinfo, bits[i], return FALSE);\r
-      count += bits[i];\r
-    }\r
-\r
-    length -= 1 + 16;\r
-\r
-    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,\r
-            bits[1], bits[2], bits[3], bits[4],\r
-            bits[5], bits[6], bits[7], bits[8]);\r
-    TRACEMS8(cinfo, 2, JTRC_HUFFBITS,\r
-            bits[9], bits[10], bits[11], bits[12],\r
-            bits[13], bits[14], bits[15], bits[16]);\r
-\r
-    if (count > 256 || ((INT32) count) > length)\r
-      ERREXIT(cinfo, JERR_DHT_COUNTS);\r
-\r
-    for (i = 0; i < count; i++)\r
-      INPUT_BYTE(cinfo, huffval[i], return FALSE);\r
-\r
-    length -= count;\r
-\r
-    if (index & 0x10) {                /* AC table definition */\r
-      index -= 0x10;\r
-      htblptr = &cinfo->ac_huff_tbl_ptrs[index];\r
-    } else {                   /* DC table definition */\r
-      htblptr = &cinfo->dc_huff_tbl_ptrs[index];\r
-    }\r
-\r
-    if (index < 0 || index >= NUM_HUFF_TBLS)\r
-      ERREXIT1(cinfo, JERR_DHT_INDEX, index);\r
-\r
-    if (*htblptr == NULL)\r
-      *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);\r
-  \r
-    MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));\r
-    MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));\r
-  }\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-get_dqt (j_decompress_ptr cinfo)\r
-/* Process a DQT marker */\r
-{\r
-  INT32 length;\r
-  int n, i, prec;\r
-  unsigned int tmp;\r
-  JQUANT_TBL *quant_ptr;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  length -= 2;\r
-\r
-  while (length > 0) {\r
-    INPUT_BYTE(cinfo, n, return FALSE);\r
-    prec = n >> 4;\r
-    n &= 0x0F;\r
-\r
-    TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);\r
-\r
-    if (n >= NUM_QUANT_TBLS)\r
-      ERREXIT1(cinfo, JERR_DQT_INDEX, n);\r
-      \r
-    if (cinfo->quant_tbl_ptrs[n] == NULL)\r
-      cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);\r
-    quant_ptr = cinfo->quant_tbl_ptrs[n];\r
-\r
-    for (i = 0; i < DCTSIZE2; i++) {\r
-      if (prec)\r
-       INPUT_2BYTES(cinfo, tmp, return FALSE);\r
-      else\r
-       INPUT_BYTE(cinfo, tmp, return FALSE);\r
-      quant_ptr->quantval[i] = (UINT16) tmp;\r
-    }\r
-\r
-    for (i = 0; i < DCTSIZE2; i += 8) {\r
-      TRACEMS8(cinfo, 2, JTRC_QUANTVALS,\r
-              quant_ptr->quantval[i  ], quant_ptr->quantval[i+1],\r
-              quant_ptr->quantval[i+2], quant_ptr->quantval[i+3],\r
-              quant_ptr->quantval[i+4], quant_ptr->quantval[i+5],\r
-              quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]);\r
-    }\r
-\r
-    length -= DCTSIZE2+1;\r
-    if (prec) length -= DCTSIZE2;\r
-  }\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-get_dri (j_decompress_ptr cinfo)\r
-/* Process a DRI marker */\r
-{\r
-  INT32 length;\r
-  unsigned int tmp;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  \r
-  if (length != 4)\r
-    ERREXIT(cinfo, JERR_BAD_LENGTH);\r
-\r
-  INPUT_2BYTES(cinfo, tmp, return FALSE);\r
-\r
-  TRACEMS1(cinfo, 1, JTRC_DRI, tmp);\r
-\r
-  cinfo->restart_interval = tmp;\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-METHODDEF boolean\r
-skip_variable (j_decompress_ptr cinfo)\r
-/* Skip over an unknown or uninteresting variable-length marker */\r
-{\r
-  INT32 length;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_2BYTES(cinfo, length, return FALSE);\r
-  \r
-  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);\r
-\r
-  INPUT_SYNC(cinfo);           /* do before skip_input_data */\r
-  (*cinfo->src->skip_input_data) (cinfo, (long) length - 2L);\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Find the next JPEG marker, save it in cinfo->unread_marker.\r
- * Returns FALSE if had to suspend before reaching a marker;\r
- * in that case cinfo->unread_marker is unchanged.\r
- *\r
- * Note that the result might not be a valid marker code,\r
- * but it will never be 0 or FF.\r
- */\r
-\r
-LOCAL boolean\r
-next_marker (j_decompress_ptr cinfo)\r
-{\r
-  int c;\r
-  INPUT_VARS(cinfo);\r
-\r
-  for (;;) {\r
-    INPUT_BYTE(cinfo, c, return FALSE);\r
-    /* Skip any non-FF bytes.\r
-     * This may look a bit inefficient, but it will not occur in a valid file.\r
-     * We sync after each discarded byte so that a suspending data source\r
-     * can discard the byte from its buffer.\r
-     */\r
-    while (c != 0xFF) {\r
-      cinfo->marker->discarded_bytes++;\r
-      INPUT_SYNC(cinfo);\r
-      INPUT_BYTE(cinfo, c, return FALSE);\r
-    }\r
-    /* This loop swallows any duplicate FF bytes.  Extra FFs are legal as\r
-     * pad bytes, so don't count them in discarded_bytes.  We assume there\r
-     * will not be so many consecutive FF bytes as to overflow a suspending\r
-     * data source's input buffer.\r
-     */\r
-    do {\r
-      INPUT_BYTE(cinfo, c, return FALSE);\r
-    } while (c == 0xFF);\r
-    if (c != 0)\r
-      break;                   /* found a valid marker, exit loop */\r
-    /* Reach here if we found a stuffed-zero data sequence (FF/00).\r
-     * Discard it and loop back to try again.\r
-     */\r
-    cinfo->marker->discarded_bytes += 2;\r
-    INPUT_SYNC(cinfo);\r
-  }\r
-\r
-  if (cinfo->marker->discarded_bytes != 0) {\r
-    WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);\r
-    cinfo->marker->discarded_bytes = 0;\r
-  }\r
-\r
-  cinfo->unread_marker = c;\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-LOCAL boolean\r
-first_marker (j_decompress_ptr cinfo)\r
-/* Like next_marker, but used to obtain the initial SOI marker. */\r
-/* For this marker, we do not allow preceding garbage or fill; otherwise,\r
- * we might well scan an entire input file before realizing it ain't JPEG.\r
- * If an application wants to process non-JFIF files, it must seek to the\r
- * SOI before calling the JPEG library.\r
- */\r
-{\r
-  int c, c2;\r
-  INPUT_VARS(cinfo);\r
-\r
-  INPUT_BYTE(cinfo, c, return FALSE);\r
-  INPUT_BYTE(cinfo, c2, return FALSE);\r
-  if (c != 0xFF || c2 != (int) M_SOI)\r
-    ERREXIT2(cinfo, JERR_NO_SOI, c, c2);\r
-\r
-  cinfo->unread_marker = c2;\r
-\r
-  INPUT_SYNC(cinfo);\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * Read markers until SOS or EOI.\r
- *\r
- * Returns same codes as are defined for jpeg_consume_input:\r
- * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.\r
- */\r
-\r
-METHODDEF int\r
-read_markers (j_decompress_ptr cinfo)\r
-{\r
-  /* Outer loop repeats once for each marker. */\r
-  for (;;) {\r
-    /* Collect the marker proper, unless we already did. */\r
-    /* NB: first_marker() enforces the requirement that SOI appear first. */\r
-    if (cinfo->unread_marker == 0) {\r
-      if (! cinfo->marker->saw_SOI) {\r
-       if (! first_marker(cinfo))\r
-         return JPEG_SUSPENDED;\r
-      } else {\r
-       if (! next_marker(cinfo))\r
-         return JPEG_SUSPENDED;\r
-      }\r
-    }\r
-    /* At this point cinfo->unread_marker contains the marker code and the\r
-     * input point is just past the marker proper, but before any parameters.\r
-     * A suspension will cause us to return with this state still true.\r
-     */\r
-    switch (cinfo->unread_marker) {\r
-    case M_SOI:\r
-      if (! get_soi(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    case M_SOF0:               /* Baseline */\r
-    case M_SOF1:               /* Extended sequential, Huffman */\r
-      if (! get_sof(cinfo, FALSE, FALSE))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    case M_SOF2:               /* Progressive, Huffman */\r
-      if (! get_sof(cinfo, TRUE, FALSE))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    case M_SOF9:               /* Extended sequential, arithmetic */\r
-      if (! get_sof(cinfo, FALSE, TRUE))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    case M_SOF10:              /* Progressive, arithmetic */\r
-      if (! get_sof(cinfo, TRUE, TRUE))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    /* Currently unsupported SOFn types */\r
-    case M_SOF3:               /* Lossless, Huffman */\r
-    case M_SOF5:               /* Differential sequential, Huffman */\r
-    case M_SOF6:               /* Differential progressive, Huffman */\r
-    case M_SOF7:               /* Differential lossless, Huffman */\r
-    case M_JPG:                        /* Reserved for JPEG extensions */\r
-    case M_SOF11:              /* Lossless, arithmetic */\r
-    case M_SOF13:              /* Differential sequential, arithmetic */\r
-    case M_SOF14:              /* Differential progressive, arithmetic */\r
-    case M_SOF15:              /* Differential lossless, arithmetic */\r
-      ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);\r
-      break;\r
-\r
-    case M_SOS:\r
-      if (! get_sos(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      cinfo->unread_marker = 0;        /* processed the marker */\r
-      return JPEG_REACHED_SOS;\r
-    \r
-    case M_EOI:\r
-      TRACEMS(cinfo, 1, JTRC_EOI);\r
-      cinfo->unread_marker = 0;        /* processed the marker */\r
-      return JPEG_REACHED_EOI;\r
-      \r
-    case M_DAC:\r
-      if (! get_dac(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-      \r
-    case M_DHT:\r
-      if (! get_dht(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-      \r
-    case M_DQT:\r
-      if (! get_dqt(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-      \r
-    case M_DRI:\r
-      if (! get_dri(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-      \r
-    case M_APP0:\r
-    case M_APP1:\r
-    case M_APP2:\r
-    case M_APP3:\r
-    case M_APP4:\r
-    case M_APP5:\r
-    case M_APP6:\r
-    case M_APP7:\r
-    case M_APP8:\r
-    case M_APP9:\r
-    case M_APP10:\r
-    case M_APP11:\r
-    case M_APP12:\r
-    case M_APP13:\r
-    case M_APP14:\r
-    case M_APP15:\r
-      if (! (*cinfo->marker->process_APPn[cinfo->unread_marker - (int) M_APP0]) (cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-      \r
-    case M_COM:\r
-      if (! (*cinfo->marker->process_COM) (cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    case M_RST0:               /* these are all parameterless */\r
-    case M_RST1:\r
-    case M_RST2:\r
-    case M_RST3:\r
-    case M_RST4:\r
-    case M_RST5:\r
-    case M_RST6:\r
-    case M_RST7:\r
-    case M_TEM:\r
-      TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);\r
-      break;\r
-\r
-    case M_DNL:                        /* Ignore DNL ... perhaps the wrong thing */\r
-      if (! skip_variable(cinfo))\r
-       return JPEG_SUSPENDED;\r
-      break;\r
-\r
-    default:                   /* must be DHP, EXP, JPGn, or RESn */\r
-      /* For now, we treat the reserved markers as fatal errors since they are\r
-       * likely to be used to signal incompatible JPEG Part 3 extensions.\r
-       * Once the JPEG 3 version-number marker is well defined, this code\r
-       * ought to change!\r
-       */\r
-      ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);\r
-      break;\r
-    }\r
-    /* Successfully processed marker, so reset state variable */\r
-    cinfo->unread_marker = 0;\r
-  } /* end loop */\r
-}\r
-\r
-\r
-/*\r
- * Read a restart marker, which is expected to appear next in the datastream;\r
- * if the marker is not there, take appropriate recovery action.\r
- * Returns FALSE if suspension is required.\r
- *\r
- * This is called by the entropy decoder after it has read an appropriate\r
- * number of MCUs.  cinfo->unread_marker may be nonzero if the entropy decoder\r
- * has already read a marker from the data source.  Under normal conditions\r
- * cinfo->unread_marker will be reset to 0 before returning; if not reset,\r
- * it holds a marker which the decoder will be unable to read past.\r
- */\r
-\r
-METHODDEF boolean\r
-read_restart_marker (j_decompress_ptr cinfo)\r
-{\r
-  /* Obtain a marker unless we already did. */\r
-  /* Note that next_marker will complain if it skips any data. */\r
-  if (cinfo->unread_marker == 0) {\r
-    if (! next_marker(cinfo))\r
-      return FALSE;\r
-  }\r
-\r
-  if (cinfo->unread_marker ==\r
-      ((int) M_RST0 + cinfo->marker->next_restart_num)) {\r
-    /* Normal case --- swallow the marker and let entropy decoder continue */\r
-    TRACEMS1(cinfo, 2, JTRC_RST, cinfo->marker->next_restart_num);\r
-    cinfo->unread_marker = 0;\r
-  } else {\r
-    /* Uh-oh, the restart markers have been messed up. */\r
-    /* Let the data source manager determine how to resync. */\r
-    if (! (*cinfo->src->resync_to_restart) (cinfo,\r
-                                           cinfo->marker->next_restart_num))\r
-      return FALSE;\r
-  }\r
-\r
-  /* Update next-restart state */\r
-  cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;\r
-\r
-  return TRUE;\r
-}\r
-\r
-\r
-/*\r
- * This is the default resync_to_restart method for data source managers\r
- * to use if they don't have any better approach.  Some data source managers\r
- * may be able to back up, or may have additional knowledge about the data\r
- * which permits a more intelligent recovery strategy; such managers would\r
- * presumably supply their own resync method.\r
- *\r
- * read_restart_marker calls resync_to_restart if it finds a marker other than\r
- * the restart marker it was expecting.  (This code is *not* used unless\r
- * a nonzero restart interval has been declared.)  cinfo->unread_marker is\r
- * the marker code actually found (might be anything, except 0 or FF).\r
- * The desired restart marker number (0..7) is passed as a parameter.\r
- * This routine is supposed to apply whatever error recovery strategy seems\r
- * appropriate in order to position the input stream to the next data segment.\r
- * Note that cinfo->unread_marker is treated as a marker appearing before\r
- * the current data-source input point; usually it should be reset to zero\r
- * before returning.\r
- * Returns FALSE if suspension is required.\r
- *\r
- * This implementation is substantially constrained by wanting to treat the\r
- * input as a data stream; this means we can't back up.  Therefore, we have\r
- * only the following actions to work with:\r
- *   1. Simply discard the marker and let the entropy decoder resume at next\r
- *      byte of file.\r
- *   2. Read forward until we find another marker, discarding intervening\r
- *      data.  (In theory we could look ahead within the current bufferload,\r
- *      without having to discard data if we don't find the desired marker.\r
- *      This idea is not implemented here, in part because it makes behavior\r
- *      dependent on buffer size and chance buffer-boundary positions.)\r
- *   3. Leave the marker unread (by failing to zero cinfo->unread_marker).\r
- *      This will cause the entropy decoder to process an empty data segment,\r
- *      inserting dummy zeroes, and then we will reprocess the marker.\r
- *\r
- * #2 is appropriate if we think the desired marker lies ahead, while #3 is\r
- * appropriate if the found marker is a future restart marker (indicating\r
- * that we have missed the desired restart marker, probably because it got\r
- * corrupted).\r
- * We apply #2 or #3 if the found marker is a restart marker no more than\r
- * two counts behind or ahead of the expected one.  We also apply #2 if the\r
- * found marker is not a legal JPEG marker code (it's certainly bogus data).\r
- * If the found marker is a restart marker more than 2 counts away, we do #1\r
- * (too much risk that the marker is erroneous; with luck we will be able to\r
- * resync at some future point).\r
- * For any valid non-restart JPEG marker, we apply #3.  This keeps us from\r
- * overrunning the end of a scan.  An implementation limited to single-scan\r
- * files might find it better to apply #2 for markers other than EOI, since\r
- * any other marker would have to be bogus data in that case.\r
- */\r
-\r
-GLOBAL boolean\r
-jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)\r
-{\r
-  int marker = cinfo->unread_marker;\r
-  int action = 1;\r
-  \r
-  /* Always put up a warning. */\r
-  WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);\r
-  \r
-  /* Outer loop handles repeated decision after scanning forward. */\r
-  for (;;) {\r
-    if (marker < (int) M_SOF0)\r
-      action = 2;              /* invalid marker */\r
-    else if (marker < (int) M_RST0 || marker > (int) M_RST7)\r
-      action = 3;              /* valid non-restart marker */\r
-    else {\r
-      if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||\r
-         marker == ((int) M_RST0 + ((desired+2) & 7)))\r
-       action = 3;             /* one of the next two expected restarts */\r
-      else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||\r
-              marker == ((int) M_RST0 + ((desired-2) & 7)))\r
-       action = 2;             /* a prior restart, so advance */\r
-      else\r
-       action = 1;             /* desired restart or too far away */\r
-    }\r
-    TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);\r
-    switch (action) {\r
-    case 1:\r
-      /* Discard marker and let entropy decoder resume processing. */\r
-      cinfo->unread_marker = 0;\r
-      return TRUE;\r
-    case 2:\r
-      /* Scan to the next marker, and repeat the decision loop. */\r
-      if (! next_marker(cinfo))\r
-       return FALSE;\r
-      marker = cinfo->unread_marker;\r
-      break;\r
-    case 3:\r
-      /* Return without advancing past this marker. */\r
-      /* Entropy decoder will be forced to process an empty segment. */\r
-      return TRUE;\r
-    }\r
-  } /* end loop */\r
-}\r
-\r
-\r
-/*\r
- * Reset marker processing state to begin a fresh datastream.\r
- */\r
-\r
-METHODDEF void\r
-reset_marker_reader (j_decompress_ptr cinfo)\r
-{\r
-  cinfo->comp_info = NULL;             /* until allocated by get_sof */\r
-  cinfo->input_scan_number = 0;                /* no SOS seen yet */\r
-  cinfo->unread_marker = 0;            /* no pending marker */\r
-  cinfo->marker->saw_SOI = FALSE;      /* set internal state too */\r
-  cinfo->marker->saw_SOF = FALSE;\r
-  cinfo->marker->discarded_bytes = 0;\r
-}\r
-\r
-\r
-/*\r
- * Initialize the marker reader module.\r
- * This is called only once, when the decompression object is created.\r
- */\r
-\r
-GLOBAL void\r
-jinit_marker_reader (j_decompress_ptr cinfo)\r
-{\r
-  int i;\r
-\r
-  /* Create subobject in permanent pool */\r
-  cinfo->marker = (struct jpeg_marker_reader *)\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,\r
-                               SIZEOF(struct jpeg_marker_reader));\r
-  /* Initialize method pointers */\r
-  cinfo->marker->reset_marker_reader = reset_marker_reader;\r
-  cinfo->marker->read_markers = read_markers;\r
-  cinfo->marker->read_restart_marker = read_restart_marker;\r
-  cinfo->marker->process_COM = skip_variable;\r
-  for (i = 0; i < 16; i++)\r
-    cinfo->marker->process_APPn[i] = skip_variable;\r
-  cinfo->marker->process_APPn[0] = get_app0;\r
-  cinfo->marker->process_APPn[14] = get_app14;\r
-  /* Reset marker processing state */\r
-  reset_marker_reader(cinfo);\r
-}\r
diff --git a/libs/jpeg6/jdmaster.cpp b/libs/jpeg6/jdmaster.cpp
deleted file mode 100644 (file)
index 9d88bb2..0000000
+++ /dev/null
@@ -1,558 +0,0 @@
-/*\r
- * jdmaster.c\r
- *\r
- * Copyright (C) 1991-1995, Thomas G. Lane.\r
- * This file is part of the Independent JPEG Group's software.\r
- * For conditions of distribution and use, see the accompanying README file.\r
- *\r
- * This file contains master control logic for the JPEG decompressor.\r
- * These routines are concerned with selecting the modules to be executed\r
- * and with determining the number of passes and the work to be done in each\r
- * pass.\r
- */\r
-\r
-#define JPEG_INTERNALS\r
-#include "jinclude.h"\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-/* Private state */\r
-\r
-typedef struct {\r
-  struct jpeg_decomp_master pub; /* public fields */\r
-\r
-  int pass_number;             /* # of passes completed */\r
-\r
-  boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */\r
-\r
-  /* Saved references to initialized quantizer modules,\r
-   * in case we need to switch modes.\r
-   */\r
-  struct jpeg_color_quantizer * quantizer_1pass;\r
-  struct jpeg_color_quantizer * quantizer_2pass;\r
-} my_decomp_master;\r
-\r
-typedef my_decomp_master * my_master_ptr;\r
-\r
-\r
-/*\r
- * Determine whether merged upsample/color conversion should be used.\r
- * CRUCIAL: this must match the actual capabilities of jdmerge.c!\r
- */\r
-\r
-LOCAL boolean\r
-use_merged_upsample (j_decompress_ptr cinfo)\r
-{\r
-#ifdef UPSAMPLE_MERGING_SUPPORTED\r
-  /* Merging is the equivalent of plain box-filter upsampling */\r
-  if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)\r
-    return FALSE;\r
-  /* jdmerge.c only supports YCC=>RGB color conversion */\r
-  if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||\r
-      cinfo->out_color_space != JCS_RGB ||\r
-      cinfo->out_color_components != RGB_PIXELSIZE)\r
-    return FALSE;\r
-  /* and it only handles 2h1v or 2h2v sampling ratios */\r
-  if (cinfo->comp_info[0].h_samp_factor != 2 ||\r
-      cinfo->comp_info[1].h_samp_factor != 1 ||\r
-      cinfo->comp_info[2].h_samp_factor != 1 ||\r
-      cinfo->comp_info[0].v_samp_factor >  2 ||\r
-      cinfo->comp_info[1].v_samp_factor != 1 ||\r
-      cinfo->comp_info[2].v_samp_factor != 1)\r
-    return FALSE;\r
-  /* furthermore, it doesn't work if we've scaled the IDCTs differently */\r
-  if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||\r
-      cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||\r
-      cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)\r
-    return FALSE;\r
-  /* ??? also need to test for upsample-time rescaling, when & if supported */\r
-  return TRUE;                 /* by golly, it'll work... */\r
-#else\r
-  return FALSE;\r
-#endif\r
-}\r
-\r
-\r
-/*\r
- * Compute output image dimensions and related values.\r
- * NOTE: this is exported for possible use by application.\r
- * Hence it mustn't do anything that can't be done twice.\r
- * Also note that it may be called before the master module is initialized!\r
- */\r
-\r
-GLOBAL void\r
-jpeg_calc_output_dimensions (j_decompress_ptr cinfo)\r
-/* Do computations that are needed before master selection phase */\r
-{\r
-#if 0  // JDC: commented out to remove warning\r
-  int ci;\r
-  jpeg_component_info *compptr;\r
-#endif\r
-\r
-  /* Prevent application from calling me at wrong times */\r
-  if (cinfo->global_state != DSTATE_READY)\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-#ifdef IDCT_SCALING_SUPPORTED\r
-\r
-  /* Compute actual output image dimensions and DCT scaling choices. */\r
-  if (cinfo->scale_num * 8 <= cinfo->scale_denom) {\r
-    /* Provide 1/8 scaling */\r
-    cinfo->output_width = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_width, 8L);\r
-    cinfo->output_height = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_height, 8L);\r
-    cinfo->min_DCT_scaled_size = 1;\r
-  } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {\r
-    /* Provide 1/4 scaling */\r
-    cinfo->output_width = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_width, 4L);\r
-    cinfo->output_height = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_height, 4L);\r
-    cinfo->min_DCT_scaled_size = 2;\r
-  } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {\r
-    /* Provide 1/2 scaling */\r
-    cinfo->output_width = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_width, 2L);\r
-    cinfo->output_height = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_height, 2L);\r
-    cinfo->min_DCT_scaled_size = 4;\r
-  } else {\r
-    /* Provide 1/1 scaling */\r
-    cinfo->output_width = cinfo->image_width;\r
-    cinfo->output_height = cinfo->image_height;\r
-    cinfo->min_DCT_scaled_size = DCTSIZE;\r
-  }\r
-  /* In selecting the actual DCT scaling for each component, we try to\r
-   * scale up the chroma components via IDCT scaling rather than upsampling.\r
-   * This saves time if the upsampler gets to use 1:1 scaling.\r
-   * Note this code assumes that the supported DCT scalings are powers of 2.\r
-   */\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-       ci++, compptr++) {\r
-    int ssize = cinfo->min_DCT_scaled_size;\r
-    while (ssize < DCTSIZE &&\r
-          (compptr->h_samp_factor * ssize * 2 <=\r
-           cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&\r
-          (compptr->v_samp_factor * ssize * 2 <=\r
-           cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {\r
-      ssize = ssize * 2;\r
-    }\r
-    compptr->DCT_scaled_size = ssize;\r
-  }\r
-\r
-  /* Recompute downsampled dimensions of components;\r
-   * application needs to know these if using raw downsampled data.\r
-   */\r
-  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\r
-       ci++, compptr++) {\r
-    /* Size in samples, after IDCT scaling */\r
-    compptr->downsampled_width = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_width *\r
-                   (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),\r
-                   (long) (cinfo->max_h_samp_factor * DCTSIZE));\r
-    compptr->downsampled_height = (JDIMENSION)\r
-      jdiv_round_up((long) cinfo->image_height *\r
-                   (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),\r
-                   (long) (cinfo->max_v_samp_factor * DCTSIZE));\r
-  }\r
-\r
-#else /* !IDCT_SCALING_SUPPORTED */\r
-\r
-  /* Hardwire it to "no scaling" */\r
-  cinfo->output_width = cinfo->image_width;\r
-  cinfo->output_height = cinfo->image_height;\r
-  /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,\r
-   * and has computed unscaled downsampled_width and downsampled_height.\r
-   */\r
-\r
-#endif /* IDCT_SCALING_SUPPORTED */\r
-\r
-  /* Report number of components in selected colorspace. */\r
-  /* Probably this should be in the color conversion module... */\r
-  switch (cinfo->out_color_space) {\r
-  case JCS_GRAYSCALE:\r
-    cinfo->out_color_components = 1;\r
-    break;\r
-  case JCS_RGB:\r
-#if RGB_PIXELSIZE != 3\r
-    cinfo->out_color_components = RGB_PIXELSIZE;\r
-    break;\r
-#endif /* else share code with YCbCr */\r
-  case JCS_YCbCr:\r
-    cinfo->out_color_components = 3;\r
-    break;\r
-  case JCS_CMYK:\r
-  case JCS_YCCK:\r
-    cinfo->out_color_components = 4;\r
-    break;\r
-  default:                     /* else must be same colorspace as in file */\r
-    cinfo->out_color_components = cinfo->num_components;\r
-    break;\r
-  }\r
-  cinfo->output_components = (cinfo->quantize_colors ? 1 :\r
-                             cinfo->out_color_components);\r
-\r
-  /* See if upsampler will want to emit more than one row at a time */\r
-  if (use_merged_upsample(cinfo))\r
-    cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;\r
-  else\r
-    cinfo->rec_outbuf_height = 1;\r
-}\r
-\r
-\r
-/*\r
- * Several decompression processes need to range-limit values to the range\r
- * 0..MAXJSAMPLE; the input value may fall somewhat outside this range\r
- * due to noise introduced by quantization, roundoff error, etc.  These\r
- * processes are inner loops and need to be as fast as possible.  On most\r
- * machines, particularly CPUs with pipelines or instruction prefetch,\r
- * a (subscript-check-less) C table lookup\r
- *             x = sample_range_limit[x];\r
- * is faster than explicit tests\r
- *             if (x < 0)  x = 0;\r
- *             else if (x > MAXJSAMPLE)  x = MAXJSAMPLE;\r
- * These processes all use a common table prepared by the routine below.\r
- *\r
- * For most steps we can mathematically guarantee that the initial value\r
- * of x is within MAXJSAMPLE+1 of the legal range, so a table running from\r
- * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient.  But for the initial\r
- * limiting step (just after the IDCT), a wildly out-of-range value is \r
- * possible if the input data is corrupt.  To avoid any chance of indexing\r
- * off the end of memory and getting a bad-pointer trap, we perform the\r
- * post-IDCT limiting thus:\r
- *             x = range_limit[x & MASK];\r
- * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit\r
- * samples.  Under normal circumstances this is more than enough range and\r
- * a correct output will be generated; with bogus input data the mask will\r
- * cause wraparound, and we will safely generate a bogus-but-in-range output.\r
- * For the post-IDCT step, we want to convert the data from signed to unsigned\r
- * representation by adding CENTERJSAMPLE at the same time that we limit it.\r
- * So the post-IDCT limiting table ends up looking like this:\r
- *   CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,\r
- *   MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),\r
- *   0          (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),\r
- *   0,1,...,CENTERJSAMPLE-1\r
- * Negative inputs select values from the upper half of the table after\r
- * masking.\r
- *\r
- * We can save some space by overlapping the start of the post-IDCT table\r
- * with the simpler range limiting table.  The post-IDCT table begins at\r
- * sample_range_limit + CENTERJSAMPLE.\r
- *\r
- * Note that the table is allocated in near data space on PCs; it's small\r
- * enough and used often enough to justify this.\r
- */\r
-\r
-LOCAL void\r
-prepare_range_limit_table (j_decompress_ptr cinfo)\r
-/* Allocate and fill in the sample_range_limit table */\r
-{\r
-  JSAMPLE * table;\r
-  int i;\r
-\r
-  table = (JSAMPLE *)\r
-    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-               (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));\r
-  table += (MAXJSAMPLE+1);     /* allow negative subscripts of simple table */\r
-  cinfo->sample_range_limit = table;\r
-  /* First segment of "simple" table: limit[x] = 0 for x < 0 */\r
-  MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));\r
-  /* Main part of "simple" table: limit[x] = x */\r
-  for (i = 0; i <= MAXJSAMPLE; i++)\r
-    table[i] = (JSAMPLE) i;\r
-  table += CENTERJSAMPLE;      /* Point to where post-IDCT table starts */\r
-  /* End of simple table, rest of first half of post-IDCT table */\r
-  for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)\r
-    table[i] = MAXJSAMPLE;\r
-  /* Second half of post-IDCT table */\r
-  MEMZERO(table + (2 * (MAXJSAMPLE+1)),\r
-         (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));\r
-  MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),\r
-         cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));\r
-}\r
-\r
-\r
-/*\r
- * Master selection of decompression modules.\r
- * This is done once at jpeg_start_decompress time.  We determine\r
- * which modules will be used and give them appropriate initialization calls.\r
- * We also initialize the decompressor input side to begin consuming data.\r
- *\r
- * Since jpeg_read_header has finished, we know what is in the SOF\r
- * and (first) SOS markers.  We also have all the application parameter\r
- * settings.\r
- */\r
-\r
-LOCAL void\r
-master_selection (j_decompress_ptr cinfo)\r
-{\r
-  my_master_ptr master = (my_master_ptr) cinfo->master;\r
-  boolean use_c_buffer;\r
-  long samplesperrow;\r
-  JDIMENSION jd_samplesperrow;\r
-\r
-  /* Initialize dimensions and other stuff */\r
-  jpeg_calc_output_dimensions(cinfo);\r
-  prepare_range_limit_table(cinfo);\r
-\r
-  /* Width of an output scanline must be representable as JDIMENSION. */\r
-  samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;\r
-  jd_samplesperrow = (JDIMENSION) samplesperrow;\r
-  if ((long) jd_samplesperrow != samplesperrow)\r
-    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);\r
-\r
-  /* Initialize my private state */\r
-  master->pass_number = 0;\r
-  master->using_merged_upsample = use_merged_upsample(cinfo);\r
-\r
-  /* Color quantizer selection */\r
-  master->quantizer_1pass = NULL;\r
-  master->quantizer_2pass = NULL;\r
-  /* No mode changes if not using buffered-image mode. */\r
-  if (! cinfo->quantize_colors || ! cinfo->buffered_image) {\r
-    cinfo->enable_1pass_quant = FALSE;\r
-    cinfo->enable_external_quant = FALSE;\r
-    cinfo->enable_2pass_quant = FALSE;\r
-  }\r
-  if (cinfo->quantize_colors) {\r
-    if (cinfo->raw_data_out)\r
-      ERREXIT(cinfo, JERR_NOTIMPL);\r
-    /* 2-pass quantizer only works in 3-component color space. */\r
-    if (cinfo->out_color_components != 3) {\r
-      cinfo->enable_1pass_quant = TRUE;\r
-      cinfo->enable_external_quant = FALSE;\r
-      cinfo->enable_2pass_quant = FALSE;\r
-      cinfo->colormap = NULL;\r
-    } else if (cinfo->colormap != NULL) {\r
-      cinfo->enable_external_quant = TRUE;\r
-    } else if (cinfo->two_pass_quantize) {\r
-      cinfo->enable_2pass_quant = TRUE;\r
-    } else {\r
-      cinfo->enable_1pass_quant = TRUE;\r
-    }\r
-\r
-    if (cinfo->enable_1pass_quant) {\r
-#ifdef QUANT_1PASS_SUPPORTED\r
-      jinit_1pass_quantizer(cinfo);\r
-      master->quantizer_1pass = cinfo->cquantize;\r
-#else\r
-      ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-#endif\r
-    }\r
-\r
-    /* We use the 2-pass code to map to external colormaps. */\r
-    if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-      jinit_2pass_quantizer(cinfo);\r
-      master->quantizer_2pass = cinfo->cquantize;\r
-#else\r
-      ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-#endif\r
-    }\r
-    /* If both quantizers are initialized, the 2-pass one is left active;\r
-     * this is necessary for starting with quantization to an external map.\r
-     */\r
-  }\r
-\r
-  /* Post-processing: in particular, color conversion first */\r
-  if (! cinfo->raw_data_out) {\r
-    if (master->using_merged_upsample) {\r
-#ifdef UPSAMPLE_MERGING_SUPPORTED\r
-      jinit_merged_upsampler(cinfo); /* does color conversion too */\r
-#else\r
-      ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-#endif\r
-    } else {\r
-      jinit_color_deconverter(cinfo);\r
-      jinit_upsampler(cinfo);\r
-    }\r
-    jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);\r
-  }\r
-  /* Inverse DCT */\r
-  jinit_inverse_dct(cinfo);\r
-  /* Entropy decoding: either Huffman or arithmetic coding. */\r
-  if (cinfo->arith_code) {\r
-    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);\r
-  } else {\r
-    if (cinfo->progressive_mode) {\r
-#ifdef D_PROGRESSIVE_SUPPORTED\r
-      jinit_phuff_decoder(cinfo);\r
-#else\r
-      ERREXIT(cinfo, JERR_NO_PROGRESSIVE);\r
-#endif\r
-    } else\r
-      jinit_huff_decoder(cinfo);\r
-  }\r
-\r
-  /* Initialize principal buffer controllers. */\r
-  use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;\r
-  jinit_d_coef_controller(cinfo, use_c_buffer);\r
-\r
-  if (! cinfo->raw_data_out)\r
-    jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);\r
-\r
-  /* We can now tell the memory manager to allocate virtual arrays. */\r
-  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);\r
-\r
-  /* Initialize input side of decompressor to consume first scan. */\r
-  (*cinfo->inputctl->start_input_pass) (cinfo);\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-  /* If jpeg_start_decompress will read the whole file, initialize\r
-   * progress monitoring appropriately.  The input step is counted\r
-   * as one pass.\r
-   */\r
-  if (cinfo->progress != NULL && ! cinfo->buffered_image &&\r
-      cinfo->inputctl->has_multiple_scans) {\r
-    int nscans;\r
-    /* Estimate number of scans to set pass_limit. */\r
-    if (cinfo->progressive_mode) {\r
-      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */\r
-      nscans = 2 + 3 * cinfo->num_components;\r
-    } else {\r
-      /* For a nonprogressive multiscan file, estimate 1 scan per component. */\r
-      nscans = cinfo->num_components;\r
-    }\r
-    cinfo->progress->pass_counter = 0L;\r
-    cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;\r
-    cinfo->progress->completed_passes = 0;\r
-    cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);\r
-    /* Count the input pass as done */\r
-    master->pass_number++;\r
-  }\r
-#endif /* D_MULTISCAN_FILES_SUPPORTED */\r
-}\r
-\r
-\r
-/*\r
- * Per-pass setup.\r
- * This is called at the beginning of each output pass.  We determine which\r
- * modules will be active during this pass and give them appropriate\r
- * start_pass calls.  We also set is_dummy_pass to indicate whether this\r
- * is a "real" output pass or a dummy pass for color quantization.\r
- * (In the latter case, jdapi.c will crank the pass to completion.)\r
- */\r
-\r
-METHODDEF void\r
-prepare_for_output_pass (j_decompress_ptr cinfo)\r
-{\r
-  my_master_ptr master = (my_master_ptr) cinfo->master;\r
-\r
-  if (master->pub.is_dummy_pass) {\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-    /* Final pass of 2-pass quantization */\r
-    master->pub.is_dummy_pass = FALSE;\r
-    (*cinfo->cquantize->start_pass) (cinfo, FALSE);\r
-    (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);\r
-    (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);\r
-#else\r
-    ERREXIT(cinfo, JERR_NOT_COMPILED);\r
-#endif /* QUANT_2PASS_SUPPORTED */\r
-  } else {\r
-    if (cinfo->quantize_colors && cinfo->colormap == NULL) {\r
-      /* Select new quantization method */\r
-      if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {\r
-       cinfo->cquantize = master->quantizer_2pass;\r
-       master->pub.is_dummy_pass = TRUE;\r
-      } else if (cinfo->enable_1pass_quant) {\r
-       cinfo->cquantize = master->quantizer_1pass;\r
-      } else {\r
-       ERREXIT(cinfo, JERR_MODE_CHANGE);\r
-      }\r
-    }\r
-    (*cinfo->idct->start_pass) (cinfo);\r
-    (*cinfo->coef->start_output_pass) (cinfo);\r
-    if (! cinfo->raw_data_out) {\r
-      if (! master->using_merged_upsample)\r
-       (*cinfo->cconvert->start_pass) (cinfo);\r
-      (*cinfo->upsample->start_pass) (cinfo);\r
-      if (cinfo->quantize_colors)\r
-       (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);\r
-      (*cinfo->post->start_pass) (cinfo,\r
-           (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));\r
-      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);\r
-    }\r
-  }\r
-\r
-  /* Set up progress monitor's pass info if present */\r
-  if (cinfo->progress != NULL) {\r
-    cinfo->progress->completed_passes = master->pass_number;\r
-    cinfo->progress->total_passes = master->pass_number +\r
-                                   (master->pub.is_dummy_pass ? 2 : 1);\r
-    /* In buffered-image mode, we assume one more output pass if EOI not\r
-     * yet reached, but no more passes if EOI has been reached.\r
-     */\r
-    if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {\r
-      cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/*\r
- * Finish up at end of an output pass.\r
- */\r
-\r
-METHODDEF void\r
-finish_output_pass (j_decompress_ptr cinfo)\r
-{\r
-  my_master_ptr master = (my_master_ptr) cinfo->master;\r
-\r
-  if (cinfo->quantize_colors)\r
-    (*cinfo->cquantize->finish_pass) (cinfo);\r
-  master->pass_number++;\r
-}\r
-\r
-\r
-#ifdef D_MULTISCAN_FILES_SUPPORTED\r
-\r
-/*\r
- * Switch to a new external colormap between output passes.\r
- */\r
-\r
-GLOBAL void\r
-jpeg_new_colormap (j_decompress_ptr cinfo)\r
-{\r
-  my_master_ptr master = (my_master_ptr) cinfo->master;\r
-\r
-  /* Prevent application from calling me at wrong times */\r
-  if (cinfo->global_state != DSTATE_BUFIMAGE)\r
-    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);\r
-\r
-  if (cinfo->quantize_colors && cinfo->enable_external_quant &&\r
-      cinfo->colormap != NULL) {\r
-    /* Select 2-pass quantizer for external colormap use */\r
-    cinfo->cquantize = master->quantizer_2pass;\r
-    /* Notify quantizer of colormap change */\r
-    (*cinfo->cquantize->new_color_map) (cinfo);\r
-    master->pub.is_dummy_pass = FALSE; /* just in case */\r
-  } else\r
-    ERREXIT(cinfo, JERR_MODE_CHANGE);\r
-}\r
-\r
-#endif /* D_MULTISCAN_FILES_SUPPORTED */\r
-\r
-\r
-/*\r
- * Initialize master decompression control and select active modules.\r
- * This is performed at the start of jpeg_start_decompress.\r
- */\r
-\r
-GLOBAL void\r
-jinit_master_decompress (j_decompress_ptr cinfo)\r
-{\r
-  my_master_ptr master;\r
-\r
-  master = (my_master_ptr)\r
-      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,\r
-                                 SIZEOF(my_decomp_master));\r
-  cinfo->master = (struct jpeg_decomp_master *) master;\r
-  master->pub.prepare_for_output_pass = prepare_for_output_pass;\r
-  master->pub.finish_output_pass = finish_output_pass;\r
-\r
-  master->pub.is_dummy_pass = FALSE;\r
-\r
-  master_selection(cinfo);\r
-}\r
-\r
diff --git a/libs/jpeg6/jdpostct.cpp b/libs/jpeg6/jdpostct.cpp
deleted file mode 100644 (file)
index 3aba0a3..0000000
+++ /dev/null
@@ -1,580 +0,0 @@
-/*\r
-\r
- * jdpostct.c\r
-\r
- *\r
-\r
- * Copyright (C) 1994-1995, Thomas G. Lane.\r
-\r
- * This file is part of the Independent JPEG Group's software.\r
-\r
- * For conditions of distribution and use, see the accompanying README file.\r
-\r
- *\r
-\r
- * This file contains the decompression postprocessing controller.\r
-\r
- * This controller manages the upsampling, color conversion, and color\r
-\r
- * quantization/reduction steps; specifically, it controls the buffering\r
-\r
- * between upsample/color conversion and color quantization/reduction.\r
-\r
- *\r
-\r
- * If no color quantization/reduction is required, then this module has no\r
-\r
- * work to do, and it just hands off to the upsample/color conversion code.\r
-\r
- * An integrated upsample/convert/quantize process would replace this module\r
-\r
- * entirely.\r
-\r
- */\r
-\r
-\r
-\r
-#define JPEG_INTERNALS\r
-\r
-#include "jinclude.h"\r
-\r
-#include "radiant_jpeglib.h"\r
-\r
-\r
-\r
-\r
-\r
-/* Private buffer controller object */\r
-\r
-\r
-\r
-typedef struct {\r
-\r
-  struct jpeg_d_post_controller pub; /* public fields */\r
-\r
-\r
-\r
-  /* Color quantization source buffer: this holds output data from\r
-\r
-   * the upsample/color conversion step to be passed to the quantizer.\r
-\r
-   * For two-pass color quantization, we need a full-image buffer;\r
-\r
-   * for one-pass operation, a strip buffer is sufficient.\r
-\r
-   */\r
-\r
-  jvirt_sarray_ptr whole_image;        /* virtual array, or NULL if one-pass */\r
-\r
-  JSAMPARRAY buffer;           /* strip buffer, or current strip of virtual */\r
-\r
-  JDIMENSION strip_height;     /* buffer size in rows */\r
-\r
-  /* for two-pass mode only: */\r
-\r
-  JDIMENSION starting_row;     /* row # of first row in current strip */\r
-\r
-  JDIMENSION next_row;         /* index of next row to fill/empty in strip */\r
-\r
-} my_post_controller;\r
-\r
-\r
-\r
-typedef my_post_controller * my_post_ptr;\r
-\r
-\r
-\r
-\r
-\r
-/* Forward declarations */\r
-\r
-METHODDEF void post_process_1pass\r
-\r
-       JPP((j_decompress_ptr cinfo,\r
-\r
-            JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\r
-\r
-            JDIMENSION in_row_groups_avail,\r
-\r
-            JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-            JDIMENSION out_rows_avail));\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-METHODDEF void post_process_prepass\r
-\r
-       JPP((j_decompress_ptr cinfo,\r
-\r
-            JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\r
-\r
-            JDIMENSION in_row_groups_avail,\r
-\r
-            JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-            JDIMENSION out_rows_avail));\r
-\r
-METHODDEF void post_process_2pass\r
-\r
-       JPP((j_decompress_ptr cinfo,\r
-\r
-            JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\r
-\r
-            JDIMENSION in_row_groups_avail,\r
-\r
-            JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-            JDIMENSION out_rows_avail));\r
-\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Initialize for a processing pass.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)\r
-\r
-{\r
-\r
-  my_post_ptr post = (my_post_ptr) cinfo->post;\r
-\r
-\r
-\r
-  switch (pass_mode) {\r
-\r
-  case JBUF_PASS_THRU:\r
-\r
-    if (cinfo->quantize_colors) {\r
-\r
-      /* Single-pass processing with color quantization. */\r
-\r
-      post->pub.post_process_data = post_process_1pass;\r
-\r
-      /* We could be doing buffered-image output before starting a 2-pass\r
-\r
-       * color quantization; in that case, jinit_d_post_controller did not\r
-\r
-       * allocate a strip buffer.  Use the virtual-array buffer as workspace.\r
-\r
-       */\r
-\r
-      if (post->buffer == NULL) {\r
-\r
-       post->buffer = (*cinfo->mem->access_virt_sarray)\r
-\r
-         ((j_common_ptr) cinfo, post->whole_image,\r
-\r
-          (JDIMENSION) 0, post->strip_height, TRUE);\r
-\r
-      }\r
-\r
-    } else {\r
-\r
-      /* For single-pass processing without color quantization,\r
-\r
-       * I have no work to do; just call the upsampler directly.\r
-\r
-       */\r
-\r
-      post->pub.post_process_data = cinfo->upsample->upsample;\r
-\r
-    }\r
-\r
-    break;\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-  case JBUF_SAVE_AND_PASS:\r
-\r
-    /* First pass of 2-pass quantization */\r
-\r
-    if (post->whole_image == NULL)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\r
-\r
-    post->pub.post_process_data = post_process_prepass;\r
-\r
-    break;\r
-\r
-  case JBUF_CRANK_DEST:\r
-\r
-    /* Second pass of 2-pass quantization */\r
-\r
-    if (post->whole_image == NULL)\r
-\r
-      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\r
-\r
-    post->pub.post_process_data = post_process_2pass;\r
-\r
-    break;\r
-\r
-#endif /* QUANT_2PASS_SUPPORTED */\r
-\r
-  default:\r
-\r
-    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);\r
-\r
-    break;\r
-\r
-  }\r
-\r
-  post->starting_row = post->next_row = 0;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-/*\r
-\r
- * Process some data in the one-pass (strip buffer) case.\r
-\r
- * This is used for color precision reduction as well as one-pass quantization.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-post_process_1pass (j_decompress_ptr cinfo,\r
-\r
-                   JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\r
-\r
-                   JDIMENSION in_row_groups_avail,\r
-\r
-                   JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-                   JDIMENSION out_rows_avail)\r
-\r
-{\r
-\r
-  my_post_ptr post = (my_post_ptr) cinfo->post;\r
-\r
-  JDIMENSION num_rows, max_rows;\r
-\r
-\r
-\r
-  /* Fill the buffer, but not more than what we can dump out in one go. */\r
-\r
-  /* Note we rely on the upsampler to detect bottom of image. */\r
-\r
-  max_rows = out_rows_avail - *out_row_ctr;\r
-\r
-  if (max_rows > post->strip_height)\r
-\r
-    max_rows = post->strip_height;\r
-\r
-  num_rows = 0;\r
-\r
-  (*cinfo->upsample->upsample) (cinfo,\r
-\r
-               input_buf, in_row_group_ctr, in_row_groups_avail,\r
-\r
-               post->buffer, &num_rows, max_rows);\r
-\r
-  /* Quantize and emit data. */\r
-\r
-  (*cinfo->cquantize->color_quantize) (cinfo,\r
-\r
-               post->buffer, output_buf + *out_row_ctr, (int) num_rows);\r
-\r
-  *out_row_ctr += num_rows;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-#ifdef QUANT_2PASS_SUPPORTED\r
-\r
-\r
-\r
-/*\r
-\r
- * Process some data in the first pass of 2-pass quantization.\r
-\r
- */\r
-\r
-\r
-\r
-METHODDEF void\r
-\r
-post_process_prepass (j_decompress_ptr cinfo,\r
-\r
-                     JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,\r
-\r
-                     JDIMENSION in_row_groups_avail,\r
-\r
-                     JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,\r
-\r
-                     JDIMENSION out_rows_avail)\r
-\r
-{\r
-\r
-  my_post_ptr post = (my_post_ptr) cinfo->post;\r
-\r
-  JDIMENSION old_next_row, num_rows;\r
-\r
-\r
-\r
-  /* Reposition virtual buffer if at start of strip. */\r
-\r
-  if (post->next_row == 0) {\r
-\r
-    post->buffer = (*cinfo->mem->access_virt_sarray)\r
-\r
-       ((j_common_ptr) cinfo, post->whole_image,\r
-\r
-        post->starting_row, post->strip_height, TRUE);\r
-\r
-  }\r
-\r
-\r
-\r
-  /* Upsample some data (up to a strip height's worth). */\r
-\r
-  old_next_row = post->next_row;\r
-\r
-  (*cinfo->upsample->upsample) (cinfo,\r
-\r
-               input_buf, in_row_group_ctr, in_row_groups_avail,\r
-\r
-               post->buffer, &post->next_row, post->strip_height);\r
-\r
-\r
-\r
-  /* Allow quantizer to scan new data.  No data is emitted, */\r
-\r
-  /* but we advance out_row_ctr so outer loop can tell when we're done. */\r
-\r
-&nbs