2 * MJPEG encoder and decoder
3 * Copyright (c) 2000, 2001 Fabrice Bellard.
4 * Copyright (c) 2003 Alex Beregszaszi
5 * Copyright (c) 2003-2004 Michael Niedermayer
7 * Support for external huffman table, various fixes (AVID workaround),
8 * aspecting, new decode_frame mechanism and apple mjpeg-b support
11 * This file is part of FFmpeg.
13 * FFmpeg is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * FFmpeg is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with FFmpeg; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 * MJPEG encoder and decoder.
33 #ifndef AVCODEC_MJPEG_H
34 #define AVCODEC_MJPEG_H
37 #include "bitstream.h"
40 /* JPEG marker codes */
43 SOF0
= 0xc0, /* baseline */
44 SOF1
= 0xc1, /* extended sequential, huffman */
45 SOF2
= 0xc2, /* progressive, huffman */
46 SOF3
= 0xc3, /* lossless, huffman */
48 SOF5
= 0xc5, /* differential sequential, huffman */
49 SOF6
= 0xc6, /* differential progressive, huffman */
50 SOF7
= 0xc7, /* differential lossless, huffman */
51 JPG
= 0xc8, /* reserved for JPEG extension */
52 SOF9
= 0xc9, /* extended sequential, arithmetic */
53 SOF10
= 0xca, /* progressive, arithmetic */
54 SOF11
= 0xcb, /* lossless, arithmetic */
56 SOF13
= 0xcd, /* differential sequential, arithmetic */
57 SOF14
= 0xce, /* differential progressive, arithmetic */
58 SOF15
= 0xcf, /* differential lossless, arithmetic */
60 DHT
= 0xc4, /* define huffman tables */
62 DAC
= 0xcc, /* define arithmetic-coding conditioning */
64 /* restart with modulo 8 count "m" */
74 SOI
= 0xd8, /* start of image */
75 EOI
= 0xd9, /* end of image */
76 SOS
= 0xda, /* start of scan */
77 DQT
= 0xdb, /* define quantization tables */
78 DNL
= 0xdc, /* define number of lines */
79 DRI
= 0xdd, /* define restart interval */
80 DHP
= 0xde, /* define hierarchical progression */
81 EXP
= 0xdf, /* expand reference components */
107 SOF48
= 0xf7, ///< JPEG-LS
108 LSE
= 0xf8, ///< JPEG-LS extension parameters
115 COM
= 0xfe, /* comment */
117 TEM
= 0x01, /* temporary private use for arithmetic coding */
119 /* 0x02 -> 0xbf reserved */
122 static inline void put_marker(PutBitContext
*p
, int code
)
124 put_bits(p
, 8, 0xff);
125 put_bits(p
, 8, code
);
128 #define PREDICT(ret, topleft, top, left, predictor)\
130 case 1: ret= left; break;\
131 case 2: ret= top; break;\
132 case 3: ret= topleft; break;\
133 case 4: ret= left + top - topleft; break;\
134 case 5: ret= left + ((top - topleft)>>1); break;\
135 case 6: ret= top + ((left - topleft)>>1); break;\
137 case 7: ret= (left + top)>>1; break;\
140 extern const uint8_t ff_mjpeg_bits_dc_luminance
[];
141 extern const uint8_t ff_mjpeg_val_dc
[];
143 extern const uint8_t ff_mjpeg_bits_dc_chrominance
[];
145 extern const uint8_t ff_mjpeg_bits_ac_luminance
[];
146 extern const uint8_t ff_mjpeg_val_ac_luminance
[];
148 extern const uint8_t ff_mjpeg_bits_ac_chrominance
[];
149 extern const uint8_t ff_mjpeg_val_ac_chrominance
[];
151 void ff_mjpeg_build_huffman_codes(uint8_t *huff_size
, uint16_t *huff_code
,
152 const uint8_t *bits_table
,
153 const uint8_t *val_table
);
155 #endif /* AVCODEC_MJPEG_H */