Statistics
| Branch: | Revision:

ffmpeg / libavcodec / i386 / vc1dsp_mmx.c @ 182f56cb

History | View | Annotate | Download (23.5 KB)

1
/*
2
 * VC-1 and WMV3 - DSP functions MMX-optimized
3
 * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
4
 *
5
 * Permission is hereby granted, free of charge, to any person
6
 * obtaining a copy of this software and associated documentation
7
 * files (the "Software"), to deal in the Software without
8
 * restriction, including without limitation the rights to use,
9
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following
12
 * conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be
15
 * included in all copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
 * OTHER DEALINGS IN THE SOFTWARE.
25
 */
26

    
27
#include "dsputil.h"
28
#include "dsputil_mmx.h"
29
#include "x86_cpu.h"
30

    
31
/** Add rounder from mm7 to mm3 and pack result at destination */
32
#define NORMALIZE_MMX(SHIFT)                                    \
33
     "paddw     %%mm7, %%mm3           \n\t" /* +bias-r */      \
34
     "paddw     %%mm7, %%mm4           \n\t" /* +bias-r */      \
35
     "psraw     "SHIFT", %%mm3         \n\t"                    \
36
     "psraw     "SHIFT", %%mm4         \n\t"
37

    
38
#define TRANSFER_DO_PACK                        \
39
     "packuswb  %%mm4, %%mm3           \n\t"    \
40
     "movq      %%mm3, (%2)            \n\t"
41

    
42
#define TRANSFER_DONT_PACK                      \
43
     "movq      %%mm3, 0(%2)           \n\t"    \
44
     "movq      %%mm4, 8(%2)           \n\t"
45

    
46
/** @see MSPEL_FILTER13_CORE for use as UNPACK macro */
47
#define DO_UNPACK(reg)  "punpcklbw %%mm0, " reg "\n\t"
48
#define DONT_UNPACK(reg)
49

    
50
/** Compute the rounder 32-r or 8-r and unpacks it to mm7 */
51
#define LOAD_ROUNDER_MMX(ROUND)                 \
52
     "movd      "ROUND", %%mm7         \n\t"    \
53
     "punpcklwd %%mm7, %%mm7           \n\t"    \
54
     "punpckldq %%mm7, %%mm7           \n\t"
55

    
56
#define SHIFT2_LINE(OFF, R0,R1,R2,R3)           \
57
    "paddw     %%mm"#R2", %%mm"#R1"    \n\t"    \
58
    "movd      (%1,%4), %%mm"#R0"      \n\t"    \
59
    "pmullw    %%mm6, %%mm"#R1"        \n\t"    \
60
    "punpcklbw %%mm0, %%mm"#R0"        \n\t"    \
61
    "movd      (%1,%3), %%mm"#R3"      \n\t"    \
62
    "psubw     %%mm"#R0", %%mm"#R1"    \n\t"    \
63
    "punpcklbw %%mm0, %%mm"#R3"        \n\t"    \
64
    "paddw     %%mm7, %%mm"#R1"        \n\t"    \
65
    "psubw     %%mm"#R3", %%mm"#R1"    \n\t"    \
66
    "psraw     %5, %%mm"#R1"           \n\t"    \
67
    "movq      %%mm"#R1", "#OFF"(%2)   \n\t"    \
68
    "add       %3, %1                  \n\t"
69

    
70
DECLARE_ALIGNED_16(static const uint64_t, fact_9) = 0x0009000900090009ULL;
71

    
72
/** Sacrifying mm6 allows to pipeline loads from src */
73
static void vc1_put_ver_16b_shift2_mmx(int16_t *dst,
74
                                       const uint8_t *src, long int stride,
75
                                       int rnd, int64_t shift)
