Statistics
| Branch: | Revision:

ffmpeg / libavcodec / i386 / cavsdsp_mmx.c @ 28748a91

History | View | Annotate | Download (19.7 KB)

1 595e7bd9 Stefan Gehrer
/*
2
 * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
3
 * Copyright (c) 2006  Stefan Gehrer <stefan.gehrer@gmx.de>
4
 *
5 56cc85a0 Diego Biurrun
 * MMX-optimized DSP functions, based on H.264 optimizations by
6 595e7bd9 Stefan Gehrer
 * Michael Niedermayer and Loren Merritt
7
 *
8 b78e7197 Diego Biurrun
 * This file is part of FFmpeg.
9
 *
10
 * FFmpeg is free software; you can redistribute it and/or
11 595e7bd9 Stefan Gehrer
 * modify it under the terms of the GNU Lesser General Public
12
 * License as published by the Free Software Foundation; either
13 b78e7197 Diego Biurrun
 * version 2.1 of the License, or (at your option) any later version.
14 595e7bd9 Stefan Gehrer
 *
15 b78e7197 Diego Biurrun
 * FFmpeg is distributed in the hope that it will be useful,
16 595e7bd9 Stefan Gehrer
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
 * Lesser General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Lesser General Public
21 b78e7197 Diego Biurrun
 * License along with FFmpeg; if not, write to the Free Software
22 e5a389a1 Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 595e7bd9 Stefan Gehrer
 */
24
25 b550bfaa Ronald S. Bultje
#include "dsputil.h"
26 182f56cb Aurelien Jacobs
#include "dsputil_mmx.h"
27 595e7bd9 Stefan Gehrer
#include "common.h"
28
29
/*****************************************************************************
30
 *
31
 * inverse transform
32
 *
33
 ****************************************************************************/
