Mercurial > libavcodec.hg
comparison h263dec.c @ 984:e162c09efbe7 libavcodec
qpel fix
author | michaelni |
---|---|
date | Thu, 09 Jan 2003 20:42:37 +0000 |
parents | ca2a303ea039 |
children | c2c116876fd7 |
comparison
equal
deleted
inserted
replaced
983:ca2a303ea039 | 984:e162c09efbe7 |
---|---|
342 pc->frame_start_found= vop_found; | 342 pc->frame_start_found= vop_found; |
343 pc->state= state; | 343 pc->state= state; |
344 return -1; | 344 return -1; |
345 } | 345 } |
346 | 346 |
347 static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ | |
348 int t, x, y, f; | |
349 | |
350 ex= clip(ex, 0, w-1); | |
351 ey= clip(ey, 0, h-1); | |
352 | |
353 buf[sy*stride + sx]+= color; | |
354 | |
355 if(ABS(ex - sx) > ABS(ey - sy)){ | |
356 if(sx > ex){ | |
357 t=sx; sx=ex; ex=t; | |
358 t=sy; sy=ey; ey=t; | |
359 } | |
360 buf+= sx + sy*stride; | |
361 ex-= sx; | |
362 f= ((ey-sy)<<16)/ex; | |
363 for(x= 0; x <= ex; x++){ | |
364 y= ((x*f) + (1<<15))>>16; | |
365 buf[y*stride + x]+= color; | |
366 } | |
367 }else{ | |
368 if(sy > ey){ | |
369 t=sx; sx=ex; ex=t; | |
370 t=sy; sy=ey; ey=t; | |
371 } | |
372 buf+= sx + sy*stride; | |
373 ey-= sy; | |
374 if(ey) f= ((ex-sx)<<16)/ey; | |
375 else f= 0; | |
376 for(y= 0; y <= ey; y++){ | |
377 x= ((y*f) + (1<<15))>>16; | |
378 buf[y*stride + x]+= color; | |
379 } | |
380 } | |
381 } | |
382 | |
347 int ff_h263_decode_frame(AVCodecContext *avctx, | 383 int ff_h263_decode_frame(AVCodecContext *avctx, |
348 void *data, int *data_size, | 384 void *data, int *data_size, |
349 UINT8 *buf, int buf_size) | 385 UINT8 *buf, int buf_size) |
350 { | 386 { |
351 MpegEncContext *s = avctx->priv_data; | 387 MpegEncContext *s = avctx->priv_data; |
470 s->padding_bug_score= 256*256*256*64; | 506 s->padding_bug_score= 256*256*256*64; |
471 | 507 |
472 if(s->xvid_build && s->xvid_build<=1) | 508 if(s->xvid_build && s->xvid_build<=1) |
473 s->workaround_bugs|= FF_BUG_QPEL_CHROMA; | 509 s->workaround_bugs|= FF_BUG_QPEL_CHROMA; |
474 | 510 |
511 #define SET_QPEL_FUNC(postfix1, postfix2) \ | |
512 s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ | |
513 s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ | |
514 s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; | |
515 | |
516 if(s->lavc_build && s->lavc_build<4653) | |
517 s->workaround_bugs|= FF_BUG_STD_QPEL; | |
518 | |
475 //printf("padding_bug_score: %d\n", s->padding_bug_score); | 519 //printf("padding_bug_score: %d\n", s->padding_bug_score); |
476 #if 0 | 520 #if 0 |
477 if(s->divx_version==500) | 521 if(s->divx_version==500) |
478 s->workaround_bugs|= FF_BUG_NO_PADDING; | 522 s->workaround_bugs|= FF_BUG_NO_PADDING; |
479 | 523 |
487 if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok | 531 if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok |
488 s->workaround_bugs|= FF_BUG_NO_PADDING; | 532 s->workaround_bugs|= FF_BUG_NO_PADDING; |
489 #endif | 533 #endif |
490 } | 534 } |
491 | 535 |
536 if(s->workaround_bugs& FF_BUG_STD_QPEL){ | |
537 SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) | |
538 SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) | |
539 SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) | |
540 SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) | |
541 SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) | |
542 SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) | |
543 | |
544 SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c) | |
545 SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c) | |
546 SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c) | |
547 SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) | |
548 SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) | |
549 SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) | |
550 } | |
492 | 551 |
493 #if 0 // dump bits per frame / qp / complexity | 552 #if 0 // dump bits per frame / qp / complexity |
494 { | 553 { |
495 static FILE *f=NULL; | 554 static FILE *f=NULL; |
496 if(!f) f=fopen("rate_qp_cplx.txt", "w"); | 555 if(!f) f=fopen("rate_qp_cplx.txt", "w"); |
643 ff_error_resilience(s); | 702 ff_error_resilience(s); |
644 } | 703 } |
645 } | 704 } |
646 | 705 |
647 MPV_frame_end(s); | 706 MPV_frame_end(s); |
648 #if 0 //dirty show MVs, we should export the MV tables and write a filter to show them | 707 |
649 { | 708 if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture.data[0]){ |
650 int mb_y; | 709 const int shift= 1 + s->quarter_sample; |
651 s->has_b_frames=1; | 710 int mb_y; |
652 for(mb_y=0; mb_y<s->mb_height; mb_y++){ | 711 uint8_t *ptr= s->last_picture.data[0]; |
653 int mb_x; | 712 s->low_delay=0; //needed to see the vectors without trashing the buffers |
654 int y= mb_y*16 + 8; | 713 |
655 for(mb_x=0; mb_x<s->mb_width; mb_x++){ | 714 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
656 int x= mb_x*16 + 8; | 715 int mb_x; |
657 uint8_t *ptr= s->last_picture.data[0]; | 716 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
658 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); | 717 const int mb_index= mb_x + mb_y*s->mb_width; |
659 int mx= (s->motion_val[xy][0]>>1) + x; | 718 if(s->co_located_type_table[mb_index] == MV_TYPE_8X8){ |
660 int my= (s->motion_val[xy][1]>>1) + y; | 719 int i; |
661 int i; | 720 for(i=0; i<4; i++){ |
662 int max; | 721 int sx= mb_x*16 + 4 + 8*(i&1); |
663 | 722 int sy= mb_y*16 + 4 + 8*(i>>1); |
664 if(mx<0) mx=0; | 723 int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); |
665 if(my<0) my=0; | 724 int mx= (s->motion_val[xy][0]>>shift) + sx; |
666 if(mx>=s->width) mx= s->width -1; | 725 int my= (s->motion_val[xy][1]>>shift) + sy; |
667 if(my>=s->height) my= s->height-1; | 726 draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
668 max= ABS(mx-x); | 727 } |
669 if(ABS(my-y) > max) max= ABS(my-y); | 728 }else{ |
670 /* the ugliest linedrawing routine ... */ | 729 int sx= mb_x*16 + 8; |
671 for(i=0; i<max; i++){ | 730 int sy= mb_y*16 + 8; |
672 int x1= x + (mx-x)*i/max; | 731 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); |
673 int y1= y + (my-y)*i/max; | 732 int mx= (s->motion_val[xy][0]>>shift) + sx; |
674 ptr[y1*s->linesize + x1]+=100; | 733 int my= (s->motion_val[xy][1]>>shift) + sy; |
675 } | 734 draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
676 ptr[y*s->linesize + x]+=100; | 735 } |
677 s->mbskip_table[mb_x + mb_y*s->mb_width]=0; | 736 s->mbskip_table[mb_index]=0; |
678 } | 737 } |
679 } | 738 } |
680 | 739 } |
681 } | 740 |
682 #endif | |
683 | 741 |
684 if(s->pict_type==B_TYPE || s->low_delay){ | 742 if(s->pict_type==B_TYPE || s->low_delay){ |
685 *pict= *(AVFrame*)&s->current_picture; | 743 *pict= *(AVFrame*)&s->current_picture; |
686 } else { | 744 } else { |
687 *pict= *(AVFrame*)&s->last_picture; | 745 *pict= *(AVFrame*)&s->last_picture; |