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 "mpegvideo.h"
28 #include "intrax8.h"
29 #include "vc1dsp.h"
30 
31 #define AC_VLC_BITS 9
32 
35 enum VC1Code {
36  VC1_CODE_RES0 = 0x00000100,
37  VC1_CODE_ENDOFSEQ = 0x0000010A,
43 };
45 
46 #define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
47 
50 enum Profile {
55 };
57 
60 enum QuantMode {
65 };
67 
70 enum DQProfile {
75 };
77 
86 };
88 
96 };
98 
101 enum MVModes {
107 };
109 
119 };
121 
124 enum BMVTypes {
129 };
131 
138  TT_8X4, // both halves
141  TT_4X8, // both halves
143 };
145 
146 enum CodingSet {
155 };
156 
159 enum COTypes {
163 };
165 
175 };
176 
181 typedef struct VC1Context{
185 
186  int bits;
187 
191  int res_y411;
192  int res_x8;
193  int multires;
196  int rangered;
197  int res_rtm_flag;
199  int reserved;
200 
201 
204  int level;
207  int broadcast;
208  int interlace;
217  int psf;
219 
220 
225  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
352  int8_t zzi_8x8[64];
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;
374 
381  uint8_t* sr_rows[2][2];
382 
383 
385  int bi_type;
386  int x8_type;
387 
388  DCTELEM (*block)[6][64];
390  uint32_t *cbp_base, *cbp;
392  int16_t (*luma_mv_base)[2], (*luma_mv)[2];
396 
397  int end_mb_x;
398 
400 
402 } VC1Context;
403 
407 static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
408 {
409  uint32_t mrk = 0xFFFFFFFF;
410 
411  if (end-src < 4)
412  return end;
413  while (src < end) {
414  mrk = (mrk << 8) | *src++;
415  if (IS_MARKER(mrk))
416  return src - 4;
417  }
418  return end;
419 }
420 
421 static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
422 {
423  int dsize = 0, i;
424 
425  if (size < 4) {
426  for (dsize = 0; dsize < size; dsize++)
427  *dst++ = *src++;
428  return size;
429  }
430  for (i = 0; i < size; i++, src++) {
431  if (src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
432  dst[dsize++] = src[1];
433  src++;
434  i++;
435  } else
436  dst[dsize++] = *src;
437  }
438  return dsize;
439 }
440 
449 
451 
455 
460 
461 #endif /* AVCODEC_VC1_H */