annotate vc1.c @ 12530:63edd10ad4bc libavcodec tip

Try to fix crashes introduced by r25218 r25218 made assumptions about the existence of past reference frames that weren't necessarily true.
author darkshikari
date Tue, 28 Sep 2010 09:06:22 +0000
parents db36486a6f89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
1 /*
9836
e678b20368cd Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents: 9815
diff changeset
2 * VC-1 and WMV3 decoder common code
4605
d4feec96fd64 Looks like I'll work on it this year too
kostya
parents: 4604
diff changeset
3 * Copyright (c) 2006-2007 Konstantin Shishkov
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
4 * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
5 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3920
diff changeset
6 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3920
diff changeset
7 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3920
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3920
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
12 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3920
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
16 * Lesser General Public License for more details.
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
17 *
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3920
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
21 */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
22
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
23 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 10379
diff changeset
24 * @file
9836
e678b20368cd Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents: 9815
diff changeset
25 * VC-1 and WMV3 decoder common code
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
26 *
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
27 */
9011
90c99bda19f5 Approved hunks for VAAPI / our new shiny hwaccel API
michael
parents: 8955
diff changeset
28 #include "internal.h"
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
29 #include "dsputil.h"
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
30 #include "avcodec.h"
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
31 #include "mpegvideo.h"
4926
194f4ced7c50 Move variables to vc1data.h
kostya
parents: 4902
diff changeset
32 #include "vc1.h"
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
33 #include "vc1data.h"
4965
f9bb3aca0888 use header instead of copying table declarations
aurel
parents: 4962
diff changeset
34 #include "msmpeg4data.h"
5605
d92fa6e5fc8c move get_unary() to its own file
aurel
parents: 5519
diff changeset
35 #include "unary.h"
5849
c1d42c875be8 Use simple IDCT for now
kostya
parents: 5848
diff changeset
36 #include "simple_idct.h"
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
37
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
38 #undef NDEBUG
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
39 #include <assert.h>
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
40
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
41 /***********************************************************************/
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
42 /**
8685
ed386fa1399e Fix Doxygen comments for VC-1 decoder.
kostya
parents: 8645
diff changeset
43 * @defgroup vc1bitplane VC-1 Bitplane decoding
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
44 * @see 8.7, p56
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
45 * @{
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
46 */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
47
8685
ed386fa1399e Fix Doxygen comments for VC-1 decoder.
kostya
parents: 8645
diff changeset
48 /**
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
49 * Imode types
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
50 * @{
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
51 */
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
52 enum Imode {
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
53 IMODE_RAW,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
54 IMODE_NORM2,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
55 IMODE_DIFF2,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
56 IMODE_NORM6,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
57 IMODE_DIFF6,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
58 IMODE_ROWSKIP,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
59 IMODE_COLSKIP
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
60 };
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
61 /** @} */ //imode defines
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
62
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
63 /** Decode rows by checking if they are skipped
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
64 * @param plane Buffer to store decoded bits
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
65 * @param[in] width Width of this buffer
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
66 * @param[in] height Height of this buffer
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
67 * @param[in] stride of this buffer
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
68 */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
69 static void decode_rowskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
70 int x, y;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
71
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
72 for (y=0; y<height; y++){
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
73 if (!get_bits1(gb)) //rowskip
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
74 memset(plane, 0, width);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
75 else
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
76 for (x=0; x<width; x++)
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
77 plane[x] = get_bits1(gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
78 plane += stride;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
79 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
80 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
81
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
82 /** Decode columns by checking if they are skipped
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
83 * @param plane Buffer to store decoded bits
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
84 * @param[in] width Width of this buffer
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
85 * @param[in] height Height of this buffer
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
86 * @param[in] stride of this buffer
5299
4623928e3b9e Replace non-existing @fixme doxygen tags with @todo.
diego
parents: 5228
diff changeset
87 * @todo FIXME: Optimize
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
88 */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
89 static void decode_colskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
90 int x, y;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
91
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
92 for (x=0; x<width; x++){
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
93 if (!get_bits1(gb)) //colskip
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
94 for (y=0; y<height; y++)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
95 plane[y*stride] = 0;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
96 else
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
97 for (y=0; y<height; y++)
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
98 plane[y*stride] = get_bits1(gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
99 plane ++;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
100 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
101 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
102
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
103 /** Decode a bitplane's bits
8685
ed386fa1399e Fix Doxygen comments for VC-1 decoder.
kostya
parents: 8645
diff changeset
104 * @param data bitplane where to store the decode bits
ed386fa1399e Fix Doxygen comments for VC-1 decoder.
kostya
parents: 8645
diff changeset
105 * @param[out] raw_flag pointer to the flag indicating that this bitplane is not coded explicitly
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
106 * @param v VC-1 context for bit reading and logging
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
107 * @return Status
5299
4623928e3b9e Replace non-existing @fixme doxygen tags with @todo.
diego
parents: 5228
diff changeset
108 * @todo FIXME: Optimize
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
109 */
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
110 static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
111 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
112 GetBitContext *gb = &v->s.gb;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
113
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
114 int imode, x, y, code, offset;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
115 uint8_t invert, *planep = data;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
116 int width, height, stride;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
117
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
118 width = v->s.mb_width;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
119 height = v->s.mb_height;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
120 stride = v->s.mb_stride;
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
121 invert = get_bits1(gb);
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
122 imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
123
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
124 *raw_flag = 0;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
125 switch (imode)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
126 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
127 case IMODE_RAW:
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
128 //Data is actually read in the MB layer (same for all tests == "raw")
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
129 *raw_flag = 1; //invert ignored
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
130 return invert;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
131 case IMODE_DIFF2:
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
132 case IMODE_NORM2:
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
133 if ((height * width) & 1)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
134 {
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
135 *planep++ = get_bits1(gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
136 offset = 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
137 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
138 else offset = 0;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
139 // decode bitplane as one long line
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
140 for (y = offset; y < height * width; y += 2) {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
141 code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
142 *planep++ = code & 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
143 offset++;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
144 if(offset == width) {
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
145 offset = 0;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
146 planep += stride - width;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
147 }
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
148 *planep++ = code >> 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
149 offset++;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
150 if(offset == width) {
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
151 offset = 0;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
152 planep += stride - width;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
153 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
154 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
155 break;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
156 case IMODE_DIFF6:
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
157 case IMODE_NORM6:
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
158 if(!(height % 3) && (width % 3)) { // use 2x3 decoding
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
159 for(y = 0; y < height; y+= 3) {
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
160 for(x = width & 1; x < width; x += 2) {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
161 code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
162 if(code < 0){
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
163 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
164 return -1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
165 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
166 planep[x + 0] = (code >> 0) & 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
167 planep[x + 1] = (code >> 1) & 1;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
168 planep[x + 0 + stride] = (code >> 2) & 1;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
169 planep[x + 1 + stride] = (code >> 3) & 1;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
170 planep[x + 0 + stride * 2] = (code >> 4) & 1;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
171 planep[x + 1 + stride * 2] = (code >> 5) & 1;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
172 }
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
173 planep += stride * 3;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
174 }
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
175 if(width & 1) decode_colskip(data, 1, height, stride, &v->s.gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
176 } else { // 3x2
3405
58c4fd135462 Correctly choose global transform mode, MV mode and fix bitplane decoding
kostya
parents: 3404
diff changeset
177 planep += (height & 1) * stride;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
178 for(y = height & 1; y < height; y += 2) {
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
179 for(x = width % 3; x < width; x += 3) {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
180 code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
181 if(code < 0){
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
182 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
183 return -1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
184 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
185 planep[x + 0] = (code >> 0) & 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
186 planep[x + 1] = (code >> 1) & 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
187 planep[x + 2] = (code >> 2) & 1;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
188 planep[x + 0 + stride] = (code >> 3) & 1;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
189 planep[x + 1 + stride] = (code >> 4) & 1;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
190 planep[x + 2 + stride] = (code >> 5) & 1;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
191 }
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
192 planep += stride * 2;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
193 }
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
194 x = width % 3;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
195 if(x) decode_colskip(data , x, height , stride, &v->s.gb);
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
196 if(height & 1) decode_rowskip(data+x, width - x, 1, stride, &v->s.gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
197 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
198 break;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
199 case IMODE_ROWSKIP:
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
200 decode_rowskip(data, width, height, stride, &v->s.gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
201 break;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
202 case IMODE_COLSKIP:
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
203 decode_colskip(data, width, height, stride, &v->s.gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
204 break;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
205 default: break;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
206 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
207
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
208 /* Applying diff operator */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
209 if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
210 {
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
211 planep = data;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
212 planep[0] ^= invert;
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
213 for (x=1; x<width; x++)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
214 planep[x] ^= planep[x-1];
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
215 for (y=1; y<height; y++)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
216 {
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
217 planep += stride;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
218 planep[0] ^= planep[-stride];
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
219 for (x=1; x<width; x++)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
220 {
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
221 if (planep[x-1] != planep[x-stride]) planep[x] ^= invert;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
222 else planep[x] ^= planep[x-1];
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
223 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
224 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
225 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
226 else if (invert)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
227 {
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
228 planep = data;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
229 for (x=0; x<stride*height; x++) planep[x] = !planep[x]; //FIXME stride
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
230 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
231 return (imode<<1) + invert;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
232 }
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
233
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
234 /** @} */ //Bitplane group
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
235
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
236 /***********************************************************************/
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
237 /** VOP Dquant decoding
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
238 * @param v VC-1 Context
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
239 */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
240 static int vop_dquant_decoding(VC1Context *v)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
241 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
242 GetBitContext *gb = &v->s.gb;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
243 int pqdiff;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
244
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
245 //variable size
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
246 if (v->dquant == 2)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
247 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
248 pqdiff = get_bits(gb, 3);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
249 if (pqdiff == 7) v->altpq = get_bits(gb, 5);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
250 else v->altpq = v->pq + pqdiff + 1;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
251 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
252 else
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
253 {
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
254 v->dquantfrm = get_bits1(gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
255 if ( v->dquantfrm )
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
256 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
257 v->dqprofile = get_bits(gb, 2);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
258 switch (v->dqprofile)
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
259 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
260 case DQPROFILE_SINGLE_EDGE:
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
261 case DQPROFILE_DOUBLE_EDGES:
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
262 v->dqsbedge = get_bits(gb, 2);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
263 break;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
264 case DQPROFILE_ALL_MBS:
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
265 v->dqbilevel = get_bits1(gb);
5682
8bf94c994691 In case when any quantizer may occur, HALFPQ should be zero
kostya
parents: 5605
diff changeset
266 if(!v->dqbilevel)
8bf94c994691 In case when any quantizer may occur, HALFPQ should be zero
kostya
parents: 5605
diff changeset
267 v->halfpq = 0;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
268 default: break; //Forbidden ?
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
269 }
3451
45724ba8d666 Fix mquant selection for ALL_MBS mode
kostya
parents: 3450
diff changeset
270 if (v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
271 {
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
272 pqdiff = get_bits(gb, 3);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
273 if (pqdiff == 7) v->altpq = get_bits(gb, 5);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
274 else v->altpq = v->pq + pqdiff + 1;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
275 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
276 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
277 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
278 return 0;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
279 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
280
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
281 static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
282
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
283 /**
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
284 * Decode Simple/Main Profiles sequence header
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
285 * @see Figure 7-8, p16-17
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
286 * @param avctx Codec context
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
287 * @param gb GetBit context initialized from Codec context extra_data
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
288 * @return Status
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
289 */
9732
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
290 int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb)
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
291 {
3692
7857ae840b0b Don't print header bits by default
kostya
parents: 3691
diff changeset
292 av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits(gb, 32));
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
293 v->profile = get_bits(gb, 2);
4604
40cd5f7f34e7 WMV3 Complex Profile initial support
kostya
parents: 4594
diff changeset
294 if (v->profile == PROFILE_COMPLEX)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
295 {
4604
40cd5f7f34e7 WMV3 Complex Profile initial support
kostya
parents: 4594
diff changeset
296 av_log(avctx, AV_LOG_ERROR, "WMV3 Complex Profile is not fully supported\n");
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
297 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
298
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
299 if (v->profile == PROFILE_ADVANCED)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
300 {
6145
ddf5d7fae101 Select scan tables for 8x4 and 4x8 blocks only once.
kostya
parents: 6099
diff changeset
301 v->zz_8x4 = ff_vc1_adv_progressive_8x4_zz;
ddf5d7fae101 Select scan tables for 8x4 and 4x8 blocks only once.
kostya
parents: 6099
diff changeset
302 v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
303 return decode_sequence_header_adv(v, gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
304 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
305 else
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
306 {
7136
7a73d76aaaa0 remove duplicate tables
stefang
parents: 7040
diff changeset
307 v->zz_8x4 = wmv2_scantableA;
7a73d76aaaa0 remove duplicate tables
stefang
parents: 7040
diff changeset
308 v->zz_4x8 = wmv2_scantableB;
12520
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
309 v->res_y411 = get_bits1(gb);
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
310 v->res_sprite = get_bits1(gb);
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
311 if (v->res_y411)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
312 {
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
313 av_log(avctx, AV_LOG_ERROR,
12520
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
314 "Old interlaced mode is not supported\n");
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
315 return -1;
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
316 }
5915f4f0e172 RES_SM in WMV3 is really two flags, so split it in decoder
kostya
parents: 12127
diff changeset
317 if (v->res_sprite) {
12521
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
318 av_log(avctx, AV_LOG_ERROR, "WMVP is not fully supported\n");
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
319 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
320 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
321
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
322 // (fps-2)/4 (->30)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
323 v->frmrtq_postproc = get_bits(gb, 3); //common
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
324 // (bitrate-32kbps)/64kbps
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
325 v->bitrtq_postproc = get_bits(gb, 5); //common
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
326 v->s.loop_filter = get_bits1(gb); //common
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
327 if(v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
328 {
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
329 av_log(avctx, AV_LOG_ERROR,
9858
53d5914a30ef Fix typo in vc1.c, make capitalization in warning/error messages more consistent.
darkshikari
parents: 9836
diff changeset
330 "LOOPFILTER shall not be enabled in Simple Profile\n");
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
331 }
7846
a7162bb60138 Make it possible to disable loop filter in VC-1.
kostya
parents: 7429
diff changeset
332 if(v->s.avctx->skip_loop_filter >= AVDISCARD_ALL)
a7162bb60138 Make it possible to disable loop filter in VC-1.
kostya
parents: 7429
diff changeset
333 v->s.loop_filter = 0;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
334
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
335 v->res_x8 = get_bits1(gb); //reserved
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
336 v->multires = get_bits1(gb);
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
337 v->res_fasttx = get_bits1(gb);
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
338 if (!v->res_fasttx)
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
339 {
6001
f4859c13426b add ff_ prefix to all simple_idct symbols
aurel
parents: 5998
diff changeset
340 v->s.dsp.vc1_inv_trans_8x8 = ff_simple_idct;
f4859c13426b add ff_ prefix to all simple_idct symbols
aurel
parents: 5998
diff changeset
341 v->s.dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
f4859c13426b add ff_ prefix to all simple_idct symbols
aurel
parents: 5998
diff changeset
342 v->s.dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
6008
2c4164b26d53 Enable 4x4 IDCT for FASTTX=0 mode in WMV3
kostya
parents: 6001
diff changeset
343 v->s.dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
9859
7a116de63777 idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents: 9858
diff changeset
344 v->s.dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add;
7a116de63777 idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents: 9858
diff changeset
345 v->s.dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
7a116de63777 idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents: 9858
diff changeset
346 v->s.dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
7a116de63777 idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents: 9858
diff changeset
347 v->s.dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
348 }
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
349
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
350 v->fastuvmc = get_bits1(gb); //common
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
351 if (!v->profile && !v->fastuvmc)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
352 {
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
353 av_log(avctx, AV_LOG_ERROR,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
354 "FASTUVMC unavailable in Simple Profile\n");
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
355 return -1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
356 }
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
357 v->extended_mv = get_bits1(gb); //common
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
358 if (!v->profile && v->extended_mv)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
359 {
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
360 av_log(avctx, AV_LOG_ERROR,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
361 "Extended MVs unavailable in Simple Profile\n");
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
362 return -1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
363 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
364 v->dquant = get_bits(gb, 2); //common
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
365 v->vstransform = get_bits1(gb); //common
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
366
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
367 v->res_transtab = get_bits1(gb);
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
368 if (v->res_transtab)
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
369 {
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
370 av_log(avctx, AV_LOG_ERROR,
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
371 "1 for reserved RES_TRANSTAB is forbidden\n");
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
372 return -1;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
373 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
374
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
375 v->overlap = get_bits1(gb); //common
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
376
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
377 v->s.resync_marker = get_bits1(gb);
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
378 v->rangered = get_bits1(gb);
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
379 if (v->rangered && v->profile == PROFILE_SIMPLE)
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
380 {
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
381 av_log(avctx, AV_LOG_INFO,
9858
53d5914a30ef Fix typo in vc1.c, make capitalization in warning/error messages more consistent.
darkshikari
parents: 9836
diff changeset
382 "RANGERED should be set to 0 in Simple Profile\n");
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
383 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
384
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
385 v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
386 v->quantizer_mode = get_bits(gb, 2); //common
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
387
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
388 v->finterpflag = get_bits1(gb); //common
12521
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
389
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
390 if (v->res_sprite) {
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
391 v->s.avctx->width = v->s.avctx->coded_width = get_bits(gb, 11);
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
392 v->s.avctx->height = v->s.avctx->coded_height = get_bits(gb, 11);
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
393 skip_bits(gb, 5); //frame rate
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
394 v->res_x8 = get_bits1(gb);
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
395 if (get_bits1(gb)) { // something to do with DC VLC selection
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
396 av_log(avctx, AV_LOG_ERROR, "Unsupported sprite feature\n");
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
397 return -1;
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
398 }
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
399 skip_bits(gb, 3); //slice code
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
400 v->res_rtm_flag = 0;
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
401 } else {
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
402 v->res_rtm_flag = get_bits1(gb); //reserved
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
403 }
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
404 if (!v->res_rtm_flag)
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
405 {
3538
f26bf13bbb69 Don't try to decode P-frames from old WMV3 variant until their format is figured
kostya
parents: 3528
diff changeset
406 // av_log(avctx, AV_LOG_ERROR,
f26bf13bbb69 Don't try to decode P-frames from old WMV3 variant until their format is figured
kostya
parents: 3528
diff changeset
407 // "0 for reserved RES_RTM_FLAG is forbidden\n");
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
408 av_log(avctx, AV_LOG_ERROR,
12127
9ba7d2a5b20a Make WMV3 decoder print more errors when decoding beta WMV9 files.
kostya
parents: 11644
diff changeset
409 "Old WMV3 version detected, some frames may be decoded incorrectly\n");
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
410 //return -1;
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
411 }
4742
184d33cce3b6 FASTTX==0 means additional 16 bits in extradata
kostya
parents: 4741
diff changeset
412 //TODO: figure out what they mean (always 0x402F)
184d33cce3b6 FASTTX==0 means additional 16 bits in extradata
kostya
parents: 4741
diff changeset
413 if(!v->res_fasttx) skip_bits(gb, 16);
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
414 av_log(avctx, AV_LOG_DEBUG,
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
415 "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
3457
ad66c11aeab4 FastUVMV vs FastUVMC typo, noticed by bond
diego
parents: 3453
diff changeset
416 "LoopFilter=%i, MultiRes=%i, FastUVMC=%i, Extended MV=%i\n"
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
417 "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n"
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
418 "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n",
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
419 v->profile, v->frmrtq_postproc, v->bitrtq_postproc,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
420 v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
421 v->rangered, v->vstransform, v->overlap, v->s.resync_marker,
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
422 v->dquant, v->quantizer_mode, avctx->max_b_frames
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
423 );
3691
ff18ceefe3d8 [Cosmetics] Remove if(profile < PROFILE_ADVANCED) from decode_sequence_header()
kostya
parents: 3690
diff changeset
424 return 0;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
425 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
426
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
427 static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
428 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
429 v->res_rtm_flag = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
430 v->level = get_bits(gb, 3);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
431 if(v->level >= 5)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
432 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
433 av_log(v->s.avctx, AV_LOG_ERROR, "Reserved LEVEL %i\n",v->level);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
434 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
435 v->chromaformat = get_bits(gb, 2);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
436 if (v->chromaformat != 1)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
437 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
438 av_log(v->s.avctx, AV_LOG_ERROR,
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
439 "Only 4:2:0 chroma format supported\n");
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
440 return -1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
441 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
442
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
443 // (fps-2)/4 (->30)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
444 v->frmrtq_postproc = get_bits(gb, 3); //common
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
445 // (bitrate-32kbps)/64kbps
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
446 v->bitrtq_postproc = get_bits(gb, 5); //common
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
447 v->postprocflag = get_bits1(gb); //common
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
448
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
449 v->s.avctx->coded_width = (get_bits(gb, 12) + 1) << 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
450 v->s.avctx->coded_height = (get_bits(gb, 12) + 1) << 1;
4474
82277cf5f051 Set codec dimensions in extradata parsing
kostya
parents: 4471
diff changeset
451 v->s.avctx->width = v->s.avctx->coded_width;
82277cf5f051 Set codec dimensions in extradata parsing
kostya
parents: 4471
diff changeset
452 v->s.avctx->height = v->s.avctx->coded_height;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
453 v->broadcast = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
454 v->interlace = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
455 v->tfcntrflag = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
456 v->finterpflag = get_bits1(gb);
5519
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
457 skip_bits1(gb); // reserved
4402
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
458
4680
71c1e1171e83 Proper handling of motion vectors for adv. profile
kostya
parents: 4605
diff changeset
459 v->s.h_edge_pos = v->s.avctx->coded_width;
71c1e1171e83 Proper handling of motion vectors for adv. profile
kostya
parents: 4605
diff changeset
460 v->s.v_edge_pos = v->s.avctx->coded_height;
71c1e1171e83 Proper handling of motion vectors for adv. profile
kostya
parents: 4605
diff changeset
461
4402
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
462 av_log(v->s.avctx, AV_LOG_DEBUG,
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
463 "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
464 "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n"
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
465 "TFCTRflag=%i, FINTERPflag=%i\n",
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
466 v->level, v->frmrtq_postproc, v->bitrtq_postproc,
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
467 v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace,
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
468 v->tfcntrflag, v->finterpflag
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
469 );
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
470
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
471 v->psf = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
472 if(v->psf) { //PsF, 6.1.13
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
473 av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n");
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
474 return -1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
475 }
4486
1d2320afa864 B-frames could not be determined from broken_link/closed_entry, use fixed value
kostya
parents: 4485
diff changeset
476 v->s.max_b_frames = v->s.avctx->max_b_frames = 7;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
477 if(get_bits1(gb)) { //Display Info - decoding is not affected by it
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
478 int w, h, ar = 0;
4467
a9f64d2a2e69 These messages are just for debug purposes
kostya
parents: 4466
diff changeset
479 av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n");
9541
7afd4f44c450 Display dimensions should not affect the real size of coded frame, thus set
kostya
parents: 9537
diff changeset
480 v->s.avctx->width = w = get_bits(gb, 14) + 1;
7afd4f44c450 Display dimensions should not affect the real size of coded frame, thus set
kostya
parents: 9537
diff changeset
481 v->s.avctx->height = h = get_bits(gb, 14) + 1;
4467
a9f64d2a2e69 These messages are just for debug purposes
kostya
parents: 4466
diff changeset
482 av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
483 if(get_bits1(gb))
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
484 ar = get_bits(gb, 4);
4414
7c42c51b1130 Set aspect ratio if present (for AP only)
kostya
parents: 4402
diff changeset
485 if(ar && ar < 14){
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
486 v->s.avctx->sample_aspect_ratio = ff_vc1_pixel_aspect[ar];
4414
7c42c51b1130 Set aspect ratio if present (for AP only)
kostya
parents: 4402
diff changeset
487 }else if(ar == 15){
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
488 w = get_bits(gb, 8);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
489 h = get_bits(gb, 8);
4414
7c42c51b1130 Set aspect ratio if present (for AP only)
kostya
parents: 4402
diff changeset
490 v->s.avctx->sample_aspect_ratio = (AVRational){w, h};
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
491 }
8583
d94775e24b0e Print VC-1 aspect ratio in debug
kostya
parents: 8582
diff changeset
492 av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", v->s.avctx->sample_aspect_ratio.num, v->s.avctx->sample_aspect_ratio.den);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
493
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
494 if(get_bits1(gb)){ //framerate stuff
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
495 if(get_bits1(gb)) {
4470
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
496 v->s.avctx->time_base.num = 32;
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
497 v->s.avctx->time_base.den = get_bits(gb, 16) + 1;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
498 } else {
4470
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
499 int nr, dr;
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
500 nr = get_bits(gb, 8);
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
501 dr = get_bits(gb, 4);
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
502 if(nr && nr < 8 && dr && dr < 3){
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
503 v->s.avctx->time_base.num = ff_vc1_fps_dr[dr - 1];
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
504 v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000;
4470
2c9a66c5223a Set frame rate from extradata
kostya
parents: 4467
diff changeset
505 }
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
506 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
507 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
508
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
509 if(get_bits1(gb)){
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
510 v->color_prim = get_bits(gb, 8);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
511 v->transfer_char = get_bits(gb, 8);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
512 v->matrix_coef = get_bits(gb, 8);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
513 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
514 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
515
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
516 v->hrd_param_flag = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
517 if(v->hrd_param_flag) {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
518 int i;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
519 v->hrd_num_leaky_buckets = get_bits(gb, 5);
5519
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
520 skip_bits(gb, 4); //bitrate exponent
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
521 skip_bits(gb, 4); //buffer size exponent
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
522 for(i = 0; i < v->hrd_num_leaky_buckets; i++) {
5519
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
523 skip_bits(gb, 16); //hrd_rate[n]
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
524 skip_bits(gb, 16); //hrd_buffer[n]
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
525 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
526 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
527 return 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
528 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
529
9732
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
530 int vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb)
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
531 {
8692
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
532 int i;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
533
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
534 av_log(avctx, AV_LOG_DEBUG, "Entry point: %08X\n", show_bits_long(gb, 32));
8692
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
535 v->broken_link = get_bits1(gb);
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
536 v->closed_entry = get_bits1(gb);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
537 v->panscanflag = get_bits1(gb);
8556
ce9d640decd1 Add refdist_flag to VC1Context.
cehoyos
parents: 8152
diff changeset
538 v->refdist_flag = get_bits1(gb);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
539 v->s.loop_filter = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
540 v->fastuvmc = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
541 v->extended_mv = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
542 v->dquant = get_bits(gb, 2);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
543 v->vstransform = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
544 v->overlap = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
545 v->quantizer_mode = get_bits(gb, 2);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
546
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
547 if(v->hrd_param_flag){
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
548 for(i = 0; i < v->hrd_num_leaky_buckets; i++) {
5519
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
549 skip_bits(gb, 8); //hrd_full[n]
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
550 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
551 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
552
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
553 if(get_bits1(gb)){
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
554 avctx->coded_width = (get_bits(gb, 12)+1)<<1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
555 avctx->coded_height = (get_bits(gb, 12)+1)<<1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
556 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
557 if(v->extended_mv)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
558 v->extended_dmv = get_bits1(gb);
8560
a683a89503eb Fill range_map* in VC1Context.
cehoyos
parents: 8556
diff changeset
559 if((v->range_mapy_flag = get_bits1(gb))) {
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
560 av_log(avctx, AV_LOG_ERROR, "Luma scaling is not supported, expect wrong picture\n");
8560
a683a89503eb Fill range_map* in VC1Context.
cehoyos
parents: 8556
diff changeset
561 v->range_mapy = get_bits(gb, 3);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
562 }
8560
a683a89503eb Fill range_map* in VC1Context.
cehoyos
parents: 8556
diff changeset
563 if((v->range_mapuv_flag = get_bits1(gb))) {
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
564 av_log(avctx, AV_LOG_ERROR, "Chroma scaling is not supported, expect wrong picture\n");
8560
a683a89503eb Fill range_map* in VC1Context.
cehoyos
parents: 8556
diff changeset
565 v->range_mapuv = get_bits(gb, 3);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
566 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
567
4402
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
568 av_log(avctx, AV_LOG_DEBUG, "Entry point info:\n"
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
569 "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n"
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
570 "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n"
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
571 "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n",
8692
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
572 v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.loop_filter,
4402
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
573 v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode);
43f4d0d7672c Add debug messages for AP headers
kostya
parents: 4401
diff changeset
574
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
575 return 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
576 }
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
577
9732
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
578 int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
579 {
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
580 int pqindex, lowquant, status;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
581
12521
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
582 if(v->res_sprite) {
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
583 skip_bits(gb, 2); //not yet deciphered
db36486a6f89 Make WMV3 decoder attempt to decode WMVP as well
kostya
parents: 12520
diff changeset
584 }
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
585 if(v->finterpflag) v->interpfrm = get_bits1(gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
586 skip_bits(gb, 2); //framecnt unused
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
587 v->rangeredfrm = 0;
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
588 if (v->rangered) v->rangeredfrm = get_bits1(gb);
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
589 v->s.pict_type = get_bits1(gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
590 if (v->s.avctx->max_b_frames) {
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
591 if (!v->s.pict_type) {
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
592 if (get_bits1(gb)) v->s.pict_type = FF_I_TYPE;
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
593 else v->s.pict_type = FF_B_TYPE;
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
594 } else v->s.pict_type = FF_P_TYPE;
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
595 } else v->s.pict_type = v->s.pict_type ? FF_P_TYPE : FF_I_TYPE;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
596
3689
6d9e8253da2a Proper support for B/BI frames
kostya
parents: 3672
diff changeset
597 v->bi_type = 0;
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
598 if(v->s.pict_type == FF_B_TYPE) {
8692
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
599 v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
600 v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
3689
6d9e8253da2a Proper support for B/BI frames
kostya
parents: 3672
diff changeset
601 if(v->bfraction == 0) {
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
602 v->s.pict_type = FF_BI_TYPE;
3515
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
603 }
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
604 }
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
605 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
5519
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
606 skip_bits(gb, 7); // skip buffer fullness
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
607
9732
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
608 if(v->parse_only)
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
609 return 0;
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
610
3474
24f293c3f3ef Rounding control for motion compensation.
kostya
parents: 3457
diff changeset
611 /* calculate RND */
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
612 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
3474
24f293c3f3ef Rounding control for motion compensation.
kostya
parents: 3457
diff changeset
613 v->rnd = 1;
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
614 if(v->s.pict_type == FF_P_TYPE)
3474
24f293c3f3ef Rounding control for motion compensation.
kostya
parents: 3457
diff changeset
615 v->rnd ^= 1;
24f293c3f3ef Rounding control for motion compensation.
kostya
parents: 3457
diff changeset
616
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
617 /* Quantizer stuff */
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
618 pqindex = get_bits(gb, 5);
6150
49a4e4d78692 pqindex=0 is forbidden
kostya
parents: 6145
diff changeset
619 if(!pqindex) return -1;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
620 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
621 v->pq = ff_vc1_pquant_table[0][pqindex];
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
622 else
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
623 v->pq = ff_vc1_pquant_table[1][pqindex];
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
624
3475
4e06affe9974 Correct inverse quantization for P-frames
kostya
parents: 3474
diff changeset
625 v->pquantizer = 1;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
626 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
627 v->pquantizer = pqindex < 9;
3475
4e06affe9974 Correct inverse quantization for P-frames
kostya
parents: 3474
diff changeset
628 if (v->quantizer_mode == QUANT_NON_UNIFORM)
4e06affe9974 Correct inverse quantization for P-frames
kostya
parents: 3474
diff changeset
629 v->pquantizer = 0;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
630 v->pqindex = pqindex;
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
631 if (pqindex < 9) v->halfpq = get_bits1(gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
632 else v->halfpq = 0;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
633 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
634 v->pquantizer = get_bits1(gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
635 v->dquantfrm = 0;
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
636 if (v->extended_mv == 1) v->mvrange = get_unary(gb, 0, 3);
3452
f024ca7c768b MVRANGE may occur in all frames and RESPIC in all but B-frames
kostya
parents: 3451
diff changeset
637 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
f024ca7c768b MVRANGE may occur in all frames and RESPIC in all but B-frames
kostya
parents: 3451
diff changeset
638 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
f024ca7c768b MVRANGE may occur in all frames and RESPIC in all but B-frames
kostya
parents: 3451
diff changeset
639 v->range_x = 1 << (v->k_x - 1);
f024ca7c768b MVRANGE may occur in all frames and RESPIC in all but B-frames
kostya
parents: 3451
diff changeset
640 v->range_y = 1 << (v->k_y - 1);
8640
ad979489c6e7 Remove the block with always false condition from vc1_parse_frame_header()
kostya
parents: 8639
diff changeset
641 if (v->multires && v->s.pict_type != FF_B_TYPE) v->respic = get_bits(gb, 2);
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
642
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
643 if(v->res_x8 && (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)){
5887
83ac4620c6ed intrax8 decoder patch by "someone"
michael
parents: 5849
diff changeset
644 v->x8_type = get_bits1(gb);
83ac4620c6ed intrax8 decoder patch by "someone"
michael
parents: 5849
diff changeset
645 }else v->x8_type = 0;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
646 //av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
647 // (v->s.pict_type == FF_P_TYPE) ? 'P' : ((v->s.pict_type == FF_I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm);
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
648
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
649 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_P_TYPE) v->use_ic = 0;
3744
805aee1f7cce For B-frames if the second reference frame signals intensity compensation
kostya
parents: 3743
diff changeset
650
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
651 switch(v->s.pict_type) {
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
652 case FF_P_TYPE:
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
653 if (v->pq < 5) v->tt_index = 0;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
654 else if(v->pq < 13) v->tt_index = 1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
655 else v->tt_index = 2;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
656
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
657 lowquant = (v->pq > 12) ? 0 : 1;
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
658 v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)];
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
659 if (v->mv_mode == MV_PMODE_INTENSITY_COMP)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
660 {
3406
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
661 int scale, shift, i;
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
662 v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)];
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
663 v->lumscale = get_bits(gb, 6);
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
664 v->lumshift = get_bits(gb, 6);
3744
805aee1f7cce For B-frames if the second reference frame signals intensity compensation
kostya
parents: 3743
diff changeset
665 v->use_ic = 1;
3406
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
666 /* fill lookup tables for intensity compensation */
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
667 if(!v->lumscale) {
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
668 scale = -64;
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
669 shift = (255 - v->lumshift * 2) << 6;
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
670 if(v->lumshift > 31)
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
671 shift += 128 << 6;
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
672 } else {
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
673 scale = v->lumscale + 32;
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
674 if(v->lumshift > 31)
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
675 shift = (v->lumshift - 64) << 6;
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
676 else
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
677 shift = v->lumshift << 6;
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
678 }
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
679 for(i = 0; i < 256; i++) {
4594
a96d905dcbaa Add av_ prefix to clip functions
reimar
parents: 4518
diff changeset
680 v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6);
a96d905dcbaa Add av_ prefix to clip functions
reimar
parents: 4518
diff changeset
681 v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
3406
75ab0c53742a Implement intensity compensation
kostya
parents: 3405
diff changeset
682 }
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
683 }
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
684 if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
685 v->s.quarter_sample = 0;
3401
e88c3bc82b15 Correctly detect when use hpel or qpel mode
kostya
parents: 3400
diff changeset
686 else if(v->mv_mode == MV_PMODE_INTENSITY_COMP) {
e88c3bc82b15 Correctly detect when use hpel or qpel mode
kostya
parents: 3400
diff changeset
687 if(v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
e88c3bc82b15 Correctly detect when use hpel or qpel mode
kostya
parents: 3400
diff changeset
688 v->s.quarter_sample = 0;
e88c3bc82b15 Correctly detect when use hpel or qpel mode
kostya
parents: 3400
diff changeset
689 else
e88c3bc82b15 Correctly detect when use hpel or qpel mode
kostya
parents: 3400
diff changeset
690 v->s.quarter_sample = 1;
e88c3bc82b15 Correctly detect when use hpel or qpel mode
kostya
parents: 3400
diff changeset
691 } else
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
692 v->s.quarter_sample = 1;
3523
7407a264d243 Set MpegEncContext->mspel flag (here it indicates that bicubic MC will be use)
kostya
parents: 3522
diff changeset
693 v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
694
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
695 if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
696 v->mv_mode2 == MV_PMODE_MIXED_MV)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
697 || v->mv_mode == MV_PMODE_MIXED_MV)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
698 {
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
699 status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
700 if (status < 0) return -1;
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
701 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
702 "Imode: %i, Invert: %i\n", status>>1, status&1);
3367
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
703 } else {
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
704 v->mv_type_is_raw = 0;
8c7b8ffc2485 Some optimization and fixes - mostly reworked MC and bitplanes.
kostya
parents: 3366
diff changeset
705 memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
706 }
3375
a1c2e1603be9 Use MpegEncContext->mbskip_table instead of custom bitplane.
kostya
parents: 3371
diff changeset
707 status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
708 if (status < 0) return -1;
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
709 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
710 "Imode: %i, Invert: %i\n", status>>1, status&1);
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
711
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
712 /* Hopefully this is correct for P frames */
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
713 v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
714 v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
715
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
716 if (v->dquant)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
717 {
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
718 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
719 vop_dquant_decoding(v);
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
720 }
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
721
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
722 v->ttfrm = 0; //FIXME Is that so ?
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
723 if (v->vstransform)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
724 {
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
725 v->ttmbf = get_bits1(gb);
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
726 if (v->ttmbf)
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
727 {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
728 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
729 }
3506
e0996476198b Set correctly quantizer and transform mode when parsing frame header.
kostya
parents: 3476
diff changeset
730 } else {
e0996476198b Set correctly quantizer and transform mode when parsing frame header.
kostya
parents: 3476
diff changeset
731 v->ttmbf = 1;
e0996476198b Set correctly quantizer and transform mode when parsing frame header.
kostya
parents: 3476
diff changeset
732 v->ttfrm = TT_8X8;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
733 }
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
734 break;
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
735 case FF_B_TYPE:
3515
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
736 if (v->pq < 5) v->tt_index = 0;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
737 else if(v->pq < 13) v->tt_index = 1;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
738 else v->tt_index = 2;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
739
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
740 v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
741 v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
3523
7407a264d243 Set MpegEncContext->mspel flag (here it indicates that bicubic MC will be use)
kostya
parents: 3522
diff changeset
742 v->s.mspel = v->s.quarter_sample;
3515
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
743
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
744 status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
745 if (status < 0) return -1;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
746 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
747 "Imode: %i, Invert: %i\n", status>>1, status&1);
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
748 status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
749 if (status < 0) return -1;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
750 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
751 "Imode: %i, Invert: %i\n", status>>1, status&1);
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
752
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
753 v->s.mv_table_index = get_bits(gb, 2);
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
754 v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
3515
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
755
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
756 if (v->dquant)
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
757 {
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
758 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
759 vop_dquant_decoding(v);
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
760 }
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
761
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
762 v->ttfrm = 0;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
763 if (v->vstransform)
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
764 {
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
765 v->ttmbf = get_bits1(gb);
3515
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
766 if (v->ttmbf)
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
767 {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
768 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
3515
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
769 }
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
770 } else {
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
771 v->ttmbf = 1;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
772 v->ttfrm = TT_8X8;
20938be7b67b Some B-frames support (parsing and decoding only, no motion compesation is done)
kostya
parents: 3514
diff changeset
773 }
3360
2c4ddf5b9217 VC-1 decoder with I-frames support and partial P-frames decoding
kostya
parents: 3359
diff changeset
774 break;
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
775 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
776
5892
efc1e9a01671 indention
michael
parents: 5887
diff changeset
777 if(!v->x8_type)
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
778 {
5892
efc1e9a01671 indention
michael
parents: 5887
diff changeset
779 /* AC Syntax */
efc1e9a01671 indention
michael
parents: 5887
diff changeset
780 v->c_ac_table_index = decode012(gb);
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
781 if (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
5892
efc1e9a01671 indention
michael
parents: 5887
diff changeset
782 {
efc1e9a01671 indention
michael
parents: 5887
diff changeset
783 v->y_ac_table_index = decode012(gb);
efc1e9a01671 indention
michael
parents: 5887
diff changeset
784 }
efc1e9a01671 indention
michael
parents: 5887
diff changeset
785 /* DC Syntax */
efc1e9a01671 indention
michael
parents: 5887
diff changeset
786 v->s.dc_table_index = get_bits1(gb);
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
787 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
788
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
789 if(v->s.pict_type == FF_BI_TYPE) {
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
790 v->s.pict_type = FF_B_TYPE;
3689
6d9e8253da2a Proper support for B/BI frames
kostya
parents: 3672
diff changeset
791 v->bi_type = 1;
6d9e8253da2a Proper support for B/BI frames
kostya
parents: 3672
diff changeset
792 }
3359
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
793 return 0;
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
794 }
87187ebe2c28 Rename VC9 to VC1 as there is no such thing as VC9
kostya
parents:
diff changeset
795
9732
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
796 int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
797 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
798 int pqindex, lowquant;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
799 int status;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
800
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
801 v->p_frame_skipped = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
802
4487
0a0a9f0c9c2d Progressive frames disguised as interlaced are supported
kostya
parents: 4486
diff changeset
803 if(v->interlace){
4471
cfbd1f3d457c Save frame header info in context variables
kostya
parents: 4470
diff changeset
804 v->fcm = decode012(gb);
10379
d580026275a1 Print error message when true interlaced VC-1 frames are encountered
kostya
parents: 9859
diff changeset
805 if(v->fcm){
d580026275a1 Print error message when true interlaced VC-1 frames are encountered
kostya
parents: 9859
diff changeset
806 if(!v->warn_interlaced++)
d580026275a1 Print error message when true interlaced VC-1 frames are encountered
kostya
parents: 9859
diff changeset
807 av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced frames/fields support is not implemented\n");
d580026275a1 Print error message when true interlaced VC-1 frames are encountered
kostya
parents: 9859
diff changeset
808 return -1;
d580026275a1 Print error message when true interlaced VC-1 frames are encountered
kostya
parents: 9859
diff changeset
809 }
4487
0a0a9f0c9c2d Progressive frames disguised as interlaced are supported
kostya
parents: 4486
diff changeset
810 }
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
811 switch(get_unary(gb, 0, 4)) {
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
812 case 0:
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
813 v->s.pict_type = FF_P_TYPE;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
814 break;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
815 case 1:
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
816 v->s.pict_type = FF_B_TYPE;
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
817 break;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
818 case 2:
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
819 v->s.pict_type = FF_I_TYPE;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
820 break;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
821 case 3:
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
822 v->s.pict_type = FF_BI_TYPE;
3693
e9be5d4bad80 Support for BI-frames in Advanced Profile
kostya
parents: 3692
diff changeset
823 break;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
824 case 4:
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
825 v->s.pict_type = FF_P_TYPE; // skipped pic
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
826 v->p_frame_skipped = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
827 return 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
828 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
829 if(v->tfcntrflag)
5519
b790f8c0ee24 use skip_bits where appropriate
alex
parents: 5513
diff changeset
830 skip_bits(gb, 8);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
831 if(v->broadcast) {
4485
81a120f5f8d0 Wrong flag tested
kostya
parents: 4474
diff changeset
832 if(!v->interlace || v->psf) {
4471
cfbd1f3d457c Save frame header info in context variables
kostya
parents: 4470
diff changeset
833 v->rptfrm = get_bits(gb, 2);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
834 } else {
4471
cfbd1f3d457c Save frame header info in context variables
kostya
parents: 4470
diff changeset
835 v->tff = get_bits1(gb);
cfbd1f3d457c Save frame header info in context variables
kostya
parents: 4470
diff changeset
836 v->rptfrm = get_bits1(gb);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
837 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
838 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
839 if(v->panscanflag) {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
840 //...
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
841 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
842 v->rnd = get_bits1(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
843 if(v->interlace)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
844 v->uvsamp = get_bits1(gb);
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
845 if(v->finterpflag) v->interpfrm = get_bits1(gb);
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
846 if(v->s.pict_type == FF_B_TYPE) {
8692
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
847 v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
48442253aac2 Record B-fraction index from frame header and two fields from entry point structure
kostya
parents: 8685
diff changeset
848 v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
849 if(v->bfraction == 0) {
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
850 v->s.pict_type = FF_BI_TYPE; /* XXX: should not happen here */
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
851 }
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
852 }
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
853 pqindex = get_bits(gb, 5);
6150
49a4e4d78692 pqindex=0 is forbidden
kostya
parents: 6145
diff changeset
854 if(!pqindex) return -1;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
855 v->pqindex = pqindex;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
856 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
857 v->pq = ff_vc1_pquant_table[0][pqindex];
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
858 else
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
859 v->pq = ff_vc1_pquant_table[1][pqindex];
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
860
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
861 v->pquantizer = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
862 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
863 v->pquantizer = pqindex < 9;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
864 if (v->quantizer_mode == QUANT_NON_UNIFORM)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
865 v->pquantizer = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
866 v->pqindex = pqindex;
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
867 if (pqindex < 9) v->halfpq = get_bits1(gb);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
868 else v->halfpq = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
869 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
870 v->pquantizer = get_bits1(gb);
8152
cddc3677e7dc 421l: postproc flag may be present in any VC-1 AP frame type
kostya
parents: 7846
diff changeset
871 if(v->postprocflag)
8639
29096719e684 VC-1 postproc field is 2 bits wide while decoder read only single bit.
kostya
parents: 8632
diff changeset
872 v->postproc = get_bits(gb, 2);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
873
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
874 if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_P_TYPE) v->use_ic = 0;
4518
e3c43b4aa9ac Intensity compensation for B-frames in AP was missing
kostya
parents: 4487
diff changeset
875
9732
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
876 if(v->parse_only)
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
877 return 0;
c25359a56edf set pict_type in VC-1 parser, fix some timestamps problems
bcoudurier
parents: 9645
diff changeset
878
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
879 switch(v->s.pict_type) {
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
880 case FF_I_TYPE:
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
881 case FF_BI_TYPE:
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
882 status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
883 if (status < 0) return -1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
884 av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: "
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
885 "Imode: %i, Invert: %i\n", status>>1, status&1);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
886 v->condover = CONDOVER_NONE;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
887 if(v->overlap && v->pq <= 8) {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
888 v->condover = decode012(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
889 if(v->condover == CONDOVER_SELECT) {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
890 status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
891 if (status < 0) return -1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
892 av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: "
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
893 "Imode: %i, Invert: %i\n", status>>1, status&1);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
894 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
895 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
896 break;
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
897 case FF_P_TYPE:
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
898 if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
899 else v->mvrange = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
900 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
901 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
902 v->range_x = 1 << (v->k_x - 1);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
903 v->range_y = 1 << (v->k_y - 1);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
904
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
905 if (v->pq < 5) v->tt_index = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
906 else if(v->pq < 13) v->tt_index = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
907 else v->tt_index = 2;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
908
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
909 lowquant = (v->pq > 12) ? 0 : 1;
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
910 v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)];
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
911 if (v->mv_mode == MV_PMODE_INTENSITY_COMP)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
912 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
913 int scale, shift, i;
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
914 v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)];
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
915 v->lumscale = get_bits(gb, 6);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
916 v->lumshift = get_bits(gb, 6);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
917 /* fill lookup tables for intensity compensation */
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
918 if(!v->lumscale) {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
919 scale = -64;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
920 shift = (255 - v->lumshift * 2) << 6;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
921 if(v->lumshift > 31)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
922 shift += 128 << 6;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
923 } else {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
924 scale = v->lumscale + 32;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
925 if(v->lumshift > 31)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
926 shift = (v->lumshift - 64) << 6;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
927 else
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
928 shift = v->lumshift << 6;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
929 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
930 for(i = 0; i < 256; i++) {
4594
a96d905dcbaa Add av_ prefix to clip functions
reimar
parents: 4518
diff changeset
931 v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6);
a96d905dcbaa Add av_ prefix to clip functions
reimar
parents: 4518
diff changeset
932 v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
933 }
4518
e3c43b4aa9ac Intensity compensation for B-frames in AP was missing
kostya
parents: 4487
diff changeset
934 v->use_ic = 1;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
935 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
936 if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
937 v->s.quarter_sample = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
938 else if(v->mv_mode == MV_PMODE_INTENSITY_COMP) {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
939 if(v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
940 v->s.quarter_sample = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
941 else
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
942 v->s.quarter_sample = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
943 } else
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
944 v->s.quarter_sample = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
945 v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
946
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
947 if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
948 v->mv_mode2 == MV_PMODE_MIXED_MV)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
949 || v->mv_mode == MV_PMODE_MIXED_MV)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
950 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
951 status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
952 if (status < 0) return -1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
953 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
954 "Imode: %i, Invert: %i\n", status>>1, status&1);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
955 } else {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
956 v->mv_type_is_raw = 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
957 memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
958 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
959 status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
960 if (status < 0) return -1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
961 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
962 "Imode: %i, Invert: %i\n", status>>1, status&1);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
963
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
964 /* Hopefully this is correct for P frames */
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
965 v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
966 v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
967 if (v->dquant)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
968 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
969 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
970 vop_dquant_decoding(v);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
971 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
972
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
973 v->ttfrm = 0; //FIXME Is that so ?
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
974 if (v->vstransform)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
975 {
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
976 v->ttmbf = get_bits1(gb);
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
977 if (v->ttmbf)
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
978 {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
979 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
980 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
981 } else {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
982 v->ttmbf = 1;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
983 v->ttfrm = TT_8X8;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
984 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
985 break;
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
986 case FF_B_TYPE:
5511
7617e066481e use get_unary from bitstream.h
alex
parents: 5299
diff changeset
987 if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3);
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
988 else v->mvrange = 0;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
989 v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
990 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
991 v->range_x = 1 << (v->k_x - 1);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
992 v->range_y = 1 << (v->k_y - 1);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
993
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
994 if (v->pq < 5) v->tt_index = 0;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
995 else if(v->pq < 13) v->tt_index = 1;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
996 else v->tt_index = 2;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
997
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
998 v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
999 v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1000 v->s.mspel = v->s.quarter_sample;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1001
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1002 status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1003 if (status < 0) return -1;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1004 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1005 "Imode: %i, Invert: %i\n", status>>1, status&1);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1006 status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1007 if (status < 0) return -1;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1008 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1009 "Imode: %i, Invert: %i\n", status>>1, status&1);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1010
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1011 v->s.mv_table_index = get_bits(gb, 2);
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
1012 v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1013
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1014 if (v->dquant)
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1015 {
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1016 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1017 vop_dquant_decoding(v);
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1018 }
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1019
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1020 v->ttfrm = 0;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1021 if (v->vstransform)
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1022 {
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
1023 v->ttmbf = get_bits1(gb);
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1024 if (v->ttmbf)
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1025 {
4949
845386be542c Add ff_ prefix to (externally) visible variables
kostya
parents: 4948
diff changeset
1026 v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
4238
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1027 }
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1028 } else {
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1029 v->ttmbf = 1;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1030 v->ttfrm = TT_8X8;
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1031 }
a784639411d6 B-frames support for adv. profile
kostya
parents: 4237
diff changeset
1032 break;
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1033 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1034
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1035 /* AC Syntax */
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1036 v->c_ac_table_index = decode012(gb);
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
1037 if (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1038 {
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1039 v->y_ac_table_index = decode012(gb);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1040 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1041 /* DC Syntax */
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5511
diff changeset
1042 v->s.dc_table_index = get_bits1(gb);
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
1043 if ((v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE) && v->dquant) {
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1044 av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1045 vop_dquant_decoding(v);
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1046 }
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1047
3693
e9be5d4bad80 Support for BI-frames in Advanced Profile
kostya
parents: 3692
diff changeset
1048 v->bi_type = 0;
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
1049 if(v->s.pict_type == FF_BI_TYPE) {
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6350
diff changeset
1050 v->s.pict_type = FF_B_TYPE;
3693
e9be5d4bad80 Support for BI-frames in Advanced Profile
kostya
parents: 3692
diff changeset
1051 v->bi_type = 1;
e9be5d4bad80 Support for BI-frames in Advanced Profile
kostya
parents: 3692
diff changeset
1052 }
3672
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1053 return 0;
9d4583fe8fca VC-1 Advanced Profile support (progressive only, tested on WVC1 samples)
kostya
parents: 3664
diff changeset
1054 }