Statistics
| Branch: | Revision:

ffmpeg / libavcodec / vc1dsp.c @ 1da6ea39

History | View | Annotate | Download (20.8 KB)

1
/*
2
 * VC-1 and WMV3 decoder - DSP functions
3
 * Copyright (c) 2006 Konstantin Shishkov
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

    
22
/**
23
* @file
24
 * VC-1 and WMV3 decoder
25
 *
26
 */
27

    
28
#include "dsputil.h"
29

    
30

    
31
/** Apply overlap transform to horizontal edge
32
*/
33
static void vc1_v_overlap_c(uint8_t* src, int stride)
34
{
35
    int i;
36
    int a, b, c, d;
37
    int d1, d2;
38
    int rnd = 1;
39
    for(i = 0; i < 8; i++) {
40
        a = src[-2*stride];
41
        b = src[-stride];
42
        c = src[0];
43
        d = src[stride];
44
        d1 = (a - d + 3 + rnd) >> 3;
45
        d2 = (a - d + b - c + 4 - rnd) >> 3;
46

    
47
        src[-2*stride] = a - d1;
48
        src[-stride] = av_clip_uint8(b - d2);
49
        src[0] = av_clip_uint8(c + d2);
50
        src[stride] = d + d1;
51
        src++;
52
        rnd = !rnd;
53
    }
54
}
55

    
56
/** Apply overlap transform to vertical edge
57
*/
58
static void vc1_h_overlap_c(uint8_t* src, int stride)
59
{
60
    int i;
61
    int a, b, c, d;
62
    int d1, d2;
63
    int rnd = 1;
64
    for(i = 0; i < 8; i++) {
65
        a = src[-2];
66
        b = src[-1];
67
        c = src[0];
68
        d = src[1];
69
        d1 = (a - d + 3 + rnd) >> 3;
70
        d2 = (a - d + b - c + 4 - rnd) >> 3;
71

    
72
        src[-2] = a - d1;
73
        src[-1] = av_clip_uint8(b - d2);
74
        src[0] = av_clip_uint8(c + d2);
75
        src[1] = d + d1;
76
        src += stride;
77
        rnd = !rnd;
78
    }
79
}
80

    
81
/**
82
 * VC-1 in-loop deblocking filter for one line
83
 * @param src source block type
84
 * @param stride block stride
85
 * @param pq block quantizer
86
 * @return whether other 3 pairs should be filtered or not
87
 * @see 8.6
88
 */
89
static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
90
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
91

    
92
    int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
93
    int a0_sign = a0 >> 31;        /* Store sign */
94
    a0 = (a0 ^ a0_sign) - a0_sign; /* a0 = FFABS(a0); */
95
    if(a0 < pq){
96
        int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
97
        int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
98
        if(a1 < a0 || a2 < a0){
99
            int clip = src[-1*stride] - src[ 0*stride];
100
            int clip_sign = clip >> 31;
101
            clip = ((clip ^ clip_sign) - clip_sign)>>1;
102
            if(clip){
103
                int a3 = FFMIN(a1, a2);
104
                int d = 5 * (a3 - a0);
105
                int d_sign = (d >> 31);
106
                d = ((d ^ d_sign) - d_sign) >> 3;
107
                d_sign ^= a0_sign;
108

    
109
                if( d_sign ^ clip_sign )
110
                    d = 0;
111
                else{
112
                    d = FFMIN(d, clip);
113
                    d = (d ^ d_sign) - d_sign;          /* Restore sign */
114
                    src[-1*stride] = cm[src[-1*stride] - d];
115
                    src[ 0*stride] = cm[src[ 0*stride] + d];
116
                }
117
                return 1;
118
            }
119
        }
120
    }
121
    return 0;
122
}
123

    
124
/**
125
 * VC-1 in-loop deblocking filter
126
 * @param src source block type
127
 * @param step distance between horizontally adjacent elements
128
 * @param stride distance between vertically adjacent elements
129
 * @param len edge length to filter (4 or 8 pixels)
130
 * @param pq block quantizer
131
 * @see 8.6
132
 */
133
static inline void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq)
134
{
135
    int i;
136
    int filt3;
137

    
138
    for(i = 0; i < len; i += 4){
139
        filt3 = vc1_filter_line(src + 2*step, stride, pq);
140
        if(filt3){
141
            vc1_filter_line(src + 0*step, stride, pq);
142
            vc1_filter_line(src + 1*step, stride, pq);
143
            vc1_filter_line(src + 3*step, stride, pq);
144
        }
145
        src += step * 4;
146
    }
147
}
148

    
149
static void vc1_v_loop_filter4_c(uint8_t *src, int stride, int pq)
150
{
151
    vc1_loop_filter(src, 1, stride, 4, pq);
152
}
153

    
154
static void vc1_h_loop_filter4_c(uint8_t *src, int stride, int pq)
155
{
156
    vc1_loop_filter(src, stride, 1, 4, pq);
157
}
158

    
159
static void vc1_v_loop_filter8_c(uint8_t *src, int stride, int pq)
160
{
161
    vc1_loop_filter(src, 1, stride, 8, pq);
162
}
163

    
164
static void vc1_h_loop_filter8_c(uint8_t *src, int stride, int pq)
165
{
166
    vc1_loop_filter(src, stride, 1, 8, pq);
167
}
168

    
169
static void vc1_v_loop_filter16_c(uint8_t *src, int stride, int pq)
170
{
171
    vc1_loop_filter(src, 1, stride, 16, pq);
172
}
173

    
174
static void vc1_h_loop_filter16_c(uint8_t *src, int stride, int pq)
175
{
176
    vc1_loop_filter(src, stride, 1, 16, pq);
177
}
178

    
179
/** Do inverse transform on 8x8 block
180
*/
181
static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
182
{
183
    int i;
184
    int dc = block[0];
185
    const uint8_t *cm;
186
    dc = (3 * dc +  1) >> 1;
187
    dc = (3 * dc + 16) >> 5;
188
    cm = ff_cropTbl + MAX_NEG_CROP + dc;
189
    for(i = 0; i < 8; i++){
190
        dest[0] = cm[dest[0]];
191
        dest[1] = cm[dest[1]];
192
        dest[2] = cm[dest[2]];
193
        dest[3] = cm[dest[3]];
194
        dest[4] = cm[dest[4]];
195
        dest[5] = cm[dest[5]];
196
        dest[6] = cm[dest[6]];
197
        dest[7] = cm[dest[7]];
198
        dest += linesize;
199
    }
200
}
201

    
202
static void vc1_inv_trans_8x8_c(DCTELEM block[64])
203
{
204
    int i;
205
    register int t1,t2,t3,t4,t5,t6,t7,t8;
206
    DCTELEM *src, *dst, temp[64];
207

    
208
    src = block;
209
    dst = temp;
210
    for(i = 0; i < 8; i++){
211
        t1 = 12 * (src[ 0] + src[32]) + 4;
212
        t2 = 12 * (src[ 0] - src[32]) + 4;
213
        t3 = 16 * src[16] +  6 * src[48];
214
        t4 =  6 * src[16] - 16 * src[48];
215

    
216
        t5 = t1 + t3;
217
        t6 = t2 + t4;
218
        t7 = t2 - t4;
219
        t8 = t1 - t3;
220

    
221
        t1 = 16 * src[ 8] + 15 * src[24] +  9 * src[40] +  4 * src[56];
222
        t2 = 15 * src[ 8] -  4 * src[24] - 16 * src[40] -  9 * src[56];
223
        t3 =  9 * src[ 8] - 16 * src[24] +  4 * src[40] + 15 * src[56];
224
        t4 =  4 * src[ 8] -  9 * src[24] + 15 * src[40] - 16 * src[56];
225

    
226
        dst[0] = (t5 + t1) >> 3;
227
        dst[1] = (t6 + t2) >> 3;
228
        dst[2] = (t7 + t3) >> 3;
229
        dst[3] = (t8 + t4) >> 3;
230
        dst[4] = (t8 - t4) >> 3;
231
        dst[5] = (t7 - t3) >> 3;
232
        dst[6] = (t6 - t2) >> 3;
233
        dst[7] = (t5 - t1) >> 3;
234

    
235
        src += 1;
236
        dst += 8;
237
    }
238

    
239
    src = temp;
240
    dst = block;
241
    for(i = 0; i < 8; i++){
242
        t1 = 12 * (src[ 0] + src[32]) + 64;
243
        t2 = 12 * (src[ 0] - src[32]) + 64;
244
        t3 = 16 * src[16] +  6 * src[48];
245
        t4 =  6 * src[16] - 16 * src[48];
246

    
247
        t5 = t1 + t3;
248
        t6 = t2 + t4;
249
        t7 = t2 - t4;
250
        t8 = t1 - t3;
251

    
252
        t1 = 16 * src[ 8] + 15 * src[24] +  9 * src[40] +  4 * src[56];
253
        t2 = 15 * src[ 8] -  4 * src[24] - 16 * src[40] -  9 * src[56];
254
        t3 =  9 * src[ 8] - 16 * src[24] +  4 * src[40] + 15 * src[56];
255
        t4 =  4 * src[ 8] -  9 * src[24] + 15 * src[40] - 16 * src[56];
256

    
257
        dst[ 0] = (t5 + t1) >> 7;
258
        dst[ 8] = (t6 + t2) >> 7;
259
        dst[16] = (t7 + t3) >> 7;
260
        dst[24] = (t8 + t4) >> 7;
261
        dst[32] = (t8 - t4 + 1) >> 7;
262
        dst[40] = (t7 - t3 + 1) >> 7;
263
        dst[48] = (t6 - t2 + 1) >> 7;
264
        dst[56] = (t5 - t1 + 1) >> 7;
265

    
266
        src++;
267
        dst++;
268
    }
269
}
270

    
271
/** Do inverse transform on 8x4 part of block
272
*/
273
static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
274
{
275
    int i;
276
    int dc = block[0];
277
    const uint8_t *cm;
278
    dc = ( 3 * dc +  1) >> 1;
279
    dc = (17 * dc + 64) >> 7;
280
    cm = ff_cropTbl + MAX_NEG_CROP + dc;
281
    for(i = 0; i < 4; i++){
282
        dest[0] = cm[dest[0]];
283
        dest[1] = cm[dest[1]];
284
        dest[2] = cm[dest[2]];
285
        dest[3] = cm[dest[3]];
286
        dest[4] = cm[dest[4]];
287
        dest[5] = cm[dest[5]];
288
        dest[6] = cm[dest[6]];
289
        dest[7] = cm[dest[7]];
290
        dest += linesize;
291
    }
292
}
293

    
294
static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, DCTELEM *block)
295
{
296
    int i;
297
    register int t1,t2,t3,t4,t5,t6,t7,t8;
298
    DCTELEM *src, *dst;
299
    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
300

    
301
    src = block;
302
    dst = block;
303
    for(i = 0; i < 4; i++){
304
        t1 = 12 * (src[0] + src[4]) + 4;
305
        t2 = 12 * (src[0] - src[4]) + 4;
306
        t3 = 16 * src[2] +  6 * src[6];
307
        t4 =  6 * src[2] - 16 * src[6];
308

    
309
        t5 = t1 + t3;
310
        t6 = t2 + t4;
311
        t7 = t2 - t4;
312
        t8 = t1 - t3;
313

    
314
        t1 = 16 * src[1] + 15 * src[3] +  9 * src[5] +  4 * src[7];
315
        t2 = 15 * src[1] -  4 * src[3] - 16 * src[5] -  9 * src[7];
316
        t3 =  9 * src[1] - 16 * src[3] +  4 * src[5] + 15 * src[7];
317
        t4 =  4 * src[1] -  9 * src[3] + 15 * src[5] - 16 * src[7];
318

    
319
        dst[0] = (t5 + t1) >> 3;
320
        dst[1] = (t6 + t2) >> 3;
321
        dst[2] = (t7 + t3) >> 3;
322
        dst[3] = (t8 + t4) >> 3;
323
        dst[4] = (t8 - t4) >> 3;
324
        dst[5] = (t7 - t3) >> 3;
325
        dst[6] = (t6 - t2) >> 3;
326
        dst[7] = (t5 - t1) >> 3;
327

    
328
        src += 8;
329
        dst += 8;
330
    }
331

    
332
    src = block;
333
    for(i = 0; i < 8; i++){
334
        t1 = 17 * (src[ 0] + src[16]) + 64;
335
        t2 = 17 * (src[ 0] - src[16]) + 64;
336
        t3 = 22 * src[ 8] + 10 * src[24];
337
        t4 = 22 * src[24] - 10 * src[ 8];
338

    
339
        dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
340
        dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
341
        dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
342
        dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
343

    
344
        src ++;
345
        dest++;
346
    }
347
}
348

    
349
/** Do inverse transform on 4x8 parts of block
350
*/
351
static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
352
{
353
    int i;
354
    int dc = block[0];
355
    const uint8_t *cm;
356
    dc = (17 * dc +  4) >> 3;
357
    dc = (12 * dc + 64) >> 7;
358
    cm = ff_cropTbl + MAX_NEG_CROP + dc;
359
    for(i = 0; i < 8; i++){
360
        dest[0] = cm[dest[0]];
361
        dest[1] = cm[dest[1]];
362
        dest[2] = cm[dest[2]];
363
        dest[3] = cm[dest[3]];
364
        dest += linesize;
365
    }
366
}
367

    
368
static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)
369
{
370
    int i;
371
    register int t1,t2,t3,t4,t5,t6,t7,t8;
372
    DCTELEM *src, *dst;
373
    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
374

    
375
    src = block;
376
    dst = block;
377
    for(i = 0; i < 8; i++){
378
        t1 = 17 * (src[0] + src[2]) + 4;
379
        t2 = 17 * (src[0] - src[2]) + 4;
380
        t3 = 22 * src[1] + 10 * src[3];
381
        t4 = 22 * src[3] - 10 * src[1];
382

    
383
        dst[0] = (t1 + t3) >> 3;
384
        dst[1] = (t2 - t4) >> 3;
385
        dst[2] = (t2 + t4) >> 3;
386
        dst[3] = (t1 - t3) >> 3;
387

    
388
        src += 8;
389
        dst += 8;
390
    }
391

    
392
    src = block;
393
    for(i = 0; i < 4; i++){
394
        t1 = 12 * (src[ 0] + src[32]) + 64;
395
        t2 = 12 * (src[ 0] - src[32]) + 64;
396
        t3 = 16 * src[16] +  6 * src[48];
397
        t4 =  6 * src[16] - 16 * src[48];
398

    
399
        t5 = t1 + t3;
400
        t6 = t2 + t4;
401
        t7 = t2 - t4;
402
        t8 = t1 - t3;
403

    
404
        t1 = 16 * src[ 8] + 15 * src[24] +  9 * src[40] +  4 * src[56];
405
        t2 = 15 * src[ 8] -  4 * src[24] - 16 * src[40] -  9 * src[56];
406
        t3 =  9 * src[ 8] - 16 * src[24] +  4 * src[40] + 15 * src[56];
407
        t4 =  4 * src[ 8] -  9 * src[24] + 15 * src[40] - 16 * src[56];
408

    
409
        dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)];
