2007-05-04 00:09:33 +00:00
|
|
|
/*
|
|
|
|
* VC-1 and WMV3 decoder
|
|
|
|
* Copyright (c) 2006-2007 Konstantin Shishkov
|
|
|
|
* Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2008-08-31 07:39:47 +00:00
|
|
|
#ifndef AVCODEC_VC1_H
|
|
|
|
#define AVCODEC_VC1_H
|
2007-06-17 00:01:30 +00:00
|
|
|
|
2007-05-06 11:01:25 +00:00
|
|
|
#include "avcodec.h"
|
|
|
|
#include "mpegvideo.h"
|
2007-11-09 21:37:48 +00:00
|
|
|
#include "intrax8.h"
|
2011-02-17 19:45:03 +00:00
|
|
|
#include "vc1dsp.h"
|
2007-05-06 11:01:25 +00:00
|
|
|
|
2012-03-06 17:59:03 +00:00
|
|
|
#define AC_VLC_BITS 9
|
|
|
|
|
2007-05-04 03:34:38 +00:00
|
|
|
/** Markers used in VC-1 AP frame data */
|
2007-05-04 00:09:33 +00:00
|
|
|
//@{
|
2011-10-11 10:00:18 +00:00
|
|
|
enum VC1Code {
|
2007-05-04 00:09:33 +00:00
|
|
|
VC1_CODE_RES0 = 0x00000100,
|
|
|
|
VC1_CODE_ENDOFSEQ = 0x0000010A,
|
|
|
|
VC1_CODE_SLICE,
|
|
|
|
VC1_CODE_FIELD,
|
|
|
|
VC1_CODE_FRAME,
|
|
|
|
VC1_CODE_ENTRYPOINT,
|
|
|
|
VC1_CODE_SEQHDR,
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
#define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
|
2007-05-04 03:34:21 +00:00
|
|
|
|
|
|
|
/** Available Profiles */
|
|
|
|
//@{
|
|
|
|
enum Profile {
|
|
|
|
PROFILE_SIMPLE,
|
|
|
|
PROFILE_MAIN,
|
|
|
|
PROFILE_COMPLEX, ///< TODO: WMV9 specific
|
|
|
|
PROFILE_ADVANCED
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Sequence quantizer mode */
|
|
|
|
//@{
|
|
|
|
enum QuantMode {
|
|
|
|
QUANT_FRAME_IMPLICIT, ///< Implicitly specified at frame level
|
|
|
|
QUANT_FRAME_EXPLICIT, ///< Explicitly specified at frame level
|
|
|
|
QUANT_NON_UNIFORM, ///< Non-uniform quant used for all frames
|
|
|
|
QUANT_UNIFORM ///< Uniform quant used for all frames
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Where quant can be changed */
|
|
|
|
//@{
|
|
|
|
enum DQProfile {
|
|
|
|
DQPROFILE_FOUR_EDGES,
|
|
|
|
DQPROFILE_DOUBLE_EDGES,
|
|
|
|
DQPROFILE_SINGLE_EDGE,
|
|
|
|
DQPROFILE_ALL_MBS
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** @name Where quant can be changed
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
enum DQSingleEdge {
|
|
|
|
DQSINGLE_BEDGE_LEFT,
|
|
|
|
DQSINGLE_BEDGE_TOP,
|
|
|
|
DQSINGLE_BEDGE_RIGHT,
|
|
|
|
DQSINGLE_BEDGE_BOTTOM
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Which pair of edges is quantized with ALTPQUANT */
|
|
|
|
//@{
|
|
|
|
enum DQDoubleEdge {
|
|
|
|
DQDOUBLE_BEDGE_TOPLEFT,
|
|
|
|
DQDOUBLE_BEDGE_TOPRIGHT,
|
|
|
|
DQDOUBLE_BEDGE_BOTTOMRIGHT,
|
|
|
|
DQDOUBLE_BEDGE_BOTTOMLEFT
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** MV modes for P frames */
|
|
|
|
//@{
|
|
|
|
enum MVModes {
|
|
|
|
MV_PMODE_1MV_HPEL_BILIN,
|
|
|
|
MV_PMODE_1MV,
|
|
|
|
MV_PMODE_1MV_HPEL,
|
|
|
|
MV_PMODE_MIXED_MV,
|
|
|
|
MV_PMODE_INTENSITY_COMP
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
2011-10-06 19:00:24 +00:00
|
|
|
/** MBMODE for interlaced frame P-picture */
|
|
|
|
//@{
|
|
|
|
enum MBModesIntfr {
|
|
|
|
MV_PMODE_INTFR_1MV,
|
|
|
|
MV_PMODE_INTFR_2MV_FIELD,
|
|
|
|
MV_PMODE_INTFR_2MV,
|
|
|
|
MV_PMODE_INTFR_4MV_FIELD,
|
|
|
|
MV_PMODE_INTFR_4MV,
|
|
|
|
MV_PMODE_INTFR_INTRA,
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
2007-05-04 03:34:21 +00:00
|
|
|
/** @name MV types for B frames */
|
|
|
|
//@{
|
|
|
|
enum BMVTypes {
|
|
|
|
BMV_TYPE_BACKWARD,
|
|
|
|
BMV_TYPE_FORWARD,
|
2011-10-06 19:00:24 +00:00
|
|
|
BMV_TYPE_INTERPOLATED,
|
|
|
|
BMV_TYPE_DIRECT
|
2007-05-04 03:34:21 +00:00
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** @name Block types for P/B frames */
|
|
|
|
//@{
|
|
|
|
enum TransformTypes {
|
|
|
|
TT_8X8,
|
|
|
|
TT_8X4_BOTTOM,
|
|
|
|
TT_8X4_TOP,
|
2011-10-11 10:00:18 +00:00
|
|
|
TT_8X4, // both halves
|
2007-05-04 03:34:21 +00:00
|
|
|
TT_4X8_RIGHT,
|
|
|
|
TT_4X8_LEFT,
|
2011-10-11 10:00:18 +00:00
|
|
|
TT_4X8, // both halves
|
2007-05-04 03:34:21 +00:00
|
|
|
TT_4X4
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
|
|
|
enum CodingSet {
|
|
|
|
CS_HIGH_MOT_INTRA = 0,
|
|
|
|
CS_HIGH_MOT_INTER,
|
|
|
|
CS_LOW_MOT_INTRA,
|
|
|
|
CS_LOW_MOT_INTER,
|
|
|
|
CS_MID_RATE_INTRA,
|
|
|
|
CS_MID_RATE_INTER,
|
|
|
|
CS_HIGH_RATE_INTRA,
|
|
|
|
CS_HIGH_RATE_INTER
|
|
|
|
};
|
|
|
|
|
|
|
|
/** @name Overlap conditions for Advanced Profile */
|
|
|
|
//@{
|
|
|
|
enum COTypes {
|
|
|
|
CONDOVER_NONE = 0,
|
|
|
|
CONDOVER_ALL,
|
|
|
|
CONDOVER_SELECT
|
|
|
|
};
|
|
|
|
//@}
|
|
|
|
|
2011-11-26 12:28:48 +00:00
|
|
|
/**
|
|
|
|
* FCM Frame Coding Mode
|
|
|
|
* @note some content might be marked interlaced
|
|
|
|
* but have fcm set to 0 as well (e.g. HD-DVD)
|
|
|
|
*/
|
|
|
|
enum FrameCodingMode {
|
|
|
|
PROGRESSIVE = 0, ///< in the bitstream is reported as 00b
|
|
|
|
ILACE_FRAME, ///< in the bitstream is reported as 10b
|
|
|
|
ILACE_FIELD ///< in the bitstream is reported as 11b
|
|
|
|
};
|
2007-05-04 03:34:21 +00:00
|
|
|
|
|
|
|
/** The VC1 Context
|
2007-07-13 13:04:55 +00:00
|
|
|
* @todo Change size wherever another size is more efficient
|
2007-05-04 03:34:21 +00:00
|
|
|
* Many members are only used for Advanced Profile
|
|
|
|
*/
|
|
|
|
typedef struct VC1Context{
|
|
|
|
MpegEncContext s;
|
2007-11-09 21:37:48 +00:00
|
|
|
IntraX8Context x8;
|
2011-02-17 19:45:03 +00:00
|
|
|
VC1DSPContext vc1dsp;
|
2007-05-04 03:34:21 +00:00
|
|
|
|
|
|
|
int bits;
|
|
|
|
|
|
|
|
/** Simple/Main Profile sequence header */
|
|
|
|
//@{
|
2010-09-26 13:54:35 +00:00
|
|
|
int res_sprite; ///< reserved, sprite mode
|
|
|
|
int res_y411; ///< reserved, old interlaced mode
|
2007-05-04 03:34:21 +00:00
|
|
|
int res_x8; ///< reserved
|
|
|
|
int multires; ///< frame-level RESPIC syntax element present
|
|
|
|
int res_fasttx; ///< reserved, always 1
|
|
|
|
int res_transtab; ///< reserved, always 0
|
|
|
|
int rangered; ///< RANGEREDFRM (range reduction) syntax element present
|
|
|
|
///< at frame level
|
|
|
|
int res_rtm_flag; ///< reserved, set to 1
|
|
|
|
int reserved; ///< reserved
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Advanced Profile */
|
|
|
|
//@{
|
|
|
|
int level; ///< 3bits, for Advanced/Simple Profile, provided by TS layer
|
|
|
|
int chromaformat; ///< 2bits, 2=4:2:0, only defined
|
|
|
|
int postprocflag; ///< Per-frame processing suggestion flag present
|
|
|
|
int broadcast; ///< TFF/RFF present
|
|
|
|
int interlace; ///< Progressive/interlaced (RPTFTM syntax element)
|
|
|
|
int tfcntrflag; ///< TFCNTR present
|
|
|
|
int panscanflag; ///< NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present
|
2009-01-09 16:51:21 +00:00
|
|
|
int refdist_flag; ///< REFDIST syntax element present in II, IP, PI or PP field picture headers
|
2007-05-04 03:34:21 +00:00
|
|
|
int extended_dmv; ///< Additional extended dmv range at P/B frame-level
|
|
|
|
int color_prim; ///< 8bits, chroma coordinates of the color primaries
|
|
|
|
int transfer_char; ///< 8bits, Opto-electronic transfer characteristics
|
|
|
|
int matrix_coef; ///< 8bits, Color primaries->YCbCr transform matrix
|
|
|
|
int hrd_param_flag; ///< Presence of Hypothetical Reference
|
|
|
|
///< Decoder parameters
|
|
|
|
int psf; ///< Progressive Segmented Frame
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Sequence header data for all Profiles
|
|
|
|
* TODO: choose between ints, uint8_ts and monobit flags
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
int profile; ///< 2bits, Profile
|
|
|
|
int frmrtq_postproc; ///< 3bits,
|
|
|
|
int bitrtq_postproc; ///< 5bits, quantized framerate-based postprocessing strength
|
2012-07-31 01:00:35 +00:00
|
|
|
int max_coded_width, max_coded_height;
|
2007-05-04 03:34:21 +00:00
|
|
|
int fastuvmc; ///< Rounding of qpel vector to hpel ? (not in Simple)
|
|
|
|
int extended_mv; ///< Ext MV in P/B (not in Simple)
|
|
|
|
int dquant; ///< How qscale varies with MBs, 2bits (not in Simple)
|
|
|
|
int vstransform; ///< variable-size [48]x[48] transform type + info
|
|
|
|
int overlap; ///< overlapped transforms in use
|
|
|
|
int quantizer_mode; ///< 2bits, quantizer mode used for sequence, see QUANT_*
|
|
|
|
int finterpflag; ///< INTERPFRM present
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Frame decoding info for all profiles */
|
|
|
|
//@{
|
2011-10-11 10:00:18 +00:00
|
|
|
uint8_t mv_mode; ///< MV coding monde
|
|
|
|
uint8_t mv_mode2; ///< Secondary MV coding mode (B frames)
|
|
|
|
int k_x; ///< Number of bits for MVs (depends on MV range)
|
|
|
|
int k_y; ///< Number of bits for MVs (depends on MV range)
|
|
|
|
int range_x, range_y; ///< MV range
|
|
|
|
uint8_t pq, altpq; ///< Current/alternate frame quantizer scale
|
|
|
|
uint8_t zz_8x8[4][64]; ///< Zigzag table for TT_8x8, permuted for IDCT
|
2011-04-16 19:07:14 +00:00
|
|
|
int left_blk_sh, top_blk_sh; ///< Either 3 or 0, positions of l/t in blk[]
|
2011-10-11 10:00:18 +00:00
|
|
|
const uint8_t* zz_8x4; ///< Zigzag scan table for TT_8x4 coding mode
|
|
|
|
const uint8_t* zz_4x8; ///< Zigzag scan table for TT_4x8 coding mode
|
2007-05-04 03:34:21 +00:00
|
|
|
/** pquant parameters */
|
|
|
|
//@{
|
|
|
|
uint8_t dquantfrm;
|
|
|
|
uint8_t dqprofile;
|
|
|
|
uint8_t dqsbedge;
|
|
|
|
uint8_t dqbilevel;
|
|
|
|
//@}
|
|
|
|
/** AC coding set indexes
|
|
|
|
* @see 8.1.1.10, p(1)10
|
|
|
|
*/
|
|
|
|
//@{
|
2011-10-11 10:00:18 +00:00
|
|
|
int c_ac_table_index; ///< Chroma index from ACFRM element
|
|
|
|
int y_ac_table_index; ///< Luma index from AC2FRM element
|
2007-05-04 03:34:21 +00:00
|
|
|
//@}
|
2011-10-11 10:00:18 +00:00
|
|
|
int ttfrm; ///< Transform type info present at frame level
|
|
|
|
uint8_t ttmbf; ///< Transform type flag
|
2011-03-22 01:26:26 +00:00
|
|
|
int *ttblk_base, *ttblk; ///< Transform type at the block level
|
2011-10-11 10:00:18 +00:00
|
|
|
int codingset; ///< index of current table set from 11.8 to use for luma block decoding
|
|
|
|
int codingset2; ///< index of current table set from 11.8 to use for chroma block decoding
|
|
|
|
int pqindex; ///< raw pqindex used in coding set selection
|
2007-05-04 03:34:21 +00:00
|
|
|
int a_avail, c_avail;
|
|
|
|
uint8_t *mb_type_base, *mb_type[3];
|
|
|
|
|
|
|
|
|
|
|
|
/** Luma compensation parameters */
|
|
|
|
//@{
|
|
|
|
uint8_t lumscale;
|
|
|
|
uint8_t lumshift;
|
|
|
|
//@}
|
|
|
|
int16_t bfraction; ///< Relative position % anchors=> how to scale MVs
|
|
|
|
uint8_t halfpq; ///< Uniform quant over image and qp+.5
|
|
|
|
uint8_t respic; ///< Frame-level flag for resized images
|
|
|
|
int buffer_fullness; ///< HRD info
|
|
|
|
/** Ranges:
|
|
|
|
* -# 0 -> [-64n 63.f] x [-32, 31.f]
|
|
|
|
* -# 1 -> [-128, 127.f] x [-64, 63.f]
|
|
|
|
* -# 2 -> [-512, 511.f] x [-128, 127.f]
|
|
|
|
* -# 3 -> [-1024, 1023.f] x [-256, 255.f]
|
|
|
|
*/
|
2011-10-11 10:00:18 +00:00
|
|
|
uint8_t mvrange; ///< Extended MV range flag
|
|
|
|
uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use
|
|
|
|
VLC *cbpcy_vlc; ///< CBPCY VLC table
|
|
|
|
int tt_index; ///< Index for Transform Type tables (to decode TTMB)
|
|
|
|
uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV)
|
|
|
|
uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs
|
|
|
|
uint8_t* forward_mb_plane; ///< bitplane for "forward" MBs
|
|
|
|
int mv_type_is_raw; ///< mv type mb plane is not coded
|
|
|
|
int dmb_is_raw; ///< direct mb plane is raw
|
|
|
|
int fmb_is_raw; ///< forward mb plane is raw
|
|
|
|
int skip_is_raw; ///< skip mb plane is not coded
|
|
|
|
uint8_t luty[256], lutuv[256]; ///< lookup tables used for intensity compensation
|
|
|
|
int use_ic; ///< use intensity compensation in B-frames
|
|
|
|
int rnd; ///< rounding control
|
2007-05-04 03:34:21 +00:00
|
|
|
|
|
|
|
/** Frame decoding info for S/M profiles only */
|
|
|
|
//@{
|
2011-10-11 10:00:18 +00:00
|
|
|
uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128)
|
2007-05-04 03:34:21 +00:00
|
|
|
uint8_t interpfrm;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Frame decoding info for Advanced profile */
|
|
|
|
//@{
|
2011-11-26 12:28:48 +00:00
|
|
|
enum FrameCodingMode fcm;
|
2007-05-04 03:34:21 +00:00
|
|
|
uint8_t numpanscanwin;
|
|
|
|
uint8_t tfcntr;
|
|
|
|
uint8_t rptfrm, tff, rff;
|
|
|
|
uint16_t topleftx;
|
|
|
|
uint16_t toplefty;
|
|
|
|
uint16_t bottomrightx;
|
|
|
|
uint16_t bottomrighty;
|
|
|
|
uint8_t uvsamp;
|
|
|
|
uint8_t postproc;
|
|
|
|
int hrd_num_leaky_buckets;
|
|
|
|
uint8_t bit_rate_exponent;
|
|
|
|
uint8_t buffer_size_exponent;
|
|
|
|
uint8_t* acpred_plane; ///< AC prediction flags bitplane
|
|
|
|
int acpred_is_raw;
|
|
|
|
uint8_t* over_flags_plane; ///< Overflags bitplane
|
|
|
|
int overflg_is_raw;
|
|
|
|
uint8_t condover;
|
|
|
|
uint16_t *hrd_rate, *hrd_buffer;
|
|
|
|
uint8_t *hrd_fullness;
|
|
|
|
uint8_t range_mapy_flag;
|
|
|
|
uint8_t range_mapuv_flag;
|
|
|
|
uint8_t range_mapy;
|
|
|
|
uint8_t range_mapuv;
|
|
|
|
//@}
|
|
|
|
|
2011-10-06 19:00:24 +00:00
|
|
|
/** Frame decoding info for interlaced picture */
|
|
|
|
uint8_t dmvrange; ///< Extended differential MV range flag
|
|
|
|
int fourmvswitch;
|
|
|
|
int intcomp;
|
|
|
|
uint8_t lumscale2; ///< for interlaced field P picture
|
|
|
|
uint8_t lumshift2;
|
|
|
|
uint8_t luty2[256], lutuv2[256]; // lookup tables used for intensity compensation
|
|
|
|
VLC* mbmode_vlc;
|
|
|
|
VLC* imv_vlc;
|
|
|
|
VLC* twomvbp_vlc;
|
|
|
|
VLC* fourmvbp_vlc;
|
|
|
|
uint8_t twomvbp;
|
|
|
|
uint8_t fourmvbp;
|
|
|
|
uint8_t* fieldtx_plane;
|
|
|
|
int fieldtx_is_raw;
|
2012-03-23 20:21:47 +00:00
|
|
|
uint8_t zzi_8x8[64];
|
2011-10-06 19:00:24 +00:00
|
|
|
uint8_t *blk_mv_type_base, *blk_mv_type; ///< 0: frame MV, 1: field MV (interlaced frame)
|
|
|
|
uint8_t *mv_f_base, *mv_f[2]; ///< 0: MV obtained from same field, 1: opposite field
|
|
|
|
uint8_t *mv_f_last_base, *mv_f_last[2];
|
|
|
|
uint8_t *mv_f_next_base, *mv_f_next[2];
|
2011-10-11 10:00:18 +00:00
|
|
|
int field_mode; ///< 1 for interlaced field pictures
|
2011-10-06 19:00:24 +00:00
|
|
|
int fptype;
|
|
|
|
int second_field;
|
2011-10-11 10:00:18 +00:00
|
|
|
int refdist; ///< distance of the current picture from reference
|
|
|
|
int numref; ///< number of past field pictures used as reference
|
|
|
|
// 0 corresponds to 1 and 1 corresponds to 2 references
|
|
|
|
int reffield; ///< if numref = 0 (1 reference) then reffield decides which
|
|
|
|
// field to use among the two fields from previous frame
|
|
|
|
int intcompfield; ///< which of the two fields to be intensity compensated
|
|
|
|
// 0: both fields, 1: bottom field, 2: top field
|
2011-10-06 19:00:24 +00:00
|
|
|
int cur_field_type; ///< 0: top, 1: bottom
|
|
|
|
int ref_field_type[2]; ///< forward and backward reference field type (top or bottom)
|
|
|
|
int blocks_off, mb_off;
|
2011-10-11 10:00:18 +00:00
|
|
|
int qs_last; ///< if qpel has been used in the previous (tr.) picture
|
2011-10-06 19:00:24 +00:00
|
|
|
int bmvtype;
|
2011-10-11 10:00:18 +00:00
|
|
|
int frfd, brfd; ///< reference frame distance (forward or backward)
|
2011-10-06 19:00:24 +00:00
|
|
|
int pic_header_flag;
|
|
|
|
|
2011-04-08 18:00:48 +00:00
|
|
|
/** Frame decoding info for sprite modes */
|
|
|
|
//@{
|
|
|
|
int new_sprite;
|
|
|
|
int two_sprites;
|
2011-08-17 12:24:42 +00:00
|
|
|
AVFrame sprite_output_frame;
|
|
|
|
int output_width, output_height, sprite_width, sprite_height;
|
|
|
|
uint8_t* sr_rows[2][2]; ///< Sprite resizer line cache
|
2011-04-08 18:00:48 +00:00
|
|
|
//@}
|
|
|
|
|
2007-05-04 03:34:21 +00:00
|
|
|
int p_frame_skipped;
|
|
|
|
int bi_type;
|
2007-11-09 21:37:48 +00:00
|
|
|
int x8_type;
|
2008-07-23 06:21:27 +00:00
|
|
|
|
2011-05-04 11:40:53 +00:00
|
|
|
DCTELEM (*block)[6][64];
|
|
|
|
int n_allocated_blks, cur_blk_idx, left_blk_idx, topleft_blk_idx, top_blk_idx;
|
2008-07-23 06:21:27 +00:00
|
|
|
uint32_t *cbp_base, *cbp;
|
2011-03-22 01:26:26 +00:00
|
|
|
uint8_t *is_intra_base, *is_intra;
|
|
|
|
int16_t (*luma_mv_base)[2], (*luma_mv)[2];
|
2011-10-11 10:00:18 +00:00
|
|
|
uint8_t bfraction_lut_index; ///< Index for BFRACTION value (see Table 40, reproduced into ff_vc1_bfraction_lut[])
|
|
|
|
uint8_t broken_link; ///< Broken link flag (BROKEN_LINK syntax element)
|
|
|
|
uint8_t closed_entry; ///< Closed entry point flag (CLOSED_ENTRY syntax element)
|
2009-05-30 00:09:00 +00:00
|
|
|
|
2012-08-24 15:45:57 +00:00
|
|
|
int end_mb_x; ///< Horizontal macroblock limit (used only by mss2)
|
|
|
|
|
2011-10-11 10:00:18 +00:00
|
|
|
int parse_only; ///< Context is used within parser
|
2009-10-10 07:35:31 +00:00
|
|
|
|
|
|
|
int warn_interlaced;
|
2007-05-04 03:34:21 +00:00
|
|
|
} VC1Context;
|
2007-06-17 00:01:30 +00:00
|
|
|
|
2009-05-30 00:09:00 +00:00
|
|
|
/** Find VC-1 marker in buffer
|
|
|
|
* @return position where next marker starts or end of buffer if no marker found
|
|
|
|
*/
|
|
|
|
static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
|
|
|
|
{
|
|
|
|
uint32_t mrk = 0xFFFFFFFF;
|
|
|
|
|
2011-10-11 10:00:18 +00:00
|
|
|
if (end-src < 4)
|
|
|
|
return end;
|
|
|
|
while (src < end) {
|
2009-05-30 00:09:00 +00:00
|
|
|
mrk = (mrk << 8) | *src++;
|
2011-10-11 10:00:18 +00:00
|
|
|
if (IS_MARKER(mrk))
|
|
|
|
return src - 4;
|
2009-05-30 00:09:00 +00:00
|
|
|
}
|
|
|
|
return end;
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
|
|
|
|
{
|
|
|
|
int dsize = 0, i;
|
|
|
|
|
2011-10-11 10:00:18 +00:00
|
|
|
if (size < 4) {
|
|
|
|
for (dsize = 0; dsize < size; dsize++)
|
|
|
|
*dst++ = *src++;
|
2009-05-30 00:09:00 +00:00
|
|
|
return size;
|
|
|
|
}
|
2011-10-11 10:00:18 +00:00
|
|
|
for (i = 0; i < size; i++, src++) {
|
|
|
|
if (src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
|
2009-05-30 00:09:00 +00:00
|
|
|
dst[dsize++] = src[1];
|
|
|
|
src++;
|
|
|
|
i++;
|
|
|
|
} else
|
|
|
|
dst[dsize++] = *src;
|
|
|
|
}
|
|
|
|
return dsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decode Simple/Main Profiles sequence header
|
|
|
|
* @see Figure 7-8, p16-17
|
|
|
|
* @param avctx Codec context
|
|
|
|
* @param gb GetBit context initialized from Codec context extra_data
|
|
|
|
* @return Status
|
|
|
|
*/
|
2012-02-15 11:00:08 +00:00
|
|
|
int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb);
|
2009-05-30 00:09:00 +00:00
|
|
|
|
2012-02-15 11:00:08 +00:00
|
|
|
int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb);
|
2009-05-30 00:09:00 +00:00
|
|
|
|
2012-02-15 11:00:08 +00:00
|
|
|
int ff_vc1_parse_frame_header (VC1Context *v, GetBitContext *gb);
|
|
|
|
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
|
2012-02-17 22:18:22 +00:00
|
|
|
int ff_vc1_init_common(VC1Context *v);
|
2009-05-30 00:09:00 +00:00
|
|
|
|
2012-08-27 17:21:00 +00:00
|
|
|
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v);
|
|
|
|
av_cold void ff_vc1_init_transposed_scantables(VC1Context *v);
|
|
|
|
av_cold int ff_vc1_decode_end(AVCodecContext *avctx);
|
|
|
|
void ff_vc1_decode_blocks(VC1Context *v);
|
|
|
|
|
2008-08-31 07:39:47 +00:00
|
|
|
#endif /* AVCODEC_VC1_H */
|