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
38
41
typedef
struct
{
42
int32_t
num_rows
;
43
uint8_t xbits[16];
44
}
IVIHuffDesc
;
45
49
typedef
struct
{
50
int32_t
tab_sel
;
51
52
VLC
*
tab
;
53
55
IVIHuffDesc
cust_desc
;
56
VLC
cust_tab
;
57
}
IVIHuffTab
;
58
59
enum
{
60
IVI_MB_HUFF
= 0,
61
IVI_BLK_HUFF
= 1
62
};
63
64
extern
VLC
ff_ivi_mb_vlc_tabs
[8];
65
extern
VLC
ff_ivi_blk_vlc_tabs
[8];
66
67
71
extern
const
uint8_t
ff_ivi_vertical_scan_8x8
[64];
72
extern
const
uint8_t
ff_ivi_horizontal_scan_8x8
[64];
73
extern
const
uint8_t
ff_ivi_direct_scan_4x4
[16];
74
75
79
typedef
void
(
InvTransformPtr
)(
const
int32_t *in, int16_t *out, uint32_t pitch,
const
uint8_t *
flags
);
80
typedef
void
(
DCTransformPtr
) (
const
int32_t *in, int16_t *out, uint32_t pitch,
int
blk_size);
81
82
86
typedef
struct
{
87
uint8_t
eob_sym
;
88
uint8_t
esc_sym
;
89
uint8_t runtab[256];
90
int8_t valtab[256];
91
}
RVMapDesc
;
92
93
extern
const
RVMapDesc
ff_ivi_rvmap_tabs
[9];
94
95
99
typedef
struct
{
100
int16_t
xpos
;
101
int16_t
ypos
;
102
uint32_t
buf_offs
;
103
uint8_t
type
;
104
uint8_t
cbp
;
105
int8_t
q_delta
;
106
int8_t
mv_x
;
107
int8_t
mv_y
;
108
}
IVIMbInfo
;
109
110
114
typedef
struct
{
115
int
xpos
;
116
int
ypos
;
117
int
width
;
118
int
height
;
119
int
is_empty
;
120
int
data_size
;
121
int
num_MBs
;
122
IVIMbInfo
*
mbs
;
123
IVIMbInfo
*
ref_mbs
;
124
}
IVITile
;
125
126
130
typedef
struct
{
131
int
plane
;
132
int
band_num
;
133
int
width
;
134
int
height
;
135
const
uint8_t *
data_ptr
;
136
int
data_size
;
137
int16_t *
buf
;
138
int16_t *
ref_buf
;
139
int16_t *bufs[3];
140
int
pitch
;
141
int
is_empty
;
142
int
mb_size
;
143
int
blk_size
;
144
int
is_halfpel
;
145
int
inherit_mv
;
146
int
inherit_qdelta
;
147
int
qdelta_present
;
148
int
quant_mat
;
149
int
glob_quant
;
150
const
uint8_t *
scan
;
151
152
IVIHuffTab
blk_vlc
;
153
154
int
num_corr
;
155
uint8_t corr[61*2];
156
int
rvmap_sel
;
157
RVMapDesc
*
rv_map
;
158
int
num_tiles
;
159
IVITile
*
tiles
;
160
InvTransformPtr
*
inv_transform
;
161
DCTransformPtr
*
dc_transform
;
162
int
is_2d_trans
;
163
int32_t
checksum
;
164
int
checksum_present
;
165
int
bufsize
;
166
const
uint16_t *
intra_base
;
167
const
uint16_t *
inter_base
;
168
const
uint8_t *
intra_scale
;
169
const
uint8_t *
inter_scale
;
170
}
IVIBandDesc
;
171
172
176
typedef
struct
{
177
uint16_t
width
;
178
uint16_t
height
;
179
uint8_t
num_bands
;
180
IVIBandDesc
*
bands
;
181
}
IVIPlaneDesc
;
182
183
184
typedef
struct
{
185
uint16_t
pic_width
;
186
uint16_t
pic_height
;
187
uint16_t
chroma_width
;
188
uint16_t
chroma_height
;
189
uint16_t
tile_width
;
190
uint16_t
tile_height
;
191
uint8_t
luma_bands
;
192
uint8_t
chroma_bands
;
193
}
IVIPicConfig
;
194
196
static
inline
int
ivi_pic_config_cmp
(
IVIPicConfig
*str1,
IVIPicConfig
*str2)
197
{
198
return
str1->
pic_width
!= str2->
pic_width
|| str1->
pic_height
!= str2->
pic_height
||
199
str1->
chroma_width
!= str2->
chroma_width
|| str1->
chroma_height
!= str2->
chroma_height
||
200
str1->
tile_width
!= str2->
tile_width
|| str1->
tile_height
!= str2->
tile_height
||
201
str1->
luma_bands
!= str2->
luma_bands
|| str1->
chroma_bands
!= str2->
chroma_bands
;
202
}
203
205
#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
206
208
#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
209
((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
210
212
#define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
213
215
static
inline
int
ivi_scale_mv
(
int
mv
,
int
mv_scale)
216
{
217
return
(mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
218
}
219
229
int
ff_ivi_create_huff_from_desc
(
const
IVIHuffDesc
*cb,
VLC
*vlc,
int
flag);
230
234
void
ff_ivi_init_static_vlc
(
void
);
235
247
int
ff_ivi_dec_huff_desc
(
GetBitContext
*gb,
int
desc_coded,
int
which_tab,
248
IVIHuffTab
*huff_tab,
AVCodecContext
*avctx);
249
257
int
ff_ivi_huff_desc_cmp
(
const
IVIHuffDesc
*desc1,
const
IVIHuffDesc
*desc2);
258
265
void
ff_ivi_huff_desc_copy
(
IVIHuffDesc
*dst,
const
IVIHuffDesc
*src);
266
274
int
ff_ivi_init_planes
(
IVIPlaneDesc
*planes,
const
IVIPicConfig
*cfg);
275
281
void
ff_ivi_free_buffers
(
IVIPlaneDesc
*planes);
282
291
int
ff_ivi_init_tiles
(
IVIPlaneDesc
*planes,
int
tile_width,
int
tile_height);
292
303
int
ff_ivi_dec_tile_data_size
(
GetBitContext
*gb);
304
316
int
ff_ivi_decode_blocks
(
GetBitContext
*gb,
IVIBandDesc
*band,
IVITile
*tile);
317
327
void
ff_ivi_process_empty_tile
(
AVCodecContext
*avctx,
IVIBandDesc
*band,
328
IVITile
*tile, int32_t mv_scale);
329
339
void
ff_ivi_output_plane
(
IVIPlaneDesc
*plane, uint8_t *dst,
int
dst_pitch);
340
344
uint16_t
ivi_calc_band_checksum
(
IVIBandDesc
*band);
345
349
int
ivi_check_band
(
IVIBandDesc
*band,
const
uint8_t *ref,
int
pitch);
350
351
#endif
/* AVCODEC_IVI_COMMON_H */