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