home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 117 / af117sub.adf / jpeglibrary.lzx / jpeglibrary / includes / jpeg / jpeg.h < prev   
C/C++ Source or Header  |  1998-09-22  |  8KB  |  186 lines

  1. #ifndef JPEG_H
  2. #define JPEG_H
  3.  
  4. /*
  5. **    $VER: jpeg.h 1.0 (2.5.98)
  6. **
  7. **    Public structures and defintions for jpeg.library.
  8. **
  9. **    © Paul Huxham
  10. **
  11. **    This software is based in part on the work of
  12. **    the Independent JPEG Group.
  13. */
  14.  
  15. #ifndef EXEC_TYPES_H
  16. #include "exec/types.h"
  17. #endif
  18.  
  19. #ifndef DOS_DOS_H
  20. #include <dos/dos.h>
  21. #endif
  22.  
  23. #ifndef UTILITY_TAGITEM_H
  24. #include <utility/tagitem.h>
  25. #endif
  26.  
  27. /*========================================================================*/
  28. /* Public object handles */
  29.  
  30. /* Used for JPEG decompression */
  31. struct JPEGDecHandle
  32. {
  33.     ULONG ptr; // Private!
  34. };
  35.  
  36. /* Used for JPEG compression */
  37. struct JPEGComHandle
  38. {
  39.     ULONG ptr; // Private!
  40. };
  41.  
  42. /*========================================================================*/
  43. /* Public callback hooks */
  44.  
  45. /* The decompress hook is called once for each scanline in the image.
  46.         a0 contains a UBYTE pointer to the scanline to copy
  47.         d0 contains a ULONG with the scanline number of this data (1 being
  48.                 first scanline)
  49.         d1 contains a ULONG with the number of bytes in this row
  50.         a1 contains the userdata
  51.  
  52.     If the hook returns a non NULL value, the decoding will be aborted -
  53.     You should NOT call any functions other than FreeJPEGDecompress() on
  54.     that jpeg object.
  55. */
  56.  
  57. typedef ULONG (*JPGD_HOOK)( void *, ULONG, ULONG, void * );
  58. typedef __asm ULONG (*JPGD_HOOK_PROTO)( register __a0 void *, register __d0 ULONG, register __d1 ULONG, register __a1 void * );
  59.  
  60. /* The compress hook is called once for each scanline in the image.
  61.         a0 contains a UBYTE **. Copy into here (*ptr=) the pointer to the image
  62.         d0 contains a ULONG with the scanline number of the scanline I want
  63.         d1 contains a ULONG with the width of the image
  64.         a1 contains the userdata
  65.  
  66.     If the hook returns a non NULL value, the encoding will be aborted -
  67.     You should NOT call any functions other than FreeJPEGCompress() on
  68.     that jpeg object.
  69. */
  70.  
  71. typedef ULONG (*JPGC_HOOK)( UBYTE **,  ULONG, ULONG, void * );
  72. typedef __asm ULONG (*JPGC_HOOK_PROTO)( register __a0 UBYTE **, register __d0 ULONG, register __d1 ULONG, register __a1 void * );
  73.  
  74. /* The progress hook is called once for each scanline in the image (during
  75.         compression and decompression).
  76.         d0 contains a ULONG with the current scanline number (1-n).
  77.         d1 contains a ULONG with the total number of scanlines.
  78.         a0 contains the userdata
  79.  
  80.     If the hook returns a non NULL value, the encoding will be aborted -
  81.     You should NOT call any functions other than FreeJPEGCompress() on
  82.     that jpeg object.
  83. */
  84.  
  85. typedef ULONG (*JPGP_HOOK)( ULONG, ULONG, void * );
  86. typedef __asm ULONG (*JPGP_HOOK_PROTO)( register __d0 ULONG, register __d1 ULONG, register __a0 void * );
  87.  
  88. /* The render hook is called once for each decompressed scanline in the
  89.         image.
  90.         a0 contains a UBYTE pointer to the scanline data
  91.         d0 contains a ULONG with the scanline number of this data (1 being
  92.                 first scanline)
  93.         d1 contains a ULONG with the number of bytes in this row
  94.         a1 contains the userdata
  95.  
  96.     If the hook returns a non NULL value, the decoding will be aborted -
  97.     You should NOT call any functions other than FreeJPEGDecompress() on
  98.     that jpeg object.
  99. */
  100.  
  101. typedef ULONG (*JPGR_HOOK)( void *, ULONG, ULONG, void * );
  102. typedef __asm ULONG (*JPGR_HOOK_PROTO)( register __a0 void *, register __d0 ULONG, register __d1 ULONG, register __a1 void * );
  103.  
  104. /*========================================================================*/
  105. /* JFIF encoder/decoder processing arithmetic */
  106. enum
  107. {
  108.     DCT_ISLOW, // Slow but accurate integer algorithm (default)
  109.     DCT_IFAST, // Faster, less accurate integer method
  110.     DCT_FLOAT // Floating-point: accurate, fast on fast hardware
  111. };
  112.  
  113. /*========================================================================*/
  114. /* Colour space defines, from JPG_ColourSpace */
  115. enum
  116. {
  117.     JPCS_UNKNOWN, // Error/unspecified
  118.     JPCS_GRAYSCALE, // Monochrome
  119.     JPCS_RGB, // Red/green/blue
  120.     JPCS_YCbCr, // Y/Cb/Cr (also known as YUV)
  121.     JPCS_CMYK, // C/M/Y/K
  122.     JPCS_YCCK // Y/Cb/Cr/K
  123. };
  124.  
  125.  
  126. /*========================================================================*/
  127. /* Jpeg tagbase */
  128. #define JPG_TB ( TAG_USER + 0x80000 )
  129.  
  130. /* Jpeg tags requiring V1.0 */
  131. #define JPG_SrcMemStream JPG_TB + 1 /* Pointer to stream data in memory (UBYTE *) */
  132. #define JPG_SrcMemStreamSize JPG_TB + 2 /* Length in bytes of data stream (ULONG) */
  133. #define JPG_DestMemStream JPG_TB + 3 /* Pointer to a pointer to created data in memory (UBYTE **) */
  134. #define JPG_DestMemStreamSize JPG_TB + 4 /* Pointer to take size of created data (ULONG *) */
  135. #define JPG_SrcFile JPG_TB + 5 /* Pointer to an open file (BPTR) */
  136. #define JPG_DestFile JPG_TB + 6 /* Pointer to an open file (BPTR) */
  137. #define JPG_DestRGBBuffer JPG_TB + 7 /* Pointer to a memory block (UBYTE *) */
  138. #define JPG_DecompressHook JPG_TB + 8 /* Pointer to a function to store scan lines */
  139. #define JPG_DecompressUserData JPG_TB + 9 /* Pointer to user data (void *) */
  140. #define JPG_SrcRGBBuffer JPG_TB + 12 /* Pointer to a memory block (UBYTE *) */
  141. #define JPG_CompressHook JPG_TB + 13 /* Pointer to a function to store scan lines */
  142. #define JPG_CompressUserData JPG_TB + 14 /* Pointer to user data (void *) */
  143.  
  144. /* Jpeg tags affecting image size and quality */
  145. #define JPG_ScaleNum JPG_TB + 10 /* Numerator for scaling (ULONG) */
  146. #define JPG_ScaleDenom JPG_TB + 11 /* Denomenator for scaling (ULONG) */
  147. #define JPG_Width JPG_TB + 20 /* Width of image in pixels (ULONG *) */
  148. #define JPG_Height JPG_TB + 21 /* Height of image in pixels (ULONG *) */
  149. #define JPG_BytesPerPixel JPG_TB + 22 /* Number of bytes per image pixel (ULONG *) */
  150. #define JPG_RowSize JPG_TB + 23 /* Size of one row (ULONG *) [GET only] */
  151. #define JPG_ColourSpace JPG_TB + 24 /* Type of image data */
  152. #define JPG_Quality JPG_TB + 25 /* Save quality of jpeg (1-100) () */
  153. #define JPG_Smoothing JPG_TB + 26 /* Save smoothing amount (0-100) () */
  154.  
  155. /* Jpeg tags requiring V2.1 */
  156. #define JPG_ProgressHook JPG_TB + 15 /* Pointer to a function to display progress status */
  157. #define JPG_ProgressUserData JPG_TB + 16 /* Pointer to user data (void *) */
  158.  
  159. /* Jpeg tags requiring V3.0 */
  160. #define JPG_MemoryPool JPG_TB + 17 /* All de/allocs are on this memory pool (void *) [U] */
  161. #define JPG_RenderHook JPG_TB + 18 /* Pointer to a function to render decoded scan lines */
  162. #define JPG_RenderUserData JPG_TB + 19 /* Pointer to user data (void *) */
  163. #define JPG_DCTMethod JPG_TB + 27 /* Use this DCT method [U] */
  164.  
  165. /*========================================================================*/
  166. /* Defined error return codes */
  167. #define JPGERR_NONE 0 /* No error */
  168. #define JPGERR_NOMEMORY 1 /* Insufficient memory */
  169. #define JPGERR_NOHANDLE 2 /* No jpeg handle supplied */
  170. #define JPGERR_CREATEOBJECT 3 /* Failed to create JPEG object */
  171. #define JPGERR_DECOMPFAILURE 4 /* Failed to decompress */
  172. #define JPGERR_NOSRCSTREAM 5 /* No source stream to decode */
  173. #define JPGERR_NODESTBUFFER 6 /* No destination rgb buffer/hook */
  174. #define JPGERR_DECOMPABORTED 7 /* Decompression aborted by user hook */
  175. #define JPGERR_NODESTSTREAM 8 /* No destination stream pointers */
  176. #define JPGERR_COMPFAILURE 9 /* Failed to compress */
  177. #define JPGERR_COMPABORTED 10 /* Compression aborted by user hook */
  178. #define JPGERR_NOIMAGESIZE 11 /* No image size supplied */
  179. #define JPGERR_ALREADYDECOMP 12 /* Handle has already been decompressed */
  180. #define JPGERR_ALREADYCOMP 13 /* Handle has already been compressed */
  181. #define JPGERR_NOTJPEG 14 /* The stream is not jpeg format */
  182. #define JPGERR_ARITHNOTSUPP 15 /* Arithmetic encoded jpeg streams are not supported */
  183. #define JPGERR_CORRUPTJPEG 16 /* The jpeg stream is corrupt */
  184.  
  185. #endif /* JPEG_H */
  186.