FFmpeg  1.2.12
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 FFmpeg.
7  *
8  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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,
44 };
46 
47 #define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
48 
51 enum Profile {
56 };
58 
61 enum QuantMode {
66 };
68 
71 enum DQProfile {
76 };
78 
87 };
89 
97 };
99 
102 enum MVModes {
108 };
110 
120 };
122 
125 enum BMVTypes {
130 };
132 
139  TT_8X4, // both halves
142  TT_4X8, // both halves
144 };
146 
147 enum CodingSet {
156 };
157 
160 enum COTypes {
164 };
166 
176 };
177 
182 typedef struct VC1Context{
187 
188  int bits;
189 
193  int res_y411;
194  int res_x8;
195  int multires;
198  int rangered;
199 
201  int reserved;
202 
203 
206  int level;
209  int broadcast;
210  int interlace;
216 
217  int psf;
218 
219 
224  int profile;
228  int fastuvmc;
230  int dquant;
232  int overlap;
235 
236 
241  int k_x;
242  int k_y;
245  uint8_t zz_8x8[4][64];
247  const uint8_t* zz_8x4;
248  const uint8_t* zz_4x8;
249 
256 
262 
263  int ttfrm;
265  int *ttblk_base, *ttblk;
266  int codingset;
268  int pqindex;
271 
272 
278  int16_t bfraction;
282 
291  int tt_index;
299  uint8_t luty[256], lutuv[256];
300  int use_ic;
301  int rnd;
302 
308 
315  uint16_t topleftx;
316  uint16_t toplefty;
317  uint16_t bottomrightx;
318  uint16_t bottomrighty;
329  uint16_t *hrd_rate, *hrd_buffer;
336 
340  int intcomp;
343  uint8_t luty2[256], lutuv2[256]; // lookup tables used for intensity compensation
358  int fptype;
360  int refdist;
361  int numref;
362  // 0 corresponds to 1 and 1 corresponds to 2 references
363  int reffield;
364  // field to use among the two fields from previous frame
366  // 0: both fields, 1: bottom field, 2: top field
368  int ref_field_type[2];
370  int qs_last;
371  int bmvtype;
372  int frfd, brfd;
375 
382  uint8_t* sr_rows[2][2];
383 
384 
386  int bi_type;
387  int x8_type;
388 
389  int16_t (*block)[6][64];
391  uint32_t *cbp_base, *cbp;
393  int16_t (*luma_mv_base)[2], (*luma_mv)[2];
397 
398  int end_mb_x;
399 
401 
403 } VC1Context;
404 
408 static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
409 {
410  uint32_t mrk = 0xFFFFFFFF;
411 
412  if (end-src < 4)
413  return end;
414  while (src < end) {
415  mrk = (mrk << 8) | *src++;
416  if (IS_MARKER(mrk))
417  return src - 4;
418  }
419  return end;
420 }
421 
423 {
424  int dsize = 0, i;
425 
426  if (size < 4) {
427  for (dsize = 0; dsize < size; dsize++)
428  *dst++ = *src++;
429  return size;
430  }
431  for (i = 0; i < size; i++, src++) {
432  if (src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
433  dst[dsize++] = src[1];
434  src++;
435  i++;
436  } else
437  dst[dsize++] = *src;
438  }
439  return dsize;
440 }
441 
450 
452 
456 
461 
462 #endif /* AVCODEC_VC1_H */