Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
libavcodec
ivi_common.h
Go to the documentation of this file.
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 Libav.
7
*
8
* Libav 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
* Libav 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 Libav; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
*/
22
29
#ifndef AVCODEC_IVI_COMMON_H
30
#define AVCODEC_IVI_COMMON_H
31
32
#include "
avcodec.h
"
33
#include "
get_bits.h
"
34
#include <stdint.h>
35
36
#define IVI_VLC_BITS 13
37
#define IVI4_STREAM_ANALYSER 0
38
#define IVI5_IS_PROTECTED 0x20
39
43
typedef
struct
{
44
int32_t
num_rows
;
45
uint8_t xbits[16];
46
}
IVIHuffDesc
;
47
51
typedef
struct
{
52
int32_t
tab_sel
;
53
54
VLC
*
tab
;
55
57
IVIHuffDesc
cust_desc
;
58
VLC
cust_tab
;
59
}
IVIHuffTab
;
60
61
enum
{
62
IVI_MB_HUFF
= 0,
63
IVI_BLK_HUFF
= 1
64
};
65
66
extern
VLC
ff_ivi_mb_vlc_tabs
[8];
67
extern
VLC
ff_ivi_blk_vlc_tabs
[8];
68
69
73
extern
const
uint8_t
ff_ivi_vertical_scan_8x8
[64];
74
extern
const
uint8_t
ff_ivi_horizontal_scan_8x8
[64];
75
extern
const
uint8_t
ff_ivi_direct_scan_4x4
[16];
76
77
81
typedef
void
(
InvTransformPtr
)(
const
int32_t *in, int16_t *out, uint32_t pitch,
const
uint8_t *
flags
);
82
typedef
void
(
DCTransformPtr
) (
const
int32_t *in, int16_t *out, uint32_t pitch,
int
blk_size);
83
84
88
typedef
struct
{
89
uint8_t
eob_sym
;
90
uint8_t
esc_sym
;
91
uint8_t runtab[256];
92
int8_t valtab[256];
93
}
RVMapDesc
;
94
95
extern
const
RVMapDesc
ff_ivi_rvmap_tabs
[9];
96
97
101
typedef
struct
{
102
int16_t
xpos
;
103
int16_t
ypos
;
104
uint32_t
buf_offs
;
105
uint8_t
type
;
106
uint8_t
cbp
;
107
int8_t
q_delta
;
108
int8_t
mv_x
;
109
int8_t
mv_y
;
110
}
IVIMbInfo
;
111
112
116
typedef
struct
{
117
int
xpos
;
118
int
ypos
;
119
int
width
;
120
int
height
;
121
int
mb_size
;
122
int
is_empty
;
123
int
data_size
;
124
int
num_MBs
;
125
IVIMbInfo
*
mbs
;
126
IVIMbInfo
*
ref_mbs
;
127
}
IVITile
;
128
129
133
typedef
struct
{
134
int
plane
;
135
int
band_num
;
136
int
width
;
137
int
height
;
138
int
aheight
;
139
const
uint8_t *
data_ptr
;
140
int
data_size
;
141
int16_t *
buf
;
142
int16_t *
ref_buf
;
143
int16_t *bufs[3];
144
int
pitch
;
145
int
is_empty
;
146
int
mb_size
;
147
int
blk_size
;
148
int
is_halfpel
;
149
int
inherit_mv
;
150
int
inherit_qdelta
;
151
int
qdelta_present
;
152
int
quant_mat
;
153
int
glob_quant
;
154
const
uint8_t *
scan
;
155
156
IVIHuffTab
blk_vlc
;
157
158
int
num_corr
;
159
uint8_t corr[61*2];
160
int
rvmap_sel
;
161
RVMapDesc
*
rv_map
;
162
int
num_tiles
;
163
IVITile
*
tiles
;
164
InvTransformPtr
*
inv_transform
;
165
int
transform_size
;
166
DCTransformPtr
*
dc_transform
;
167
int
is_2d_trans
;
168
int32_t
checksum
;
169
int
checksum_present
;
170
int
bufsize
;
171
const
uint16_t *
intra_base
;
172
const
uint16_t *
inter_base
;
173
const
uint8_t *
intra_scale
;
174
const
uint8_t *
inter_scale
;
175
}
IVIBandDesc
;
176
177
181
typedef
struct
{
182
uint16_t
width
;
183
uint16_t
height
;
184
uint8_t
num_bands
;
185
IVIBandDesc
*
bands
;
186
}
IVIPlaneDesc
;
187
188
189
typedef
struct
{
190
uint16_t
pic_width
;
191
uint16_t
pic_height
;
192
uint16_t
chroma_width
;
193
uint16_t
chroma_height
;
194
uint16_t
tile_width
;
195
uint16_t
tile_height
;
196
uint8_t
luma_bands
;
197
uint8_t
chroma_bands
;
198
}
IVIPicConfig
;
199
200
typedef
struct
IVI45DecContext
{
201
GetBitContext
gb
;
202
AVFrame
frame
;
203
RVMapDesc
rvmap_tabs
[9];
204
205
uint32_t
frame_num
;
206
int
frame_type
;
207
int
prev_frame_type
;
208
uint32_t
data_size
;
209
int
is_scalable
;
210
int
transp_status
;
211
const
uint8_t *
frame_data
;
212
int
inter_scal
;
213
uint32_t
frame_size
;
214
uint32_t
pic_hdr_size
;
215
uint8_t
frame_flags
;
216
uint16_t
checksum
;
217
218
IVIPicConfig
pic_conf
;
219
IVIPlaneDesc
planes
[3];
220
221
int
buf_switch
;
222
int
dst_buf
;
223
int
ref_buf
;
224
int
ref2_buf
;
225
226
IVIHuffTab
mb_vlc
;
227
IVIHuffTab
blk_vlc
;
228
229
uint8_t
rvmap_sel
;
230
uint8_t
in_imf
;
231
uint8_t
in_q
;
232
uint8_t
pic_glob_quant
;
233
uint8_t
unknown1
;
234
235
uint16_t
gop_hdr_size
;
236
uint8_t
gop_flags
;
237
uint32_t
lock_word
;
238
239
#if IVI4_STREAM_ANALYSER
240
uint8_t has_b_frames;
241
uint8_t has_transp;
242
uint8_t uses_tiling;
243
uint8_t uses_haar;
244
uint8_t uses_fullpel;
245
#endif
246
247
int (*
decode_pic_hdr
) (
struct
IVI45DecContext
*ctx,
AVCodecContext
*avctx);
248
int (*
decode_band_hdr
) (
struct
IVI45DecContext
*ctx,
IVIBandDesc
*band,
AVCodecContext
*avctx);
249
int (*
decode_mb_info
) (
struct
IVI45DecContext
*ctx,
IVIBandDesc
*band,
IVITile
*tile,
AVCodecContext
*avctx);
250
void
(*
switch_buffers
) (
struct
IVI45DecContext
*ctx);
251
int (*
is_nonnull_frame
)(
struct
IVI45DecContext
*ctx);
252
253
int
gop_invalid
;
254
}
IVI45DecContext
;
255
257
static
inline
int
ivi_pic_config_cmp
(
IVIPicConfig
*str1,
IVIPicConfig
*str2)
258
{
259
return
str1->
pic_width
!= str2->
pic_width
|| str1->
pic_height
!= str2->
pic_height
||
260
str1->
chroma_width
!= str2->
chroma_width
|| str1->
chroma_height
!= str2->
chroma_height
||
261
str1->
tile_width
!= str2->
tile_width
|| str1->
tile_height
!= str2->
tile_height
||
262
str1->
luma_bands
!= str2->
luma_bands
|| str1->
chroma_bands
!= str2->
chroma_bands
;
263
}
264
266
#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
267
269
#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
270
((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
271
273
#define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
274
276
static
inline
int
ivi_scale_mv
(
int
mv
,
int
mv_scale)
277
{
278
return
(mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
279
}
280
290
int
ff_ivi_create_huff_from_desc
(
const
IVIHuffDesc
*cb,
VLC
*vlc,
int
flag);
291
295
void
ff_ivi_init_static_vlc
(
void
);
296
308
int
ff_ivi_dec_huff_desc
(
GetBitContext
*
gb
,
int
desc_coded,
int
which_tab,
309
IVIHuffTab
*huff_tab,
AVCodecContext
*avctx);
310
318
int
ff_ivi_huff_desc_cmp
(
const
IVIHuffDesc
*desc1,
const
IVIHuffDesc
*desc2);
319
326
void
ff_ivi_huff_desc_copy
(
IVIHuffDesc
*dst,
const
IVIHuffDesc
*src);
327
335
int
ff_ivi_init_planes
(
IVIPlaneDesc
*
planes
,
const
IVIPicConfig
*cfg);
336
342
void
ff_ivi_free_buffers
(
IVIPlaneDesc
*
planes
);
343
352
int
ff_ivi_init_tiles
(
IVIPlaneDesc
*
planes
,
int
tile_width,
int
tile_height);
353
364
int
ff_ivi_dec_tile_data_size
(
GetBitContext
*
gb
);
365
377
int
ff_ivi_decode_blocks
(
GetBitContext
*
gb
,
IVIBandDesc
*band,
IVITile
*tile);
378
388
void
ff_ivi_output_plane
(
IVIPlaneDesc
*plane, uint8_t *dst,
int
dst_pitch);
389
393
uint16_t
ivi_calc_band_checksum
(
IVIBandDesc
*band);
394
398
int
ivi_check_band
(
IVIBandDesc
*band,
const
uint8_t *ref,
int
pitch);
399
400
int
ff_ivi_decode_frame
(
AVCodecContext
*avctx,
void
*
data
,
int
*
data_size
,
401
AVPacket
*avpkt);
402
av_cold
int
ff_ivi_decode_close
(
AVCodecContext
*avctx);
403
404
#endif
/* AVCODEC_IVI_COMMON_H */