34
35
static inline void cavs_idct8_1d(int16_t *block, uint64_t bias)
36
{
37
    asm volatile(
38
        "movq 112(%0), %%mm4  \n\t" /* mm4 = src7 */
39
        "movq  16(%0), %%mm5  \n\t" /* mm5 = src1 */
40
        "movq  80(%0), %%mm2  \n\t" /* mm2 = src5 */
41
        "movq  48(%0), %%mm7  \n\t" /* mm7 = src3 */
42
        "movq   %%mm4, %%mm0  \n\t"
43
        "movq   %%mm5, %%mm3  \n\t"
44
        "movq   %%mm2, %%mm6  \n\t"
45
        "movq   %%mm7, %%mm1  \n\t"
46
47
        "paddw  %%mm4, %%mm4  \n\t" /* mm4 = 2*src7 */
48
        "paddw  %%mm3, %%mm3  \n\t" /* mm3 = 2*src1 */
49
        "paddw  %%mm6, %%mm6  \n\t" /* mm6 = 2*src5 */
50
        "paddw  %%mm1, %%mm1  \n\t" /* mm1 = 2*src3 */
51
        "paddw  %%mm4, %%mm0  \n\t" /* mm0 = 3*src7 */
52
        "paddw  %%mm3, %%mm5  \n\t" /* mm5 = 3*src1 */
53
        "paddw  %%mm6, %%mm2  \n\t" /* mm2 = 3*src5 */
54
        "paddw  %%mm1, %%mm7  \n\t" /* mm7 = 3*src3 */
55
        "psubw  %%mm4, %%mm5  \n\t" /* mm5 = 3*src1 - 2*src7 = a0 */
56
        "paddw  %%mm6, %%mm7  \n\t" /* mm7 = 3*src3 + 2*src5 = a1 */
57
        "psubw  %%mm2, %%mm1  \n\t" /* mm1 = 2*src3 - 3*src5 = a2 */
58
        "paddw  %%mm0, %%mm3  \n\t" /* mm3 = 2*src1 + 3*src7 = a3 */
59
60
        "movq   %%mm5, %%mm4  \n\t"
61
        "movq   %%mm7, %%mm6  \n\t"
62
        "movq   %%mm3, %%mm0  \n\t"
63
        "movq   %%mm1, %%mm2  \n\t"
64
        SUMSUB_BA( %%mm7, %%mm5 )   /* mm7 = a0 + a1  mm5 = a0 - a1 */
65
        "paddw  %%mm3, %%mm7  \n\t" /* mm7 = a0 + a1 + a3 */
66
        "paddw  %%mm1, %%mm5  \n\t" /* mm5 = a0 - a1 + a2 */
67
        "paddw  %%mm7, %%mm7  \n\t"
68
        "paddw  %%mm5, %%mm5  \n\t"
69
        "paddw  %%mm6, %%mm7  \n\t" /* mm7 = b4 */
70
        "paddw  %%mm4, %%mm5  \n\t" /* mm5 = b5 */
71
72
        SUMSUB_BA( %%mm1, %%mm3 )   /* mm1 = a3 + a2  mm3 = a3 - a2 */
73
        "psubw  %%mm1, %%mm4  \n\t" /* mm4 = a0 - a2 - a3 */
74
        "movq   %%mm4, %%mm1  \n\t" /* mm1 = a0 - a2 - a3 */
75
        "psubw  %%mm6, %%mm3  \n\t" /* mm3 = a3 - a2 - a1 */
76
        "paddw  %%mm1, %%mm1  \n\t"
77
        "paddw  %%mm3, %%mm3  \n\t"
78
        "psubw  %%mm2, %%mm1  \n\t" /* mm1 = b7 */
79
        "paddw  %%mm0, %%mm3  \n\t" /* mm3 = b6 */
80
81
        "movq  32(%0), %%mm2  \n\t" /* mm2 = src2 */
82
        "movq  96(%0), %%mm6  \n\t" /* mm6 = src6 */
83
        "movq   %%mm2, %%mm4  \n\t"
84
        "movq   %%mm6, %%mm0  \n\t"
85
        "psllw  $2,    %%mm4  \n\t" /* mm4 = 4*src2 */
86
        "psllw  $2,    %%mm6  \n\t" /* mm6 = 4*src6 */
87
        "paddw  %%mm4, %%mm2  \n\t" /* mm2 = 5*src2 */
88
        "paddw  %%mm6, %%mm0  \n\t" /* mm0 = 5*src6 */
89
        "paddw  %%mm2, %%mm2  \n\t"
90
        "paddw  %%mm0, %%mm0  \n\t"
91
        "psubw  %%mm0, %%mm4  \n\t" /* mm4 = 4*src2 - 10*src6 = a7 */
92
        "paddw  %%mm2, %%mm6  \n\t" /* mm6 = 4*src6 + 10*src2 = a6 */
93
94
        "movq    (%0), %%mm2  \n\t" /* mm2 = src0 */
95
        "movq  64(%0), %%mm0  \n\t" /* mm0 = src4 */
96
        SUMSUB_BA( %%mm0, %%mm2 )   /* mm0 = src0+src4  mm2 = src0-src4 */
97
        "psllw  $3,    %%mm0  \n\t"
98
        "psllw  $3,    %%mm2  \n\t"
99
        "paddw  %1,    %%mm0  \n\t" /* add rounding bias */
100
        "paddw  %1,    %%mm2  \n\t" /* add rounding bias */
101
102
        SUMSUB_BA( %%mm6, %%mm0 )   /* mm6 = a4 + a6  mm0 = a4 - a6 */
103
        SUMSUB_BA( %%mm4, %%mm2 )   /* mm4 = a5 + a7  mm2 = a5 - a7 */
104
        SUMSUB_BA( %%mm7, %%mm6 )   /* mm7 = dst0  mm6 = dst7 */
105
        SUMSUB_BA( %%mm5, %%mm4 )   /* mm5 = dst1  mm4 = dst6 */
106
        SUMSUB_BA( %%mm3, %%mm2 )   /* mm3 = dst2  mm2 = dst5 */
107
        SUMSUB_BA( %%mm1, %%mm0 )   /* mm1 = dst3  mm0 = dst4 */
108
        :: "r"(block), "m"(bias)
109
    );
110
}
111
112
static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
113
{
114
    int i;
115
    DECLARE_ALIGNED_8(int16_t, b2[64]);
116
117
    for(i=0; i<2; i++){
118
        DECLARE_ALIGNED_8(uint64_t, tmp);
119
120
        cavs_idct8_1d(block+4*i, ff_pw_4);
121
122
        asm volatile(
123
            "psraw     $3, %%mm7  \n\t"
124
            "psraw     $3, %%mm6  \n\t"
125
            "psraw     $3, %%mm5  \n\t"
126
            "psraw     $3, %%mm4  \n\t"
127
            "psraw     $3, %%mm3  \n\t"
128
            "psraw     $3, %%mm2  \n\t"
129
            "psraw     $3, %%mm1  \n\t"
130
            "psraw     $3, %%mm0  \n\t"
131
            "movq   %%mm7,    %0   \n\t"
132
            TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
133
            "movq   %%mm0,  8(%1)  \n\t"
134
            "movq   %%mm6, 24(%1)  \n\t"
135
            "movq   %%mm7, 40(%1)  \n\t"
136
            "movq   %%mm4, 56(%1)  \n\t"
137
            "movq    %0,    %%mm7  \n\t"
138
            TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
139
            "movq   %%mm7,   (%1)  \n\t"
140
            "movq   %%mm1, 16(%1)  \n\t"
141
            "movq   %%mm0, 32(%1)  \n\t"
142
            "movq   %%mm3, 48(%1)  \n\t"
143
            : "=m"(tmp)
144
            : "r"(b2+32*i)
145
            : "memory"
146
        );
147
    }
148
149
    for(i=0; i<2; i++){
150
        cavs_idct8_1d(b2+4*i, ff_pw_64);
151
152
        asm volatile(
153
            "psraw     $7, %%mm7  \n\t"
154
            "psraw     $7, %%mm6  \n\t"
155
            "psraw     $7, %%mm5  \n\t"
156
            "psraw     $7, %%mm4  \n\t"
157
            "psraw     $7, %%mm3  \n\t"
158
            "psraw     $7, %%mm2  \n\t"
159
            "psraw     $7, %%mm1  \n\t"
160
            "psraw     $7, %%mm0  \n\t"
161
            "movq   %%mm7,    (%0)  \n\t"
162
            "movq   %%mm5,  16(%0)  \n\t"
163
            "movq   %%mm3,  32(%0)  \n\t"
164
            "movq   %%mm1,  48(%0)  \n\t"
165
            "movq   %%mm0,  64(%0)  \n\t"
166
            "movq   %%mm2,  80(%0)  \n\t"
167
            "movq   %%mm4,  96(%0)  \n\t"
168
            "movq   %%mm6, 112(%0)  \n\t"
169
            :: "r"(b2+4*i)
170
            : "memory"
171
        );
172
    }
173
174
    add_pixels_clamped_mmx(b2, dst, stride);
175
176
    /* clear block */
177
    asm volatile(
178
            "pxor %%mm7, %%mm7   \n\t"
179
            "movq %%mm7, (%0)    \n\t"
180
            "movq %%mm7, 8(%0)   \n\t"
181
            "movq %%mm7, 16(%0)  \n\t"
182
            "movq %%mm7, 24(%0)  \n\t"
183
            "movq %%mm7, 32(%0)  \n\t"
184
            "movq %%mm7, 40(%0)  \n\t"
185
            "movq %%mm7, 48(%0)  \n\t"
186
            "movq %%mm7, 56(%0)  \n\t"
187
            "movq %%mm7, 64(%0)  \n\t"
188
            "movq %%mm7, 72(%0)  \n\t"
189
            "movq %%mm7, 80(%0)  \n\t"
190
            "movq %%mm7, 88(%0)  \n\t"
191
            "movq %%mm7, 96(%0)  \n\t"
192
            "movq %%mm7, 104(%0) \n\t"
193
            "movq %%mm7, 112(%0) \n\t"
194
            "movq %%mm7, 120(%0) \n\t"
195
            :: "r" (block)
196
    );
197
}
198
199
/*****************************************************************************
200
 *
201
 * motion compensation
202
 *
203
 ****************************************************************************/
