00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef AVCODEC_VC1_H
00024 #define AVCODEC_VC1_H
00025
00026 #include "avcodec.h"
00027 #include "mpegvideo.h"
00028 #include "intrax8.h"
00029 #include "vc1dsp.h"
00030
00033 enum VC1Code{
00034 VC1_CODE_RES0 = 0x00000100,
00035 VC1_CODE_ENDOFSEQ = 0x0000010A,
00036 VC1_CODE_SLICE,
00037 VC1_CODE_FIELD,
00038 VC1_CODE_FRAME,
00039 VC1_CODE_ENTRYPOINT,
00040 VC1_CODE_SEQHDR,
00041 };
00043
00044 #define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
00045
00048 enum Profile {
00049 PROFILE_SIMPLE,
00050 PROFILE_MAIN,
00051 PROFILE_COMPLEX,
00052 PROFILE_ADVANCED
00053 };
00055
00058 enum QuantMode {
00059 QUANT_FRAME_IMPLICIT,
00060 QUANT_FRAME_EXPLICIT,
00061 QUANT_NON_UNIFORM,
00062 QUANT_UNIFORM
00063 };
00065
00068 enum DQProfile {
00069 DQPROFILE_FOUR_EDGES,
00070 DQPROFILE_DOUBLE_EDGES,
00071 DQPROFILE_SINGLE_EDGE,
00072 DQPROFILE_ALL_MBS
00073 };
00075
00079 enum DQSingleEdge {
00080 DQSINGLE_BEDGE_LEFT,
00081 DQSINGLE_BEDGE_TOP,
00082 DQSINGLE_BEDGE_RIGHT,
00083 DQSINGLE_BEDGE_BOTTOM
00084 };
00086
00089 enum DQDoubleEdge {
00090 DQDOUBLE_BEDGE_TOPLEFT,
00091 DQDOUBLE_BEDGE_TOPRIGHT,
00092 DQDOUBLE_BEDGE_BOTTOMRIGHT,
00093 DQDOUBLE_BEDGE_BOTTOMLEFT
00094 };
00096
00099 enum MVModes {
00100 MV_PMODE_1MV_HPEL_BILIN,
00101 MV_PMODE_1MV,
00102 MV_PMODE_1MV_HPEL,
00103 MV_PMODE_MIXED_MV,
00104 MV_PMODE_INTENSITY_COMP
00105 };
00107
00110 enum BMVTypes {
00111 BMV_TYPE_BACKWARD,
00112 BMV_TYPE_FORWARD,
00113 BMV_TYPE_INTERPOLATED
00114 };
00116
00119 enum TransformTypes {
00120 TT_8X8,
00121 TT_8X4_BOTTOM,
00122 TT_8X4_TOP,
00123 TT_8X4,
00124 TT_4X8_RIGHT,
00125 TT_4X8_LEFT,
00126 TT_4X8,
00127 TT_4X4
00128 };
00130
00131 enum CodingSet {
00132 CS_HIGH_MOT_INTRA = 0,
00133 CS_HIGH_MOT_INTER,
00134 CS_LOW_MOT_INTRA,
00135 CS_LOW_MOT_INTER,
00136 CS_MID_RATE_INTRA,
00137 CS_MID_RATE_INTER,
00138 CS_HIGH_RATE_INTRA,
00139 CS_HIGH_RATE_INTER
00140 };
00141
00144 enum COTypes {
00145 CONDOVER_NONE = 0,
00146 CONDOVER_ALL,
00147 CONDOVER_SELECT
00148 };
00150
00151
00156 typedef struct VC1Context{
00157 MpegEncContext s;
00158 IntraX8Context x8;
00159 VC1DSPContext vc1dsp;
00160
00161 int bits;
00162
00165 int res_sprite;
00166 int res_y411;
00167 int res_x8;
00168 int multires;
00169 int res_fasttx;
00170 int res_transtab;
00171 int rangered;
00172
00173 int res_rtm_flag;
00174 int reserved;
00175
00176
00179 int level;
00180 int chromaformat;
00181 int postprocflag;
00182 int broadcast;
00183 int interlace;
00184 int tfcntrflag;
00185 int panscanflag;
00186 int refdist_flag;
00187 int extended_dmv;
00188 int color_prim;
00189 int transfer_char;
00190 int matrix_coef;
00191 int hrd_param_flag;
00192
00193 int psf;
00194
00195
00200 int profile;
00201 int frmrtq_postproc;
00202 int bitrtq_postproc;
00203 int fastuvmc;
00204 int extended_mv;
00205 int dquant;
00206 int vstransform;
00207 int overlap;
00208 int quantizer_mode;
00209 int finterpflag;
00210
00211
00214 uint8_t mv_mode;
00215 uint8_t mv_mode2;
00216 int k_x;
00217 int k_y;
00218 int range_x, range_y;
00219 uint8_t pq, altpq;
00220 uint8_t zz_8x8[4][64];
00221 int left_blk_sh, top_blk_sh;
00222 const uint8_t* zz_8x4;
00223 const uint8_t* zz_4x8;
00224
00226 uint8_t dquantfrm;
00227 uint8_t dqprofile;
00228 uint8_t dqsbedge;
00229 uint8_t dqbilevel;
00231
00235 int c_ac_table_index;
00236 int y_ac_table_index;
00237
00238 int ttfrm;
00239 uint8_t ttmbf;
00240 int *ttblk_base, *ttblk;
00241 int codingset;
00242 int codingset2;
00243 int pqindex;
00244 int a_avail, c_avail;
00245 uint8_t *mb_type_base, *mb_type[3];
00246
00247
00250 uint8_t lumscale;
00251 uint8_t lumshift;
00253 int16_t bfraction;
00254 uint8_t halfpq;
00255 uint8_t respic;
00256 int buffer_fullness;
00257
00263 uint8_t mvrange;
00264 uint8_t pquantizer;
00265 VLC *cbpcy_vlc;
00266 int tt_index;
00267 uint8_t* mv_type_mb_plane;
00268 uint8_t* direct_mb_plane;
00269 int mv_type_is_raw;
00270 int dmb_is_raw;
00271 int skip_is_raw;
00272 uint8_t luty[256], lutuv[256];
00273 int use_ic;
00274 int rnd;
00275
00278 uint8_t rangeredfrm;
00279 uint8_t interpfrm;
00281
00284 uint8_t fcm;
00285 uint8_t numpanscanwin;
00286 uint8_t tfcntr;
00287 uint8_t rptfrm, tff, rff;
00288 uint16_t topleftx;
00289 uint16_t toplefty;
00290 uint16_t bottomrightx;
00291 uint16_t bottomrighty;
00292 uint8_t uvsamp;
00293 uint8_t postproc;
00294 int hrd_num_leaky_buckets;
00295 uint8_t bit_rate_exponent;
00296 uint8_t buffer_size_exponent;
00297 uint8_t* acpred_plane;
00298 int acpred_is_raw;
00299 uint8_t* over_flags_plane;
00300 int overflg_is_raw;
00301 uint8_t condover;
00302 uint16_t *hrd_rate, *hrd_buffer;
00303 uint8_t *hrd_fullness;
00304 uint8_t range_mapy_flag;
00305 uint8_t range_mapuv_flag;
00306 uint8_t range_mapy;
00307 uint8_t range_mapuv;
00309
00312 int new_sprite;
00313 int two_sprites;
00315
00316 int p_frame_skipped;
00317 int bi_type;
00318 int x8_type;
00319
00320 DCTELEM (*block)[6][64];
00321 int n_allocated_blks, cur_blk_idx, left_blk_idx, topleft_blk_idx, top_blk_idx;
00322 uint32_t *cbp_base, *cbp;
00323 uint8_t *is_intra_base, *is_intra;
00324 int16_t (*luma_mv_base)[2], (*luma_mv)[2];
00325 uint8_t bfraction_lut_index;
00326 uint8_t broken_link;
00327 uint8_t closed_entry;
00328
00329 int parse_only;
00330
00331 int warn_interlaced;
00332 } VC1Context;
00333
00337 static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
00338 {
00339 uint32_t mrk = 0xFFFFFFFF;
00340
00341 if(end-src < 4) return end;
00342 while(src < end){
00343 mrk = (mrk << 8) | *src++;
00344 if(IS_MARKER(mrk))
00345 return src-4;
00346 }
00347 return end;
00348 }
00349
00350 static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
00351 {
00352 int dsize = 0, i;
00353
00354 if(size < 4){
00355 for(dsize = 0; dsize < size; dsize++) *dst++ = *src++;
00356 return size;
00357 }
00358 for(i = 0; i < size; i++, src++) {
00359 if(src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
00360 dst[dsize++] = src[1];
00361 src++;
00362 i++;
00363 } else
00364 dst[dsize++] = *src;
00365 }
00366 return dsize;
00367 }
00368
00376 int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb);
00377
00378 int vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb);
00379
00380 int vc1_parse_frame_header (VC1Context *v, GetBitContext *gb);
00381 int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
00382
00383 #endif