76
{
77
    int  w = 3;
78

    
79
    asm volatile(
80
        LOAD_ROUNDER_MMX("%6")
81
        "movq      %7, %%mm6               \n\t"
82
        "1:                                \n\t"
83
        "movd      (%1), %%mm2             \n\t"
84
        "add       %3, %1                  \n\t"
85
        "movd      (%1), %%mm3             \n\t"
86
        "punpcklbw %%mm0, %%mm2            \n\t"
87
        "punpcklbw %%mm0, %%mm3            \n\t"
88
        SHIFT2_LINE(  0, 1, 2, 3, 4)
89
        SHIFT2_LINE( 24, 2, 3, 4, 1)
90
        SHIFT2_LINE( 48, 3, 4, 1, 2)
91
        SHIFT2_LINE( 72, 4, 1, 2, 3)
92
        SHIFT2_LINE( 96, 1, 2, 3, 4)
93
        SHIFT2_LINE(120, 2, 3, 4, 1)
94
        SHIFT2_LINE(144, 3, 4, 1, 2)
95
        SHIFT2_LINE(168, 4, 1, 2, 3)
96
        "sub       %8, %1                  \n\t"
97
        "add       $8, %2                  \n\t"
98
        "dec       %0                      \n\t"
99
        "jnz 1b                            \n\t"
100
        : "+g"(w), "+r"(src), "+r"(dst)
101
        : "r"(stride), "r"(-2*stride), "m"(shift),
102
          "m"(rnd), "m"(fact_9), "g"(9*stride-4)
103
        : "memory"
104
    );
105
}
106

    
107
/**
108
 * Data is already unpacked, so some operations can directly be made from
109
 * memory.
110
 */
111
static void vc1_put_hor_16b_shift2_mmx(uint8_t *dst, long int stride,
112
                                       const int16_t *src, int rnd)
113
{
114
    int h = 8;
115

    
116
    src -= 1;
117
    rnd -= (-1+9+9-1)*1024; /* Add -1024 bias */
118
    asm volatile(
119
        LOAD_ROUNDER_MMX("%4")
120
        "movq      %6, %%mm6               \n\t"
121
        "movq      %5, %%mm5               \n\t"
122
        "1:                                \n\t"
123
        "movq      2*0+0(%1), %%mm1        \n\t"
124
        "movq      2*0+8(%1), %%mm2        \n\t"
125
        "movq      2*1+0(%1), %%mm3        \n\t"
126
        "movq      2*1+8(%1), %%mm4        \n\t"
127
        "paddw     2*3+0(%1), %%mm1        \n\t"
128
        "paddw     2*3+8(%1), %%mm2        \n\t"
129
        "paddw     2*2+0(%1), %%mm3        \n\t"
130
        "paddw     2*2+8(%1), %%mm4        \n\t"
131
        "pmullw    %%mm5, %%mm3            \n\t"
132
        "pmullw    %%mm5, %%mm4            \n\t"
133
        "psubw     %%mm1, %%mm3            \n\t"
134
        "psubw     %%mm2, %%mm4            \n\t"
135
        NORMALIZE_MMX("$7")
136
        /* Remove bias */
137
        "paddw     %%mm6, %%mm3            \n\t"
138
        "paddw     %%mm6, %%mm4            \n\t"
139
        TRANSFER_DO_PACK
140
        "add       $24, %1                 \n\t"
141
        "add       %3, %2                  \n\t"
142
        "dec       %0                      \n\t"
143
        "jnz 1b                            \n\t"
144
        : "+g"(h), "+r" (src),  "+r" (dst)
145
        : "g"(stride), "m"(rnd), "m"(fact_9), "m"(ff_pw_128)
146
        : "memory"
147
    );
148
}
149

    
150

    
151
/**
152
 * Purely vertical or horizontal 1/2 shift interpolation.
153
 * Sacrify mm6 for *9 factor.
154
 */
155
static void vc1_put_shift2_mmx(uint8_t *dst, const uint8_t *src,
156
                               long int stride, int rnd, long int offset)
