Mercurial > libavcodec.hg
annotate vc1dec.c @ 12518:67e7e49058c2 libavcodec
Split and then simplify address generation macro.
Allows nasm to work for this code.
author | reimar |
---|---|
date | Sun, 26 Sep 2010 09:08:11 +0000 |
parents | 7e93f85e48bf |
children | db36486a6f89 |
rev | line source |
---|---|
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1 /* |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2 * VC-1 and WMV3 decoder |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3 * Copyright (c) 2006-2007 Konstantin Shishkov |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
4 * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
5 * |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
6 * This file is part of FFmpeg. |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
7 * |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
12 * |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
17 * |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
21 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
22 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
23 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11560
diff
changeset
|
24 * @file |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
25 * VC-1 and WMV3 decoder |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
26 * |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
27 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
28 #include "internal.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
29 #include "dsputil.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
30 #include "avcodec.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
31 #include "mpegvideo.h" |
11230 | 32 #include "h263.h" |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
33 #include "vc1.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
34 #include "vc1data.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
35 #include "vc1acdata.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
36 #include "msmpeg4data.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
37 #include "unary.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
38 #include "simple_idct.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
39 #include "mathops.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
40 #include "vdpau_internal.h" |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
41 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
42 #undef NDEBUG |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
43 #include <assert.h> |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
44 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
45 #define MB_INTRA_VLC_BITS 9 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
46 #define DC_VLC_BITS 9 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
47 #define AC_VLC_BITS 9 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
48 static const uint16_t table_mb_intra[64][2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
49 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
50 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
51 static const uint16_t vlc_offs[] = { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
52 0, 520, 552, 616, 1128, 1160, 1224, 1740, 1772, 1836, 1900, 2436, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
53 2986, 3050, 3610, 4154, 4218, 4746, 5326, 5390, 5902, 6554, 7658, 8620, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
54 9262, 10202, 10756, 11310, 12228, 15078 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
55 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
56 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
57 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
58 * Init VC-1 specific tables and VC1Context members |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
59 * @param v The VC1Context to initialize |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
60 * @return Status |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
61 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
62 static int vc1_init_common(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
63 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
64 static int done = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
65 int i = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
66 static VLC_TYPE vlc_table[15078][2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
67 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
68 v->hrd_rate = v->hrd_buffer = NULL; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
69 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
70 /* VLC tables */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
71 if(!done) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
72 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
73 INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
74 ff_vc1_bfraction_bits, 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
75 ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
76 INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
77 ff_vc1_norm2_bits, 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
78 ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
79 INIT_VLC_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
80 ff_vc1_norm6_bits, 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
81 ff_vc1_norm6_codes, 2, 2, 556); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
82 INIT_VLC_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
83 ff_vc1_imode_bits, 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
84 ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
85 for (i=0; i<3; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
86 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
87 ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i*3+0]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
88 ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i*3+1] - vlc_offs[i*3+0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
89 init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
90 ff_vc1_ttmb_bits[i], 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
91 ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
92 ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i*3+1]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
93 ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i*3+2] - vlc_offs[i*3+1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
94 init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
95 ff_vc1_ttblk_bits[i], 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
96 ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
97 ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i*3+2]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
98 ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i*3+3] - vlc_offs[i*3+2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
99 init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
100 ff_vc1_subblkpat_bits[i], 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
101 ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
102 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
103 for(i=0; i<4; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
104 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
105 ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i*3+9]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
106 ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i*3+10] - vlc_offs[i*3+9]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
107 init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
108 ff_vc1_4mv_block_pattern_bits[i], 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
109 ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
110 ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i*3+10]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
111 ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i*3+11] - vlc_offs[i*3+10]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
112 init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
113 ff_vc1_cbpcy_p_bits[i], 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
114 ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
115 ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i*3+11]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
116 ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i*3+12] - vlc_offs[i*3+11]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
117 init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
118 ff_vc1_mv_diff_bits[i], 1, 1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
119 ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
120 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
121 for(i=0; i<8; i++){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
122 ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i+21]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
123 ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i+22] - vlc_offs[i+21]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
124 init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, vc1_ac_sizes[i], |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
125 &vc1_ac_tables[i][0][1], 8, 4, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
126 &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_NEW_STATIC); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
127 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
128 done = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
129 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
130 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
131 /* Other defaults */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
132 v->pq = -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
133 v->mvrange = 0; /* 7.1.1.18, p80 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
134 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
135 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
136 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
137 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
138 /***********************************************************************/ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
139 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
140 * @defgroup vc1bitplane VC-1 Bitplane decoding |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
141 * @see 8.7, p56 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
142 * @{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
143 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
144 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
145 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
146 * Imode types |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
147 * @{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
148 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
149 enum Imode { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
150 IMODE_RAW, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
151 IMODE_NORM2, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
152 IMODE_DIFF2, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
153 IMODE_NORM6, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
154 IMODE_DIFF6, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
155 IMODE_ROWSKIP, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
156 IMODE_COLSKIP |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
157 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
158 /** @} */ //imode defines |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
159 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
160 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
161 /** @} */ //Bitplane group |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
162 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
163 static void vc1_loop_filter_iblk(MpegEncContext *s, int pq) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
164 { |
12142 | 165 int j; |
166 if (!s->first_slice_line) { | |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
167 s->dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq); |
12142 | 168 if (s->mb_x) |
169 s->dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize, s->linesize, pq); | |
170 s->dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize+8, s->linesize, pq); | |
171 for(j = 0; j < 2; j++){ | |
172 s->dsp.vc1_v_loop_filter8(s->dest[j+1], s->uvlinesize, pq); | |
173 if (s->mb_x) | |
174 s->dsp.vc1_h_loop_filter8(s->dest[j+1]-8*s->uvlinesize, s->uvlinesize, pq); | |
175 } | |
176 } | |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
177 s->dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq); |
12142 | 178 |
179 if (s->mb_y == s->mb_height-1) { | |
180 if (s->mb_x) { | |
181 s->dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq); | |
182 s->dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq); | |
183 s->dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq); | |
184 } | |
185 s->dsp.vc1_h_loop_filter16(s->dest[0] + 8, s->linesize, pq); | |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
186 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
187 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
188 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
189 /** Put block onto picture |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
190 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
191 static void vc1_put_block(VC1Context *v, DCTELEM block[6][64]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
192 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
193 uint8_t *Y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
194 int ys, us, vs; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
195 DSPContext *dsp = &v->s.dsp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
196 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
197 if(v->rangeredfrm) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
198 int i, j, k; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
199 for(k = 0; k < 6; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
200 for(j = 0; j < 8; j++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
201 for(i = 0; i < 8; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
202 block[k][i + j*8] = ((block[k][i + j*8] - 128) << 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
203 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
204 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
205 ys = v->s.current_picture.linesize[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
206 us = v->s.current_picture.linesize[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
207 vs = v->s.current_picture.linesize[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
208 Y = v->s.dest[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
209 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
210 dsp->put_pixels_clamped(block[0], Y, ys); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
211 dsp->put_pixels_clamped(block[1], Y + 8, ys); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
212 Y += ys * 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
213 dsp->put_pixels_clamped(block[2], Y, ys); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
214 dsp->put_pixels_clamped(block[3], Y + 8, ys); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
215 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
216 if(!(v->s.flags & CODEC_FLAG_GRAY)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
217 dsp->put_pixels_clamped(block[4], v->s.dest[1], us); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
218 dsp->put_pixels_clamped(block[5], v->s.dest[2], vs); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
219 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
220 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
221 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
222 /** Do motion compensation over 1 macroblock |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
223 * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
224 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
225 static void vc1_mc_1mv(VC1Context *v, int dir) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
226 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
227 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
228 DSPContext *dsp = &v->s.dsp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
229 uint8_t *srcY, *srcU, *srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
230 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
231 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
232 if(!v->s.last_picture.data[0])return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
233 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
234 mx = s->mv[dir][0][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
235 my = s->mv[dir][0][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
236 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
237 // store motion vectors for further use in B frames |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
238 if(s->pict_type == FF_P_TYPE) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
239 s->current_picture.motion_val[1][s->block_index[0]][0] = mx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
240 s->current_picture.motion_val[1][s->block_index[0]][1] = my; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
241 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
242 uvmx = (mx + ((mx & 3) == 3)) >> 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
243 uvmy = (my + ((my & 3) == 3)) >> 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
244 if(v->fastuvmc) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
245 uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
246 uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
247 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
248 if(!dir) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
249 srcY = s->last_picture.data[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
250 srcU = s->last_picture.data[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
251 srcV = s->last_picture.data[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
252 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
253 srcY = s->next_picture.data[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
254 srcU = s->next_picture.data[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
255 srcV = s->next_picture.data[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
256 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
257 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
258 src_x = s->mb_x * 16 + (mx >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
259 src_y = s->mb_y * 16 + (my >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
260 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
261 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
262 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
263 if(v->profile != PROFILE_ADVANCED){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
264 src_x = av_clip( src_x, -16, s->mb_width * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
265 src_y = av_clip( src_y, -16, s->mb_height * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
266 uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
267 uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
268 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
269 src_x = av_clip( src_x, -17, s->avctx->coded_width); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
270 src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
271 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
272 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
273 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
274 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
275 srcY += src_y * s->linesize + src_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
276 srcU += uvsrc_y * s->uvlinesize + uvsrc_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
277 srcV += uvsrc_y * s->uvlinesize + uvsrc_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
278 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
279 /* for grayscale we should not try to read from unknown area */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
280 if(s->flags & CODEC_FLAG_GRAY) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
281 srcU = s->edge_emu_buffer + 18 * s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
282 srcV = s->edge_emu_buffer + 18 * s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
283 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
284 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
285 if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
286 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel*3 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
287 || (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 16 - s->mspel*3){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
288 uint8_t *uvbuf= s->edge_emu_buffer + 19 * s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
289 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
290 srcY -= s->mspel * (1 + s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
291 ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
292 src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
293 srcY = s->edge_emu_buffer; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
294 ff_emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
295 uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
296 ff_emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
297 uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
298 srcU = uvbuf; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
299 srcV = uvbuf + 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
300 /* if we deal with range reduction we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
301 if(v->rangeredfrm) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
302 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
303 uint8_t *src, *src2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
304 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
305 src = srcY; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
306 for(j = 0; j < 17 + s->mspel*2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
307 for(i = 0; i < 17 + s->mspel*2; i++) src[i] = ((src[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
308 src += s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
309 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
310 src = srcU; src2 = srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
311 for(j = 0; j < 9; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
312 for(i = 0; i < 9; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
313 src[i] = ((src[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
314 src2[i] = ((src2[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
315 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
316 src += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
317 src2 += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
318 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
319 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
320 /* if we deal with intensity compensation we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
321 if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
322 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
323 uint8_t *src, *src2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
324 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
325 src = srcY; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
326 for(j = 0; j < 17 + s->mspel*2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
327 for(i = 0; i < 17 + s->mspel*2; i++) src[i] = v->luty[src[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
328 src += s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
329 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
330 src = srcU; src2 = srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
331 for(j = 0; j < 9; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
332 for(i = 0; i < 9; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
333 src[i] = v->lutuv[src[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
334 src2[i] = v->lutuv[src2[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
335 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
336 src += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
337 src2 += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
338 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
339 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
340 srcY += s->mspel * (1 + s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
341 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
342 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
343 if(s->mspel) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
344 dxy = ((my & 3) << 2) | (mx & 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
345 dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
346 dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
347 srcY += s->linesize * 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
348 dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
349 dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
350 } else { // hpel mc - always used for luma |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
351 dxy = (my & 2) | ((mx & 2) >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
352 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
353 if(!v->rnd) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
354 dsp->put_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
355 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
356 dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
357 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
358 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
359 if(s->flags & CODEC_FLAG_GRAY) return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
360 /* Chroma MC always uses qpel bilinear */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
361 uvmx = (uvmx&3)<<1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
362 uvmy = (uvmy&3)<<1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
363 if(!v->rnd){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
364 dsp->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
365 dsp->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
366 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
367 dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
368 dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
369 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
370 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
371 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
372 /** Do motion compensation for 4-MV macroblock - luminance block |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
373 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
374 static void vc1_mc_4mv_luma(VC1Context *v, int n) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
375 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
376 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
377 DSPContext *dsp = &v->s.dsp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
378 uint8_t *srcY; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
379 int dxy, mx, my, src_x, src_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
380 int off; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
381 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
382 if(!v->s.last_picture.data[0])return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
383 mx = s->mv[0][n][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
384 my = s->mv[0][n][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
385 srcY = s->last_picture.data[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
386 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
387 off = s->linesize * 4 * (n&2) + (n&1) * 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
388 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
389 src_x = s->mb_x * 16 + (n&1) * 8 + (mx >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
390 src_y = s->mb_y * 16 + (n&2) * 4 + (my >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
391 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
392 if(v->profile != PROFILE_ADVANCED){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
393 src_x = av_clip( src_x, -16, s->mb_width * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
394 src_y = av_clip( src_y, -16, s->mb_height * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
395 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
396 src_x = av_clip( src_x, -17, s->avctx->coded_width); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
397 src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
398 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
399 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
400 srcY += src_y * s->linesize + src_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
401 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
402 if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
403 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 8 - s->mspel*2 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
404 || (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 8 - s->mspel*2){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
405 srcY -= s->mspel * (1 + s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
406 ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 9+s->mspel*2, 9+s->mspel*2, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
407 src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
408 srcY = s->edge_emu_buffer; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
409 /* if we deal with range reduction we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
410 if(v->rangeredfrm) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
411 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
412 uint8_t *src; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
413 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
414 src = srcY; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
415 for(j = 0; j < 9 + s->mspel*2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
416 for(i = 0; i < 9 + s->mspel*2; i++) src[i] = ((src[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
417 src += s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
418 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
419 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
420 /* if we deal with intensity compensation we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
421 if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
422 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
423 uint8_t *src; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
424 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
425 src = srcY; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
426 for(j = 0; j < 9 + s->mspel*2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
427 for(i = 0; i < 9 + s->mspel*2; i++) src[i] = v->luty[src[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
428 src += s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
429 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
430 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
431 srcY += s->mspel * (1 + s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
432 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
433 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
434 if(s->mspel) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
435 dxy = ((my & 3) << 2) | (mx & 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
436 dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
437 } else { // hpel mc - always used for luma |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
438 dxy = (my & 2) | ((mx & 2) >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
439 if(!v->rnd) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
440 dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
441 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
442 dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
443 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
444 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
445 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
446 static inline int median4(int a, int b, int c, int d) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
447 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
448 if(a < b) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
449 if(c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
450 else return (FFMIN(b, c) + FFMAX(a, d)) / 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
451 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
452 if(c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
453 else return (FFMIN(a, c) + FFMAX(b, d)) / 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
454 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
455 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
456 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
457 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
458 /** Do motion compensation for 4-MV macroblock - both chroma blocks |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
459 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
460 static void vc1_mc_4mv_chroma(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
461 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
462 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
463 DSPContext *dsp = &v->s.dsp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
464 uint8_t *srcU, *srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
465 int uvmx, uvmy, uvsrc_x, uvsrc_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
466 int i, idx, tx = 0, ty = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
467 int mvx[4], mvy[4], intra[4]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
468 static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
469 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
470 if(!v->s.last_picture.data[0])return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
471 if(s->flags & CODEC_FLAG_GRAY) return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
472 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
473 for(i = 0; i < 4; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
474 mvx[i] = s->mv[0][i][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
475 mvy[i] = s->mv[0][i][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
476 intra[i] = v->mb_type[0][s->block_index[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
477 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
478 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
479 /* calculate chroma MV vector from four luma MVs */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
480 idx = (intra[3] << 3) | (intra[2] << 2) | (intra[1] << 1) | intra[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
481 if(!idx) { // all blocks are inter |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
482 tx = median4(mvx[0], mvx[1], mvx[2], mvx[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
483 ty = median4(mvy[0], mvy[1], mvy[2], mvy[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
484 } else if(count[idx] == 1) { // 3 inter blocks |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
485 switch(idx) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
486 case 0x1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
487 tx = mid_pred(mvx[1], mvx[2], mvx[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
488 ty = mid_pred(mvy[1], mvy[2], mvy[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
489 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
490 case 0x2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
491 tx = mid_pred(mvx[0], mvx[2], mvx[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
492 ty = mid_pred(mvy[0], mvy[2], mvy[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
493 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
494 case 0x4: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
495 tx = mid_pred(mvx[0], mvx[1], mvx[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
496 ty = mid_pred(mvy[0], mvy[1], mvy[3]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
497 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
498 case 0x8: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
499 tx = mid_pred(mvx[0], mvx[1], mvx[2]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
500 ty = mid_pred(mvy[0], mvy[1], mvy[2]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
501 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
502 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
503 } else if(count[idx] == 2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
504 int t1 = 0, t2 = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
505 for(i=0; i<3;i++) if(!intra[i]) {t1 = i; break;} |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
506 for(i= t1+1; i<4; i++)if(!intra[i]) {t2 = i; break;} |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
507 tx = (mvx[t1] + mvx[t2]) / 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
508 ty = (mvy[t1] + mvy[t2]) / 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
509 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
510 s->current_picture.motion_val[1][s->block_index[0]][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
511 s->current_picture.motion_val[1][s->block_index[0]][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
512 return; //no need to do MC for inter blocks |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
513 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
514 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
515 s->current_picture.motion_val[1][s->block_index[0]][0] = tx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
516 s->current_picture.motion_val[1][s->block_index[0]][1] = ty; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
517 uvmx = (tx + ((tx&3) == 3)) >> 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
518 uvmy = (ty + ((ty&3) == 3)) >> 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
519 if(v->fastuvmc) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
520 uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
521 uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
522 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
523 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
524 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
525 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
526 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
527 if(v->profile != PROFILE_ADVANCED){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
528 uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
529 uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
530 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
531 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
532 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
533 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
534 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
535 srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
536 srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
537 if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
538 || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
539 || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - 9){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
540 ff_emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
541 uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
542 ff_emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, 8+1, 8+1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
543 uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
544 srcU = s->edge_emu_buffer; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
545 srcV = s->edge_emu_buffer + 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
546 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
547 /* if we deal with range reduction we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
548 if(v->rangeredfrm) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
549 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
550 uint8_t *src, *src2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
551 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
552 src = srcU; src2 = srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
553 for(j = 0; j < 9; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
554 for(i = 0; i < 9; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
555 src[i] = ((src[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
556 src2[i] = ((src2[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
557 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
558 src += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
559 src2 += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
560 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
561 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
562 /* if we deal with intensity compensation we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
563 if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
564 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
565 uint8_t *src, *src2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
566 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
567 src = srcU; src2 = srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
568 for(j = 0; j < 9; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
569 for(i = 0; i < 9; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
570 src[i] = v->lutuv[src[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
571 src2[i] = v->lutuv[src2[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
572 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
573 src += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
574 src2 += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
575 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
576 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
577 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
578 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
579 /* Chroma MC always uses qpel bilinear */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
580 uvmx = (uvmx&3)<<1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
581 uvmy = (uvmy&3)<<1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
582 if(!v->rnd){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
583 dsp->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
584 dsp->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
585 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
586 dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
587 dsp->put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
588 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
589 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
590 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
591 /***********************************************************************/ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
592 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
593 * @defgroup vc1block VC-1 Block-level functions |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
594 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
595 * @{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
596 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
597 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
598 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
599 * @def GET_MQUANT |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
600 * @brief Get macroblock-level quantizer scale |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
601 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
602 #define GET_MQUANT() \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
603 if (v->dquantfrm) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
604 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
605 int edges = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
606 if (v->dqprofile == DQPROFILE_ALL_MBS) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
607 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
608 if (v->dqbilevel) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
609 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
610 mquant = (get_bits1(gb)) ? v->altpq : v->pq; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
611 } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
612 else \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
613 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
614 mqdiff = get_bits(gb, 3); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
615 if (mqdiff != 7) mquant = v->pq + mqdiff; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
616 else mquant = get_bits(gb, 5); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
617 } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
618 } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
619 if(v->dqprofile == DQPROFILE_SINGLE_EDGE) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
620 edges = 1 << v->dqsbedge; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
621 else if(v->dqprofile == DQPROFILE_DOUBLE_EDGES) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
622 edges = (3 << v->dqsbedge) % 15; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
623 else if(v->dqprofile == DQPROFILE_FOUR_EDGES) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
624 edges = 15; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
625 if((edges&1) && !s->mb_x) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
626 mquant = v->altpq; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
627 if((edges&2) && s->first_slice_line) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
628 mquant = v->altpq; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
629 if((edges&4) && s->mb_x == (s->mb_width - 1)) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
630 mquant = v->altpq; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
631 if((edges&8) && s->mb_y == (s->mb_height - 1)) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
632 mquant = v->altpq; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
633 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
634 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
635 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
636 * @def GET_MVDATA(_dmv_x, _dmv_y) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
637 * @brief Get MV differentials |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
638 * @see MVDATA decoding from 8.3.5.2, p(1)20 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
639 * @param _dmv_x Horizontal differential for decoded MV |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
640 * @param _dmv_y Vertical differential for decoded MV |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
641 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
642 #define GET_MVDATA(_dmv_x, _dmv_y) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
643 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table,\ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
644 VC1_MV_DIFF_VLC_BITS, 2); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
645 if (index > 36) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
646 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
647 mb_has_coeffs = 1; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
648 index -= 37; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
649 } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
650 else mb_has_coeffs = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
651 s->mb_intra = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
652 if (!index) { _dmv_x = _dmv_y = 0; } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
653 else if (index == 35) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
654 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
655 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
656 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
657 } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
658 else if (index == 36) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
659 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
660 _dmv_x = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
661 _dmv_y = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
662 s->mb_intra = 1; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
663 } \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
664 else \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
665 { \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
666 index1 = index%6; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
667 if (!s->quarter_sample && index1 == 5) val = 1; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
668 else val = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
669 if(size_table[index1] - val > 0) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
670 val = get_bits(gb, size_table[index1] - val); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
671 else val = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
672 sign = 0 - (val&1); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
673 _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
674 \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
675 index1 = index/6; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
676 if (!s->quarter_sample && index1 == 5) val = 1; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
677 else val = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
678 if(size_table[index1] - val > 0) \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
679 val = get_bits(gb, size_table[index1] - val); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
680 else val = 0; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
681 sign = 0 - (val&1); \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
682 _dmv_y = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
683 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
684 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
685 /** Predict and set motion vector |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
686 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
687 static inline void vc1_pred_mv(MpegEncContext *s, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t* is_intra) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
688 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
689 int xy, wrap, off = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
690 int16_t *A, *B, *C; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
691 int px, py; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
692 int sum; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
693 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
694 /* scale MV difference to be quad-pel */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
695 dmv_x <<= 1 - s->quarter_sample; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
696 dmv_y <<= 1 - s->quarter_sample; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
697 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
698 wrap = s->b8_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
699 xy = s->block_index[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
700 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
701 if(s->mb_intra){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
702 s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
703 s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
704 s->current_picture.motion_val[1][xy][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
705 s->current_picture.motion_val[1][xy][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
706 if(mv1) { /* duplicate motion data for 1-MV block */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
707 s->current_picture.motion_val[0][xy + 1][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
708 s->current_picture.motion_val[0][xy + 1][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
709 s->current_picture.motion_val[0][xy + wrap][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
710 s->current_picture.motion_val[0][xy + wrap][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
711 s->current_picture.motion_val[0][xy + wrap + 1][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
712 s->current_picture.motion_val[0][xy + wrap + 1][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
713 s->current_picture.motion_val[1][xy + 1][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
714 s->current_picture.motion_val[1][xy + 1][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
715 s->current_picture.motion_val[1][xy + wrap][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
716 s->current_picture.motion_val[1][xy + wrap][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
717 s->current_picture.motion_val[1][xy + wrap + 1][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
718 s->current_picture.motion_val[1][xy + wrap + 1][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
719 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
720 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
721 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
722 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
723 C = s->current_picture.motion_val[0][xy - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
724 A = s->current_picture.motion_val[0][xy - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
725 if(mv1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
726 off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
727 else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
728 //in 4-MV mode different blocks have different B predictor position |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
729 switch(n){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
730 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
731 off = (s->mb_x > 0) ? -1 : 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
732 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
733 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
734 off = (s->mb_x == (s->mb_width - 1)) ? -1 : 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
735 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
736 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
737 off = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
738 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
739 case 3: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
740 off = -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
741 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
742 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
743 B = s->current_picture.motion_val[0][xy - wrap + off]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
744 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
745 if(!s->first_slice_line || (n==2 || n==3)) { // predictor A is not out of bounds |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
746 if(s->mb_width == 1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
747 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
748 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
749 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
750 px = mid_pred(A[0], B[0], C[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
751 py = mid_pred(A[1], B[1], C[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
752 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
753 } else if(s->mb_x || (n==1 || n==3)) { // predictor C is not out of bounds |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
754 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
755 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
756 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
757 px = py = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
758 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
759 /* Pullback MV as specified in 8.3.5.3.4 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
760 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
761 int qx, qy, X, Y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
762 qx = (s->mb_x << 6) + ((n==1 || n==3) ? 32 : 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
763 qy = (s->mb_y << 6) + ((n==2 || n==3) ? 32 : 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
764 X = (s->mb_width << 6) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
765 Y = (s->mb_height << 6) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
766 if(mv1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
767 if(qx + px < -60) px = -60 - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
768 if(qy + py < -60) py = -60 - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
769 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
770 if(qx + px < -28) px = -28 - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
771 if(qy + py < -28) py = -28 - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
772 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
773 if(qx + px > X) px = X - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
774 if(qy + py > Y) py = Y - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
775 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
776 /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
777 if((!s->first_slice_line || (n==2 || n==3)) && (s->mb_x || (n==1 || n==3))) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
778 if(is_intra[xy - wrap]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
779 sum = FFABS(px) + FFABS(py); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
780 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
781 sum = FFABS(px - A[0]) + FFABS(py - A[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
782 if(sum > 32) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
783 if(get_bits1(&s->gb)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
784 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
785 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
786 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
787 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
788 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
789 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
790 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
791 if(is_intra[xy - 1]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
792 sum = FFABS(px) + FFABS(py); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
793 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
794 sum = FFABS(px - C[0]) + FFABS(py - C[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
795 if(sum > 32) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
796 if(get_bits1(&s->gb)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
797 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
798 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
799 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
800 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
801 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
802 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
803 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
804 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
805 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
806 /* store MV using signed modulus of MV range defined in 4.11 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
807 s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
808 s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
809 if(mv1) { /* duplicate motion data for 1-MV block */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
810 s->current_picture.motion_val[0][xy + 1][0] = s->current_picture.motion_val[0][xy][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
811 s->current_picture.motion_val[0][xy + 1][1] = s->current_picture.motion_val[0][xy][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
812 s->current_picture.motion_val[0][xy + wrap][0] = s->current_picture.motion_val[0][xy][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
813 s->current_picture.motion_val[0][xy + wrap][1] = s->current_picture.motion_val[0][xy][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
814 s->current_picture.motion_val[0][xy + wrap + 1][0] = s->current_picture.motion_val[0][xy][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
815 s->current_picture.motion_val[0][xy + wrap + 1][1] = s->current_picture.motion_val[0][xy][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
816 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
817 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
818 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
819 /** Motion compensation for direct or interpolated blocks in B-frames |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
820 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
821 static void vc1_interp_mc(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
822 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
823 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
824 DSPContext *dsp = &v->s.dsp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
825 uint8_t *srcY, *srcU, *srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
826 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
827 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
828 if(!v->s.next_picture.data[0])return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
829 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
830 mx = s->mv[1][0][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
831 my = s->mv[1][0][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
832 uvmx = (mx + ((mx & 3) == 3)) >> 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
833 uvmy = (my + ((my & 3) == 3)) >> 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
834 if(v->fastuvmc) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
835 uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
836 uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
837 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
838 srcY = s->next_picture.data[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
839 srcU = s->next_picture.data[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
840 srcV = s->next_picture.data[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
841 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
842 src_x = s->mb_x * 16 + (mx >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
843 src_y = s->mb_y * 16 + (my >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
844 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
845 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
846 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
847 if(v->profile != PROFILE_ADVANCED){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
848 src_x = av_clip( src_x, -16, s->mb_width * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
849 src_y = av_clip( src_y, -16, s->mb_height * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
850 uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
851 uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
852 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
853 src_x = av_clip( src_x, -17, s->avctx->coded_width); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
854 src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
855 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
856 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
857 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
858 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
859 srcY += src_y * s->linesize + src_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
860 srcU += uvsrc_y * s->uvlinesize + uvsrc_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
861 srcV += uvsrc_y * s->uvlinesize + uvsrc_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
862 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
863 /* for grayscale we should not try to read from unknown area */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
864 if(s->flags & CODEC_FLAG_GRAY) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
865 srcU = s->edge_emu_buffer + 18 * s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
866 srcV = s->edge_emu_buffer + 18 * s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
867 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
868 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
869 if(v->rangeredfrm |
9881
c69559e9f6c3
Edge emulation should be used in B-frame MC in mspel mode with
kostya
parents:
9863
diff
changeset
|
870 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel*3 |
c69559e9f6c3
Edge emulation should be used in B-frame MC in mspel mode with
kostya
parents:
9863
diff
changeset
|
871 || (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 16 - s->mspel*3){ |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
872 uint8_t *uvbuf= s->edge_emu_buffer + 19 * s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
873 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
874 srcY -= s->mspel * (1 + s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
875 ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
876 src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
877 srcY = s->edge_emu_buffer; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
878 ff_emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
879 uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
880 ff_emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
881 uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
882 srcU = uvbuf; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
883 srcV = uvbuf + 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
884 /* if we deal with range reduction we need to scale source blocks */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
885 if(v->rangeredfrm) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
886 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
887 uint8_t *src, *src2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
888 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
889 src = srcY; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
890 for(j = 0; j < 17 + s->mspel*2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
891 for(i = 0; i < 17 + s->mspel*2; i++) src[i] = ((src[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
892 src += s->linesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
893 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
894 src = srcU; src2 = srcV; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
895 for(j = 0; j < 9; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
896 for(i = 0; i < 9; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
897 src[i] = ((src[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
898 src2[i] = ((src2[i] - 128) >> 1) + 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
899 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
900 src += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
901 src2 += s->uvlinesize; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
902 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
903 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
904 srcY += s->mspel * (1 + s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
905 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
906 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
907 if(s->mspel) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
908 dxy = ((my & 3) << 2) | (mx & 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
909 dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
910 dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
911 srcY += s->linesize * 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
912 dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
913 dsp->avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
914 } else { // hpel mc |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
915 dxy = (my & 2) | ((mx & 2) >> 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
916 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
917 if(!v->rnd) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
918 dsp->avg_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
919 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
920 dsp->avg_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
921 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
922 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
923 if(s->flags & CODEC_FLAG_GRAY) return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
924 /* Chroma MC always uses qpel blilinear */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
925 uvmx = (uvmx&3)<<1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
926 uvmy = (uvmy&3)<<1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
927 if(!v->rnd){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
928 dsp->avg_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
929 dsp->avg_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
930 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
931 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
932 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
933 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
934 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
935 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
936 static av_always_inline int scale_mv(int value, int bfrac, int inv, int qs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
937 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
938 int n = bfrac; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
939 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
940 #if B_FRACTION_DEN==256 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
941 if(inv) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
942 n -= 256; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
943 if(!qs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
944 return 2 * ((value * n + 255) >> 9); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
945 return (value * n + 128) >> 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
946 #else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
947 if(inv) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
948 n -= B_FRACTION_DEN; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
949 if(!qs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
950 return 2 * ((value * n + B_FRACTION_DEN - 1) / (2 * B_FRACTION_DEN)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
951 return (value * n + B_FRACTION_DEN/2) / B_FRACTION_DEN; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
952 #endif |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
953 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
954 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
955 /** Reconstruct motion vector for B-frame and do motion compensation |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
956 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
957 static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mode) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
958 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
959 if(v->use_ic) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
960 v->mv_mode2 = v->mv_mode; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
961 v->mv_mode = MV_PMODE_INTENSITY_COMP; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
962 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
963 if(direct) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
964 vc1_mc_1mv(v, 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
965 vc1_interp_mc(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
966 if(v->use_ic) v->mv_mode = v->mv_mode2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
967 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
968 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
969 if(mode == BMV_TYPE_INTERPOLATED) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
970 vc1_mc_1mv(v, 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
971 vc1_interp_mc(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
972 if(v->use_ic) v->mv_mode = v->mv_mode2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
973 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
974 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
975 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
976 if(v->use_ic && (mode == BMV_TYPE_BACKWARD)) v->mv_mode = v->mv_mode2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
977 vc1_mc_1mv(v, (mode == BMV_TYPE_BACKWARD)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
978 if(v->use_ic) v->mv_mode = v->mv_mode2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
979 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
980 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
981 static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
982 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
983 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
984 int xy, wrap, off = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
985 int16_t *A, *B, *C; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
986 int px, py; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
987 int sum; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
988 int r_x, r_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
989 const uint8_t *is_intra = v->mb_type[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
990 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
991 r_x = v->range_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
992 r_y = v->range_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
993 /* scale MV difference to be quad-pel */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
994 dmv_x[0] <<= 1 - s->quarter_sample; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
995 dmv_y[0] <<= 1 - s->quarter_sample; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
996 dmv_x[1] <<= 1 - s->quarter_sample; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
997 dmv_y[1] <<= 1 - s->quarter_sample; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
998 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
999 wrap = s->b8_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1000 xy = s->block_index[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1001 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1002 if(s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1003 s->current_picture.motion_val[0][xy][0] = |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1004 s->current_picture.motion_val[0][xy][1] = |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1005 s->current_picture.motion_val[1][xy][0] = |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1006 s->current_picture.motion_val[1][xy][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1007 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1008 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1009 s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1010 s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1011 s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1012 s->mv[1][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1013 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1014 /* Pullback predicted motion vectors as specified in 8.4.5.4 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1015 s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1016 s->mv[0][0][1] = av_clip(s->mv[0][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1017 s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1018 s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1019 if(direct) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1020 s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1021 s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1022 s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1023 s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1024 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1025 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1026 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1027 if((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1028 C = s->current_picture.motion_val[0][xy - 2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1029 A = s->current_picture.motion_val[0][xy - wrap*2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1030 off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1031 B = s->current_picture.motion_val[0][xy - wrap*2 + off]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1032 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1033 if(!s->mb_x) C[0] = C[1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1034 if(!s->first_slice_line) { // predictor A is not out of bounds |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1035 if(s->mb_width == 1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1036 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1037 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1038 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1039 px = mid_pred(A[0], B[0], C[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1040 py = mid_pred(A[1], B[1], C[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1041 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1042 } else if(s->mb_x) { // predictor C is not out of bounds |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1043 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1044 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1045 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1046 px = py = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1047 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1048 /* Pullback MV as specified in 8.3.5.3.4 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1049 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1050 int qx, qy, X, Y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1051 if(v->profile < PROFILE_ADVANCED) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1052 qx = (s->mb_x << 5); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1053 qy = (s->mb_y << 5); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1054 X = (s->mb_width << 5) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1055 Y = (s->mb_height << 5) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1056 if(qx + px < -28) px = -28 - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1057 if(qy + py < -28) py = -28 - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1058 if(qx + px > X) px = X - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1059 if(qy + py > Y) py = Y - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1060 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1061 qx = (s->mb_x << 6); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1062 qy = (s->mb_y << 6); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1063 X = (s->mb_width << 6) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1064 Y = (s->mb_height << 6) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1065 if(qx + px < -60) px = -60 - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1066 if(qy + py < -60) py = -60 - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1067 if(qx + px > X) px = X - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1068 if(qy + py > Y) py = Y - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1069 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1070 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1071 /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1072 if(0 && !s->first_slice_line && s->mb_x) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1073 if(is_intra[xy - wrap]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1074 sum = FFABS(px) + FFABS(py); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1075 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1076 sum = FFABS(px - A[0]) + FFABS(py - A[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1077 if(sum > 32) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1078 if(get_bits1(&s->gb)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1079 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1080 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1081 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1082 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1083 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1084 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1085 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1086 if(is_intra[xy - 2]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1087 sum = FFABS(px) + FFABS(py); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1088 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1089 sum = FFABS(px - C[0]) + FFABS(py - C[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1090 if(sum > 32) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1091 if(get_bits1(&s->gb)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1092 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1093 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1094 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1095 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1096 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1097 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1098 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1099 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1100 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1101 /* store MV using signed modulus of MV range defined in 4.11 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1102 s->mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1103 s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1104 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1105 if((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1106 C = s->current_picture.motion_val[1][xy - 2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1107 A = s->current_picture.motion_val[1][xy - wrap*2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1108 off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1109 B = s->current_picture.motion_val[1][xy - wrap*2 + off]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1110 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1111 if(!s->mb_x) C[0] = C[1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1112 if(!s->first_slice_line) { // predictor A is not out of bounds |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1113 if(s->mb_width == 1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1114 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1115 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1116 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1117 px = mid_pred(A[0], B[0], C[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1118 py = mid_pred(A[1], B[1], C[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1119 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1120 } else if(s->mb_x) { // predictor C is not out of bounds |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1121 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1122 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1123 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1124 px = py = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1125 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1126 /* Pullback MV as specified in 8.3.5.3.4 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1127 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1128 int qx, qy, X, Y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1129 if(v->profile < PROFILE_ADVANCED) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1130 qx = (s->mb_x << 5); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1131 qy = (s->mb_y << 5); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1132 X = (s->mb_width << 5) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1133 Y = (s->mb_height << 5) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1134 if(qx + px < -28) px = -28 - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1135 if(qy + py < -28) py = -28 - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1136 if(qx + px > X) px = X - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1137 if(qy + py > Y) py = Y - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1138 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1139 qx = (s->mb_x << 6); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1140 qy = (s->mb_y << 6); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1141 X = (s->mb_width << 6) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1142 Y = (s->mb_height << 6) - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1143 if(qx + px < -60) px = -60 - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1144 if(qy + py < -60) py = -60 - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1145 if(qx + px > X) px = X - qx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1146 if(qy + py > Y) py = Y - qy; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1147 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1148 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1149 /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1150 if(0 && !s->first_slice_line && s->mb_x) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1151 if(is_intra[xy - wrap]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1152 sum = FFABS(px) + FFABS(py); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1153 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1154 sum = FFABS(px - A[0]) + FFABS(py - A[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1155 if(sum > 32) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1156 if(get_bits1(&s->gb)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1157 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1158 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1159 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1160 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1161 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1162 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1163 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1164 if(is_intra[xy - 2]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1165 sum = FFABS(px) + FFABS(py); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1166 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1167 sum = FFABS(px - C[0]) + FFABS(py - C[1]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1168 if(sum > 32) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1169 if(get_bits1(&s->gb)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1170 px = A[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1171 py = A[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1172 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1173 px = C[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1174 py = C[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1175 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1176 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1177 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1178 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1179 /* store MV using signed modulus of MV range defined in 4.11 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1180 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1181 s->mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1182 s->mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1183 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1184 s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1185 s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1186 s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1187 s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1188 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1189 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1190 /** Get predicted DC value for I-frames only |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1191 * prediction dir: left=0, top=1 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1192 * @param s MpegEncContext |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1193 * @param overlap flag indicating that overlap filtering is used |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1194 * @param pq integer part of picture quantizer |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1195 * @param[in] n block index in the current MB |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1196 * @param dc_val_ptr Pointer to DC predictor |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1197 * @param dir_ptr Prediction direction for use in AC prediction |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1198 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1199 static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1200 int16_t **dc_val_ptr, int *dir_ptr) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1201 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1202 int a, b, c, wrap, pred, scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1203 int16_t *dc_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1204 static const uint16_t dcpred[32] = { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1205 -1, 1024, 512, 341, 256, 205, 171, 146, 128, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1206 114, 102, 93, 85, 79, 73, 68, 64, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1207 60, 57, 54, 51, 49, 47, 45, 43, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1208 41, 39, 38, 37, 35, 34, 33 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1209 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1210 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1211 /* find prediction - wmv3_dc_scale always used here in fact */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1212 if (n < 4) scale = s->y_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1213 else scale = s->c_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1214 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1215 wrap = s->block_wrap[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1216 dc_val= s->dc_val[0] + s->block_index[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1217 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1218 /* B A |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1219 * C X |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1220 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1221 c = dc_val[ - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1222 b = dc_val[ - 1 - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1223 a = dc_val[ - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1224 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1225 if (pq < 9 || !overlap) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1226 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1227 /* Set outer values */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1228 if (s->first_slice_line && (n!=2 && n!=3)) b=a=dcpred[scale]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1229 if (s->mb_x == 0 && (n!=1 && n!=3)) b=c=dcpred[scale]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1230 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1231 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1232 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1233 /* Set outer values */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1234 if (s->first_slice_line && (n!=2 && n!=3)) b=a=0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1235 if (s->mb_x == 0 && (n!=1 && n!=3)) b=c=0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1236 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1237 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1238 if (abs(a - b) <= abs(b - c)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1239 pred = c; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1240 *dir_ptr = 1;//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1241 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1242 pred = a; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1243 *dir_ptr = 0;//top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1244 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1245 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1246 /* update predictor */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1247 *dc_val_ptr = &dc_val[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1248 return pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1249 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1250 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1251 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1252 /** Get predicted DC value |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1253 * prediction dir: left=0, top=1 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1254 * @param s MpegEncContext |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1255 * @param overlap flag indicating that overlap filtering is used |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1256 * @param pq integer part of picture quantizer |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1257 * @param[in] n block index in the current MB |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1258 * @param a_avail flag indicating top block availability |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1259 * @param c_avail flag indicating left block availability |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1260 * @param dc_val_ptr Pointer to DC predictor |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1261 * @param dir_ptr Prediction direction for use in AC prediction |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1262 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1263 static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1264 int a_avail, int c_avail, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1265 int16_t **dc_val_ptr, int *dir_ptr) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1266 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1267 int a, b, c, wrap, pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1268 int16_t *dc_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1269 int mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1270 int q1, q2 = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1271 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1272 wrap = s->block_wrap[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1273 dc_val= s->dc_val[0] + s->block_index[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1274 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1275 /* B A |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1276 * C X |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1277 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1278 c = dc_val[ - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1279 b = dc_val[ - 1 - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1280 a = dc_val[ - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1281 /* scale predictors if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1282 q1 = s->current_picture.qscale_table[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1283 if(c_avail && (n!= 1 && n!=3)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1284 q2 = s->current_picture.qscale_table[mb_pos - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1285 if(q2 && q2 != q1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1286 c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1287 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1288 if(a_avail && (n!= 2 && n!=3)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1289 q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1290 if(q2 && q2 != q1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1291 a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1292 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1293 if(a_avail && c_avail && (n!=3)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1294 int off = mb_pos; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1295 if(n != 1) off--; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1296 if(n != 2) off -= s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1297 q2 = s->current_picture.qscale_table[off]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1298 if(q2 && q2 != q1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1299 b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1300 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1301 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1302 if(a_avail && c_avail) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1303 if(abs(a - b) <= abs(b - c)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1304 pred = c; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1305 *dir_ptr = 1;//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1306 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1307 pred = a; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1308 *dir_ptr = 0;//top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1309 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1310 } else if(a_avail) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1311 pred = a; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1312 *dir_ptr = 0;//top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1313 } else if(c_avail) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1314 pred = c; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1315 *dir_ptr = 1;//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1316 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1317 pred = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1318 *dir_ptr = 1;//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1319 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1320 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1321 /* update predictor */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1322 *dc_val_ptr = &dc_val[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1323 return pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1324 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1325 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1326 /** @} */ // Block group |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1327 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1328 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1329 * @defgroup vc1_std_mb VC1 Macroblock-level functions in Simple/Main Profiles |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1330 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1331 * @{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1332 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1333 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1334 static inline int vc1_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1335 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1336 int xy, wrap, pred, a, b, c; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1337 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1338 xy = s->block_index[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1339 wrap = s->b8_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1340 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1341 /* B C |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1342 * A X |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1343 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1344 a = s->coded_block[xy - 1 ]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1345 b = s->coded_block[xy - 1 - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1346 c = s->coded_block[xy - wrap]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1347 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1348 if (b == c) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1349 pred = a; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1350 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1351 pred = c; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1352 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1353 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1354 /* store value */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1355 *coded_block_ptr = &s->coded_block[xy]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1356 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1357 return pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1358 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1359 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1360 /** |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1361 * Decode one AC coefficient |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1362 * @param v The VC1 context |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1363 * @param last Last coefficient |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1364 * @param skip How much zero coefficients to skip |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1365 * @param value Decoded AC coefficient value |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1366 * @param codingset set of VLC to decode data |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1367 * @see 8.1.3.4 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1368 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1369 static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1370 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1371 GetBitContext *gb = &v->s.gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1372 int index, escape, run = 0, level = 0, lst = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1373 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1374 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1375 if (index != vc1_ac_sizes[codingset] - 1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1376 run = vc1_index_decode_table[codingset][index][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1377 level = vc1_index_decode_table[codingset][index][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1378 lst = index >= vc1_last_decode_table[codingset]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1379 if(get_bits1(gb)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1380 level = -level; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1381 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1382 escape = decode210(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1383 if (escape != 2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1384 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1385 run = vc1_index_decode_table[codingset][index][0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1386 level = vc1_index_decode_table[codingset][index][1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1387 lst = index >= vc1_last_decode_table[codingset]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1388 if(escape == 0) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1389 if(lst) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1390 level += vc1_last_delta_level_table[codingset][run]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1391 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1392 level += vc1_delta_level_table[codingset][run]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1393 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1394 if(lst) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1395 run += vc1_last_delta_run_table[codingset][level] + 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1396 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1397 run += vc1_delta_run_table[codingset][level] + 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1398 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1399 if(get_bits1(gb)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1400 level = -level; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1401 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1402 int sign; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1403 lst = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1404 if(v->s.esc3_level_length == 0) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1405 if(v->pq < 8 || v->dquantfrm) { // table 59 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1406 v->s.esc3_level_length = get_bits(gb, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1407 if(!v->s.esc3_level_length) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1408 v->s.esc3_level_length = get_bits(gb, 2) + 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1409 } else { //table 60 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1410 v->s.esc3_level_length = get_unary(gb, 1, 6) + 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1411 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1412 v->s.esc3_run_length = 3 + get_bits(gb, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1413 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1414 run = get_bits(gb, v->s.esc3_run_length); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1415 sign = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1416 level = get_bits(gb, v->s.esc3_level_length); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1417 if(sign) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1418 level = -level; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1419 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1420 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1421 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1422 *last = lst; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1423 *skip = run; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1424 *value = level; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1425 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1426 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1427 /** Decode intra block in intra frames - should be faster than decode_intra_block |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1428 * @param v VC1Context |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1429 * @param block block to decode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1430 * @param[in] n subblock index |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1431 * @param coded are AC coeffs present or not |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1432 * @param codingset set of VLC to decode data |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1433 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1434 static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1435 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1436 GetBitContext *gb = &v->s.gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1437 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1438 int dc_pred_dir = 0; /* Direction of the DC prediction used */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1439 int i; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1440 int16_t *dc_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1441 int16_t *ac_val, *ac_val2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1442 int dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1443 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1444 /* Get DC differential */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1445 if (n < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1446 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1447 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1448 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1449 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1450 if (dcdiff < 0){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1451 av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1452 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1453 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1454 if (dcdiff) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1455 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1456 if (dcdiff == 119 /* ESC index value */) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1457 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1458 /* TODO: Optimize */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1459 if (v->pq == 1) dcdiff = get_bits(gb, 10); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1460 else if (v->pq == 2) dcdiff = get_bits(gb, 9); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1461 else dcdiff = get_bits(gb, 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1462 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1463 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1464 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1465 if (v->pq == 1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1466 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1467 else if (v->pq == 2) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1468 dcdiff = (dcdiff<<1) + get_bits1(gb) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1469 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1470 if (get_bits1(gb)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1471 dcdiff = -dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1472 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1473 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1474 /* Prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1475 dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1476 *dc_val = dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1477 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1478 /* Store the quantized DC coeff, used for prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1479 if (n < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1480 block[0] = dcdiff * s->y_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1481 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1482 block[0] = dcdiff * s->c_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1483 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1484 /* Skip ? */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1485 if (!coded) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1486 goto not_coded; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1487 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1488 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1489 //AC Decoding |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1490 i = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1491 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1492 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1493 int last = 0, skip, value; |
11982
669bf7f6c986
Change type of zz_table to uint8_t to match the scantables it points to.
reimar
parents:
11796
diff
changeset
|
1494 const uint8_t *zz_table; |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1495 int scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1496 int k; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1497 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1498 scale = v->pq * 2 + v->halfpq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1499 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1500 if(v->s.ac_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1501 if(!dc_pred_dir) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1502 zz_table = wmv1_scantable[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1503 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1504 zz_table = wmv1_scantable[3]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1505 } else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1506 zz_table = wmv1_scantable[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1507 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1508 ac_val = s->ac_val[0][0] + s->block_index[n] * 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1509 ac_val2 = ac_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1510 if(dc_pred_dir) //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1511 ac_val -= 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1512 else //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1513 ac_val -= 16 * s->block_wrap[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1514 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1515 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1516 vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1517 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1518 if(i > 63) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1519 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1520 block[zz_table[i++]] = value; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1521 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1522 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1523 /* apply AC prediction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1524 if(s->ac_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1525 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1526 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1527 block[k << 3] += ac_val[k]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1528 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1529 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1530 block[k] += ac_val[k + 8]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1531 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1532 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1533 /* save AC coeffs for further prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1534 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1535 ac_val2[k] = block[k << 3]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1536 ac_val2[k + 8] = block[k]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1537 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1538 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1539 /* scale AC coeffs */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1540 for(k = 1; k < 64; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1541 if(block[k]) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1542 block[k] *= scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1543 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1544 block[k] += (block[k] < 0) ? -v->pq : v->pq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1545 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1546 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1547 if(s->ac_pred) i = 63; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1548 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1549 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1550 not_coded: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1551 if(!coded) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1552 int k, scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1553 ac_val = s->ac_val[0][0] + s->block_index[n] * 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1554 ac_val2 = ac_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1555 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1556 i = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1557 scale = v->pq * 2 + v->halfpq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1558 memset(ac_val2, 0, 16 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1559 if(dc_pred_dir) {//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1560 ac_val -= 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1561 if(s->ac_pred) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1562 memcpy(ac_val2, ac_val, 8 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1563 } else {//top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1564 ac_val -= 16 * s->block_wrap[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1565 if(s->ac_pred) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1566 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1567 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1568 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1569 /* apply AC prediction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1570 if(s->ac_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1571 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1572 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1573 block[k << 3] = ac_val[k] * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1574 if(!v->pquantizer && block[k << 3]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1575 block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1576 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1577 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1578 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1579 block[k] = ac_val[k + 8] * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1580 if(!v->pquantizer && block[k]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1581 block[k] += (block[k] < 0) ? -v->pq : v->pq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1582 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1583 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1584 i = 63; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1585 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1586 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1587 s->block_last_index[n] = i; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1588 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1589 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1590 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1591 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1592 /** Decode intra block in intra frames - should be faster than decode_intra_block |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1593 * @param v VC1Context |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1594 * @param block block to decode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1595 * @param[in] n subblock number |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1596 * @param coded are AC coeffs present or not |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1597 * @param codingset set of VLC to decode data |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1598 * @param mquant quantizer value for this macroblock |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1599 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1600 static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset, int mquant) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1601 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1602 GetBitContext *gb = &v->s.gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1603 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1604 int dc_pred_dir = 0; /* Direction of the DC prediction used */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1605 int i; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1606 int16_t *dc_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1607 int16_t *ac_val, *ac_val2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1608 int dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1609 int a_avail = v->a_avail, c_avail = v->c_avail; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1610 int use_pred = s->ac_pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1611 int scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1612 int q1, q2 = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1613 int mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1614 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1615 /* Get DC differential */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1616 if (n < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1617 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1618 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1619 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1620 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1621 if (dcdiff < 0){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1622 av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1623 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1624 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1625 if (dcdiff) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1626 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1627 if (dcdiff == 119 /* ESC index value */) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1628 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1629 /* TODO: Optimize */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1630 if (mquant == 1) dcdiff = get_bits(gb, 10); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1631 else if (mquant == 2) dcdiff = get_bits(gb, 9); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1632 else dcdiff = get_bits(gb, 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1633 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1634 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1635 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1636 if (mquant == 1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1637 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1638 else if (mquant == 2) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1639 dcdiff = (dcdiff<<1) + get_bits1(gb) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1640 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1641 if (get_bits1(gb)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1642 dcdiff = -dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1643 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1644 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1645 /* Prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1646 dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1647 *dc_val = dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1648 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1649 /* Store the quantized DC coeff, used for prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1650 if (n < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1651 block[0] = dcdiff * s->y_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1652 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1653 block[0] = dcdiff * s->c_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1654 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1655 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1656 //AC Decoding |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1657 i = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1658 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1659 /* check if AC is needed at all */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1660 if(!a_avail && !c_avail) use_pred = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1661 ac_val = s->ac_val[0][0] + s->block_index[n] * 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1662 ac_val2 = ac_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1663 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1664 scale = mquant * 2 + ((mquant == v->pq) ? v->halfpq : 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1665 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1666 if(dc_pred_dir) //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1667 ac_val -= 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1668 else //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1669 ac_val -= 16 * s->block_wrap[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1670 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1671 q1 = s->current_picture.qscale_table[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1672 if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1673 if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1674 if(dc_pred_dir && n==1) q2 = q1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1675 if(!dc_pred_dir && n==2) q2 = q1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1676 if(n==3) q2 = q1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1677 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1678 if(coded) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1679 int last = 0, skip, value; |
11982
669bf7f6c986
Change type of zz_table to uint8_t to match the scantables it points to.
reimar
parents:
11796
diff
changeset
|
1680 const uint8_t *zz_table; |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1681 int k; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1682 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1683 if(v->s.ac_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1684 if(!dc_pred_dir) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1685 zz_table = wmv1_scantable[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1686 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1687 zz_table = wmv1_scantable[3]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1688 } else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1689 zz_table = wmv1_scantable[1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1690 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1691 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1692 vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1693 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1694 if(i > 63) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1695 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1696 block[zz_table[i++]] = value; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1697 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1698 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1699 /* apply AC prediction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1700 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1701 /* scale predictors if needed*/ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1702 if(q2 && q1!=q2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1703 q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1704 q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1705 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1706 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1707 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1708 block[k << 3] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1709 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1710 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1711 block[k] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1712 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1713 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1714 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1715 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1716 block[k << 3] += ac_val[k]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1717 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1718 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1719 block[k] += ac_val[k + 8]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1720 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1721 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1722 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1723 /* save AC coeffs for further prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1724 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1725 ac_val2[k] = block[k << 3]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1726 ac_val2[k + 8] = block[k]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1727 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1728 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1729 /* scale AC coeffs */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1730 for(k = 1; k < 64; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1731 if(block[k]) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1732 block[k] *= scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1733 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1734 block[k] += (block[k] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1735 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1736 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1737 if(use_pred) i = 63; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1738 } else { // no AC coeffs |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1739 int k; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1740 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1741 memset(ac_val2, 0, 16 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1742 if(dc_pred_dir) {//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1743 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1744 memcpy(ac_val2, ac_val, 8 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1745 if(q2 && q1!=q2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1746 q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1747 q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1748 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1749 ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1750 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1751 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1752 } else {//top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1753 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1754 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1755 if(q2 && q1!=q2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1756 q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1757 q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1758 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1759 ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1760 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1761 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1762 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1763 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1764 /* apply AC prediction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1765 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1766 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1767 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1768 block[k << 3] = ac_val2[k] * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1769 if(!v->pquantizer && block[k << 3]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1770 block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1771 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1772 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1773 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1774 block[k] = ac_val2[k + 8] * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1775 if(!v->pquantizer && block[k]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1776 block[k] += (block[k] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1777 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1778 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1779 i = 63; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1780 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1781 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1782 s->block_last_index[n] = i; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1783 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1784 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1785 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1786 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1787 /** Decode intra block in inter frames - more generic version than vc1_decode_i_block |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1788 * @param v VC1Context |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1789 * @param block block to decode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1790 * @param[in] n subblock index |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1791 * @param coded are AC coeffs present or not |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1792 * @param mquant block quantizer |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1793 * @param codingset set of VLC to decode data |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1794 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1795 static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1796 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1797 GetBitContext *gb = &v->s.gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1798 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1799 int dc_pred_dir = 0; /* Direction of the DC prediction used */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1800 int i; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1801 int16_t *dc_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1802 int16_t *ac_val, *ac_val2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1803 int dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1804 int mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1805 int a_avail = v->a_avail, c_avail = v->c_avail; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1806 int use_pred = s->ac_pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1807 int scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1808 int q1, q2 = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1809 |
9860
7e82083caab7
VC-1/WMV3 decoding: don't clear blocks unless they're actually used.
darkshikari
parents:
9859
diff
changeset
|
1810 s->dsp.clear_block(block); |
7e82083caab7
VC-1/WMV3 decoding: don't clear blocks unless they're actually used.
darkshikari
parents:
9859
diff
changeset
|
1811 |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1812 /* XXX: Guard against dumb values of mquant */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1813 mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant ); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1814 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1815 /* Set DC scale - y and c use the same */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1816 s->y_dc_scale = s->y_dc_scale_table[mquant]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1817 s->c_dc_scale = s->c_dc_scale_table[mquant]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1818 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1819 /* Get DC differential */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1820 if (n < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1821 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1822 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1823 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1824 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1825 if (dcdiff < 0){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1826 av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1827 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1828 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1829 if (dcdiff) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1830 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1831 if (dcdiff == 119 /* ESC index value */) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1832 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1833 /* TODO: Optimize */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1834 if (mquant == 1) dcdiff = get_bits(gb, 10); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1835 else if (mquant == 2) dcdiff = get_bits(gb, 9); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1836 else dcdiff = get_bits(gb, 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1837 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1838 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1839 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1840 if (mquant == 1) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1841 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1842 else if (mquant == 2) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1843 dcdiff = (dcdiff<<1) + get_bits1(gb) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1844 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1845 if (get_bits1(gb)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1846 dcdiff = -dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1847 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1848 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1849 /* Prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1850 dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1851 *dc_val = dcdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1852 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1853 /* Store the quantized DC coeff, used for prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1854 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1855 if (n < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1856 block[0] = dcdiff * s->y_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1857 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1858 block[0] = dcdiff * s->c_dc_scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1859 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1860 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1861 //AC Decoding |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1862 i = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1863 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1864 /* check if AC is needed at all and adjust direction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1865 if(!a_avail) dc_pred_dir = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1866 if(!c_avail) dc_pred_dir = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1867 if(!a_avail && !c_avail) use_pred = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1868 ac_val = s->ac_val[0][0] + s->block_index[n] * 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1869 ac_val2 = ac_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1870 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1871 scale = mquant * 2 + v->halfpq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1872 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1873 if(dc_pred_dir) //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1874 ac_val -= 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1875 else //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1876 ac_val -= 16 * s->block_wrap[n]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1877 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1878 q1 = s->current_picture.qscale_table[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1879 if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1880 if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1881 if(dc_pred_dir && n==1) q2 = q1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1882 if(!dc_pred_dir && n==2) q2 = q1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1883 if(n==3) q2 = q1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1884 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1885 if(coded) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1886 int last = 0, skip, value; |
11982
669bf7f6c986
Change type of zz_table to uint8_t to match the scantables it points to.
reimar
parents:
11796
diff
changeset
|
1887 const uint8_t *zz_table; |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1888 int k; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1889 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1890 zz_table = wmv1_scantable[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1891 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1892 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1893 vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1894 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1895 if(i > 63) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1896 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1897 block[zz_table[i++]] = value; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1898 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1899 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1900 /* apply AC prediction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1901 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1902 /* scale predictors if needed*/ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1903 if(q2 && q1!=q2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1904 q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1905 q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1906 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1907 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1908 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1909 block[k << 3] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1910 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1911 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1912 block[k] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1913 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1914 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1915 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1916 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1917 block[k << 3] += ac_val[k]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1918 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1919 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1920 block[k] += ac_val[k + 8]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1921 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1922 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1923 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1924 /* save AC coeffs for further prediction */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1925 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1926 ac_val2[k] = block[k << 3]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1927 ac_val2[k + 8] = block[k]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1928 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1929 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1930 /* scale AC coeffs */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1931 for(k = 1; k < 64; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1932 if(block[k]) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1933 block[k] *= scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1934 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1935 block[k] += (block[k] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1936 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1937 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1938 if(use_pred) i = 63; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1939 } else { // no AC coeffs |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1940 int k; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1941 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1942 memset(ac_val2, 0, 16 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1943 if(dc_pred_dir) {//left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1944 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1945 memcpy(ac_val2, ac_val, 8 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1946 if(q2 && q1!=q2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1947 q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1948 q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1949 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1950 ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1951 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1952 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1953 } else {//top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1954 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1955 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1956 if(q2 && q1!=q2) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1957 q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1958 q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1959 for(k = 1; k < 8; k++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1960 ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1961 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1962 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1963 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1964 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1965 /* apply AC prediction if needed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1966 if(use_pred) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1967 if(dc_pred_dir) { //left |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1968 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1969 block[k << 3] = ac_val2[k] * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1970 if(!v->pquantizer && block[k << 3]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1971 block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1972 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1973 } else { //top |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1974 for(k = 1; k < 8; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1975 block[k] = ac_val2[k + 8] * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1976 if(!v->pquantizer && block[k]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1977 block[k] += (block[k] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1978 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1979 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1980 i = 63; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1981 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1982 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1983 s->block_last_index[n] = i; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1984 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1985 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1986 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1987 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1988 /** Decode P block |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1989 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1990 static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1991 uint8_t *dst, int linesize, int skip_block, int apply_filter, int cbp_top, int cbp_left) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1992 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1993 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1994 GetBitContext *gb = &s->gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1995 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1996 int subblkpat = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1997 int scale, off, idx, last, skip, value; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1998 int ttblk = ttmb & 7; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
1999 int pat = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2000 |
9860
7e82083caab7
VC-1/WMV3 decoding: don't clear blocks unless they're actually used.
darkshikari
parents:
9859
diff
changeset
|
2001 s->dsp.clear_block(block); |
7e82083caab7
VC-1/WMV3 decoding: don't clear blocks unless they're actually used.
darkshikari
parents:
9859
diff
changeset
|
2002 |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2003 if(ttmb == -1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2004 ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2005 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2006 if(ttblk == TT_4X4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2007 subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2008 } |
12127
9ba7d2a5b20a
Make WMV3 decoder print more errors when decoding beta WMV9 files.
kostya
parents:
11982
diff
changeset
|
2009 if((ttblk != TT_8X8 && ttblk != TT_4X4) |
9ba7d2a5b20a
Make WMV3 decoder print more errors when decoding beta WMV9 files.
kostya
parents:
11982
diff
changeset
|
2010 && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block)) |
9ba7d2a5b20a
Make WMV3 decoder print more errors when decoding beta WMV9 files.
kostya
parents:
11982
diff
changeset
|
2011 || (!v->res_rtm_flag && !first_block))) { |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2012 subblkpat = decode012(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2013 if(subblkpat) subblkpat ^= 3; //swap decoded pattern bits |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2014 if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) ttblk = TT_8X4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2015 if(ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) ttblk = TT_4X8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2016 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2017 scale = 2 * mquant + ((v->pq == mquant) ? v->halfpq : 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2018 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2019 // convert transforms like 8X4_TOP to generic TT and SUBBLKPAT |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2020 if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2021 subblkpat = 2 - (ttblk == TT_8X4_TOP); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2022 ttblk = TT_8X4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2023 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2024 if(ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2025 subblkpat = 2 - (ttblk == TT_4X8_LEFT); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2026 ttblk = TT_4X8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2027 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2028 switch(ttblk) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2029 case TT_8X8: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2030 pat = 0xF; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2031 i = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2032 last = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2033 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2034 vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2035 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2036 if(i > 63) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2037 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2038 idx = wmv1_scantable[0][i++]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2039 block[idx] = value * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2040 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2041 block[idx] += (block[idx] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2042 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2043 if(!skip_block){ |
9859
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2044 if(i==1) |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2045 s->dsp.vc1_inv_trans_8x8_dc(dst, linesize, block); |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2046 else{ |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2047 s->dsp.vc1_inv_trans_8x8(block); |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2048 s->dsp.add_pixels_clamped(block, dst, linesize); |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2049 } |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2050 if(apply_filter && cbp_top & 0xC) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2051 s->dsp.vc1_v_loop_filter8(dst, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2052 if(apply_filter && cbp_left & 0xA) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2053 s->dsp.vc1_h_loop_filter8(dst, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2054 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2055 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2056 case TT_4X4: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2057 pat = ~subblkpat & 0xF; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2058 for(j = 0; j < 4; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2059 last = subblkpat & (1 << (3 - j)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2060 i = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2061 off = (j & 1) * 4 + (j & 2) * 16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2062 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2063 vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2064 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2065 if(i > 15) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2066 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2067 idx = ff_vc1_simple_progressive_4x4_zz[i++]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2068 block[idx + off] = value * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2069 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2070 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2071 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2072 if(!(subblkpat & (1 << (3 - j))) && !skip_block){ |
9859
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2073 if(i==1) |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2074 s->dsp.vc1_inv_trans_4x4_dc(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2075 else |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2076 s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2077 if(apply_filter && (j&2 ? pat & (1<<(j-2)) : (cbp_top & (1 << (j + 2))))) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2078 s->dsp.vc1_v_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2079 if(apply_filter && (j&1 ? pat & (1<<(j-1)) : (cbp_left & (1 << (j + 1))))) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2080 s->dsp.vc1_h_loop_filter4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2081 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2082 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2083 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2084 case TT_8X4: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2085 pat = ~((subblkpat & 2)*6 + (subblkpat & 1)*3) & 0xF; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2086 for(j = 0; j < 2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2087 last = subblkpat & (1 << (1 - j)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2088 i = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2089 off = j * 32; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2090 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2091 vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2092 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2093 if(i > 31) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2094 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2095 idx = v->zz_8x4[i++]+off; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2096 block[idx] = value * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2097 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2098 block[idx] += (block[idx] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2099 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2100 if(!(subblkpat & (1 << (1 - j))) && !skip_block){ |
9859
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2101 if(i==1) |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2102 s->dsp.vc1_inv_trans_8x4_dc(dst + j*4*linesize, linesize, block + off); |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2103 else |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2104 s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2105 if(apply_filter && j ? pat & 0x3 : (cbp_top & 0xC)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2106 s->dsp.vc1_v_loop_filter8(dst + j*4*linesize, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2107 if(apply_filter && cbp_left & (2 << j)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2108 s->dsp.vc1_h_loop_filter4(dst + j*4*linesize, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2109 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2110 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2111 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2112 case TT_4X8: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2113 pat = ~(subblkpat*5) & 0xF; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2114 for(j = 0; j < 2; j++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2115 last = subblkpat & (1 << (1 - j)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2116 i = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2117 off = j * 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2118 while (!last) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2119 vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2120 i += skip; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2121 if(i > 31) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2122 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2123 idx = v->zz_4x8[i++]+off; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2124 block[idx] = value * scale; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2125 if(!v->pquantizer) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2126 block[idx] += (block[idx] < 0) ? -mquant : mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2127 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2128 if(!(subblkpat & (1 << (1 - j))) && !skip_block){ |
9859
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2129 if(i==1) |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2130 s->dsp.vc1_inv_trans_4x8_dc(dst + j*4, linesize, block + off); |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2131 else |
7a116de63777
idct_dc for VC-1/WMV3 decoder; ~11% faster decoding overall.
darkshikari
parents:
9836
diff
changeset
|
2132 s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2133 if(apply_filter && cbp_top & (2 << j)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2134 s->dsp.vc1_v_loop_filter4(dst + j*4, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2135 if(apply_filter && j ? pat & 0x5 : (cbp_left & 0xA)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2136 s->dsp.vc1_h_loop_filter8(dst + j*4, linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2137 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2138 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2139 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2140 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2141 return pat; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2142 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2143 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2144 /** @} */ // Macroblock group |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2145 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2146 static const int size_table [6] = { 0, 2, 3, 4, 5, 8 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2147 static const int offset_table[6] = { 0, 1, 3, 7, 15, 31 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2148 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2149 /** Decode one P-frame MB (in Simple/Main profile) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2150 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2151 static int vc1_decode_p_mb(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2152 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2153 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2154 GetBitContext *gb = &s->gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2155 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2156 int mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2157 int cbp; /* cbp decoding stuff */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2158 int mqdiff, mquant; /* MB quantization */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2159 int ttmb = v->ttfrm; /* MB Transform type */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2160 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2161 int mb_has_coeffs = 1; /* last_flag */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2162 int dmv_x, dmv_y; /* Differential MV components */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2163 int index, index1; /* LUT indexes */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2164 int val, sign; /* temp values */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2165 int first_block = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2166 int dst_idx, off; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2167 int skipped, fourmv; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2168 int block_cbp = 0, pat; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2169 int apply_loop_filter; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2170 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2171 mquant = v->pq; /* Loosy initialization */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2172 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2173 if (v->mv_type_is_raw) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2174 fourmv = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2175 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2176 fourmv = v->mv_type_mb_plane[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2177 if (v->skip_is_raw) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2178 skipped = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2179 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2180 skipped = v->s.mbskip_table[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2181 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2182 apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2183 if (!fourmv) /* 1MV mode */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2184 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2185 if (!skipped) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2186 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2187 GET_MVDATA(dmv_x, dmv_y); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2188 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2189 if (s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2190 s->current_picture.motion_val[1][s->block_index[0]][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2191 s->current_picture.motion_val[1][s->block_index[0]][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2192 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2193 s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2194 vc1_pred_mv(s, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2195 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2196 /* FIXME Set DC val for inter block ? */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2197 if (s->mb_intra && !mb_has_coeffs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2198 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2199 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2200 s->ac_pred = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2201 cbp = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2202 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2203 else if (mb_has_coeffs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2204 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2205 if (s->mb_intra) s->ac_pred = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2206 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2207 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2208 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2209 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2210 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2211 mquant = v->pq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2212 cbp = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2213 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2214 s->current_picture.qscale_table[mb_pos] = mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2215 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2216 if (!v->ttmbf && !s->mb_intra && mb_has_coeffs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2217 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2218 VC1_TTMB_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2219 if(!s->mb_intra) vc1_mc_1mv(v, 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2220 dst_idx = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2221 for (i=0; i<6; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2222 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2223 s->dc_val[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2224 dst_idx += i >> 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2225 val = ((cbp >> (5 - i)) & 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2226 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2227 v->mb_type[0][s->block_index[i]] = s->mb_intra; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2228 if(s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2229 /* check if prediction blocks A and C are available */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2230 v->a_avail = v->c_avail = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2231 if(i == 2 || i == 3 || !s->first_slice_line) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2232 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2233 if(i == 1 || i == 3 || s->mb_x) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2234 v->c_avail = v->mb_type[0][s->block_index[i] - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2235 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2236 vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2237 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2238 s->dsp.vc1_inv_trans_8x8(s->block[i]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2239 if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; |
11796
f917cd286e41
321l: do not use shifted s->linesize instead of correct s->uvlinesize.
kostya
parents:
11644
diff
changeset
|
2240 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2241 if(v->pq >= 9 && v->overlap) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2242 if(v->c_avail) |
11796
f917cd286e41
321l: do not use shifted s->linesize instead of correct s->uvlinesize.
kostya
parents:
11644
diff
changeset
|
2243 s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2244 if(v->a_avail) |
11796
f917cd286e41
321l: do not use shifted s->linesize instead of correct s->uvlinesize.
kostya
parents:
11644
diff
changeset
|
2245 s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2246 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2247 if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2248 int left_cbp, top_cbp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2249 if(i & 4){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2250 left_cbp = v->cbp[s->mb_x - 1] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2251 top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2252 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2253 left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2254 top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2255 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2256 if(left_cbp & 0xC) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2257 s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2258 if(top_cbp & 0xA) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2259 s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2260 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2261 block_cbp |= 0xF << (i << 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2262 } else if(val) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2263 int left_cbp = 0, top_cbp = 0, filter = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2264 if(apply_loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2265 filter = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2266 if(i & 4){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2267 left_cbp = v->cbp[s->mb_x - 1] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2268 top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2269 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2270 left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2271 top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2272 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2273 if(left_cbp & 0xC) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2274 s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2275 if(top_cbp & 0xA) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2276 s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2277 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2278 pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2279 block_cbp |= pat << (i << 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2280 if(!v->ttmbf && ttmb < 8) ttmb = -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2281 first_block = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2282 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2283 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2284 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2285 else //Skipped |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2286 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2287 s->mb_intra = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2288 for(i = 0; i < 6; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2289 v->mb_type[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2290 s->dc_val[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2291 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2292 s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2293 s->current_picture.qscale_table[mb_pos] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2294 vc1_pred_mv(s, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2295 vc1_mc_1mv(v, 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2296 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2297 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2298 } //1MV mode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2299 else //4MV mode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2300 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2301 if (!skipped /* unskipped MB */) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2302 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2303 int intra_count = 0, coded_inter = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2304 int is_intra[6], is_coded[6]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2305 /* Get CBPCY */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2306 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2307 for (i=0; i<6; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2308 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2309 val = ((cbp >> (5 - i)) & 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2310 s->dc_val[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2311 s->mb_intra = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2312 if(i < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2313 dmv_x = dmv_y = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2314 s->mb_intra = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2315 mb_has_coeffs = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2316 if(val) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2317 GET_MVDATA(dmv_x, dmv_y); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2318 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2319 vc1_pred_mv(s, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2320 if(!s->mb_intra) vc1_mc_4mv_luma(v, i); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2321 intra_count += s->mb_intra; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2322 is_intra[i] = s->mb_intra; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2323 is_coded[i] = mb_has_coeffs; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2324 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2325 if(i&4){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2326 is_intra[i] = (intra_count >= 3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2327 is_coded[i] = val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2328 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2329 if(i == 4) vc1_mc_4mv_chroma(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2330 v->mb_type[0][s->block_index[i]] = is_intra[i]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2331 if(!coded_inter) coded_inter = !is_intra[i] & is_coded[i]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2332 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2333 // if there are no coded blocks then don't do anything more |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2334 if(!intra_count && !coded_inter) return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2335 dst_idx = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2336 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2337 s->current_picture.qscale_table[mb_pos] = mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2338 /* test if block is intra and has pred */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2339 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2340 int intrapred = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2341 for(i=0; i<6; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2342 if(is_intra[i]) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2343 if(((!s->first_slice_line || (i==2 || i==3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]]) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2344 || ((s->mb_x || (i==1 || i==3)) && v->mb_type[0][s->block_index[i] - 1])) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2345 intrapred = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2346 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2347 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2348 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2349 if(intrapred)s->ac_pred = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2350 else s->ac_pred = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2351 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2352 if (!v->ttmbf && coded_inter) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2353 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2354 for (i=0; i<6; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2355 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2356 dst_idx += i >> 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2357 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2358 s->mb_intra = is_intra[i]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2359 if (is_intra[i]) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2360 /* check if prediction blocks A and C are available */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2361 v->a_avail = v->c_avail = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2362 if(i == 2 || i == 3 || !s->first_slice_line) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2363 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2364 if(i == 1 || i == 3 || s->mb_x) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2365 v->c_avail = v->mb_type[0][s->block_index[i] - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2366 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2367 vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2368 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2369 s->dsp.vc1_inv_trans_8x8(s->block[i]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2370 if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2371 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2372 if(v->pq >= 9 && v->overlap) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2373 if(v->c_avail) |
11796
f917cd286e41
321l: do not use shifted s->linesize instead of correct s->uvlinesize.
kostya
parents:
11644
diff
changeset
|
2374 s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2375 if(v->a_avail) |
11796
f917cd286e41
321l: do not use shifted s->linesize instead of correct s->uvlinesize.
kostya
parents:
11644
diff
changeset
|
2376 s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2377 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2378 if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2379 int left_cbp, top_cbp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2380 if(i & 4){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2381 left_cbp = v->cbp[s->mb_x - 1] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2382 top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2383 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2384 left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2385 top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2386 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2387 if(left_cbp & 0xC) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2388 s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2389 if(top_cbp & 0xA) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2390 s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2391 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2392 block_cbp |= 0xF << (i << 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2393 } else if(is_coded[i]) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2394 int left_cbp = 0, top_cbp = 0, filter = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2395 if(v->s.loop_filter && s->mb_x && s->mb_x != (s->mb_width - 1) && s->mb_y && s->mb_y != (s->mb_height - 1)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2396 filter = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2397 if(i & 4){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2398 left_cbp = v->cbp[s->mb_x - 1] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2399 top_cbp = v->cbp[s->mb_x - s->mb_stride] >> (i * 4); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2400 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2401 left_cbp = (i & 1) ? (cbp >> ((i-1)*4)) : (v->cbp[s->mb_x - 1] >> ((i+1)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2402 top_cbp = (i & 2) ? (cbp >> ((i-2)*4)) : (v->cbp[s->mb_x - s->mb_stride] >> ((i+2)*4)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2403 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2404 if(left_cbp & 0xC) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2405 s->dsp.vc1_v_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2406 if(top_cbp & 0xA) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2407 s->dsp.vc1_h_loop_filter8(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2408 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2409 pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), filter, left_cbp, top_cbp); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2410 block_cbp |= pat << (i << 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2411 if(!v->ttmbf && ttmb < 8) ttmb = -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2412 first_block = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2413 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2414 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2415 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2416 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2417 else //Skipped MB |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2418 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2419 s->mb_intra = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2420 s->current_picture.qscale_table[mb_pos] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2421 for (i=0; i<6; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2422 v->mb_type[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2423 s->dc_val[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2424 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2425 for (i=0; i<4; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2426 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2427 vc1_pred_mv(s, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2428 vc1_mc_4mv_luma(v, i); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2429 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2430 vc1_mc_4mv_chroma(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2431 s->current_picture.qscale_table[mb_pos] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2432 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2433 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2434 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2435 v->cbp[s->mb_x] = block_cbp; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2436 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2437 /* Should never happen */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2438 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2439 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2440 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2441 /** Decode one B-frame MB (in Main profile) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2442 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2443 static void vc1_decode_b_mb(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2444 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2445 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2446 GetBitContext *gb = &s->gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2447 int i, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2448 int mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2449 int cbp = 0; /* cbp decoding stuff */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2450 int mqdiff, mquant; /* MB quantization */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2451 int ttmb = v->ttfrm; /* MB Transform type */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2452 int mb_has_coeffs = 0; /* last_flag */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2453 int index, index1; /* LUT indexes */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2454 int val, sign; /* temp values */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2455 int first_block = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2456 int dst_idx, off; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2457 int skipped, direct; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2458 int dmv_x[2], dmv_y[2]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2459 int bmvtype = BMV_TYPE_BACKWARD; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2460 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2461 mquant = v->pq; /* Loosy initialization */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2462 s->mb_intra = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2463 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2464 if (v->dmb_is_raw) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2465 direct = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2466 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2467 direct = v->direct_mb_plane[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2468 if (v->skip_is_raw) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2469 skipped = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2470 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2471 skipped = v->s.mbskip_table[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2472 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2473 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2474 for(i = 0; i < 6; i++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2475 v->mb_type[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2476 s->dc_val[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2477 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2478 s->current_picture.qscale_table[mb_pos] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2479 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2480 if (!direct) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2481 if (!skipped) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2482 GET_MVDATA(dmv_x[0], dmv_y[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2483 dmv_x[1] = dmv_x[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2484 dmv_y[1] = dmv_y[0]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2485 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2486 if(skipped || !s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2487 bmvtype = decode012(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2488 switch(bmvtype) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2489 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2490 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2491 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2492 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2493 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2494 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2495 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2496 bmvtype = BMV_TYPE_INTERPOLATED; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2497 dmv_x[0] = dmv_y[0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2498 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2499 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2500 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2501 for(i = 0; i < 6; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2502 v->mb_type[0][s->block_index[i]] = s->mb_intra; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2503 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2504 if (skipped) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2505 if(direct) bmvtype = BMV_TYPE_INTERPOLATED; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2506 vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2507 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2508 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2509 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2510 if (direct) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2511 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2512 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2513 s->mb_intra = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2514 s->current_picture.qscale_table[mb_pos] = mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2515 if(!v->ttmbf) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2516 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2517 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2518 vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2519 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2520 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2521 if(!mb_has_coeffs && !s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2522 /* no coded blocks - effectively skipped */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2523 vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2524 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2525 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2526 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2527 if(s->mb_intra && !mb_has_coeffs) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2528 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2529 s->current_picture.qscale_table[mb_pos] = mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2530 s->ac_pred = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2531 cbp = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2532 vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2533 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2534 if(bmvtype == BMV_TYPE_INTERPOLATED) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2535 GET_MVDATA(dmv_x[0], dmv_y[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2536 if(!mb_has_coeffs) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2537 /* interpolated skipped block */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2538 vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2539 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2540 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2541 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2542 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2543 vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2544 if(!s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2545 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2546 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2547 if(s->mb_intra) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2548 s->ac_pred = get_bits1(gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2549 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2550 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2551 s->current_picture.qscale_table[mb_pos] = mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2552 if(!v->ttmbf && !s->mb_intra && mb_has_coeffs) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2553 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2554 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2555 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2556 dst_idx = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2557 for (i=0; i<6; i++) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2558 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2559 s->dc_val[0][s->block_index[i]] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2560 dst_idx += i >> 2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2561 val = ((cbp >> (5 - i)) & 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2562 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2563 v->mb_type[0][s->block_index[i]] = s->mb_intra; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2564 if(s->mb_intra) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2565 /* check if prediction blocks A and C are available */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2566 v->a_avail = v->c_avail = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2567 if(i == 2 || i == 3 || !s->first_slice_line) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2568 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2569 if(i == 1 || i == 3 || s->mb_x) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2570 v->c_avail = v->mb_type[0][s->block_index[i] - 1]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2571 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2572 vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2573 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2574 s->dsp.vc1_inv_trans_8x8(s->block[i]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2575 if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; |
11796
f917cd286e41
321l: do not use shifted s->linesize instead of correct s->uvlinesize.
kostya
parents:
11644
diff
changeset
|
2576 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2577 } else if(val) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2578 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), 0, 0, 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2579 if(!v->ttmbf && ttmb < 8) ttmb = -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2580 first_block = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2581 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2582 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2583 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2584 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2585 /** Decode blocks of I-frame |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2586 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2587 static void vc1_decode_i_blocks(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2588 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2589 int k, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2590 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2591 int cbp, val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2592 uint8_t *coded_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2593 int mb_pos; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2594 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2595 /* select codingmode used for VLC tables selection */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2596 switch(v->y_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2597 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2598 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2599 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2600 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2601 v->codingset = CS_HIGH_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2602 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2603 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2604 v->codingset = CS_MID_RATE_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2605 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2606 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2607 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2608 switch(v->c_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2609 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2610 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2611 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2612 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2613 v->codingset2 = CS_HIGH_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2614 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2615 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2616 v->codingset2 = CS_MID_RATE_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2617 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2618 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2619 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2620 /* Set DC scale - y and c use the same */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2621 s->y_dc_scale = s->y_dc_scale_table[v->pq]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2622 s->c_dc_scale = s->c_dc_scale_table[v->pq]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2623 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2624 //do frame decode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2625 s->mb_x = s->mb_y = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2626 s->mb_intra = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2627 s->first_slice_line = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2628 for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { |
9863
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2629 s->mb_x = 0; |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2630 ff_init_block_index(s); |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2631 for(; s->mb_x < s->mb_width; s->mb_x++) { |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2632 ff_update_block_index(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2633 s->dsp.clear_blocks(s->block[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2634 mb_pos = s->mb_x + s->mb_y * s->mb_width; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2635 s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2636 s->current_picture.qscale_table[mb_pos] = v->pq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2637 s->current_picture.motion_val[1][s->block_index[0]][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2638 s->current_picture.motion_val[1][s->block_index[0]][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2639 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2640 // do actual MB decoding and displaying |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2641 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2642 v->s.ac_pred = get_bits1(&v->s.gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2643 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2644 for(k = 0; k < 6; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2645 val = ((cbp >> (5 - k)) & 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2646 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2647 if (k < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2648 int pred = vc1_coded_block_pred(&v->s, k, &coded_val); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2649 val = val ^ pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2650 *coded_val = val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2651 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2652 cbp |= val << (5 - k); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2653 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2654 vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2655 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2656 s->dsp.vc1_inv_trans_8x8(s->block[k]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2657 if(v->pq >= 9 && v->overlap) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2658 for(j = 0; j < 64; j++) s->block[k][j] += 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2659 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2660 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2661 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2662 vc1_put_block(v, s->block); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2663 if(v->pq >= 9 && v->overlap) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2664 if(s->mb_x) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2665 s->dsp.vc1_h_overlap(s->dest[0], s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2666 s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2667 if(!(s->flags & CODEC_FLAG_GRAY)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2668 s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2669 s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2670 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2671 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2672 s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2673 s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2674 if(!s->first_slice_line) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2675 s->dsp.vc1_v_overlap(s->dest[0], s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2676 s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2677 if(!(s->flags & CODEC_FLAG_GRAY)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2678 s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2679 s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2680 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2681 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2682 s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2683 s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2684 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2685 if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2686 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2687 if(get_bits_count(&s->gb) > v->bits) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2688 ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2689 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2690 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2691 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2692 } |
12141
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2693 if (!v->s.loop_filter) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2694 ff_draw_horiz_band(s, s->mb_y * 16, 16); |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2695 else if (s->mb_y) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2696 ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2697 |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2698 s->first_slice_line = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2699 } |
12141
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2700 if (v->s.loop_filter) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2701 ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2702 ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2703 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2704 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2705 /** Decode blocks of I-frame for advanced profile |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2706 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2707 static void vc1_decode_i_blocks_adv(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2708 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2709 int k, j; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2710 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2711 int cbp, val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2712 uint8_t *coded_val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2713 int mb_pos; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2714 int mquant = v->pq; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2715 int mqdiff; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2716 int overlap; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2717 GetBitContext *gb = &s->gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2718 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2719 /* select codingmode used for VLC tables selection */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2720 switch(v->y_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2721 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2722 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2723 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2724 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2725 v->codingset = CS_HIGH_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2726 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2727 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2728 v->codingset = CS_MID_RATE_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2729 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2730 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2731 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2732 switch(v->c_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2733 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2734 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2735 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2736 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2737 v->codingset2 = CS_HIGH_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2738 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2739 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2740 v->codingset2 = CS_MID_RATE_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2741 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2742 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2743 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2744 //do frame decode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2745 s->mb_x = s->mb_y = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2746 s->mb_intra = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2747 s->first_slice_line = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2748 for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { |
9863
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2749 s->mb_x = 0; |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2750 ff_init_block_index(s); |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2751 for(;s->mb_x < s->mb_width; s->mb_x++) { |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2752 ff_update_block_index(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2753 s->dsp.clear_blocks(s->block[0]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2754 mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2755 s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2756 s->current_picture.motion_val[1][s->block_index[0]][0] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2757 s->current_picture.motion_val[1][s->block_index[0]][1] = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2758 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2759 // do actual MB decoding and displaying |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2760 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2761 if(v->acpred_is_raw) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2762 v->s.ac_pred = get_bits1(&v->s.gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2763 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2764 v->s.ac_pred = v->acpred_plane[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2765 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2766 if(v->condover == CONDOVER_SELECT) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2767 if(v->overflg_is_raw) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2768 overlap = get_bits1(&v->s.gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2769 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2770 overlap = v->over_flags_plane[mb_pos]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2771 } else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2772 overlap = (v->condover == CONDOVER_ALL); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2773 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2774 GET_MQUANT(); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2775 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2776 s->current_picture.qscale_table[mb_pos] = mquant; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2777 /* Set DC scale - y and c use the same */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2778 s->y_dc_scale = s->y_dc_scale_table[mquant]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2779 s->c_dc_scale = s->c_dc_scale_table[mquant]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2780 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2781 for(k = 0; k < 6; k++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2782 val = ((cbp >> (5 - k)) & 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2783 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2784 if (k < 4) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2785 int pred = vc1_coded_block_pred(&v->s, k, &coded_val); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2786 val = val ^ pred; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2787 *coded_val = val; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2788 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2789 cbp |= val << (5 - k); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2790 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2791 v->a_avail = !s->first_slice_line || (k==2 || k==3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2792 v->c_avail = !!s->mb_x || (k==1 || k==3); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2793 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2794 vc1_decode_i_block_adv(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2795 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2796 s->dsp.vc1_inv_trans_8x8(s->block[k]); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2797 for(j = 0; j < 64; j++) s->block[k][j] += 128; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2798 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2799 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2800 vc1_put_block(v, s->block); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2801 if(overlap) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2802 if(s->mb_x) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2803 s->dsp.vc1_h_overlap(s->dest[0], s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2804 s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2805 if(!(s->flags & CODEC_FLAG_GRAY)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2806 s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2807 s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2808 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2809 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2810 s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2811 s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2812 if(!s->first_slice_line) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2813 s->dsp.vc1_v_overlap(s->dest[0], s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2814 s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2815 if(!(s->flags & CODEC_FLAG_GRAY)) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2816 s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2817 s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2818 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2819 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2820 s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2821 s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2822 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2823 if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2824 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2825 if(get_bits_count(&s->gb) > v->bits) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2826 ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2827 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2828 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2829 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2830 } |
12141
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2831 if (!v->s.loop_filter) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2832 ff_draw_horiz_band(s, s->mb_y * 16, 16); |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2833 else if (s->mb_y) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2834 ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2835 s->first_slice_line = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2836 } |
12141
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2837 if (v->s.loop_filter) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2838 ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2839 ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2840 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2841 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2842 static void vc1_decode_p_blocks(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2843 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2844 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2845 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2846 /* select codingmode used for VLC tables selection */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2847 switch(v->c_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2848 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2849 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2850 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2851 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2852 v->codingset = CS_HIGH_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2853 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2854 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2855 v->codingset = CS_MID_RATE_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2856 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2857 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2858 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2859 switch(v->c_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2860 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2861 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2862 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2863 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2864 v->codingset2 = CS_HIGH_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2865 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2866 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2867 v->codingset2 = CS_MID_RATE_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2868 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2869 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2870 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2871 s->first_slice_line = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2872 memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2873 for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { |
9863
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2874 s->mb_x = 0; |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2875 ff_init_block_index(s); |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2876 for(; s->mb_x < s->mb_width; s->mb_x++) { |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2877 ff_update_block_index(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2878 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2879 vc1_decode_p_mb(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2880 if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2881 ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2882 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2883 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2884 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2885 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2886 memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0])*s->mb_stride); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2887 ff_draw_horiz_band(s, s->mb_y * 16, 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2888 s->first_slice_line = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2889 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2890 ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2891 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2892 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2893 static void vc1_decode_b_blocks(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2894 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2895 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2896 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2897 /* select codingmode used for VLC tables selection */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2898 switch(v->c_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2899 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2900 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2901 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2902 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2903 v->codingset = CS_HIGH_MOT_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2904 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2905 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2906 v->codingset = CS_MID_RATE_INTRA; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2907 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2908 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2909 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2910 switch(v->c_ac_table_index){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2911 case 0: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2912 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2913 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2914 case 1: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2915 v->codingset2 = CS_HIGH_MOT_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2916 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2917 case 2: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2918 v->codingset2 = CS_MID_RATE_INTER; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2919 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2920 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2921 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2922 s->first_slice_line = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2923 for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { |
9863
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2924 s->mb_x = 0; |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2925 ff_init_block_index(s); |
ff0ea87dd64e
VC-1/WMV: Remove redundant ff_init_block_index() calls.
darkshikari
parents:
9860
diff
changeset
|
2926 for(; s->mb_x < s->mb_width; s->mb_x++) { |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2927 ff_update_block_index(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2928 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2929 vc1_decode_b_mb(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2930 if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2931 ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2932 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2933 return; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2934 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2935 if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2936 } |
12141
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2937 if (!v->s.loop_filter) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2938 ff_draw_horiz_band(s, s->mb_y * 16, 16); |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2939 else if (s->mb_y) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2940 ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2941 s->first_slice_line = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2942 } |
12141
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2943 if (v->s.loop_filter) |
c3682c0606e3
vc1: ff_draw_horiz_band needs a one row delay when the loop filter is active
conrad
parents:
12127
diff
changeset
|
2944 ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2945 ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2946 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2947 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2948 static void vc1_decode_skip_blocks(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2949 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2950 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2951 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2952 ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2953 s->first_slice_line = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2954 for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2955 s->mb_x = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2956 ff_init_block_index(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2957 ff_update_block_index(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2958 memcpy(s->dest[0], s->last_picture.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2959 memcpy(s->dest[1], s->last_picture.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2960 memcpy(s->dest[2], s->last_picture.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2961 ff_draw_horiz_band(s, s->mb_y * 16, 16); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2962 s->first_slice_line = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2963 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2964 s->pict_type = FF_P_TYPE; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2965 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2966 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2967 static void vc1_decode_blocks(VC1Context *v) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2968 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2969 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2970 v->s.esc3_level_length = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2971 if(v->x8_type){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2972 ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) ); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2973 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2974 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2975 switch(v->s.pict_type) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2976 case FF_I_TYPE: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2977 if(v->profile == PROFILE_ADVANCED) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2978 vc1_decode_i_blocks_adv(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2979 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2980 vc1_decode_i_blocks(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2981 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2982 case FF_P_TYPE: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2983 if(v->p_frame_skipped) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2984 vc1_decode_skip_blocks(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2985 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2986 vc1_decode_p_blocks(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2987 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2988 case FF_B_TYPE: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2989 if(v->bi_type){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2990 if(v->profile == PROFILE_ADVANCED) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2991 vc1_decode_i_blocks_adv(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2992 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2993 vc1_decode_i_blocks(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2994 }else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2995 vc1_decode_b_blocks(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2996 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2997 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2998 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
2999 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3000 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3001 /** Initialize a VC1/WMV3 decoder |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3002 * @todo TODO: Handle VC-1 IDUs (Transport level?) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3003 * @todo TODO: Decypher remaining bits in extra_data |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3004 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3005 static av_cold int vc1_decode_init(AVCodecContext *avctx) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3006 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3007 VC1Context *v = avctx->priv_data; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3008 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3009 GetBitContext gb; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3010 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3011 if (!avctx->extradata_size || !avctx->extradata) return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3012 if (!(avctx->flags & CODEC_FLAG_GRAY)) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3013 avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3014 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3015 avctx->pix_fmt = PIX_FMT_GRAY8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3016 avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3017 v->s.avctx = avctx; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3018 avctx->flags |= CODEC_FLAG_EMU_EDGE; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3019 v->s.flags |= CODEC_FLAG_EMU_EDGE; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3020 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3021 if(avctx->idct_algo==FF_IDCT_AUTO){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3022 avctx->idct_algo=FF_IDCT_WMV2; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3023 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3024 |
11270
f64dd8297105
ff_msmpeg4_decode_init() calls ff_h263_decode_init() which calls
kostya
parents:
11230
diff
changeset
|
3025 if(ff_msmpeg4_decode_init(avctx) < 0) |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3026 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3027 if (vc1_init_common(v) < 0) return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3028 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3029 avctx->coded_width = avctx->width; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3030 avctx->coded_height = avctx->height; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3031 if (avctx->codec_id == CODEC_ID_WMV3) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3032 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3033 int count = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3034 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3035 // looks like WMV3 has a sequence header stored in the extradata |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3036 // advanced sequence header may be before the first frame |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3037 // the last byte of the extradata is a version number, 1 for the |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3038 // samples we can decode |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3039 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3040 init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3041 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3042 if (vc1_decode_sequence_header(avctx, v, &gb) < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3043 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3044 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3045 count = avctx->extradata_size*8 - get_bits_count(&gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3046 if (count>0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3047 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3048 av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3049 count, get_bits(&gb, count)); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3050 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3051 else if (count < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3052 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3053 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3054 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3055 } else { // VC1/WVC1 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3056 const uint8_t *start = avctx->extradata; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3057 uint8_t *end = avctx->extradata + avctx->extradata_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3058 const uint8_t *next; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3059 int size, buf2_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3060 uint8_t *buf2 = NULL; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3061 int seq_initialized = 0, ep_initialized = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3062 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3063 if(avctx->extradata_size < 16) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3064 av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3065 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3066 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3067 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3068 buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); |
10369
71a38fce15bc
Since some junk may be or may be not present before actual VC-1 extradata,
kostya
parents:
10260
diff
changeset
|
3069 start = find_next_marker(start, end); // in WVC1 extradata first byte is its size, but can be 0 in mkv |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3070 next = start; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3071 for(; next < end; start = next){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3072 next = find_next_marker(start + 4, end); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3073 size = next - start - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3074 if(size <= 0) continue; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3075 buf2_size = vc1_unescape_buffer(start + 4, size, buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3076 init_get_bits(&gb, buf2, buf2_size * 8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3077 switch(AV_RB32(start)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3078 case VC1_CODE_SEQHDR: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3079 if(vc1_decode_sequence_header(avctx, v, &gb) < 0){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3080 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3081 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3082 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3083 seq_initialized = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3084 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3085 case VC1_CODE_ENTRYPOINT: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3086 if(vc1_decode_entry_point(avctx, v, &gb) < 0){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3087 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3088 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3089 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3090 ep_initialized = 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3091 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3092 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3093 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3094 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3095 if(!seq_initialized || !ep_initialized){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3096 av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n"); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3097 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3098 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3099 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3100 avctx->has_b_frames= !!(avctx->max_b_frames); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3101 s->low_delay = !avctx->has_b_frames; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3102 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3103 s->mb_width = (avctx->coded_width+15)>>4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3104 s->mb_height = (avctx->coded_height+15)>>4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3105 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3106 /* Allocate mb bitplanes */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3107 v->mv_type_mb_plane = av_malloc(s->mb_stride * s->mb_height); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3108 v->direct_mb_plane = av_malloc(s->mb_stride * s->mb_height); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3109 v->acpred_plane = av_malloc(s->mb_stride * s->mb_height); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3110 v->over_flags_plane = av_malloc(s->mb_stride * s->mb_height); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3111 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3112 v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3113 v->cbp = v->cbp_base + s->mb_stride; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3114 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3115 /* allocate block type info in that way so it could be used with s->block_index[] */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3116 v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3117 v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3118 v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3119 v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3120 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3121 /* Init coded blocks info */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3122 if (v->profile == PROFILE_ADVANCED) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3123 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3124 // if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3125 // return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3126 // if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3127 // return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3128 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3129 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3130 ff_intrax8_common_init(&v->x8,s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3131 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3132 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3133 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3134 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3135 /** Decode a VC1/WMV3 frame |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3136 * @todo TODO: Handle VC-1 IDUs (Transport level?) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3137 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3138 static int vc1_decode_frame(AVCodecContext *avctx, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3139 void *data, int *data_size, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3140 AVPacket *avpkt) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3141 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3142 const uint8_t *buf = avpkt->data; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3143 int buf_size = avpkt->size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3144 VC1Context *v = avctx->priv_data; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3145 MpegEncContext *s = &v->s; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3146 AVFrame *pict = data; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3147 uint8_t *buf2 = NULL; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3148 const uint8_t *buf_start = buf; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3149 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3150 /* no supplementary picture */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3151 if (buf_size == 0) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3152 /* special case for last picture */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3153 if (s->low_delay==0 && s->next_picture_ptr) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3154 *pict= *(AVFrame*)s->next_picture_ptr; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3155 s->next_picture_ptr= NULL; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3156 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3157 *data_size = sizeof(AVFrame); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3158 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3159 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3160 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3161 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3162 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3163 /* We need to set current_picture_ptr before reading the header, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3164 * otherwise we cannot store anything in there. */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3165 if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3166 int i= ff_find_unused_picture(s, 0); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3167 s->current_picture_ptr= &s->picture[i]; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3168 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3169 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3170 if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3171 if (v->profile < PROFILE_ADVANCED) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3172 avctx->pix_fmt = PIX_FMT_VDPAU_WMV3; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3173 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3174 avctx->pix_fmt = PIX_FMT_VDPAU_VC1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3175 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3176 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3177 //for advanced profile we may need to parse and unescape data |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3178 if (avctx->codec_id == CODEC_ID_VC1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3179 int buf_size2 = 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3180 buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3181 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3182 if(IS_MARKER(AV_RB32(buf))){ /* frame starts with marker and needs to be parsed */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3183 const uint8_t *start, *end, *next; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3184 int size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3185 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3186 next = buf; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3187 for(start = buf, end = buf + buf_size; next < end; start = next){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3188 next = find_next_marker(start + 4, end); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3189 size = next - start - 4; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3190 if(size <= 0) continue; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3191 switch(AV_RB32(start)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3192 case VC1_CODE_FRAME: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3193 if (avctx->hwaccel || |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3194 s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3195 buf_start = start; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3196 buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3197 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3198 case VC1_CODE_ENTRYPOINT: /* it should be before frame data */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3199 buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3200 init_get_bits(&s->gb, buf2, buf_size2*8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3201 vc1_decode_entry_point(avctx, v, &s->gb); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3202 break; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3203 case VC1_CODE_SLICE: |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3204 av_log(avctx, AV_LOG_ERROR, "Sliced decoding is not implemented (yet)\n"); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3205 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3206 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3207 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3208 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3209 }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3210 const uint8_t *divider; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3211 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3212 divider = find_next_marker(buf, buf + buf_size); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3213 if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3214 av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n"); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3215 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3216 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3217 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3218 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3219 buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3220 // TODO |
10382 | 3221 if(!v->warn_interlaced++) |
3222 av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced WVC1 support is not implemented\n"); | |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3223 av_free(buf2);return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3224 }else{ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3225 buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3226 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3227 init_get_bits(&s->gb, buf2, buf_size2*8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3228 } else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3229 init_get_bits(&s->gb, buf, buf_size*8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3230 // do parse frame header |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3231 if(v->profile < PROFILE_ADVANCED) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3232 if(vc1_parse_frame_header(v, &s->gb) == -1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3233 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3234 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3235 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3236 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3237 if(vc1_parse_frame_header_adv(v, &s->gb) == -1) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3238 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3239 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3240 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3241 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3242 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3243 // for hurry_up==5 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3244 s->current_picture.pict_type= s->pict_type; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3245 s->current_picture.key_frame= s->pict_type == FF_I_TYPE; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3246 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3247 /* skip B-frames if we don't have reference frames */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3248 if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3249 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3250 return -1;//buf_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3251 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3252 /* skip b frames if we are in a hurry */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3253 if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return -1;//buf_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3254 if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3255 || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3256 || avctx->skip_frame >= AVDISCARD_ALL) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3257 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3258 return buf_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3259 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3260 /* skip everything if we are in a hurry>=5 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3261 if(avctx->hurry_up>=5) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3262 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3263 return -1;//buf_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3264 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3265 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3266 if(s->next_p_frame_damaged){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3267 if(s->pict_type==FF_B_TYPE) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3268 return buf_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3269 else |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3270 s->next_p_frame_damaged=0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3271 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3272 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3273 if(MPV_frame_start(s, avctx) < 0) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3274 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3275 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3276 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3277 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3278 s->me.qpel_put= s->dsp.put_qpel_pixels_tab; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3279 s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3280 |
9994
cd2b3ecdb1c9
Do not check for both CONFIG_VC1_VDPAU_DECODER and CONFIG_WMV3_VDPAU_DECODER,
diego
parents:
9881
diff
changeset
|
3281 if ((CONFIG_VC1_VDPAU_DECODER) |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3282 &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3283 ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3284 else if (avctx->hwaccel) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3285 if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3286 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3287 if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3288 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3289 if (avctx->hwaccel->end_frame(avctx) < 0) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3290 return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3291 } else { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3292 ff_er_frame_start(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3293 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3294 v->bits = buf_size * 8; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3295 vc1_decode_blocks(v); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3296 //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), buf_size*8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3297 // if(get_bits_count(&s->gb) > buf_size * 8) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3298 // return -1; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3299 ff_er_frame_end(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3300 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3301 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3302 MPV_frame_end(s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3303 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3304 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3305 assert(s->current_picture.pict_type == s->pict_type); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3306 if (s->pict_type == FF_B_TYPE || s->low_delay) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3307 *pict= *(AVFrame*)s->current_picture_ptr; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3308 } else if (s->last_picture_ptr != NULL) { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3309 *pict= *(AVFrame*)s->last_picture_ptr; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3310 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3311 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3312 if(s->last_picture_ptr || s->low_delay){ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3313 *data_size = sizeof(AVFrame); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3314 ff_print_debug_info(s, pict); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3315 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3316 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3317 av_free(buf2); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3318 return buf_size; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3319 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3320 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3321 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3322 /** Close a VC1/WMV3 decoder |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3323 * @warning Initial try at using MpegEncContext stuff |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3324 */ |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3325 static av_cold int vc1_decode_end(AVCodecContext *avctx) |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3326 { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3327 VC1Context *v = avctx->priv_data; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3328 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3329 av_freep(&v->hrd_rate); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3330 av_freep(&v->hrd_buffer); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3331 MPV_common_end(&v->s); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3332 av_freep(&v->mv_type_mb_plane); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3333 av_freep(&v->direct_mb_plane); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3334 av_freep(&v->acpred_plane); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3335 av_freep(&v->over_flags_plane); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3336 av_freep(&v->mb_type_base); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3337 av_freep(&v->cbp_base); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3338 ff_intrax8_common_end(&v->x8); |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3339 return 0; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3340 } |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3341 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3342 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3343 AVCodec vc1_decoder = { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3344 "vc1", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11270
diff
changeset
|
3345 AVMEDIA_TYPE_VIDEO, |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3346 CODEC_ID_VC1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3347 sizeof(VC1Context), |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3348 vc1_decode_init, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3349 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3350 vc1_decode_end, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3351 vc1_decode_frame, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3352 CODEC_CAP_DR1 | CODEC_CAP_DELAY, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3353 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3354 .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3355 .pix_fmts = ff_hwaccel_pixfmt_list_420 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3356 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3357 |
9996
38a57d201569
Only enable WMV3 decoder when it has been turned on in the build system.
diego
parents:
9994
diff
changeset
|
3358 #if CONFIG_WMV3_DECODER |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3359 AVCodec wmv3_decoder = { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3360 "wmv3", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11270
diff
changeset
|
3361 AVMEDIA_TYPE_VIDEO, |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3362 CODEC_ID_WMV3, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3363 sizeof(VC1Context), |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3364 vc1_decode_init, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3365 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3366 vc1_decode_end, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3367 vc1_decode_frame, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3368 CODEC_CAP_DR1 | CODEC_CAP_DELAY, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3369 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3370 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3371 .pix_fmts = ff_hwaccel_pixfmt_list_420 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3372 }; |
9996
38a57d201569
Only enable WMV3 decoder when it has been turned on in the build system.
diego
parents:
9994
diff
changeset
|
3373 #endif |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3374 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3375 #if CONFIG_WMV3_VDPAU_DECODER |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3376 AVCodec wmv3_vdpau_decoder = { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3377 "wmv3_vdpau", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11270
diff
changeset
|
3378 AVMEDIA_TYPE_VIDEO, |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3379 CODEC_ID_WMV3, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3380 sizeof(VC1Context), |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3381 vc1_decode_init, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3382 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3383 vc1_decode_end, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3384 vc1_decode_frame, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3385 CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3386 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3387 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"), |
10146
38cfe222e1a4
Mark all pix_fmts and supported_framerates compound literals as const.
reimar
parents:
9996
diff
changeset
|
3388 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_WMV3, PIX_FMT_NONE} |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3389 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3390 #endif |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3391 |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3392 #if CONFIG_VC1_VDPAU_DECODER |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3393 AVCodec vc1_vdpau_decoder = { |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3394 "vc1_vdpau", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11270
diff
changeset
|
3395 AVMEDIA_TYPE_VIDEO, |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3396 CODEC_ID_VC1, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3397 sizeof(VC1Context), |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3398 vc1_decode_init, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3399 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3400 vc1_decode_end, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3401 vc1_decode_frame, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3402 CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3403 NULL, |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3404 .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"), |
10146
38cfe222e1a4
Mark all pix_fmts and supported_framerates compound literals as const.
reimar
parents:
9996
diff
changeset
|
3405 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_VC1, PIX_FMT_NONE} |
9836
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3406 }; |
e678b20368cd
Split decoder-specific code off from vc1.c into vc1dec.c and keep code
diego
parents:
diff
changeset
|
3407 #endif |