204
205
/* vertical filter [-1 -2 96 42 -7  0]  */
206
#define QPEL_CAVSV1(A,B,C,D,E,F,OP)      \
207
        "movd (%0), "#F"            \n\t"\
208
        "movq "#C", %%mm6           \n\t"\
209
        "pmullw %5, %%mm6           \n\t"\
210
        "movq "#D", %%mm7           \n\t"\
211
        "pmullw %6, %%mm7           \n\t"\
212
        "psllw $3, "#E"             \n\t"\
213
        "psubw "#E", %%mm6          \n\t"\
214
        "psraw $3, "#E"             \n\t"\
215
        "paddw %%mm7, %%mm6         \n\t"\
216
        "paddw "#E", %%mm6          \n\t"\
217
        "paddw "#B", "#B"           \n\t"\
218
        "pxor %%mm7, %%mm7          \n\t"\
219
        "add %2, %0                 \n\t"\
220
        "punpcklbw %%mm7, "#F"      \n\t"\
221
        "psubw "#B", %%mm6          \n\t"\
222
        "psraw $1, "#B"             \n\t"\
223
        "psubw "#A", %%mm6          \n\t"\
224
        "paddw %4, %%mm6            \n\t"\
225
        "psraw $7, %%mm6            \n\t"\
226
        "packuswb %%mm6, %%mm6      \n\t"\