157
{
158
    int h = 8;
159

    
160
    rnd = 8-rnd;
161
    asm volatile(
162
        LOAD_ROUNDER_MMX("%6")
163
        "movq      %8, %%mm6               \n\t"
164
        "1:                                \n\t"
165
        "movd      0(%1   ), %%mm3         \n\t"
166
        "movd      4(%1   ), %%mm4         \n\t"
167
        "movd      0(%1,%3), %%mm1         \n\t"
168
        "movd      4(%1,%3), %%mm2         \n\t"
169
        "add       %3, %1                  \n\t"
170
        "punpcklbw %%mm0, %%mm3            \n\t"
171
        "punpcklbw %%mm0, %%mm4            \n\t"
172
        "punpcklbw %%mm0, %%mm1            \n\t"
173
        "punpcklbw %%mm0, %%mm2            \n\t"
174
        "paddw     %%mm1, %%mm3            \n\t"
175
        "paddw     %%mm2, %%mm4            \n\t"
176
        "movd      0(%1,%4), %%mm1         \n\t"
177
        "movd      4(%1,%4), %%mm2         \n\t"
178
        "pmullw    %%mm6, %%mm3            \n\t" /* 0,9,9,0*/
179
        "pmullw    %%mm6, %%mm4            \n\t" /* 0,9,9,0*/
180
        "punpcklbw %%mm0, %%mm1            \n\t"
181
        "punpcklbw %%mm0, %%mm2            \n\t"
182
        "psubw     %%mm1, %%mm3            \n\t" /*-1,9,9,0*/
183
        "psubw     %%mm2, %%mm4            \n\t" /*-1,9,9,0*/
184
        "movd      0(%1,%3), %%mm1         \n\t"
185
        "movd      4(%1,%3), %%mm2         \n\t"
186
        "punpcklbw %%mm0, %%mm1            \n\t"
187
        "punpcklbw %%mm0, %%mm2            \n\t"
188
        "psubw     %%mm1, %%mm3            \n\t" /*-1,9,9,-1*/
189
        "psubw     %%mm2, %%mm4            \n\t" /*-1,9,9,-1*/
190
        NORMALIZE_MMX("$4")
191
        TRANSFER_DO_PACK
192
        "add       %7, %1                  \n\t"
193
        "add       %5, %2                  \n\t"
194
        "dec       %0                      \n\t"
195
        "jnz 1b                            \n\t"
196
        : "+g"(h), "+r"(src),  "+r"(dst)
197
        : "r"(offset), "r"(-2*offset), "g"(stride), "m"(rnd),
198
          "g"(stride-offset), "m"(fact_9)
199
        : "memory"
200
    );
201
}
202

    
203
/**
204
 * Filter coefficients made global to allow access by all 1 or 3 quarter shift
205
 * interpolation functions.
206
 */
207
DECLARE_ALIGNED_16(static const uint64_t, fact_53) = 0x0035003500350035ULL;
208
DECLARE_ALIGNED_16(static const uint64_t, fact_18) = 0x0012001200120012ULL;
209

    
210
/**
211
 * Core of the 1/4 and 3/4 shift bicubic interpolation.
212
 *
213
 * @param UNPACK  Macro unpacking arguments from 8 to 16bits (can be empty).
214
 * @param MOVQ    "movd 1" or "movq 2", if data read is already unpacked.
215
 * @param A1      Address of 1st tap (beware of unpacked/packed).
216
 * @param A2      Address of 2nd tap
217
 * @param A3      Address of 3rd tap
218
 * @param A4      Address of 4th tap
219
 */
220
#define MSPEL_FILTER13_CORE(UNPACK, MOVQ, A1, A2, A3, A4, POS)  \
221
     MOVQ "*0+"A1", %%mm1       \n\t"                           \
222
     MOVQ "*4+"A1", %%mm2       \n\t"                           \
223
     UNPACK("%%mm1")                                            \
224
     UNPACK("%%mm2")                                            \
