comparison vc1dsp.c @ 9437:8aa2e86549cd libavcodec

VC1: Do qpel when needed for both MVs in a B frame
author conrad
date Tue, 14 Apr 2009 19:26:33 +0000
parents e9d9d946f213
children a91f60938763
comparison
equal deleted inserted replaced
9436:dfed6a243bab 9437:8aa2e86549cd
346 return 0; //should not occur 346 return 0; //should not occur
347 } 347 }
348 348
349 /** Function used to do motion compensation with bicubic interpolation 349 /** Function used to do motion compensation with bicubic interpolation
350 */ 350 */
351 static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd) 351 #define VC1_MSPEL_MC(OP, OPNAME)\
352 { 352 static void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)\
353 int i, j; 353 {\
354 354 int i, j;\
355 if (vmode) { /* Horizontal filter to apply */ 355 \
356 int r; 356 if (vmode) { /* Horizontal filter to apply */\
357 357 int r;\
358 if (hmode) { /* Vertical filter to apply, output to tmp */ 358 \
359 static const int shift_value[] = { 0, 5, 1, 5 }; 359 if (hmode) { /* Vertical filter to apply, output to tmp */\
360 int shift = (shift_value[hmode]+shift_value[vmode])>>1; 360 static const int shift_value[] = { 0, 5, 1, 5 };\
361 int16_t tmp[11*8], *tptr = tmp; 361 int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
362 362 int16_t tmp[11*8], *tptr = tmp;\
363 r = (1<<(shift-1)) + rnd-1; 363 \
364 364 r = (1<<(shift-1)) + rnd-1;\
365 src -= 1; 365 \
366 for(j = 0; j < 8; j++) { 366 src -= 1;\
367 for(i = 0; i < 11; i++) 367 for(j = 0; j < 8; j++) {\
368 tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift; 368 for(i = 0; i < 11; i++)\
369 src += stride; 369 tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;\
370 tptr += 11; 370 src += stride;\
371 } 371 tptr += 11;\
372 372 }\
373 r = 64-rnd; 373 \
374 tptr = tmp+1; 374 r = 64-rnd;\
375 for(j = 0; j < 8; j++) { 375 tptr = tmp+1;\
376 for(i = 0; i < 8; i++) 376 for(j = 0; j < 8; j++) {\
377 dst[i] = av_clip_uint8((vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7); 377 for(i = 0; i < 8; i++)\
378 dst += stride; 378 OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);\
379 tptr += 11; 379 dst += stride;\
380 } 380 tptr += 11;\
381 381 }\
382 return; 382 \
383 } 383 return;\
384 else { /* No horizontal filter, output 8 lines to dst */ 384 }\
385 r = 1-rnd; 385 else { /* No horizontal filter, output 8 lines to dst */\
386 386 r = 1-rnd;\
387 for(j = 0; j < 8; j++) { 387 \
388 for(i = 0; i < 8; i++) 388 for(j = 0; j < 8; j++) {\
389 dst[i] = av_clip_uint8(vc1_mspel_filter(src + i, stride, vmode, r)); 389 for(i = 0; i < 8; i++)\
390 src += stride; 390 OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r));\
391 dst += stride; 391 src += stride;\
392 } 392 dst += stride;\
393 return; 393 }\
394 } 394 return;\
395 } 395 }\
396 396 }\
397 /* Horizontal mode with no vertical mode */ 397 \
398 for(j = 0; j < 8; j++) { 398 /* Horizontal mode with no vertical mode */\
399 for(i = 0; i < 8; i++) 399 for(j = 0; j < 8; j++) {\
400 dst[i] = av_clip_uint8(vc1_mspel_filter(src + i, 1, hmode, rnd)); 400 for(i = 0; i < 8; i++)\
401 dst += stride; 401 OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd));\
402 src += stride; 402 dst += stride;\
403 } 403 src += stride;\
404 } 404 }\
405 }
406
407 #define op_put(a, b) a = av_clip_uint8(b)
408 #define op_avg(a, b) a = (a + av_clip_uint8(b) + 1) >> 1
409
410 VC1_MSPEL_MC(op_put, put_)
411 VC1_MSPEL_MC(op_avg, avg_)
405 412
406 /* pixel functions - really are entry points to vc1_mspel_mc */ 413 /* pixel functions - really are entry points to vc1_mspel_mc */
407 414
408 /* this one is defined in dsputil.c */ 415 /* this one is defined in dsputil.c */
409 void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd); 416 void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
417 void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
410 418
411 #define PUT_VC1_MSPEL(a, b)\ 419 #define PUT_VC1_MSPEL(a, b)\
412 static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \ 420 static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
413 vc1_mspel_mc(dst, src, stride, a, b, rnd); \ 421 put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
422 }\
423 static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
424 avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
414 } 425 }
415 426
416 PUT_VC1_MSPEL(1, 0) 427 PUT_VC1_MSPEL(1, 0)
417 PUT_VC1_MSPEL(2, 0) 428 PUT_VC1_MSPEL(2, 0)
418 PUT_VC1_MSPEL(3, 0) 429 PUT_VC1_MSPEL(3, 0)
454 dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c; 465 dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c;
455 dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c; 466 dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c;
456 dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c; 467 dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c;
457 dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c; 468 dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
458 dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c; 469 dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
459 } 470
471 dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_vc1_mspel_mc00_c;
472 dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_c;
473 dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_c;
474 dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_c;
475 dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_c;
476 dsp->avg_vc1_mspel_pixels_tab[ 5] = avg_vc1_mspel_mc11_c;
477 dsp->avg_vc1_mspel_pixels_tab[ 6] = avg_vc1_mspel_mc21_c;
478 dsp->avg_vc1_mspel_pixels_tab[ 7] = avg_vc1_mspel_mc31_c;
479 dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_c;
480 dsp->avg_vc1_mspel_pixels_tab[ 9] = avg_vc1_mspel_mc12_c;
481 dsp->avg_vc1_mspel_pixels_tab[10] = avg_vc1_mspel_mc22_c;
482 dsp->avg_vc1_mspel_pixels_tab[11] = avg_vc1_mspel_mc32_c;
483 dsp->avg_vc1_mspel_pixels_tab[12] = avg_vc1_mspel_mc03_c;
484 dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_c;
485 dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_c;
486 dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_c;
487 }