227
        OP(%%mm6, (%1), A, d)            \
228
        "add %3, %1                 \n\t"
229
230
/* vertical filter [ 0 -1  5  5 -1  0]  */
231
#define QPEL_CAVSV2(A,B,C,D,E,F,OP)      \
232
        "movd (%0), "#F"            \n\t"\
233
        "movq "#C", %%mm6           \n\t"\
234
        "paddw "#D", %%mm6          \n\t"\
235
        "pmullw %5, %%mm6           \n\t"\
236
        "add %2, %0                 \n\t"\
237
        "punpcklbw %%mm7, "#F"      \n\t"\
238
        "psubw "#B", %%mm6          \n\t"\
239
        "psubw "#E", %%mm6          \n\t"\
240
        "paddw %4, %%mm6            \n\t"\
241
        "psraw $3, %%mm6            \n\t"\
242
        "packuswb %%mm6, %%mm6      \n\t"\
243
        OP(%%mm6, (%1), A, d)            \
244
        "add %3, %1                 \n\t"
245
246
/* vertical filter [ 0 -7 42 96 -2 -1]  */
247
#define QPEL_CAVSV3(A,B,C,D,E,F,OP)      \
248
        "movd (%0), "#F"            \n\t"\
249
        "movq "#C", %%mm6           \n\t"\
250
        "pmullw %6, %%mm6           \n\t"\
251
        "movq "#D", %%mm7           \n\t"\
252
        "pmullw %5, %%mm7           \n\t"\
253
        "psllw $3, "#B"             \n\t"\
254
        "psubw "#B", %%mm6          \n\t"\
255
        "psraw $3, "#B"             \n\t"\
256
        "paddw %%mm7, %%mm6         \n\t"\
257
        "paddw "#B", %%mm6          \n\t"\
258
        "paddw "#E", "#E"           \n\t"\
259
        "pxor %%mm7, %%mm7          \n\t"\
260
        "add %2, %0                 \n\t"\
261
        "punpcklbw %%mm7, "#F"      \n\t"\
262
        "psubw "#E", %%mm6          \n\t"\
263
        "psraw $1, "#E"             \n\t"\
264
        "psubw "#F", %%mm6          \n\t"\
265
        "paddw %4, %%mm6            \n\t"\
266
        "psraw $7, %%mm6            \n\t"\
267
        "packuswb %%mm6, %%mm6      \n\t"\
268
        OP(%%mm6, (%1), A, d)            \
269
        "add %3, %1                 \n\t"
270
271
272
#define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\
273
    int w= 2;\
274
    src -= 2*srcStride;\
275
    \
