istereo2

diff libs/libjpeg/jmemsys.h @ 2:81d35769f546

added the tunnel effect source
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 19 Sep 2015 05:51:51 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/libjpeg/jmemsys.h	Sat Sep 19 05:51:51 2015 +0300
     1.3 @@ -0,0 +1,198 @@
     1.4 +/*
     1.5 + * jmemsys.h
     1.6 + *
     1.7 + * Copyright (C) 1992-1997, Thomas G. Lane.
     1.8 + * This file is part of the Independent JPEG Group's software.
     1.9 + * For conditions of distribution and use, see the accompanying README file.
    1.10 + *
    1.11 + * This include file defines the interface between the system-independent
    1.12 + * and system-dependent portions of the JPEG memory manager.  No other
    1.13 + * modules need include it.  (The system-independent portion is jmemmgr.c;
    1.14 + * there are several different versions of the system-dependent portion.)
    1.15 + *
    1.16 + * This file works as-is for the system-dependent memory managers supplied
    1.17 + * in the IJG distribution.  You may need to modify it if you write a
    1.18 + * custom memory manager.  If system-dependent changes are needed in
    1.19 + * this file, the best method is to #ifdef them based on a configuration
    1.20 + * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR
    1.21 + * and USE_MAC_MEMMGR.
    1.22 + */
    1.23 +
    1.24 +
    1.25 +/* Short forms of external names for systems with brain-damaged linkers. */
    1.26 +
    1.27 +#ifdef NEED_SHORT_EXTERNAL_NAMES
    1.28 +#define jpeg_get_small		jGetSmall
    1.29 +#define jpeg_free_small		jFreeSmall
    1.30 +#define jpeg_get_large		jGetLarge
    1.31 +#define jpeg_free_large		jFreeLarge
    1.32 +#define jpeg_mem_available	jMemAvail
    1.33 +#define jpeg_open_backing_store	jOpenBackStore
    1.34 +#define jpeg_mem_init		jMemInit
    1.35 +#define jpeg_mem_term		jMemTerm
    1.36 +#endif /* NEED_SHORT_EXTERNAL_NAMES */
    1.37 +
    1.38 +
    1.39 +/*
    1.40 + * These two functions are used to allocate and release small chunks of
    1.41 + * memory.  (Typically the total amount requested through jpeg_get_small is
    1.42 + * no more than 20K or so; this will be requested in chunks of a few K each.)
    1.43 + * Behavior should be the same as for the standard library functions malloc
    1.44 + * and free; in particular, jpeg_get_small must return NULL on failure.
    1.45 + * On most systems, these ARE malloc and free.  jpeg_free_small is passed the
    1.46 + * size of the object being freed, just in case it's needed.
    1.47 + * On an 80x86 machine using small-data memory model, these manage near heap.
    1.48 + */
    1.49 +
    1.50 +EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject));
    1.51 +EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object,
    1.52 +				  size_t sizeofobject));
    1.53 +
    1.54 +/*
    1.55 + * These two functions are used to allocate and release large chunks of
    1.56 + * memory (up to the total free space designated by jpeg_mem_available).
    1.57 + * The interface is the same as above, except that on an 80x86 machine,
    1.58 + * far pointers are used.  On most other machines these are identical to
    1.59 + * the jpeg_get/free_small routines; but we keep them separate anyway,
    1.60 + * in case a different allocation strategy is desirable for large chunks.
    1.61 + */
    1.62 +
    1.63 +EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo,
    1.64 +				       size_t sizeofobject));
    1.65 +EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object,
    1.66 +				  size_t sizeofobject));
    1.67 +
    1.68 +/*
    1.69 + * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may
    1.70 + * be requested in a single call to jpeg_get_large (and jpeg_get_small for that
    1.71 + * matter, but that case should never come into play).  This macro is needed
    1.72 + * to model the 64Kb-segment-size limit of far addressing on 80x86 machines.
    1.73 + * On those machines, we expect that jconfig.h will provide a proper value.
    1.74 + * On machines with 32-bit flat address spaces, any large constant may be used.
    1.75 + *
    1.76 + * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type
    1.77 + * size_t and will be a multiple of sizeof(align_type).
    1.78 + */
    1.79 +
    1.80 +#ifndef MAX_ALLOC_CHUNK		/* may be overridden in jconfig.h */
    1.81 +#define MAX_ALLOC_CHUNK  1000000000L
    1.82 +#endif
    1.83 +
    1.84 +/*
    1.85 + * This routine computes the total space still available for allocation by
    1.86 + * jpeg_get_large.  If more space than this is needed, backing store will be
    1.87 + * used.  NOTE: any memory already allocated must not be counted.
    1.88 + *
    1.89 + * There is a minimum space requirement, corresponding to the minimum
    1.90 + * feasible buffer sizes; jmemmgr.c will request that much space even if
    1.91 + * jpeg_mem_available returns zero.  The maximum space needed, enough to hold
    1.92 + * all working storage in memory, is also passed in case it is useful.
    1.93 + * Finally, the total space already allocated is passed.  If no better
    1.94 + * method is available, cinfo->mem->max_memory_to_use - already_allocated
    1.95 + * is often a suitable calculation.
    1.96 + *
    1.97 + * It is OK for jpeg_mem_available to underestimate the space available
    1.98 + * (that'll just lead to more backing-store access than is really necessary).
    1.99 + * However, an overestimate will lead to failure.  Hence it's wise to subtract
   1.100 + * a slop factor from the true available space.  5% should be enough.
   1.101 + *
   1.102 + * On machines with lots of virtual memory, any large constant may be returned.
   1.103 + * Conversely, zero may be returned to always use the minimum amount of memory.
   1.104 + */
   1.105 +
   1.106 +EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo,
   1.107 +				     long min_bytes_needed,
   1.108 +				     long max_bytes_needed,
   1.109 +				     long already_allocated));
   1.110 +
   1.111 +
   1.112 +/*
   1.113 + * This structure holds whatever state is needed to access a single
   1.114 + * backing-store object.  The read/write/close method pointers are called
   1.115 + * by jmemmgr.c to manipulate the backing-store object; all other fields
   1.116 + * are private to the system-dependent backing store routines.
   1.117 + */
   1.118 +
   1.119 +#define TEMP_NAME_LENGTH   64	/* max length of a temporary file's name */
   1.120 +
   1.121 +
   1.122 +#ifdef USE_MSDOS_MEMMGR		/* DOS-specific junk */
   1.123 +
   1.124 +typedef unsigned short XMSH;	/* type of extended-memory handles */
   1.125 +typedef unsigned short EMSH;	/* type of expanded-memory handles */
   1.126 +
   1.127 +typedef union {
   1.128 +  short file_handle;		/* DOS file handle if it's a temp file */
   1.129 +  XMSH xms_handle;		/* handle if it's a chunk of XMS */
   1.130 +  EMSH ems_handle;		/* handle if it's a chunk of EMS */
   1.131 +} handle_union;
   1.132 +
   1.133 +#endif /* USE_MSDOS_MEMMGR */
   1.134 +
   1.135 +#ifdef USE_MAC_MEMMGR		/* Mac-specific junk */
   1.136 +#include <Files.h>
   1.137 +#endif /* USE_MAC_MEMMGR */
   1.138 +
   1.139 +
   1.140 +typedef struct backing_store_struct * backing_store_ptr;
   1.141 +
   1.142 +typedef struct backing_store_struct {
   1.143 +  /* Methods for reading/writing/closing this backing-store object */
   1.144 +  JMETHOD(void, read_backing_store, (j_common_ptr cinfo,
   1.145 +				     backing_store_ptr info,
   1.146 +				     void FAR * buffer_address,
   1.147 +				     long file_offset, long byte_count));
   1.148 +  JMETHOD(void, write_backing_store, (j_common_ptr cinfo,
   1.149 +				      backing_store_ptr info,
   1.150 +				      void FAR * buffer_address,
   1.151 +				      long file_offset, long byte_count));
   1.152 +  JMETHOD(void, close_backing_store, (j_common_ptr cinfo,
   1.153 +				      backing_store_ptr info));
   1.154 +
   1.155 +  /* Private fields for system-dependent backing-store management */
   1.156 +#ifdef USE_MSDOS_MEMMGR
   1.157 +  /* For the MS-DOS manager (jmemdos.c), we need: */
   1.158 +  handle_union handle;		/* reference to backing-store storage object */
   1.159 +  char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
   1.160 +#else
   1.161 +#ifdef USE_MAC_MEMMGR
   1.162 +  /* For the Mac manager (jmemmac.c), we need: */
   1.163 +  short temp_file;		/* file reference number to temp file */
   1.164 +  FSSpec tempSpec;		/* the FSSpec for the temp file */
   1.165 +  char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
   1.166 +#else
   1.167 +  /* For a typical implementation with temp files, we need: */
   1.168 +  FILE * temp_file;		/* stdio reference to temp file */
   1.169 +  char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */
   1.170 +#endif
   1.171 +#endif
   1.172 +} backing_store_info;
   1.173 +
   1.174 +
   1.175 +/*
   1.176 + * Initial opening of a backing-store object.  This must fill in the
   1.177 + * read/write/close pointers in the object.  The read/write routines
   1.178 + * may take an error exit if the specified maximum file size is exceeded.
   1.179 + * (If jpeg_mem_available always returns a large value, this routine can
   1.180 + * just take an error exit.)
   1.181 + */
   1.182 +
   1.183 +EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo,
   1.184 +					  backing_store_ptr info,
   1.185 +					  long total_bytes_needed));
   1.186 +
   1.187 +
   1.188 +/*
   1.189 + * These routines take care of any system-dependent initialization and
   1.190 + * cleanup required.  jpeg_mem_init will be called before anything is
   1.191 + * allocated (and, therefore, nothing in cinfo is of use except the error
   1.192 + * manager pointer).  It should return a suitable default value for
   1.193 + * max_memory_to_use; this may subsequently be overridden by the surrounding
   1.194 + * application.  (Note that max_memory_to_use is only important if
   1.195 + * jpeg_mem_available chooses to consult it ... no one else will.)
   1.196 + * jpeg_mem_term may assume that all requested memory has been freed and that
   1.197 + * all opened backing-store objects have been closed.
   1.198 + */
   1.199 +
   1.200 +EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo));
   1.201 +EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo));