ilint.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: ilint.h /main/4 1996/01/08 12:14:49 lehors $ */
  24. /**---------------------------------------------------------------------
  25. ***
  26. *** (c)Copyright 1991 Hewlett-Packard Co.
  27. ***
  28. *** RESTRICTED RIGHTS LEGEND
  29. *** Use, duplication, or disclosure by the U.S. Government is subject to
  30. *** restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
  31. *** Technical Data and Computer Software clause in DFARS 252.227-7013.
  32. *** Hewlett-Packard Company
  33. *** 3000 Hanover Street
  34. *** Palo Alto, CA 94304 U.S.A.
  35. *** Rights for non-DOD U.S. Government Departments and Agencies are as set
  36. *** forth in FAR 52.227-19(c)(1,2).
  37. ***
  38. ***-------------------------------------------------------------------*/
  39. #ifndef ILINT_H
  40. #define ILINT_H
  41. /* General internal definitions for Image Library (IL).
  42. */
  43. /* use autotools detection to determine endianess */
  44. #if defined(HAVE_CONFIG_H)
  45. # include <cde_config.h>
  46. #endif
  47. #ifndef WORDS_BIGENDIAN
  48. # define LSB_BIT_ORDER
  49. #endif
  50. #include <stddef.h> /* for size_t declaration */
  51. #ifndef IL_H
  52. #include "il.h"
  53. #endif
  54. #ifndef ILPIPELEM_H
  55. #include "ilpipelem.h"
  56. #endif
  57. #ifdef TRUE
  58. #undef TRUE
  59. #endif
  60. #ifdef FALSE
  61. #undef FALSE
  62. #endif
  63. #define FALSE 0
  64. #define TRUE 1
  65. #ifndef __STDC__
  66. #ifdef NULL
  67. #undef NULL
  68. #endif
  69. #define NULL 0
  70. #endif
  71. /* IL_EXTERN is declared in place of "extern" for functions / data
  72. that are external (in other another source file) but not public
  73. (meant to be accessed by callers). ilall.c redefines to null
  74. so that external references are not generated.
  75. */
  76. #ifndef IL_EXTERN
  77. #define IL_EXTERN extern
  78. #endif
  79. /* IL_PRIVATE is declared for functions / data that are private
  80. to the IL but need to be referenced by other source modules.
  81. ilall.c redefines to "static" so external symbol is not generated.
  82. */
  83. #ifndef IL_PRIVATE
  84. #define IL_PRIVATE
  85. #endif
  86. /* New definitions for JPEG. These may be moved to il.h and exposed
  87. to users in the future ...
  88. */
  89. /* ilImageDes.compInfo.JPEG.flags masks. All other bits must be 0 */
  90. #define IL_JPEGM_RAW (1<<0)
  91. typedef struct {
  92. short QTableIndex;
  93. short DCTableIndex;
  94. short ACTableIndex;
  95. short reserved; /* must be zero (0) */
  96. } ilJPEGSampleData;
  97. typedef struct {
  98. ilPtr QTables[4];
  99. ilPtr DCTables[4];
  100. ilPtr ACTables[4];
  101. int restartInterval;
  102. ilJPEGSampleData sample[IL_MAX_SAMPLES];
  103. } ilJPEGData;
  104. /* Maximums that correspond to defines in /ilinc/il.h .
  105. WARNING: MUST CHANGE THESE IF IL.H DEFINES CHANGE.
  106. (These defines are here rather than in the public file to discourage
  107. public use of "max" defines, which would break if more codes were added
  108. (for example if application has a table of size MAX_?).
  109. */
  110. #define IL_MAX_TYPE 4 /* IL_BITONAL, etc. */
  111. #define IL_MAX_COMPRESSION 5 /* IL_UNCOMPRESSED, etc. */
  112. #define IL_MAX_OBJECT_TYPE 7 /* IL_NULL_OBJECT, etc. */
  113. #define IL_MAX_BYTE_ORDER 1 /* IL_MSB_FIRST, etc. */
  114. #define IL_MAX_SAMPLE_ORDER 2 /* IL_SAMPLE_PIXELS, etc. */
  115. /* First part of all IL objects. More object-specific data may follow. Notes:
  116. refCount reference count. Code which "attaches" to an object (e.g.
  117. when an object is referenced in a pipe) should increment
  118. refCount, and should call ilDestroyObject() when detaching
  119. from the object. The caller must have the same number of
  120. calls to ilDestroyObject() as inc's of refCount for object.
  121. */
  122. typedef struct {
  123. ilObjectPublicRec p; /* /ilinc/il.h , e.g. "context" */
  124. unsigned long refCount; /* see notes */
  125. ilPtr pNext, pPrev; /* private to /ilc/ilobject.c */
  126. void (*Destroy)(); /* private to /ilc/ilobject.c */
  127. } ilObjectRec, *ilObjectPtr;
  128. /* From /ilc/ilobject.c : */
  129. /* Creates an object of size "sizeInBytes" and returns a ptr to it, or null
  130. if failure (the error code in "context" is set in either case). The object
  131. is added to the given "context". "sizeInBytes" must be a minimum of
  132. "sizeof(ilObjectRec)".
  133. The function "Destroy" will be called by ilDestroyObject(), as:
  134. Destroy (ilObjectPtr pObject);
  135. Before destroying this object. The Destroy() function must free any
  136. object-specific data etc. It MUST not touch the fields in the object header
  137. (ilObjectRec) or free *pObject.
  138. */
  139. IL_EXTERN ilObjectPtr _ilCreateObject (
  140. ilContext context, /* context to add object to */
  141. int objectType, /* code for object, e.g. IL_PIPE */
  142. void (*Destroy)(), /* destroy function; see above */
  143. /* Use the portable(correct) type for sizeof() operator, bug report OSF_QAR#32082 */
  144. size_t sizeInBytes /* size of object to create */
  145. );
  146. /* From /ilc/ilimage.c : */
  147. /* Validate the given image descriptor at "pDes" and the image format at
  148. "pFormat" if it is non-null and validate that they are compatible
  149. with each other.
  150. If "allowPrivateTypes" is true, private image type codes are allowed;
  151. otherwise an error is declared. Should be true for client images.
  152. Return 0 (IL_OK) if valid, else error code.
  153. NOTE: this function defines valid compressions and nBitsPerSample.
  154. */
  155. IL_EXTERN ilError _ilValidateDesFormat (
  156. ilBool allowPrivateTypes,
  157. const ilImageDes *pDes,
  158. const ilImageFormat *pFormat
  159. );
  160. /* From /ilc/ilcontext.c : */
  161. /* Intersect the rectangle "*pSrcRect" with the rect "*pDstRect",
  162. storing the result in "*pDstRect".
  163. */
  164. IL_EXTERN void _ilIntersectRect (
  165. ilRect *pSrcRect,
  166. ilRect *pDstRect
  167. );
  168. /* Table of shift values, indexed by YCbCr subsample values (1, 2 or 4) */
  169. IL_EXTERN const int _ilSubsampleShift [];
  170. /* Allocate _nBytes from heap and return a ptr to it.
  171. If IL_GARBAGE_MALLOC defined, init the alloc'd space with garbage
  172. to help find unit'd vars/image errors.
  173. */
  174. #ifdef IL_GARBAGE_MALLOC
  175. IL_EXTERN void *_ilMallocAndInitWithGarbage (unsigned long nBytes);
  176. # define IL_MALLOC(_nBytes) (_ilMallocAndInitWithGarbage (_nBytes))
  177. #else
  178. # define IL_MALLOC(_nBytes) (malloc (_nBytes))
  179. #endif
  180. /* Allocate _nBytes from heap, zero it, and return a ptr to it.
  181. */
  182. #define IL_MALLOC_ZERO(_nBytes) (calloc ((_nBytes), 1))
  183. /* Reallocate the given _ptr to be of size _nBytes.
  184. */
  185. #define IL_REALLOC(_ptr, _nBytes) (realloc ((_ptr), (_nBytes)))
  186. /* Free given block (*_ptr), allocated by IL_MALLOC[_ZERO]().
  187. */
  188. #define IL_FREE(_ptr) (free (_ptr))
  189. /* Print the given message if debug msgs enabled.
  190. */
  191. #ifdef IL_DEBUG_MSGS
  192. # define IL_DEBUG(_msg) (printf (stderr, _msg))
  193. # define IL_DEBUG_DEC(_msg, _decValue) (printf (stderr, _msg, _decValue))
  194. #else
  195. # define IL_DEBUG(_msg)
  196. # define IL_DEBUG_DEC(_msg, _decValue)
  197. #endif
  198. #endif