225
     "pmullw    "POS", %%mm1    \n\t"                           \
226
     "pmullw    "POS", %%mm2    \n\t"                           \
227
     MOVQ "*0+"A2", %%mm3       \n\t"                           \
228
     MOVQ "*4+"A2", %%mm4       \n\t"                           \
229
     UNPACK("%%mm3")                                            \
230
     UNPACK("%%mm4")                                            \
231
     "pmullw    %%mm6, %%mm3    \n\t" /* *18 */                 \
232
     "pmullw    %%mm6, %%mm4    \n\t" /* *18 */                 \
233
     "psubw     %%mm1, %%mm3    \n\t" /* 18,-3 */               \
234
     "psubw     %%mm2, %%mm4    \n\t" /* 18,-3 */               \
235
     MOVQ "*0+"A4", %%mm1       \n\t"                           \
236
     MOVQ "*4+"A4", %%mm2       \n\t"                           \
237
     UNPACK("%%mm1")                                            \
238
     UNPACK("%%mm2")                                            \
239
     "psllw     $2, %%mm1       \n\t" /* 4* */                  \
240
     "psllw     $2, %%mm2       \n\t" /* 4* */                  \
241
     "psubw     %%mm1, %%mm3    \n\t" /* -4,18,-3 */            \
242
     "psubw     %%mm2, %%mm4    \n\t" /* -4,18,-3 */            \
243
     MOVQ "*0+"A3", %%mm1       \n\t"                           \
244
     MOVQ "*4+"A3", %%mm2       \n\t"                           \
245
     UNPACK("%%mm1")                                            \
246
     UNPACK("%%mm2")                                            \
247
     "pmullw    %%mm5, %%mm1    \n\t" /* *53 */                 \
248
     "pmullw    %%mm5, %%mm2    \n\t" /* *53 */                 \
249
     "paddw     %%mm1, %%mm3    \n\t" /* 4,53,18,-3 */          \
250
     "paddw     %%mm2, %%mm4    \n\t" /* 4,53,18,-3 */
251

    
252
/**
253
 * Macro to build the vertical 16bits version of vc1_put_shift[13].
254
 * Here, offset=src_stride. Parameters passed A1 to A4 must use
255
 * %3 (src_stride) and %4 (3*src_stride).
256
 *
257
 * @param  NAME   Either 1 or 3
258
 * @see MSPEL_FILTER13_CORE for information on A1->A4
259
 */
260
#define MSPEL_FILTER13_VER_16B(NAME, A1, A2, A3, A4)                    \
261
static void                                                             \
262
vc1_put_ver_16b_ ## NAME ## _mmx(int16_t *dst, const uint8_t *src,      \
263
                                 long int src_stride,                   \
264
                                 int rnd, int64_t shift)                \
