Revision 7919d10c

View differences:

libavcodec/vc1dsp.c
322 322
}
323 323

  
324 324
/* motion compensation functions */
325
/** Filter in case of 2 filters */
326
#define VC1_MSPEL_FILTER_16B(DIR, TYPE)                                 \
327
static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, int stride, int mode) \
328
{                                                                       \
329
    switch(mode){                                                       \
330
    case 0: /* no shift - should not occur */                           \
331
        return 0;                                                       \
332
    case 1: /* 1/4 shift */                                             \
333
        return -4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2]; \
334
    case 2: /* 1/2 shift */                                             \
335
        return -src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2]; \
336
    case 3: /* 3/4 shift */                                             \
337
        return -3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2]; \
338
    }                                                                   \
339
    return 0; /* should not occur */                                    \
340
}
341

  
342
VC1_MSPEL_FILTER_16B(ver, uint8_t);
343
VC1_MSPEL_FILTER_16B(hor, int16_t);
344

  
325 345

  
326 346
/** Filter used to interpolate fractional pel values
327 347
 */
......
344 364
 */
345 365
static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)
346 366
{
347
    int i, j;
348
    uint8_t tmp[8*11], *tptr;
349
    int r;
350

  
351
    r = rnd;
352
    src -= stride;
353
    tptr = tmp;
354
    for(j = 0; j < 11; j++) {
355
        for(i = 0; i < 8; i++)
356
            tptr[i] = av_clip_uint8(vc1_mspel_filter(src + i, 1, hmode, r));
357
        src += stride;
358
        tptr += 8;
367
    int     i, j;
368

  
369
    if (vmode) { /* Horizontal filter to apply */
370
        int r;
371

  
372
        if (hmode) { /* Vertical filter to apply, output to tmp */
373
            static const int shift_value[] = { 0, 5, 1, 5 };
374
            int              shift = (shift_value[hmode]+shift_value[vmode])>>1;
375
            int16_t          tmp[11*8], *tptr = tmp;
376

  
377
            r = (1<<(shift-1)) + rnd-1;
378

  
379
            src -= 1;
380
            for(j = 0; j < 8; j++) {
381
                for(i = 0; i < 11; i++)
382
                    tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;
383
                src += stride;
384
                tptr += 11;
385
            }
386

  
387
            r = 64-rnd;
388
            tptr = tmp+1;
389
            for(j = 0; j < 8; j++) {
390
                for(i = 0; i < 8; i++)
391
                    dst[i] = av_clip_uint8((vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);
392
                dst += stride;
393
                tptr += 11;
394
            }
395

  
396
            return;
397
        }
398
        else { /* No horizontal filter, output 8 lines to dst */
399
            r = 1-rnd;
400

  
401
            for(j = 0; j < 8; j++) {
402
                for(i = 0; i < 8; i++)
403
                    dst[i] = av_clip_uint8(vc1_mspel_filter(src + i, stride, vmode, r));
404
                src += stride;
405
                dst += stride;
406
            }
407
            return;
408
        }
359 409
    }
360
    r = 1 - rnd;
361 410

  
362
    tptr = tmp + 8;
411
    /* Horizontal mode with no vertical mode */
363 412
    for(j = 0; j < 8; j++) {
364 413
        for(i = 0; i < 8; i++)
365
            dst[i] = av_clip_uint8(vc1_mspel_filter(tptr + i, 8, vmode, r));
414
            dst[i] = av_clip_uint8(vc1_mspel_filter(src + i, 1, hmode, rnd));
366 415
        dst += stride;
367
        tptr += 8;
416
        src += stride;
368 417
    }
369 418
}
370 419

  

Also available in: Unified diff