Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jinclude.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * jinclude.h
  3. *
  4. * Copyright (C) 1991-1994, Thomas G. Lane.
  5. * This file is part of the Independent JPEG Group's software.
  6. * For conditions of distribution and use, see the accompanying README file.
  7. *
  8. * This file exists to provide a single place to fix any problems with
  9. * including the wrong system include files. (Common problems are taken
  10. * care of by the standard jconfig symbols, but on really weird systems
  11. * you may have to edit this file.)
  12. *
  13. * NOTE: this file is NOT intended to be included by applications using the
  14. * JPEG library. Most applications need only include jpeglib.h.
  15. */
  16. /* Include auto-config file to find out which system include files we need. */
  17. #ifndef __jinclude_h__
  18. #define __jinclude_h__
  19. #include "jconfig.h" /* auto configuration options */
  20. #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
  21. /*
  22. * We need the NULL macro and size_t typedef.
  23. * On an ANSI-conforming system it is sufficient to include <stddef.h>.
  24. * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
  25. * pull in <sys/types.h> as well.
  26. * Note that the core JPEG library does not require <stdio.h>;
  27. * only the default error handler and data source/destination modules do.
  28. * But we must pull it in because of the references to FILE in jpeglib.h.
  29. * You can remove those references if you want to compile without <stdio.h>.
  30. */
  31. #ifdef HAVE_STDDEF_H
  32. #include <stddef.h>
  33. #endif
  34. #ifdef HAVE_STDLIB_H
  35. #include <stdlib.h>
  36. #endif
  37. #ifdef NEED_SYS_TYPES_H
  38. #include <sys/types.h>
  39. #endif
  40. #include <stdio.h>
  41. /*
  42. * We need memory copying and zeroing functions, plus strncpy().
  43. * ANSI and System V implementations declare these in <string.h>.
  44. * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  45. * Some systems may declare memset and memcpy in <memory.h>.
  46. *
  47. * NOTE: we assume the size parameters to these functions are of type size_t.
  48. * Change the casts in these macros if not!
  49. */
  50. #ifdef NEED_BSD_STRINGS
  51. #include <strings.h>
  52. #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
  53. #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
  54. #else /* not BSD, assume ANSI/SysV string lib */
  55. #include <string.h>
  56. #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
  57. #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
  58. #endif
  59. /*
  60. * In ANSI C, and indeed any rational implementation, size_t is also the
  61. * type returned by sizeof(). However, it seems there are some irrational
  62. * implementations out there, in which sizeof() returns an int even though
  63. * size_t is defined as long or unsigned long. To ensure consistent results
  64. * we always use this SIZEOF() macro in place of using sizeof() directly.
  65. */
  66. #define SIZEOF(object) ((size_t) sizeof(object))
  67. /*
  68. * The modules that use fread() and fwrite() always invoke them through
  69. * these macros. On some systems you may need to twiddle the argument casts.
  70. * CAUTION: argument order is different from underlying functions!
  71. */
  72. #define JFREAD(file,buf,sizeofbuf) \
  73. ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  74. #define JFWRITE(file,buf,sizeofbuf) \
  75. ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  76. typedef enum { /* JPEG marker codes */
  77. M_SOF0 = 0xc0,
  78. M_SOF1 = 0xc1,
  79. M_SOF2 = 0xc2,
  80. M_SOF3 = 0xc3,
  81. M_SOF5 = 0xc5,
  82. M_SOF6 = 0xc6,
  83. M_SOF7 = 0xc7,
  84. M_JPG = 0xc8,
  85. M_SOF9 = 0xc9,
  86. M_SOF10 = 0xca,
  87. M_SOF11 = 0xcb,
  88. M_SOF13 = 0xcd,
  89. M_SOF14 = 0xce,
  90. M_SOF15 = 0xcf,
  91. M_DHT = 0xc4,
  92. M_DAC = 0xcc,
  93. M_RST0 = 0xd0,
  94. M_RST1 = 0xd1,
  95. M_RST2 = 0xd2,
  96. M_RST3 = 0xd3,
  97. M_RST4 = 0xd4,
  98. M_RST5 = 0xd5,
  99. M_RST6 = 0xd6,
  100. M_RST7 = 0xd7,
  101. M_SOI = 0xd8,
  102. M_EOI = 0xd9,
  103. M_SOS = 0xda,
  104. M_DQT = 0xdb,
  105. M_DNL = 0xdc,
  106. M_DRI = 0xdd,
  107. M_DHP = 0xde,
  108. M_EXP = 0xdf,
  109. M_APP0 = 0xe0,
  110. M_APP1 = 0xe1,
  111. M_APP2 = 0xe2,
  112. M_APP3 = 0xe3,
  113. M_APP4 = 0xe4,
  114. M_APP5 = 0xe5,
  115. M_APP6 = 0xe6,
  116. M_APP7 = 0xe7,
  117. M_APP8 = 0xe8,
  118. M_APP9 = 0xe9,
  119. M_APP10 = 0xea,
  120. M_APP11 = 0xeb,
  121. M_APP12 = 0xec,
  122. M_APP13 = 0xed,
  123. M_APP14 = 0xee,
  124. M_APP15 = 0xef,
  125. M_JPG0 = 0xf0,
  126. M_JPG13 = 0xfd,
  127. M_COM = 0xfe,
  128. M_TEM = 0x01,
  129. M_ERROR = 0x100
  130. } JPEG_MARKER;
  131. /*
  132. * Figure F.12: extend sign bit.
  133. * On some machines, a shift and add will be faster than a table lookup.
  134. */
  135. #ifdef AVOID_TABLES
  136. #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
  137. #else
  138. #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
  139. static const int extend_test[16] = /* entry n is 2**(n-1) */
  140. { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
  141. 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
  142. static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
  143. { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
  144. ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
  145. ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
  146. ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
  147. #endif /* AVOID_TABLES */
  148. #endif