comparison mjpeg.h @ 5003:ddb28de352bb libavcodec

split jpeg_ls into jpeglsdec, jpeglsenc and jpegls
author aurel
date Sun, 13 May 2007 23:16:56 +0000
parents
children eb0ad6423405
comparison
equal deleted inserted replaced
5002:09cb686ffc0b 5003:ddb28de352bb
1 /*
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
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * Support for external huffman table, various fixes (AVID workaround),
24 * aspecting, new decode_frame mechanism and apple mjpeg-b support
25 * by Alex Beregszaszi
26 */
27
28 /**
29 * @file mjpeg.h
30 * MJPEG encoder and decoder.
31 */
32
33 #ifndef MJPEG_H
34 #define MJPEG_H
35
36 #include "avcodec.h"
37 #include "bitstream.h"
38 #include "dsputil.h"
39 #include "mpegvideo.h"
40
41
42 /* JPEG marker codes */
43 typedef enum {
44 /* start of frame */
45 SOF0 = 0xc0, /* baseline */
46 SOF1 = 0xc1, /* extended sequential, huffman */
47 SOF2 = 0xc2, /* progressive, huffman */
48 SOF3 = 0xc3, /* lossless, huffman */
49
50 SOF5 = 0xc5, /* differential sequential, huffman */
51 SOF6 = 0xc6, /* differential progressive, huffman */
52 SOF7 = 0xc7, /* differential lossless, huffman */
53 JPG = 0xc8, /* reserved for JPEG extension */
54 SOF9 = 0xc9, /* extended sequential, arithmetic */
55 SOF10 = 0xca, /* progressive, arithmetic */
56 SOF11 = 0xcb, /* lossless, arithmetic */
57
58 SOF13 = 0xcd, /* differential sequential, arithmetic */
59 SOF14 = 0xce, /* differential progressive, arithmetic */
60 SOF15 = 0xcf, /* differential lossless, arithmetic */
61
62 DHT = 0xc4, /* define huffman tables */
63
64 DAC = 0xcc, /* define arithmetic-coding conditioning */
65
66 /* restart with modulo 8 count "m" */
67 RST0 = 0xd0,
68 RST1 = 0xd1,
69 RST2 = 0xd2,
70 RST3 = 0xd3,
71 RST4 = 0xd4,
72 RST5 = 0xd5,
73 RST6 = 0xd6,
74 RST7 = 0xd7,
75
76 SOI = 0xd8, /* start of image */
77 EOI = 0xd9, /* end of image */
78 SOS = 0xda, /* start of scan */
79 DQT = 0xdb, /* define quantization tables */
80 DNL = 0xdc, /* define number of lines */
81 DRI = 0xdd, /* define restart interval */
82 DHP = 0xde, /* define hierarchical progression */
83 EXP = 0xdf, /* expand reference components */
84
85 APP0 = 0xe0,
86 APP1 = 0xe1,
87 APP2 = 0xe2,
88 APP3 = 0xe3,
89 APP4 = 0xe4,
90 APP5 = 0xe5,
91 APP6 = 0xe6,
92 APP7 = 0xe7,
93 APP8 = 0xe8,
94 APP9 = 0xe9,
95 APP10 = 0xea,
96 APP11 = 0xeb,
97 APP12 = 0xec,
98 APP13 = 0xed,
99 APP14 = 0xee,
100 APP15 = 0xef,
101
102 JPG0 = 0xf0,
103 JPG1 = 0xf1,
104 JPG2 = 0xf2,
105 JPG3 = 0xf3,
106 JPG4 = 0xf4,
107 JPG5 = 0xf5,
108 JPG6 = 0xf6,
109 SOF48 = 0xf7, ///< JPEG-LS
110 LSE = 0xf8, ///< JPEG-LS extension parameters
111 JPG9 = 0xf9,
112 JPG10 = 0xfa,
113 JPG11 = 0xfb,
114 JPG12 = 0xfc,
115 JPG13 = 0xfd,
116
117 COM = 0xfe, /* comment */
118
119 TEM = 0x01, /* temporary private use for arithmetic coding */
120
121 /* 0x02 -> 0xbf reserved */
122 } JPEG_MARKER;
123
124 static inline void put_marker(PutBitContext *p, int code)
125 {
126 put_bits(p, 8, 0xff);
127 put_bits(p, 8, code);
128 }
129
130 #define MAX_COMPONENTS 4
131
132 typedef struct MJpegDecodeContext {
133 AVCodecContext *avctx;
134 GetBitContext gb;
135
136 int start_code; /* current start code */
137 int buffer_size;
138 uint8_t *buffer;
139
140 int16_t quant_matrixes[4][64];
141 VLC vlcs[2][4];
142 int qscale[4]; ///< quantizer scale calculated from quant_matrixes
143
144 int org_height; /* size given at codec init */
145 int first_picture; /* true if decoding first picture */
146 int interlaced; /* true if interlaced */
147 int bottom_field; /* true if bottom field */
148 int lossless;
149 int ls;
150 int progressive;
151 int rgb;
152 int rct; /* standard rct */
153 int pegasus_rct; /* pegasus reversible colorspace transform */
154 int bits; /* bits per component */
155
156 int maxval;
157 int near; ///< near lossless bound (si 0 for lossless)
158 int t1,t2,t3;
159 int reset; ///< context halfing intervall ?rename
160
161 int width, height;
162 int mb_width, mb_height;
163 int nb_components;
164 int component_id[MAX_COMPONENTS];
165 int h_count[MAX_COMPONENTS]; /* horizontal and vertical count for each component */
166 int v_count[MAX_COMPONENTS];
167 int comp_index[MAX_COMPONENTS];
168 int dc_index[MAX_COMPONENTS];
169 int ac_index[MAX_COMPONENTS];
170 int nb_blocks[MAX_COMPONENTS];
171 int h_scount[MAX_COMPONENTS];
172 int v_scount[MAX_COMPONENTS];
173 int h_max, v_max; /* maximum h and v counts */
174 int quant_index[4]; /* quant table index for each component */
175 int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
176 AVFrame picture; /* picture structure */
177 int linesize[MAX_COMPONENTS]; ///< linesize << interlaced
178 int8_t *qscale_table;
179 DECLARE_ALIGNED_8(DCTELEM, block[64]);
180 ScanTable scantable;
181 DSPContext dsp;
182
183 int restart_interval;
184 int restart_count;
185
186 int buggy_avid;
187 int cs_itu601;
188 int interlace_polarity;
189
190 int mjpb_skiptosod;
191
192 int cur_scan; /* current scan, used by JPEG-LS */
193 } MJpegDecodeContext;
194
195 #endif /* MJPEG_H */