265
{                                                                       \
266
    int h = 8;                                                          \
267
    src -= src_stride;                                                  \
268
    asm volatile(                                                       \
269
        LOAD_ROUNDER_MMX("%5")                                          \
270
        "movq      %7, %%mm5       \n\t"                                \
271
        "movq      %8, %%mm6       \n\t"                                \
272
        ASMALIGN(3)                                                     \
273
        "1:                        \n\t"                                \
274
        MSPEL_FILTER13_CORE(DO_UNPACK, "movd  1", A1, A2, A3, A4, "%9") \
275
        NORMALIZE_MMX("%6")                                             \
276
        TRANSFER_DONT_PACK                                              \
277
        /* Last 3 (in fact 4) bytes on the line */                      \
278
        "movd      8+"A1", %%mm1   \n\t"                                \
279
        DO_UNPACK("%%mm1")                                              \
280
        "movq      %%mm1, %%mm3    \n\t"                                \
281
        "paddw     %%mm1, %%mm1    \n\t"                                \
282
        "paddw     %%mm3, %%mm1    \n\t" /* 3* */                       \
283
        "movd      8+"A2", %%mm3   \n\t"                                \
284
        DO_UNPACK("%%mm3")                                              \
285
        "pmullw    %%mm6, %%mm3    \n\t" /* *18 */                      \
286
        "psubw     %%mm1, %%mm3    \n\t" /*18,-3 */                     \
287
        "movd      8+"A3", %%mm1   \n\t"                                \
288
        DO_UNPACK("%%mm1")                                              \
289
        "pmullw    %%mm5, %%mm1    \n\t" /* *53 */                      \
290
        "paddw     %%mm1, %%mm3    \n\t" /*53,18,-3 */                  \
291
        "movd      8+"A4", %%mm1   \n\t"                                \
292
        DO_UNPACK("%%mm1")                                              \
293
        "psllw     $2, %%mm1       \n\t" /* 4* */                       \
294
        "psubw     %%mm1, %%mm3    \n\t"                                \
295
        "paddw     %%mm7, %%mm3    \n\t"                                \
296
        "psraw     %6, %%mm3       \n\t"                                \
297
        "movq      %%mm3, 16(%2)   \n\t"                                \
298
        "add       %3, %1          \n\t"                                \
299
        "add       $24, %2         \n\t"                                \
300
        "dec       %0              \n\t"                                \
301
        "jnz 1b                    \n\t"                                \
302
        : "+g"(h), "+r" (src),  "+r" (dst)                              \
303
        : "r"(src_stride), "r"(3*src_stride),                           \
304
          "m"(rnd), "m"(shift),                                         \
305
          "m"(fact_53), "m"(fact_18), "m"(ff_pw_3)                      \
306
        : "memory"                                                      \
307
    );                                                                  \
308
}
309

    
310
/**
311
 * Macro to build the horizontal 16bits version of vc1_put_shift[13].
312
 * Here, offset=16bits, so parameters passed A1 to A4 should be simple.
313
 *
314
 * @param  NAME   Either 1 or 3
315
 * @see MSPEL_FILTER13_CORE for information on A1->A4
316
 */
317
#define MSPEL_FILTER13_HOR_16B(NAME, A1, A2, A3, A4)                    \
318
static void                                                             \
319
vc1_put_hor_16b_ ## NAME ## _mmx(uint8_t *dst, long int stride,         \
320
                                 const int16_t *src, int rnd)           \
321
{                                                                       \
322
    int h = 8;                                                          \
323
    src -= 1;                                                           \
324
    rnd -= (-4+58+13-3)*256; /* Add -256 bias */                        \
325
    asm volatile(                                                       \
326
        LOAD_ROUNDER_MMX("%4")                                          \
327
        "movq      %6, %%mm6       \n\t"                                \
328
        "movq      %5, %%mm5       \n\t"                                \
329
        ASMALIGN(3)                                                     \
330
        "1:                        \n\t"                                \
331
        MSPEL_FILTER13_CORE(DONT_UNPACK, "movq 2", A1, A2, A3, A4, "%8")\
332
        NORMALIZE_MMX("$7")                                             \
333
        /* Remove bias */                                               \
334
        "paddw     %7, %%mm3       \n\t"                                \
335
        "paddw     %7, %%mm4       \n\t"                                \
336
        TRANSFER_DO_PACK                                                \
337
        "add       $24, %1         \n\t"                                \
338
        "add       %3, %2          \n\t"                                \
339
        "dec       %0              \n\t"                                \
340
        "jnz 1b                    \n\t"                                \
341
        : "+g"(h), "+r" (src),  "+r" (dst)                              \
342
        : "g"(stride), "m"(rnd), "m"(fact_53), "m"(fact_18),            \
343
          "m"(ff_pw_128), "m"(ff_pw_3)                                  \
344
        : "memory"                                                      \
345
    );                                                                  \
346
}
347

    
348
/**
349
 * Macro to build the 8bits, any direction, version of vc1_put_shift[13].
350
 * Here, offset=src_stride. Parameters passed A1 to A4 must use
351
 * %3 (offset) and %4 (3*offset).
352
 *
353
 * @param  NAME   Either 1 or 3
354
 * @see MSPEL_FILTER13_CORE for information on A1->A4
355
 */