410
        dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)];
411
        dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)];
412
        dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)];
413
        dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)];
414
        dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)];
415
        dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)];
416
        dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)];
417

    
418
        src ++;
419
        dest++;
420
    }
421
}
422

    
423
/** Do inverse transform on 4x4 part of block
424
*/
425
static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
426
{
427
    int i;
428
    int dc = block[0];
429
    const uint8_t *cm;
430
    dc = (17 * dc +  4) >> 3;
431
    dc = (17 * dc + 64) >> 7;
432
    cm = ff_cropTbl + MAX_NEG_CROP + dc;
433
    for(i = 0; i < 4; i++){
434
        dest[0] = cm[dest[0]];
435
        dest[1] = cm[dest[1]];
436
        dest[2] = cm[dest[2]];
437
        dest[3] = cm[dest[3]];
438
        dest += linesize;
439
    }
440
}
441

    
442
static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
443
{
444
    int i;
445
    register int t1,t2,t3,t4;
446
    DCTELEM *src, *dst;
447
    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
448

    
449
    src = block;
450
    dst = block;
451
    for(i = 0; i < 4; i++){
452
        t1 = 17 * (src[0] + src[2]) + 4;
453
        t2 = 17 * (src[0] - src[2]) + 4;
454
        t3 = 22 * src[1] + 10 * src[3];
455
        t4 = 22 * src[3] - 10 * src[1];
456

    
457
        dst[0] = (t1 + t3) >> 3;
458
        dst[1] = (t2 - t4) >> 3;
459
        dst[2] = (t2 + t4) >> 3;
460
        dst[3] = (t1 - t3) >> 3;
461

    
462
        src += 8;
463
        dst += 8;
464
    }
465

    
466
    src = block;
467
    for(i = 0; i < 4; i++){
468
        t1 = 17 * (src[ 0] + src[16]) + 64;
469
        t2 = 17 * (src[ 0] - src[16]) + 64;
470
        t3 = 22 * src[ 8] + 10 * src[24];
471
        t4 = 22 * src[24] - 10 * src[ 8];
472

    
473
        dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
474
        dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
475
        dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
476
        dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
477

    
478
        src ++;
479
        dest++;
480
    }
481
}
482

    
483
/* motion compensation functions */
484
/** Filter in case of 2 filters */
485
#define VC1_MSPEL_FILTER_16B(DIR, TYPE)                                 \
486
static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, int stride, int mode) \
487
{                                                                       \
488
    switch(mode){                                                       \
489
    case 0: /* no shift - should not occur */                           \
490
        return 0;                                                       \
491
    case 1: /* 1/4 shift */                                             \
492
        return -4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2]; \
493
    case 2: /* 1/2 shift */                                             \
494
        return -src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2]; \
