Libav
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
libavcodec
vc1.h
Go to the documentation of this file.
1
/*
2
* VC-1 and WMV3 decoder
3
* Copyright (c) 2006-2007 Konstantin Shishkov
4
* Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
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
23
#ifndef AVCODEC_VC1_H
24
#define AVCODEC_VC1_H
25
26
#include "
avcodec.h
"
27
#include "
h264chroma.h
"
28
#include "
mpegvideo.h
"
29
#include "
intrax8.h
"
30
#include "
vc1dsp.h
"
31
32
#define AC_VLC_BITS 9
33
36
enum
VC1Code
{
37
VC1_CODE_RES0
= 0x00000100,
38
VC1_CODE_ENDOFSEQ
= 0x0000010A,
39
VC1_CODE_SLICE
,
40
VC1_CODE_FIELD
,
41
VC1_CODE_FRAME
,
42
VC1_CODE_ENTRYPOINT
,
43
VC1_CODE_SEQHDR
,
44
};
46
47
#define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
48
51
enum
Profile
{
52
PROFILE_SIMPLE
,
53
PROFILE_MAIN
,
54
PROFILE_COMPLEX
,
55
PROFILE_ADVANCED
56
};
58
61
enum
QuantMode
{
62
QUANT_FRAME_IMPLICIT
,
63
QUANT_FRAME_EXPLICIT
,
64
QUANT_NON_UNIFORM
,
65
QUANT_UNIFORM
66
};
68
71
enum
DQProfile
{
72
DQPROFILE_FOUR_EDGES
,
73
DQPROFILE_DOUBLE_EDGES
,
74
DQPROFILE_SINGLE_EDGE
,
75
DQPROFILE_ALL_MBS
76
};
78
82
enum
DQSingleEdge
{
83
DQSINGLE_BEDGE_LEFT
,
84
DQSINGLE_BEDGE_TOP
,
85
DQSINGLE_BEDGE_RIGHT
,
86
DQSINGLE_BEDGE_BOTTOM
87
};
89
92
enum
DQDoubleEdge
{
93
DQDOUBLE_BEDGE_TOPLEFT
,
94
DQDOUBLE_BEDGE_TOPRIGHT
,
95
DQDOUBLE_BEDGE_BOTTOMRIGHT
,
96
DQDOUBLE_BEDGE_BOTTOMLEFT
97
};
99
102
enum
MVModes
{
103
MV_PMODE_1MV_HPEL_BILIN
,
104
MV_PMODE_1MV
,
105
MV_PMODE_1MV_HPEL
,
106
MV_PMODE_MIXED_MV
,
107
MV_PMODE_INTENSITY_COMP
108
};
110
113
enum
MBModesIntfr
{
114
MV_PMODE_INTFR_1MV
,
115
MV_PMODE_INTFR_2MV_FIELD
,
116
MV_PMODE_INTFR_2MV
,
117
MV_PMODE_INTFR_4MV_FIELD
,
118
MV_PMODE_INTFR_4MV
,
119
MV_PMODE_INTFR_INTRA
,
120
};
122
125
enum
BMVTypes
{
126
BMV_TYPE_BACKWARD
,
127
BMV_TYPE_FORWARD
,
128
BMV_TYPE_INTERPOLATED
,
129
BMV_TYPE_DIRECT
130
};
132
135
enum
TransformTypes
{
136
TT_8X8
,
137
TT_8X4_BOTTOM
,
138
TT_8X4_TOP
,
139
TT_8X4
,
// both halves
140
TT_4X8_RIGHT
,
141
TT_4X8_LEFT
,
142
TT_4X8
,
// both halves
143
TT_4X4
144
};
146
147
enum
CodingSet
{
148
CS_HIGH_MOT_INTRA
= 0,
149
CS_HIGH_MOT_INTER
,
150
CS_LOW_MOT_INTRA
,
151
CS_LOW_MOT_INTER
,
152
CS_MID_RATE_INTRA
,
153
CS_MID_RATE_INTER
,
154
CS_HIGH_RATE_INTRA
,
155
CS_HIGH_RATE_INTER
156
};
157
160
enum
COTypes
{
161
CONDOVER_NONE
= 0,
162
CONDOVER_ALL
,
163
CONDOVER_SELECT
164
};
166
172
enum
FrameCodingMode
{
173
PROGRESSIVE
= 0,
174
ILACE_FRAME
,
175
ILACE_FIELD
176
};
177
182
typedef
struct
VC1Context
{
183
MpegEncContext
s
;
184
IntraX8Context
x8
;
185
H264ChromaContext
h264chroma
;
186
VC1DSPContext
vc1dsp
;
187
188
int
bits
;
189
192
int
res_sprite
;
193
int
res_y411
;
194
int
res_x8
;
195
int
multires
;
196
int
res_fasttx
;
197
int
res_transtab
;
198
int
rangered
;
199
200
int
res_rtm_flag
;
201
int
reserved
;
202
203
206
int
level
;
207
int
chromaformat
;
208
int
postprocflag
;
209
int
broadcast
;
210
int
interlace
;
211
int
tfcntrflag
;
212
int
panscanflag
;
213
int
refdist_flag
;
214
int
extended_dmv
;
215
int
color_prim
;
216
int
transfer_char
;
217
int
matrix_coef
;
218
int
hrd_param_flag
;
219
220
int
psf
;
221
222
227
int
profile
;
228
int
frmrtq_postproc
;
229
int
bitrtq_postproc
;
230
int
fastuvmc
;
231
int
extended_mv
;
232
int
dquant
;
233
int
vstransform
;
234
int
overlap
;
235
int
quantizer_mode
;
236
int
finterpflag
;
237
238
241
uint8_t
mv_mode
;
242
uint8_t
mv_mode2
;
243
int
k_x
;
244
int
k_y
;
245
int
range_x
,
range_y
;
246
uint8_t
pq
,
altpq
;
247
uint8_t
zz_8x8
[4][64];
248
int
left_blk_sh
,
top_blk_sh
;
249
const
uint8_t
*
zz_8x4
;
250
const
uint8_t
*
zz_4x8
;
251
253
uint8_t
dquantfrm
;
254
uint8_t
dqprofile
;
255
uint8_t
dqsbedge
;
256
uint8_t
dqbilevel
;
258
262
int
c_ac_table_index
;
263
int
y_ac_table_index
;
264
265
int
ttfrm
;
266
uint8_t
ttmbf
;
267
int
*
ttblk_base
, *
ttblk
;
268
int
codingset
;
269
int
codingset2
;
270
int
pqindex
;
271
int
a_avail
,
c_avail
;
272
uint8_t
*
mb_type_base
, *
mb_type
[3];
273
274
277
uint8_t
lumscale
;
278
uint8_t
lumshift
;
280
int16_t
bfraction
;
281
uint8_t
halfpq
;
282
uint8_t
respic
;
283
int
buffer_fullness
;
284
290
uint8_t
mvrange
;
291
uint8_t
pquantizer
;
292
VLC
*
cbpcy_vlc
;
293
int
tt_index
;
294
uint8_t
*
mv_type_mb_plane
;
295
uint8_t
*
direct_mb_plane
;
296
uint8_t
*
forward_mb_plane
;
297
int
mv_type_is_raw
;
298
int
dmb_is_raw
;
299
int
fmb_is_raw
;
300
int
skip_is_raw
;
301
uint8_t
last_luty
[2][256],
last_lutuv
[2][256];
302
uint8_t
aux_luty
[2][256],
aux_lutuv
[2][256];
303
uint8_t
next_luty
[2][256],
next_lutuv
[2][256];
304
uint8_t
(*
curr_luty
)[256] ,(*curr_lutuv)[256];
305
int
last_use_ic
,
curr_use_ic
,
next_use_ic
,
aux_use_ic
;
306
int
rnd
;
307
310
uint8_t
rangeredfrm
;
311
uint8_t
interpfrm
;
313
316
enum
FrameCodingMode
fcm
;
317
uint8_t
numpanscanwin
;
318
uint8_t
tfcntr
;
319
uint8_t
rptfrm
,
tff
,
rff
;
320
uint16_t
topleftx
;
321
uint16_t
toplefty
;
322
uint16_t
bottomrightx
;
323
uint16_t
bottomrighty
;
324
uint8_t
uvsamp
;
325
uint8_t
postproc
;
326
int
hrd_num_leaky_buckets
;
327
uint8_t
bit_rate_exponent
;
328
uint8_t
buffer_size_exponent
;
329
uint8_t
*
acpred_plane
;
330
int
acpred_is_raw
;
331
uint8_t
*
over_flags_plane
;
332
int
overflg_is_raw
;
333
uint8_t
condover
;
334
uint16_t *
hrd_rate
, *
hrd_buffer
;
335
uint8_t
*
hrd_fullness
;
336
uint8_t
range_mapy_flag
;
337
uint8_t
range_mapuv_flag
;
338
uint8_t
range_mapy
;
339
uint8_t
range_mapuv
;
341
343
uint8_t
dmvrange
;
344
int
fourmvswitch
;
345
int
intcomp
;
346
uint8_t
lumscale2
;
347
uint8_t
lumshift2
;
348
VLC
*
mbmode_vlc
;
349
VLC
*
imv_vlc
;
350
VLC
*
twomvbp_vlc
;
351
VLC
*
fourmvbp_vlc
;
352
uint8_t
twomvbp
;
353
uint8_t
fourmvbp
;
354
uint8_t
*
fieldtx_plane
;
355
int
fieldtx_is_raw
;
356
int8_t
zzi_8x8
[64];
357
uint8_t
*
blk_mv_type_base
, *
blk_mv_type
;
358
uint8_t
*
mv_f_base
, *
mv_f
[2];
359
uint8_t
*
mv_f_next_base
, *
mv_f_next
[2];
360
int
field_mode
;
361
int
fptype
;
362
int
second_field
;
363
int
refdist
;
364
int
numref
;
365
// 0 corresponds to 1 and 1 corresponds to 2 references
366
int
reffield
;
367
// field to use among the two fields from previous frame
368
int
intcompfield
;
369
// 0: both fields, 1: bottom field, 2: top field
370
int
cur_field_type
;
371
int
ref_field_type
[2];
372
int
blocks_off
,
mb_off
;
373
int
qs_last
;
374
int
bmvtype
;
375
int
frfd
,
brfd
;
376
int
first_pic_header_flag
;
377
int
pic_header_flag
;
378
381
int
new_sprite
;
382
int
two_sprites
;
383
AVFrame
*
sprite_output_frame
;
384
int
output_width
,
output_height
,
sprite_width
,
sprite_height
;
385
uint8_t
*
sr_rows
[2][2];
386
387
388
int
p_frame_skipped
;
389
int
bi_type
;
390
int
x8_type
;
391
392
int16_t (*
block
)[6][64];
393
int
n_allocated_blks
,
cur_blk_idx
,
left_blk_idx
,
topleft_blk_idx
,
top_blk_idx
;
394
uint32_t *
cbp_base
, *
cbp
;
395
uint8_t
*
is_intra_base
, *
is_intra
;
396
int16_t (*
luma_mv_base
)[2], (*luma_mv)[2];
397
uint8_t
bfraction_lut_index
;
398
uint8_t
broken_link
;
399
uint8_t
closed_entry
;
400
401
int
end_mb_x
;
402
403
int
parse_only
;
404
int
resync_marker
;
405
}
VC1Context
;
406
410
static
av_always_inline
const
uint8_t
*
find_next_marker
(
const
uint8_t
*src,
const
uint8_t
*end)
411
{
412
uint32_t mrk = 0xFFFFFFFF;
413
414
if
(end-src < 4)
415
return
end;
416
while
(src < end) {
417
mrk = (mrk << 8) | *src++;
418
if
(
IS_MARKER
(mrk))
419
return
src - 4;
420
}
421
return
end;
422
}
423
424
static
av_always_inline
int
vc1_unescape_buffer
(
const
uint8_t
*src,
int
size
,
uint8_t
*dst)
425
{
426
int
dsize = 0, i;
427
428
if
(size < 4) {
429
for
(dsize = 0; dsize <
size
; dsize++)
430
*dst++ = *src++;
431
return
size
;
432
}
433
for
(i = 0; i <
size
; i++, src++) {
434
if
(src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
435
dst[dsize++] = src[1];
436
src++;
437
i++;
438
}
else
439
dst[dsize++] = *src;
440
}
441
return
dsize;
442
}
443
451
int
ff_vc1_decode_sequence_header
(
AVCodecContext
*avctx,
VC1Context
*v,
GetBitContext
*gb);
452
453
int
ff_vc1_decode_entry_point
(
AVCodecContext
*avctx,
VC1Context
*v,
GetBitContext
*gb);
454
455
int
ff_vc1_parse_frame_header
(
VC1Context
*v,
GetBitContext
*gb);
456
int
ff_vc1_parse_frame_header_adv
(
VC1Context
*v,
GetBitContext
*gb);
457
int
ff_vc1_init_common
(
VC1Context
*v);
458
459
int
ff_vc1_decode_init_alloc_tables
(
VC1Context
*v);
460
void
ff_vc1_init_transposed_scantables
(
VC1Context
*v);
461
int
ff_vc1_decode_end
(
AVCodecContext
*avctx);
462
void
ff_vc1_decode_blocks
(
VC1Context
*v);
463
464
#endif
/* AVCODEC_VC1_H */
Generated on Thu Sep 30 2021 23:03:16 for Libav by
1.8.1.2