276
    while(w--){\
277
      asm volatile(\
278
        "pxor %%mm7, %%mm7          \n\t"\
279
        "movd (%0), %%mm0           \n\t"\
280
        "add %2, %0                 \n\t"\
281
        "movd (%0), %%mm1           \n\t"\
282
        "add %2, %0                 \n\t"\
283
        "movd (%0), %%mm2           \n\t"\
284
        "add %2, %0                 \n\t"\
285
        "movd (%0), %%mm3           \n\t"\
286
        "add %2, %0                 \n\t"\
287
        "movd (%0), %%mm4           \n\t"\
288
        "add %2, %0                 \n\t"\
289
        "punpcklbw %%mm7, %%mm0     \n\t"\
290
        "punpcklbw %%mm7, %%mm1     \n\t"\
291
        "punpcklbw %%mm7, %%mm2     \n\t"\
292
        "punpcklbw %%mm7, %%mm3     \n\t"\
293
        "punpcklbw %%mm7, %%mm4     \n\t"\
294
        VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
295
        VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
296
        VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
297
        VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
298
        VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
299
        VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
300
        VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
301
        VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
302
        \
303
        : "+a"(src), "+c"(dst)\
304
        : "S"((long)srcStride), "D"((long)dstStride), "m"(ADD), "m"(MUL1), "m"(MUL2)\
305
        : "memory"\
306
     );\
307
     if(h==16){\
308
        asm volatile(\
309
            VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
310
            VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
311
            VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
312
            VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
313
            VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
314
            VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
315
            VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
316
            VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
317
            \
318
           : "+a"(src), "+c"(dst)\
319
           : "S"((long)srcStride), "D"((long)dstStride), "m"(ADD),  "m"(MUL1), "m"(MUL2)\
320
           : "memory"\
321
        );\
322
     }\
323
     src += 4-(h+5)*srcStride;\
324
     dst += 4-h*dstStride;\
325
   }
326
327
#define QPEL_CAVS(OPNAME, OP, MMX)\
328
static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
329
    int h=8;\
330
    asm volatile(\
331
        "pxor %%mm7, %%mm7          \n\t"\
332
        "movq %5, %%mm6             \n\t"\
333
        "1:                         \n\t"\
334
        "movq    (%0), %%mm0        \n\t"\
335
        "movq   1(%0), %%mm2        \n\t"\
336
        "movq %%mm0, %%mm1          \n\t"\
337
        "movq %%mm2, %%mm3          \n\t"\
338
        "punpcklbw %%mm7, %%mm0     \n\t"\
339
        "punpckhbw %%mm7, %%mm1     \n\t"\
340
        "punpcklbw %%mm7, %%mm2     \n\t"\
341
        "punpckhbw %%mm7, %%mm3     \n\t"\
342
        "paddw %%mm2, %%mm0         \n\t"\
343
        "paddw %%mm3, %%mm1         \n\t"\
344
        "pmullw %%mm6, %%mm0        \n\t"\
345
        "pmullw %%mm6, %%mm1        \n\t"\
346
        "movq   -1(%0), %%mm2       \n\t"\
347
        "movq    2(%0), %%mm4       \n\t"\
348
        "movq %%mm2, %%mm3          \n\t"\
349
        "movq %%mm4, %%mm5          \n\t"\
350
        "punpcklbw %%mm7, %%mm2     \n\t"\
351
        "punpckhbw %%mm7, %%mm3     \n\t"\
352
        "punpcklbw %%mm7, %%mm4     \n\t"\
353
        "punpckhbw %%mm7, %%mm5     \n\t"\
354
        "paddw %%mm4, %%mm2         \n\t"\
355
        "paddw %%mm3, %%mm5         \n\t"\
356
        "psubw %%mm2, %%mm0         \n\t"\
357
        "psubw %%mm5, %%mm1         \n\t"\
358
        "movq %6, %%mm5             \n\t"\
359
        "paddw %%mm5, %%mm0         \n\t"\
360
        "paddw %%mm5, %%mm1         \n\t"\
361
        "psraw $3, %%mm0            \n\t"\
362
        "psraw $3, %%mm1            \n\t"\
363
        "packuswb %%mm1, %%mm0      \n\t"\
364
        OP(%%mm0, (%1),%%mm5, q)         \
365
        "add %3, %0                 \n\t"\
366
        "add %4, %1                 \n\t"\
367
        "decl %2                    \n\t"\
368
        " jnz 1b                    \n\t"\
369
        : "+a"(src), "+c"(dst), "+m"(h)\
370
        : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_4)\
