annotate vc1dsp.c @ 5882:51fc10d9fdff libavcodec

rename some msmpeg4 symbols and make them non-static so that they can be used in standalone wmv2.c
author aurel
date Wed, 07 Nov 2007 23:23:35 +0000
parents 90d90aecc83c
children 90de28dfd8d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
1 /*
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
2 * VC-1 and WMV3 decoder - DSP functions
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
3 * Copyright (c) 2006 Konstantin Shishkov
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3665
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3665
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3665
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3665
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3665
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
15 * Lesser General Public License for more details.
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
16 *
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3665
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
20 */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
21
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
22 /**
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
23 * @file vc1dsp.c
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
24 * VC-1 and WMV3 decoder
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
25 *
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
26 */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
27
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
28 #include "dsputil.h"
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
29
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
30
4210
6f6fe05712e4 Fix comments
kostya
parents: 3947
diff changeset
31 /** Apply overlap transform to horizontal edge
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
32 */
4239
30b14d0f2324 Correct rounding values in overlap filtering
kostya
parents: 4211
diff changeset
33 static void vc1_v_overlap_c(uint8_t* src, int stride)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
34 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
35 int i;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
36 int a, b, c, d;
4211
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
37 int d1, d2;
4239
30b14d0f2324 Correct rounding values in overlap filtering
kostya
parents: 4211
diff changeset
38 int rnd = 1;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
39 for(i = 0; i < 8; i++) {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
40 a = src[-2*stride];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
41 b = src[-stride];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
42 c = src[0];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
43 d = src[stride];
4211
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
44 d1 = (a - d + 3 + rnd) >> 3;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
45 d2 = (a - d + b - c + 4 - rnd) >> 3;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
46
4211
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
47 src[-2*stride] = a - d1;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
48 src[-stride] = b - d2;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
49 src[0] = c + d2;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
50 src[stride] = d + d1;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
51 src++;
4239
30b14d0f2324 Correct rounding values in overlap filtering
kostya
parents: 4211
diff changeset
52 rnd = !rnd;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
53 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
54 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
55
4210
6f6fe05712e4 Fix comments
kostya
parents: 3947
diff changeset
56 /** Apply overlap transform to vertical edge
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
57 */
4239
30b14d0f2324 Correct rounding values in overlap filtering
kostya
parents: 4211
diff changeset
58 static void vc1_h_overlap_c(uint8_t* src, int stride)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
59 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
60 int i;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
61 int a, b, c, d;
4211
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
62 int d1, d2;
4239
30b14d0f2324 Correct rounding values in overlap filtering
kostya
parents: 4211
diff changeset
63 int rnd = 1;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
64 for(i = 0; i < 8; i++) {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
65 a = src[-2];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
66 b = src[-1];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
67 c = src[0];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
68 d = src[1];
4211
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
69 d1 = (a - d + 3 + rnd) >> 3;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
70 d2 = (a - d + b - c + 4 - rnd) >> 3;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
71
4211
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
72 src[-2] = a - d1;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
73 src[-1] = b - d2;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
74 src[0] = c + d2;
ff9a94fce879 Optimize overlapping
kostya
parents: 4210
diff changeset
75 src[1] = d + d1;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
76 src += stride;
4239
30b14d0f2324 Correct rounding values in overlap filtering
kostya
parents: 4211
diff changeset
77 rnd = !rnd;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
78 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
79 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
80
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
81
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
82 /** Do inverse transform on 8x8 block
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
83 */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
84 static void vc1_inv_trans_8x8_c(DCTELEM block[64])
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
85 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
86 int i;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
87 register int t1,t2,t3,t4,t5,t6,t7,t8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
88 DCTELEM *src, *dst;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
89
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
90 src = block;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
91 dst = block;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
92 for(i = 0; i < 8; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
93 t1 = 12 * (src[0] + src[4]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
94 t2 = 12 * (src[0] - src[4]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
95 t3 = 16 * src[2] + 6 * src[6];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
96 t4 = 6 * src[2] - 16 * src[6];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
97
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
98 t5 = t1 + t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
99 t6 = t2 + t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
100 t7 = t2 - t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
101 t8 = t1 - t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
102
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
103 t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
104 t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
105 t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
106 t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
107
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
108 dst[0] = (t5 + t1 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
109 dst[1] = (t6 + t2 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
110 dst[2] = (t7 + t3 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
111 dst[3] = (t8 + t4 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
112 dst[4] = (t8 - t4 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
113 dst[5] = (t7 - t3 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
114 dst[6] = (t6 - t2 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
115 dst[7] = (t5 - t1 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
116
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
117 src += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
118 dst += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
119 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
120
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
121 src = block;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
122 dst = block;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
123 for(i = 0; i < 8; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
124 t1 = 12 * (src[ 0] + src[32]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
125 t2 = 12 * (src[ 0] - src[32]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
126 t3 = 16 * src[16] + 6 * src[48];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
127 t4 = 6 * src[16] - 16 * src[48];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
128
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
129 t5 = t1 + t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
130 t6 = t2 + t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
131 t7 = t2 - t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
132 t8 = t1 - t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
133
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
134 t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
135 t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
136 t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
137 t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
138
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
139 dst[ 0] = (t5 + t1 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
140 dst[ 8] = (t6 + t2 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
141 dst[16] = (t7 + t3 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
142 dst[24] = (t8 + t4 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
143 dst[32] = (t8 - t4 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
144 dst[40] = (t7 - t3 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
145 dst[48] = (t6 - t2 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
146 dst[56] = (t5 - t1 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
147
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
148 src++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
149 dst++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
150 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
151 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
152
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
153 /** Do inverse transform on 8x4 part of block
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
154 */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
155 static void vc1_inv_trans_8x4_c(DCTELEM block[64], int n)
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
156 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
157 int i;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
158 register int t1,t2,t3,t4,t5,t6,t7,t8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
159 DCTELEM *src, *dst;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
160 int off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
161
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
162 off = n * 32;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
163 src = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
164 dst = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
165 for(i = 0; i < 4; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
166 t1 = 12 * (src[0] + src[4]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
167 t2 = 12 * (src[0] - src[4]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
168 t3 = 16 * src[2] + 6 * src[6];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
169 t4 = 6 * src[2] - 16 * src[6];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
170
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
171 t5 = t1 + t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
172 t6 = t2 + t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
173 t7 = t2 - t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
174 t8 = t1 - t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
175
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
176 t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
177 t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
178 t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
179 t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
180
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
181 dst[0] = (t5 + t1 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
182 dst[1] = (t6 + t2 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
183 dst[2] = (t7 + t3 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
184 dst[3] = (t8 + t4 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
185 dst[4] = (t8 - t4 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
186 dst[5] = (t7 - t3 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
187 dst[6] = (t6 - t2 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
188 dst[7] = (t5 - t1 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
189
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
190 src += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
191 dst += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
192 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
193
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
194 src = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
195 dst = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
196 for(i = 0; i < 8; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
197 t1 = 17 * (src[ 0] + src[16]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
198 t2 = 17 * (src[ 0] - src[16]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
199 t3 = 22 * src[ 8];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
200 t4 = 22 * src[24];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
201 t5 = 10 * src[ 8];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
202 t6 = 10 * src[24];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
203
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
204 dst[ 0] = (t1 + t3 + t6 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
205 dst[ 8] = (t2 - t4 + t5 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
206 dst[16] = (t2 + t4 - t5 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
207 dst[24] = (t1 - t3 - t6 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
208
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
209 src ++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
210 dst ++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
211 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
212 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
213
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
214 /** Do inverse transform on 4x8 parts of block
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
215 */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
216 static void vc1_inv_trans_4x8_c(DCTELEM block[64], int n)
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
217 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
218 int i;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
219 register int t1,t2,t3,t4,t5,t6,t7,t8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
220 DCTELEM *src, *dst;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
221 int off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
222
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
223 off = n * 4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
224 src = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
225 dst = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
226 for(i = 0; i < 8; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
227 t1 = 17 * (src[0] + src[2]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
228 t2 = 17 * (src[0] - src[2]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
229 t3 = 22 * src[1];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
230 t4 = 22 * src[3];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
231 t5 = 10 * src[1];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
232 t6 = 10 * src[3];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
233
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
234 dst[0] = (t1 + t3 + t6 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
235 dst[1] = (t2 - t4 + t5 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
236 dst[2] = (t2 + t4 - t5 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
237 dst[3] = (t1 - t3 - t6 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
238
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
239 src += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
240 dst += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
241 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
242
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
243 src = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
244 dst = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
245 for(i = 0; i < 4; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
246 t1 = 12 * (src[ 0] + src[32]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
247 t2 = 12 * (src[ 0] - src[32]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
248 t3 = 16 * src[16] + 6 * src[48];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
249 t4 = 6 * src[16] - 16 * src[48];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
250
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
251 t5 = t1 + t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
252 t6 = t2 + t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
253 t7 = t2 - t4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
254 t8 = t1 - t3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
255
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
256 t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
257 t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
258 t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
259 t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
260
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
261 dst[ 0] = (t5 + t1 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
262 dst[ 8] = (t6 + t2 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
263 dst[16] = (t7 + t3 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
264 dst[24] = (t8 + t4 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
265 dst[32] = (t8 - t4 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
266 dst[40] = (t7 - t3 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
267 dst[48] = (t6 - t2 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
268 dst[56] = (t5 - t1 + 64 + 1) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
269
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
270 src++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
271 dst++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
272 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
273 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
274
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
275 /** Do inverse transform on 4x4 part of block
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
276 */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
277 static void vc1_inv_trans_4x4_c(DCTELEM block[64], int n)
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
278 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
279 int i;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
280 register int t1,t2,t3,t4,t5,t6;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
281 DCTELEM *src, *dst;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
282 int off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
283
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
284 off = (n&1) * 4 + (n&2) * 16;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
285 src = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
286 dst = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
287 for(i = 0; i < 4; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
288 t1 = 17 * (src[0] + src[2]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
289 t2 = 17 * (src[0] - src[2]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
290 t3 = 22 * src[1];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
291 t4 = 22 * src[3];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
292 t5 = 10 * src[1];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
293 t6 = 10 * src[3];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
294
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
295 dst[0] = (t1 + t3 + t6 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
296 dst[1] = (t2 - t4 + t5 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
297 dst[2] = (t2 + t4 - t5 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
298 dst[3] = (t1 - t3 - t6 + 4) >> 3;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
299
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
300 src += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
301 dst += 8;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
302 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
303
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
304 src = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
305 dst = block + off;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
306 for(i = 0; i < 4; i++){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
307 t1 = 17 * (src[ 0] + src[16]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
308 t2 = 17 * (src[ 0] - src[16]);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
309 t3 = 22 * src[ 8];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
310 t4 = 22 * src[24];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
311 t5 = 10 * src[ 8];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
312 t6 = 10 * src[24];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
313
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
314 dst[ 0] = (t1 + t3 + t6 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
315 dst[ 8] = (t2 - t4 + t5 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
316 dst[16] = (t2 + t4 - t5 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
317 dst[24] = (t1 - t3 - t6 + 64) >> 7;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
318
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
319 src ++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
320 dst ++;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
321 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
322 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
323
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
324 /* motion compensation functions */
5416
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
325 /** Filter in case of 2 filters */
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
326 #define VC1_MSPEL_FILTER_16B(DIR, TYPE) \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
327 static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, int stride, int mode) \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
328 { \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
329 switch(mode){ \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
330 case 0: /* no shift - should not occur */ \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
331 return 0; \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
332 case 1: /* 1/4 shift */ \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
333 return -4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2]; \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
334 case 2: /* 1/2 shift */ \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
335 return -src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2]; \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
336 case 3: /* 3/4 shift */ \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
337 return -3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2]; \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
338 } \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
339 return 0; /* should not occur */ \
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
340 }
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
341
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
342 VC1_MSPEL_FILTER_16B(ver, uint8_t);
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
343 VC1_MSPEL_FILTER_16B(hor, int16_t);
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
344
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
345
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
346 /** Filter used to interpolate fractional pel values
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
347 */
4283
d6f83e2f8804 rename always_inline to av_always_inline and move to common.h
mru
parents: 4239
diff changeset
348 static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
349 {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
350 switch(mode){
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
351 case 0: //no shift
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
352 return src[0];
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
353 case 1: // 1/4 shift
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
354 return (-4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2] + 32 - r) >> 6;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
355 case 2: // 1/2 shift
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
356 return (-src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2] + 8 - r) >> 4;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
357 case 3: // 3/4 shift
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
358 return (-3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2] + 32 - r) >> 6;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
359 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
360 return 0; //should not occur
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
361 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
362
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
363 /** Function used to do motion compensation with bicubic interpolation
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
364 */
5253
a69976bf878c Pass modes as parameters instead of calculating them inplace.
kostya
parents: 5252
diff changeset
365 static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
366 {
5416
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
367 int i, j;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
368
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
369 if (vmode) { /* Horizontal filter to apply */
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
370 int r;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
371
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
372 if (hmode) { /* Vertical filter to apply, output to tmp */
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
373 static const int shift_value[] = { 0, 5, 1, 5 };
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
374 int shift = (shift_value[hmode]+shift_value[vmode])>>1;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
375 int16_t tmp[11*8], *tptr = tmp;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
376
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
377 r = (1<<(shift-1)) + rnd-1;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
378
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
379 src -= 1;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
380 for(j = 0; j < 8; j++) {
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
381 for(i = 0; i < 11; i++)
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
382 tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
383 src += stride;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
384 tptr += 11;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
385 }
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
386
5416
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
387 r = 64-rnd;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
388 tptr = tmp+1;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
389 for(j = 0; j < 8; j++) {
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
390 for(i = 0; i < 8; i++)
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
391 dst[i] = av_clip_uint8((vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
392 dst += stride;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
393 tptr += 11;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
394 }
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
395
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
396 return;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
397 }
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
398 else { /* No horizontal filter, output 8 lines to dst */
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
399 r = 1-rnd;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
400
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
401 for(j = 0; j < 8; j++) {
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
402 for(i = 0; i < 8; i++)
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
403 dst[i] = av_clip_uint8(vc1_mspel_filter(src + i, stride, vmode, r));
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
404 src += stride;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
405 dst += stride;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
406 }
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
407 return;
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
408 }
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
409 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
410
5416
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
411 /* Horizontal mode with no vertical mode */
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
412 for(j = 0; j < 8; j++) {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
413 for(i = 0; i < 8; i++)
5416
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
414 dst[i] = av_clip_uint8(vc1_mspel_filter(src + i, 1, hmode, rnd));
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
415 dst += stride;
5416
90d90aecc83c Make bicubic interpolation standard compliant
kostya
parents: 5253
diff changeset
416 src += stride;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
417 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
418 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
419
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
420 /* pixel functions - really are entry points to vc1_mspel_mc */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
421
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
422 /* this one is defined in dsputil.c */
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
423 void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
424
5252
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
425 #define PUT_VC1_MSPEL(a, b)\
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
426 static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
5253
a69976bf878c Pass modes as parameters instead of calculating them inplace.
kostya
parents: 5252
diff changeset
427 vc1_mspel_mc(dst, src, stride, a, b, rnd); \
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
428 }
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
429
5252
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
430 PUT_VC1_MSPEL(1, 0)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
431 PUT_VC1_MSPEL(2, 0)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
432 PUT_VC1_MSPEL(3, 0)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
433
5252
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
434 PUT_VC1_MSPEL(0, 1)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
435 PUT_VC1_MSPEL(1, 1)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
436 PUT_VC1_MSPEL(2, 1)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
437 PUT_VC1_MSPEL(3, 1)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
438
5252
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
439 PUT_VC1_MSPEL(0, 2)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
440 PUT_VC1_MSPEL(1, 2)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
441 PUT_VC1_MSPEL(2, 2)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
442 PUT_VC1_MSPEL(3, 2)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
443
5252
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
444 PUT_VC1_MSPEL(0, 3)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
445 PUT_VC1_MSPEL(1, 3)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
446 PUT_VC1_MSPEL(2, 3)
e4b9ca118ab1 Replace function declarations with macro
kostya
parents: 5251
diff changeset
447 PUT_VC1_MSPEL(3, 3)
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
448
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
449 void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
450 dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
451 dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
452 dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
453 dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
454 dsp->vc1_h_overlap = vc1_h_overlap_c;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
455 dsp->vc1_v_overlap = vc1_v_overlap_c;
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
456
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
457 dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_c;
5251
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
458 dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
459 dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
460 dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
461 dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
462 dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
463 dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
464 dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
465 dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
466 dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
467 dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
468 dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
469 dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
470 dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
471 dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
f2a1fa269c12 Drop ff_ prefix for static functions
kostya
parents: 5215
diff changeset
472 dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
3526
7dc8e4a12105 New functions in DSPContext for VC-1 decoding
kostya
parents:
diff changeset
473 }