495
    case 3: /* 3/4 shift */                                             \
496
        return -3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2]; \
497
    }                                                                   \
498
    return 0; /* should not occur */                                    \
499
}
500

    
501
VC1_MSPEL_FILTER_16B(ver, uint8_t);
502
VC1_MSPEL_FILTER_16B(hor, int16_t);
503

    
504

    
505
/** Filter used to interpolate fractional pel values
506
 */
507
static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
508
{
509
    switch(mode){
510
    case 0: //no shift
511
        return src[0];
512
    case 1: // 1/4 shift
513
        return (-4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2] + 32 - r) >> 6;
514
    case 2: // 1/2 shift
515
        return (-src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2] + 8 - r) >> 4;
516
    case 3: // 3/4 shift
517
        return (-3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2] + 32 - r) >> 6;
518
    }
519
    return 0; //should not occur
520
}
521

    
522
/** Function used to do motion compensation with bicubic interpolation
523
 */
524
#define VC1_MSPEL_MC(OP, OPNAME)\
525
static void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)\
526
{\
527
    int     i, j;\
528
\
529
    if (vmode) { /* Horizontal filter to apply */\
530
        int r;\
531
\
532
        if (hmode) { /* Vertical filter to apply, output to tmp */\
533
            static const int shift_value[] = { 0, 5, 1, 5 };\
534
            int              shift = (shift_value[hmode]+shift_value[vmode])>>1;\
535
            int16_t          tmp[11*8], *tptr = tmp;\
536
\
537
            r = (1<<(shift-1)) + rnd-1;\
538
\
539
            src -= 1;\
540
            for(j = 0; j < 8; j++) {\
541
                for(i = 0; i < 11; i++)\
542
                    tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;\
543
                src += stride;\
544
                tptr += 11;\
545
            }\
546
\
547
            r = 64-rnd;\
548
            tptr = tmp+1;\
549
            for(j = 0; j < 8; j++) {\
550
                for(i = 0; i < 8; i++)\
551
                    OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);\
552
                dst += stride;\
553
                tptr += 11;\
554
            }\
555
\
556
            return;\
557
        }\
558
        else { /* No horizontal filter, output 8 lines to dst */\
559
            r = 1-rnd;\
560
\
561
            for(j = 0; j < 8; j++) {\
562
                for(i = 0; i < 8; i++)\
563
                    OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r));\
564
                src += stride;\
565
                dst += stride;\
566
            }\