356
#define MSPEL_FILTER13_8B(NAME, A1, A2, A3, A4)                         \
357
static void                                                             \
358
vc1_put_## NAME ## _mmx(uint8_t *dst, const uint8_t *src,               \
359
                        long int stride, int rnd, long int offset)      \
360
{                                                                       \
361
    int h = 8;                                                          \
362
    src -= offset;                                                      \
363
    rnd = 32-rnd;                                                       \
364
    asm volatile (                                                      \
365
        LOAD_ROUNDER_MMX("%6")                                          \
366
        "movq      %7, %%mm5       \n\t"                                \
367
        "movq      %8, %%mm6       \n\t"                                \
368
        ASMALIGN(3)                                                     \
369
        "1:                        \n\t"                                \
370
        MSPEL_FILTER13_CORE(DO_UNPACK, "movd   1", A1, A2, A3, A4, "%9")\
371
        NORMALIZE_MMX("$6")                                             \
372
        TRANSFER_DO_PACK                                                \
373
        "add       %5, %1          \n\t"                                \
374
        "add       %5, %2          \n\t"                                \
375
        "dec       %0              \n\t"                                \
376
        "jnz 1b                    \n\t"                                \
377
        : "+g"(h), "+r" (src),  "+r" (dst)                              \
378
        : "r"(offset), "r"(3*offset), "g"(stride), "m"(rnd),            \
379
          "m"(fact_53), "m"(fact_18), "m"(ff_pw_3)                      \
380
        : "memory"                                                      \
381
    );                                                                  \
382
}
383

    
384
/** 1/4 shift bicubic interpolation */
385
MSPEL_FILTER13_8B     (shift1, "0(%1,%4  )", "0(%1,%3,2)", "0(%1,%3  )", "0(%1     )")
386
MSPEL_FILTER13_VER_16B(shift1, "0(%1,%4  )", "0(%1,%3,2)", "0(%1,%3  )", "0(%1     )")
387
MSPEL_FILTER13_HOR_16B(shift1, "2*3(%1)", "2*2(%1)", "2*1(%1)", "2*0(%1)")
388

    
389
/** 3/4 shift bicubic interpolation */
390
MSPEL_FILTER13_8B     (shift3, "0(%1     )", "0(%1,%3  )", "0(%1,%3,2)", "0(%1,%4  )")
391
MSPEL_FILTER13_VER_16B(shift3, "0(%1     )", "0(%1,%3  )", "0(%1,%3,2)", "0(%1,%4  )")
392
MSPEL_FILTER13_HOR_16B(shift3, "2*0(%1)", "2*1(%1)", "2*2(%1)", "2*3(%1)")
393

    
394
typedef void (*vc1_mspel_mc_filter_ver_16bits)(int16_t *dst, const uint8_t *src, long int src_stride, int rnd, int64_t shift);
395
typedef void (*vc1_mspel_mc_filter_hor_16bits)(uint8_t *dst, long int dst_stride, const int16_t *src, int rnd);
396
typedef void (*vc1_mspel_mc_filter_8bits)(uint8_t *dst, const uint8_t *src, long int stride, int rnd, long int offset);
397

    
398
/**
399
 * Interpolates fractional pel values by applying proper vertical then
400
 * horizontal filter.
401
 *
402
 * @param  dst     Destination buffer for interpolated pels.
403
 * @param  src     Source buffer.
404
 * @param  stride  Stride for both src and dst buffers.
405
 * @param  hmode   Horizontal filter (expressed in quarter pixels shift).
406
 * @param  hmode   Vertical filter.
407
 * @param  rnd     Rounding bias.
408
 */
