ilint.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 librararies 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. #include <stddef.h> /* for size_t declaration */
  44. #ifndef IL_H
  45. #include "il.h"
  46. #endif
  47. #ifndef ILPIPELEM_H
  48. #include "ilpipelem.h"
  49. #endif
  50. #ifdef TRUE
  51. #undef TRUE
  52. #endif
  53. #ifdef FALSE
  54. #undef FALSE
  55. #endif
  56. #define FALSE 0
  57. #define TRUE 1
  58. #ifndef __STDC__
  59. #ifdef NULL
  60. #undef NULL
  61. #endif
  62. #define NULL 0
  63. #endif
  64. /* IL_EXTERN is declared in place of "extern" for functions / data
  65. that are external (in other another source file) but not public
  66. (meant to be accessed by callers). ilall.c redefines to null
  67. so that external references are not generated.
  68. */
  69. #ifndef IL_EXTERN
  70. #define IL_EXTERN extern
  71. #endif
  72. /* IL_PRIVATE is declared for functions / data that are private
  73. to the IL but need to be referenced by other source modules.
  74. ilall.c redefines to "static" so external symbol is not generated.
  75. */
  76. #ifndef IL_PRIVATE
  77. #define IL_PRIVATE
  78. #endif
  79. /* New definitions for JPEG. These may be moved to il.h and exposed
  80. to users in the future ...
  81. */
  82. /* ilImageDes.compInfo.JPEG.flags masks. All other bits must be 0 */
  83. #define IL_JPEGM_RAW (1<<0)
  84. typedef struct {
  85. short QTableIndex;
  86. short DCTableIndex;
  87. short ACTableIndex;
  88. short reserved; /* must be zero (0) */
  89. } ilJPEGSampleData;
  90. typedef struct {
  91. ilPtr QTables[4];
  92. ilPtr DCTables[4];
  93. ilPtr ACTables[4];
  94. int restartInterval;
  95. ilJPEGSampleData sample[IL_MAX_SAMPLES];
  96. } ilJPEGData;
  97. /* Maximums that correspond to defines in /ilinc/il.h .
  98. WARNING: MUST CHANGE THESE IF IL.H DEFINES CHANGE.
  99. (These defines are here rather than in the public file to discourage
  100. public use of "max" defines, which would break if more codes were added
  101. (for example if application has a table of size MAX_?).
  102. */
  103. #define IL_MAX_TYPE 4 /* IL_BITONAL, etc. */
  104. #define IL_MAX_COMPRESSION 5 /* IL_UNCOMPRESSED, etc. */
  105. #define IL_MAX_OBJECT_TYPE 7 /* IL_NULL_OBJECT, etc. */
  106. #define IL_MAX_BYTE_ORDER 1 /* IL_MSB_FIRST, etc. */
  107. #define IL_MAX_SAMPLE_ORDER 2 /* IL_SAMPLE_PIXELS, etc. */
  108. /* First part of all IL objects. More object-specific data may follow. Notes:
  109. refCount reference count. Code which "attaches" to an object (e.g.
  110. when an object is referenced in a pipe) should increment
  111. refCount, and should call ilDestroyObject() when detaching
  112. from the object. The caller must have the same number of
  113. calls to ilDestroyObject() as inc's of refCount for object.
  114. */
  115. typedef struct {
  116. ilObjectPublicRec p; /* /ilinc/il.h , e.g. "context" */
  117. unsigned long refCount; /* see notes */
  118. ilPtr pNext, pPrev; /* private to /ilc/ilobject.c */
  119. void (*Destroy)(); /* private to /ilc/ilobject.c */
  120. } ilObjectRec, *ilObjectPtr;
  121. /* From /ilc/ilobject.c : */
  122. /* Creates an object of size "sizeInBytes" and returns a ptr to it, or null
  123. if failure (the error code in "context" is set in either case). The object
  124. is added to the given "context". "sizeInBytes" must be a minimum of
  125. "sizeof(ilObjectRec)".
  126. The function "Destroy" will be called by ilDestroyObject(), as:
  127. Destroy (ilObjectPtr pObject);
  128. Before destroying this object. The Destroy() function must free any
  129. object-specific data etc. It MUST not touch the fields in the object header
  130. (ilObjectRec) or free *pObject.
  131. */
  132. IL_EXTERN ilObjectPtr _ilCreateObject (
  133. ilContext context, /* context to add object to */
  134. int objectType, /* code for object, e.g. IL_PIPE */
  135. void (*Destroy)(), /* destroy function; see above */
  136. /* Use the portable(correct) type for sizeof() operator, bug report OSF_QAR#32082 */
  137. size_t sizeInBytes /* size of object to create */
  138. );
  139. /* From /ilc/ilimage.c : */
  140. /* Validate the given image descriptor at "pDes" and the image format at
  141. "pFormat" if it is non-null and validate that they are compatible
  142. with each other.
  143. If "allowPrivateTypes" is true, private image type codes are allowed;
  144. otherwise an error is declared. Should be true for client images.
  145. Return 0 (IL_OK) if valid, else error code.
  146. NOTE: this function defines valid compressions and nBitsPerSample.
  147. */
  148. IL_EXTERN ilError _ilValidateDesFormat (
  149. ilBool allowPrivateTypes,
  150. register const ilImageDes *pDes,
  151. register const ilImageFormat *pFormat
  152. );
  153. /* From /ilc/ilcontext.c : */
  154. /* Intersect the rectangle "*pSrcRect" with the rect "*pDstRect",
  155. storing the result in "*pDstRect".
  156. */
  157. IL_EXTERN void _ilIntersectRect (
  158. ilRect *pSrcRect,
  159. ilRect *pDstRect
  160. );
  161. /* Table of shift values, indexed by YCbCr subsample values (1, 2 or 4) */
  162. IL_EXTERN const int _ilSubsampleShift [];
  163. /* Allocate _nBytes from heap and return a ptr to it.
  164. If IL_GARBAGE_MALLOC defined, init the alloc'd space with garbage
  165. to help find unit'd vars/image errors.
  166. */
  167. #ifdef IL_GARBAGE_MALLOC
  168. IL_EXTERN void *_ilMallocAndInitWithGarbage (unsigned long nBytes);
  169. # define IL_MALLOC(_nBytes) (_ilMallocAndInitWithGarbage (_nBytes))
  170. #else
  171. # define IL_MALLOC(_nBytes) (malloc (_nBytes))
  172. #endif
  173. /* Allocate _nBytes from heap, zero it, and return a ptr to it.
  174. */
  175. #define IL_MALLOC_ZERO(_nBytes) (calloc ((_nBytes), 1))
  176. /* Reallocate the given _ptr to be of size _nBytes.
  177. */
  178. #define IL_REALLOC(_ptr, _nBytes) (realloc ((_ptr), (_nBytes)))
  179. /* Free given block (*_ptr), allocated by IL_MALLOC[_ZERO]().
  180. */
  181. #define IL_FREE(_ptr) (free (_ptr))
  182. /* Print the given message if debug msgs enabled.
  183. */
  184. #ifdef IL_DEBUG_MSGS
  185. # define IL_DEBUG(_msg) (printf (stderr, _msg))
  186. # define IL_DEBUG_DEC(_msg, _decValue) (printf (stderr, _msg, _decValue))
  187. #else
  188. # define IL_DEBUG(_msg)
  189. # define IL_DEBUG_DEC(_msg, _decValue)
  190. #endif
  191. #endif