567
            return;\
568
        }\
569
    }\
570
\
571
    /* Horizontal mode with no vertical mode */\
572
    for(j = 0; j < 8; j++) {\
573
        for(i = 0; i < 8; i++)\
574
            OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd));\
575
        dst += stride;\
576
        src += stride;\
577
    }\
578
}
579

    
580
#define op_put(a, b) a = av_clip_uint8(b)
581
#define op_avg(a, b) a = (a + av_clip_uint8(b) + 1) >> 1
582

    
583
VC1_MSPEL_MC(op_put, put_)
584
VC1_MSPEL_MC(op_avg, avg_)
585

    
586
/* pixel functions - really are entry points to vc1_mspel_mc */
587

    
588
#define PUT_VC1_MSPEL(a, b)\
589
static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
590
     put_vc1_mspel_mc(dst, src, stride, a, b, rnd);                         \
591
}\
592
static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
593
     avg_vc1_mspel_mc(dst, src, stride, a, b, rnd);                         \
594
}
595

    
596
PUT_VC1_MSPEL(1, 0)
597
PUT_VC1_MSPEL(2, 0)
598
PUT_VC1_MSPEL(3, 0)
599

    
600
PUT_VC1_MSPEL(0, 1)
601
PUT_VC1_MSPEL(1, 1)
602
PUT_VC1_MSPEL(2, 1)
603
PUT_VC1_MSPEL(3, 1)
604

    
605
PUT_VC1_MSPEL(0, 2)
606
PUT_VC1_MSPEL(1, 2)
607
PUT_VC1_MSPEL(2, 2)
608
PUT_VC1_MSPEL(3, 2)
609

    
610
PUT_VC1_MSPEL(0, 3)
611
PUT_VC1_MSPEL(1, 3)
612
PUT_VC1_MSPEL(2, 3)
613
PUT_VC1_MSPEL(3, 3)
614

    
615
av_cold void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
616
    dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
