Libav
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,
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  int res_rtm_flag;
201  int reserved;
202 
203 
206  int level;
209  int broadcast;
210  int interlace;
219  int psf;
221 
222 
227  int profile;
230  int fastuvmc;
232  int dquant;
234  int overlap;
237 
238 
243  int k_x;
244  int k_y;
247  uint8_t zz_8x8[4][64];
249  const uint8_t* zz_8x4;
250  const uint8_t* zz_4x8;
251 
258 
264 
265  int ttfrm;
267  int *ttblk_base, *ttblk;
268  int codingset;
270  int pqindex;
273 
274 
280  int16_t bfraction;
284 
293  int tt_index;
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];
306  int rnd;
307 
313 
320  uint16_t topleftx;
321  uint16_t toplefty;
322  uint16_t bottomrightx;
323  uint16_t bottomrighty;
334  uint16_t *hrd_rate, *hrd_buffer;
341 
345  int intcomp;
356  int8_t zzi_8x8[64];
361  int fptype;
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
369  // 0: both fields, 1: bottom field, 2: top field
371  int ref_field_type[2];
373  int qs_last;
374  int bmvtype;
375  int frfd, brfd;
378 
385  uint8_t* sr_rows[2][2];
386 
387 
389  int bi_type;
390  int x8_type;
391 
392  int16_t (*block)[6][64];
394  uint32_t *cbp_base, *cbp;
396  int16_t (*luma_mv_base)[2], (*luma_mv)[2];
400 
401  int end_mb_x;
402 
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 
452 
454 
458 
463 
464 #endif /* AVCODEC_VC1_H */