371
        : "memory"\
372
    );\
373
}\
374
\
375
static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
376
  QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42)      \
377
}\
378
\
379
static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
380
  QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_5)         \
381
}\
382
\
383
static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
384
  QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42)      \
385
}\
386
\
387
static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
388
    OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst  , src  , dstStride, srcStride, 8);\
389
}\
390
static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
391
    OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst  , src  , dstStride, srcStride, 16);\
392
    OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
393
}\
394
\
395
static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
396
    OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst  , src  , dstStride, srcStride, 8);\
397
}\
398
static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
399
    OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst  , src  , dstStride, srcStride, 16);\
400
    OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
401
}\
402
\
403
static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
404
    OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst  , src  , dstStride, srcStride, 8);\
405
}\
406
static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
407
    OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst  , src  , dstStride, srcStride, 16);\
408
    OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
409
}\
410
\
411
static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
412
    OPNAME ## cavs_qpel8_h_ ## MMX(dst  , src  , dstStride, srcStride);\
413
    OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
414
    src += 8*srcStride;\
415
    dst += 8*dstStride;\
416
    OPNAME ## cavs_qpel8_h_ ## MMX(dst  , src  , dstStride, srcStride);\
417
    OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
418
}\
419
420
#define CAVS_MC(OPNAME, SIZE, MMX) \
421
static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
422
    OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\
423
}\
424
\
425
static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
426
    OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\
427
}\
428
\
429
static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
430
    OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\
431
}\
432
\
433
static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
434
    OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\
435
}\
436
437
#define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b "    \n\t"
438
#define AVG_3DNOW_OP(a,b,temp, size) \
439
"mov" #size " " #b ", " #temp "   \n\t"\
440
"pavgusb " #temp ", " #a "        \n\t"\
441
"mov" #size " " #a ", " #b "      \n\t"
442
#define AVG_MMX2_OP(a,b,temp, size) \
443
"mov" #size " " #b ", " #temp "   \n\t"\
444
"pavgb " #temp ", " #a "          \n\t"\
445
"mov" #size " " #a ", " #b "      \n\t"
446
447
QPEL_CAVS(put_,       PUT_OP, 3dnow)
448
QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow)
449
QPEL_CAVS(put_,       PUT_OP, mmx2)
450
QPEL_CAVS(avg_,  AVG_MMX2_OP, mmx2)
451
452
CAVS_MC(put_, 8, 3dnow)
453
CAVS_MC(put_, 16,3dnow)
454
CAVS_MC(avg_, 8, 3dnow)
455
CAVS_MC(avg_, 16,3dnow)
456
CAVS_MC(put_, 8, mmx2)
457
CAVS_MC(put_, 16,mmx2)
458
CAVS_MC(avg_, 8, mmx2)
459
CAVS_MC(avg_, 16,mmx2)
460
461
void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
462
void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
463
void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
464
void ff_avg_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
465
466
void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) {
467
#define dspfunc(PFX, IDX, NUM) \
468
    c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
469
    c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \
470
    c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_mmx2; \
471
    c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_mmx2; \
472
    c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_mmx2; \
473
474
    dspfunc(put_cavs_qpel, 0, 16);
475
    dspfunc(put_cavs_qpel, 1, 8);
476
    dspfunc(avg_cavs_qpel, 0, 16);
477
    dspfunc(avg_cavs_qpel, 1, 8);
478
#undef dspfunc
479
    c->cavs_idct8_add = cavs_idct8_add_mmx;
480
}
481
482
void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) {
483
#define dspfunc(PFX, IDX, NUM) \
484
    c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
485
    c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \
486
    c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_3dnow; \
487
    c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_3dnow; \
488
    c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_3dnow; \
489
490
    dspfunc(put_cavs_qpel, 0, 16);
491
    dspfunc(put_cavs_qpel, 1, 8);
492
    dspfunc(avg_cavs_qpel, 0, 16);
493
    dspfunc(avg_cavs_qpel, 1, 8);
494
#undef dspfunc
495
    c->cavs_idct8_add = cavs_idct8_add_mmx;
496
}