comparison vc1dsp.c @ 5416:90d90aecc83c libavcodec

Make bicubic interpolation standard compliant Patch by Christophe GISQUET (echo -e "christophe\056gisquet\100 (antonym to malloc()) \056fr") Thread [PATCH] Binary identicity for ffvc1 (was Re: [PATCH] VC-1 MMX DSP functions)
author kostya
date Sun, 29 Jul 2007 04:04:21 +0000
parents a69976bf878c
children 90de28dfd8d6
comparison
equal deleted inserted replaced
5415:8bf7358978c8 5416:90d90aecc83c
320 dst ++; 320 dst ++;
321 } 321 }
322 } 322 }
323 323
324 /* motion compensation functions */ 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 /** Filter used to interpolate fractional pel values 346 /** Filter used to interpolate fractional pel values
327 */ 347 */
328 static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r) 348 static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
329 { 349 {
342 362
343 /** Function used to do motion compensation with bicubic interpolation 363 /** Function used to do motion compensation with bicubic interpolation
344 */ 364 */
345 static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd) 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; 367 int i, j;
348 uint8_t tmp[8*11], *tptr; 368
349 int r; 369 if (vmode) { /* Horizontal filter to apply */
350 370 int r;
351 r = rnd; 371
352 src -= stride; 372 if (hmode) { /* Vertical filter to apply, output to tmp */
353 tptr = tmp; 373 static const int shift_value[] = { 0, 5, 1, 5 };
354 for(j = 0; j < 11; j++) { 374 int shift = (shift_value[hmode]+shift_value[vmode])>>1;
355 for(i = 0; i < 8; i++) 375 int16_t tmp[11*8], *tptr = tmp;
356 tptr[i] = av_clip_uint8(vc1_mspel_filter(src + i, 1, hmode, r)); 376
357 src += stride; 377 r = (1<<(shift-1)) + rnd-1;
358 tptr += 8; 378
359 } 379 src -= 1;
360 r = 1 - rnd; 380 for(j = 0; j < 8; j++) {
361 381 for(i = 0; i < 11; i++)
362 tptr = tmp + 8; 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 }
409 }
410
411 /* Horizontal mode with no vertical mode */
363 for(j = 0; j < 8; j++) { 412 for(j = 0; j < 8; j++) {
364 for(i = 0; i < 8; i++) 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 dst += stride; 415 dst += stride;
367 tptr += 8; 416 src += stride;
368 } 417 }
369 } 418 }
370 419
371 /* pixel functions - really are entry points to vc1_mspel_mc */ 420 /* pixel functions - really are entry points to vc1_mspel_mc */
372 421