1 /*
2 * common functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
3 *
4 * Copyright (c) 2009 Maxim Poliakovski
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * This file contains structures and macros shared by both Indeo4 and
26 * Indeo5 decoders.
27 */
28
29 #ifndef AVCODEC_IVI_H
30 #define AVCODEC_IVI_H
31
34 #include <stdint.h>
35
36 /**
37 * Indeo 4 frame types.
38 */
39 enum {
47 };
48
49 #define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
50 #define IVI5_IS_PROTECTED 0x20
51
52 /**
53 * huffman codebook descriptor
54 */
59
60 /**
61 * macroblock/block huffman table descriptor
62 */
65 /// or "7" for custom one
66 VLC *
tab;
/// pointer to the table associated with tab_sel
67
68 /// the following are used only when tab_sel == 7
72
73 enum {
74 IVI_MB_HUFF = 0,
/// Huffman table is used for coding macroblocks
76 };
77
78
79 /**
80 * Common scan patterns (defined in ivi_common.c)
81 */
85
86
87 /**
88 * Declare inverse transform function types
89 */
92
93
94 /**
95 * run-value (RLE) table descriptor
96 */
103
105
106
107 /**
108 * information for Indeo macroblock (16x16, 8x8 or 4x4)
109 */
113 uint32_t
buf_offs;
///< address in the output buffer for this mb
114 uint8_t
type;
///< macroblock type: 0 - INTRA, 1 - INTER
115 uint8_t
cbp;
///< coded block pattern
117 int8_t
mv_x;
///< motion vector (x component)
118 int8_t
mv_y;
///< motion vector (y component)
119 int8_t
b_mv_x;
///< second motion vector (x component)
120 int8_t
b_mv_y;
///< second motion vector (y component)
122
123
124 /**
125 * information for Indeo tile
126 */
133 int is_empty;
///< = 1 if this tile doesn't contain any data
135 int num_MBs;
///< number of macroblocks in this tile
139
140
141 /**
142 * information for Indeo wavelet band
143 */
145 int plane;
///< plane number this band belongs to
150 const uint8_t *
data_ptr;
///< ptr to the first byte of the band data
152 int16_t *
buf;
///< pointer to the output buffer for this band
153 int16_t *
ref_buf;
///< pointer to the reference frame buffer (for motion compensation)
154 int16_t *
b_ref_buf;
///< pointer to the second reference frame buffer (for motion compensation)
155 int16_t *
bufs[4];
///< array of pointers to the band buffers
156 ptrdiff_t
pitch;
///< pitch associated with the buffers above
157 int is_empty;
///< = 1 if this band doesn't contain any data
160 int is_halfpel;
///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
161 int inherit_mv;
///< tells if motion vector is inherited from reference macroblock
162 int inherit_qdelta;
///< tells if quantiser delta is inherited from reference macroblock
163 int qdelta_present;
///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
166 const uint8_t *
scan;
///< ptr to the scan pattern
168
170
172 uint8_t
corr[61*2];
///< rvmap correction pairs
180 int is_2d_trans;
///< 1 indicates that the two-dimensional inverse transform is used
184 const uint16_t *
intra_base;
///< quantization matrix for intra blocks
185 const uint16_t *
inter_base;
///< quantization matrix for inter blocks
186 const uint8_t *
intra_scale;
///< quantization coefficient for intra blocks
187 const uint8_t *
inter_scale;
///< quantization coefficient for inter blocks
189
190
191 /**
192 * color plane (luma or chroma) information
193 */
197 uint8_t
num_bands;
///< number of bands this plane subdivided into
200
201
212
216
220 uint32_t
data_size;
///< size of the frame data in bytes from picture header
223 int inter_scal;
///< signals a sequence of scalable inter frames
228
231
233 int dst_buf;
///< buffer index for the currently decoded frame
234 int ref_buf;
///< inter frame reference buffer index
235 int ref2_buf;
///< temporal storage for switching buffers
237
240
243 uint8_t
in_q;
///< flag for explicitly stored quantiser delta
246
250
253 uint8_t
has_transp;
///< transparency mode status: 1 - enabled
257
263
266
268
272
273 /** compare some properties of two pictures */
275 {
280 }
281
282 /** calculate number of tiles in a stride */
283 #define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
284
285 /** calculate number of macroblocks in a tile */
286 #define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
287 ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
288
289 /** convert unsigned values into signed ones (the sign is in the LSB) */
290 #define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
291
292 /** scale motion vector */
294 {
296 }
297
298 /**
299 * Initialize static codes used for macroblock and block decoding.
300 */
302
303 /**
304 * Decode a huffman codebook descriptor from the bitstream
305 * and select specified huffman table.
306 *
307 * @param[in,out] gb the GetBit context
308 * @param[in] desc_coded flag signalling if table descriptor was coded
309 * @param[in] which_tab codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
310 * @param[out] huff_tab pointer to the descriptor of the selected table
311 * @param[in] avctx AVCodecContext pointer
312 * @return zero on success, negative value otherwise
313 */
316
317 /**
318 * Initialize planes (prepares descriptors, allocates buffers etc).
319 *
320 * @param[in,out] planes pointer to the array of the plane descriptors
321 * @param[in] cfg pointer to the ivi_pic_config structure describing picture layout
322 * @param[in] is_indeo4 flag signalling if it is Indeo 4 or not
323 * @return result code: 0 - OK
324 */
327
328 /**
329 * Initialize tile and macroblock descriptors.
330 *
331 * @param[in,out] planes pointer to the array of the plane descriptors
332 * @param[in] tile_width tile width
333 * @param[in] tile_height tile height
334 * @return result code: 0 - OK
335 */
337
341
342 #endif /* AVCODEC_IVI_H */