617
    dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
618
    dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
619
    dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
620
    dsp->vc1_inv_trans_8x8_dc = vc1_inv_trans_8x8_dc_c;
621
    dsp->vc1_inv_trans_4x8_dc = vc1_inv_trans_4x8_dc_c;
622
    dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_c;
623
    dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_c;
624
    dsp->vc1_h_overlap = vc1_h_overlap_c;
625
    dsp->vc1_v_overlap = vc1_v_overlap_c;
626
    dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c;
627
    dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c;
628
    dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c;
629
    dsp->vc1_h_loop_filter8 = vc1_h_loop_filter8_c;
630
    dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c;
631
    dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c;
632

    
633
    dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_pixels8x8_c;
634
    dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;
635
    dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_c;
636
    dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_c;
637
    dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_c;
638
    dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_c;
639
    dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_c;
640
    dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_c;
641
    dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_c;
642
    dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_c;
643
    dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_c;
644
    dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c;
645
    dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c;
646
    dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c;
647
    dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
648
    dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
649

    
650
    dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_pixels8x8_c;
651
    dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_c;
652
    dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_c;
653
    dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_c;
654
    dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_c;
655
    dsp->avg_vc1_mspel_pixels_tab[ 5] = avg_vc1_mspel_mc11_c;
656
    dsp->avg_vc1_mspel_pixels_tab[ 6] = avg_vc1_mspel_mc21_c;
657
    dsp->avg_vc1_mspel_pixels_tab[ 7] = avg_vc1_mspel_mc31_c;
658
    dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_c;
659
    dsp->avg_vc1_mspel_pixels_tab[ 9] = avg_vc1_mspel_mc12_c;
660
    dsp->avg_vc1_mspel_pixels_tab[10] = avg_vc1_mspel_mc22_c;
661
    dsp->avg_vc1_mspel_pixels_tab[11] = avg_vc1_mspel_mc32_c;
662
    dsp->avg_vc1_mspel_pixels_tab[12] = avg_vc1_mspel_mc03_c;
663
    dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_c;
664
    dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_c;
665
    dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_c;
666
}