comparison rv10.c @ 2848:78ad77267785 libavcodec

error concealment fix
author michael
date Thu, 01 Sep 2005 00:15:12 +0000
parents eaa57c3336fc
children ef2149182f1c
comparison
equal deleted inserted replaced
2847:712c84b9d8ce 2848:78ad77267785
618 return -1; 618 return -1;
619 } 619 }
620 //if(s->pict_type == P_TYPE) return 0; 620 //if(s->pict_type == P_TYPE) return 0;
621 621
622 if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) { 622 if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
623 if(s->current_picture_ptr){ //FIXME write parser so we always have complete frames?
624 ff_er_frame_end(s);
625 MPV_frame_end(s);
626 s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
627 }
623 if(MPV_frame_start(s, avctx) < 0) 628 if(MPV_frame_start(s, avctx) < 0)
624 return -1; 629 return -1;
630 ff_er_frame_start(s);
625 } 631 }
626 632
627 #ifdef DEBUG 633 #ifdef DEBUG
628 printf("qscale=%d\n", s->qscale); 634 printf("qscale=%d\n", s->qscale);
629 #endif 635 #endif
671 677
672 s->mv_dir = MV_DIR_FORWARD; 678 s->mv_dir = MV_DIR_FORWARD;
673 s->mv_type = MV_TYPE_16X16; 679 s->mv_type = MV_TYPE_16X16;
674 ret=ff_h263_decode_mb(s, s->block); 680 ret=ff_h263_decode_mb(s, s->block);
675 681
676 if (ret == SLICE_ERROR) { 682 if (ret == SLICE_ERROR || s->gb.size_in_bits < get_bits_count(&s->gb)) {
677 av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); 683 av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
678 return -1; 684 return -1;
679 } 685 }
680 if(s->pict_type != B_TYPE) 686 if(s->pict_type != B_TYPE)
681 ff_h263_update_motion_val(s); 687 ff_h263_update_motion_val(s);
690 } 696 }
691 if(s->mb_x == s->resync_mb_x) 697 if(s->mb_x == s->resync_mb_x)
692 s->first_slice_line=0; 698 s->first_slice_line=0;
693 if(ret == SLICE_END) break; 699 if(ret == SLICE_END) break;
694 } 700 }
701
702 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
695 703
696 return buf_size; 704 return buf_size;
697 } 705 }
698 706
699 static int rv10_decode_frame(AVCodecContext *avctx, 707 static int rv10_decode_frame(AVCodecContext *avctx,
721 if(i+1 == avctx->slice_count) 729 if(i+1 == avctx->slice_count)
722 size= buf_size - offset; 730 size= buf_size - offset;
723 else 731 else
724 size= avctx->slice_offset[i+1] - offset; 732 size= avctx->slice_offset[i+1] - offset;
725 733
726 if( rv10_decode_packet(avctx, buf+offset, size) < 0 ) 734 rv10_decode_packet(avctx, buf+offset, size);
727 return -1;
728 } 735 }
729 }else{ 736 }else{
730 if( rv10_decode_packet(avctx, buf, buf_size) < 0 ) 737 rv10_decode_packet(avctx, buf, buf_size);
731 return -1;
732 } 738 }
733 739
734 if(s->mb_y>=s->mb_height){ 740 if(s->mb_y>=s->mb_height){
741 ff_er_frame_end(s);
735 MPV_frame_end(s); 742 MPV_frame_end(s);
736 743
737 if(s->pict_type==B_TYPE || s->low_delay){ 744 if(s->pict_type==B_TYPE || s->low_delay){
738 *pict= *(AVFrame*)&s->current_picture; 745 *pict= *(AVFrame*)&s->current_picture;
739 ff_print_debug_info(s, pict); 746 ff_print_debug_info(s, pict);
741 *pict= *(AVFrame*)&s->last_picture; 748 *pict= *(AVFrame*)&s->last_picture;
742 ff_print_debug_info(s, pict); 749 ff_print_debug_info(s, pict);
743 } 750 }
744 if(s->last_picture_ptr || s->low_delay) 751 if(s->last_picture_ptr || s->low_delay)
745 *data_size = sizeof(AVFrame); 752 *data_size = sizeof(AVFrame);
753 s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...)
746 } 754 }
747 755
748 return buf_size; 756 return buf_size;
749 } 757 }
750 758