409
static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride,
410
                         int hmode, int vmode, int rnd)
411
{
412
    static const vc1_mspel_mc_filter_ver_16bits vc1_put_shift_ver_16bits[] =
413
         { NULL, vc1_put_ver_16b_shift1_mmx, vc1_put_ver_16b_shift2_mmx, vc1_put_ver_16b_shift3_mmx };
414
    static const vc1_mspel_mc_filter_hor_16bits vc1_put_shift_hor_16bits[] =
415
         { NULL, vc1_put_hor_16b_shift1_mmx, vc1_put_hor_16b_shift2_mmx, vc1_put_hor_16b_shift3_mmx };
416
    static const vc1_mspel_mc_filter_8bits vc1_put_shift_8bits[] =
417
         { NULL, vc1_put_shift1_mmx, vc1_put_shift2_mmx, vc1_put_shift3_mmx };
418

    
419
    asm volatile(
420
        "pxor %%mm0, %%mm0         \n\t"
421
        ::: "memory"
422
    );
423

    
424
    if (vmode) { /* Vertical filter to apply */
425
        if (hmode) { /* Horizontal filter to apply, output to tmp */
426
            static const int shift_value[] = { 0, 5, 1, 5 };
427
            int              shift = (shift_value[hmode]+shift_value[vmode])>>1;
428
            int              r;
429
            DECLARE_ALIGNED_16(int16_t, tmp[12*8]);
430

    
431
            r = (1<<(shift-1)) + rnd-1;
432
            vc1_put_shift_ver_16bits[vmode](tmp, src-1, stride, r, shift);
433

    
434
            vc1_put_shift_hor_16bits[hmode](dst, stride, tmp+1, 64-rnd);
435
            return;
436
        }
437
        else { /* No horizontal filter, output 8 lines to dst */
438
            vc1_put_shift_8bits[vmode](dst, src, stride, 1-rnd, stride);
439
            return;
440
        }
441
    }
442

    
443
    /* Horizontal mode with no vertical mode */
444
    vc1_put_shift_8bits[hmode](dst, src, stride, rnd, 1);
445
}
446

    
447
static void put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
448
    put_pixels8_mmx(dst, src, stride, 8);
449
}
450

    
451
/** Macro to ease bicubic filter interpolation functions declarations */
452
#define DECLARE_FUNCTION(a, b)                                          \
453
static void put_vc1_mspel_mc ## a ## b ## _mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
454
     vc1_mspel_mc(dst, src, stride, a, b, rnd);                         \
455
}
456

    
457
DECLARE_FUNCTION(0, 1)
458
DECLARE_FUNCTION(0, 2)
459
DECLARE_FUNCTION(0, 3)
460

    
461
DECLARE_FUNCTION(1, 0)
462
DECLARE_FUNCTION(1, 1)
463
DECLARE_FUNCTION(1, 2)
464
DECLARE_FUNCTION(1, 3)
465

    
466
DECLARE_FUNCTION(2, 0)
467
DECLARE_FUNCTION(2, 1)
468
DECLARE_FUNCTION(2, 2)
469
DECLARE_FUNCTION(2, 3)
470

    
471
DECLARE_FUNCTION(3, 0)
472
DECLARE_FUNCTION(3, 1)
473
DECLARE_FUNCTION(3, 2)
474
DECLARE_FUNCTION(3, 3)
475

    
476
void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
477
    dsp->put_vc1_mspel_pixels_tab[ 0] = put_vc1_mspel_mc00_mmx;
478
    dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
479
    dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_mmx;
480
    dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_mmx;
481

    
482
    dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_mmx;
483
    dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_mmx;
484
    dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_mmx;
485
    dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_mmx;
486

    
487
    dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_mmx;
488
    dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_mmx;
489
    dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_mmx;
490
    dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_mmx;
491

    
492
    dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_mmx;
493
    dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_mmx;
494
    dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_mmx;
495
    dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_mmx;
496
}