Mercurial > libavcodec.hg
comparison error_resilience.c @ 1668:30746f429df6 libavcodec
move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
cleanups & fixes by me
| author | michael |
|---|---|
| date | Tue, 09 Dec 2003 01:49:56 +0000 |
| parents | 932d306bf1dc |
| children | 8bccf5eda14b |
comparison
equal
deleted
inserted
replaced
| 1667:720c073661a1 | 1668:30746f429df6 |
|---|---|
| 207 int left_intra= IS_INTRA(s->current_picture.mb_type [( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]); | 207 int left_intra= IS_INTRA(s->current_picture.mb_type [( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]); |
| 208 int right_intra= IS_INTRA(s->current_picture.mb_type [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]); | 208 int right_intra= IS_INTRA(s->current_picture.mb_type [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]); |
| 209 int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 209 int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 210 int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 210 int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 211 int offset= b_x*8 + b_y*stride*8; | 211 int offset= b_x*8 + b_y*stride*8; |
| 212 int16_t *left_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x <<(1-is_luma))]; | 212 int16_t *left_mv= s->current_picture.motion_val[0][s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x <<(1-is_luma))]; |
| 213 int16_t *right_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((b_x+1)<<(1-is_luma))]; | 213 int16_t *right_mv= s->current_picture.motion_val[0][s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((b_x+1)<<(1-is_luma))]; |
| 214 | 214 |
| 215 if(!(left_damage||right_damage)) continue; // both undamaged | 215 if(!(left_damage||right_damage)) continue; // both undamaged |
| 216 | 216 |
| 217 if( (!left_intra) && (!right_intra) | 217 if( (!left_intra) && (!right_intra) |
| 218 && ABS(left_mv[0]-right_mv[0]) + ABS(left_mv[1]+right_mv[1]) < 2) continue; | 218 && ABS(left_mv[0]-right_mv[0]) + ABS(left_mv[1]+right_mv[1]) < 2) continue; |
| 267 int top_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]); | 267 int top_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]); |
| 268 int bottom_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]); | 268 int bottom_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]); |
| 269 int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 269 int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 270 int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 270 int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 271 int offset= b_x*8 + b_y*stride*8; | 271 int offset= b_x*8 + b_y*stride*8; |
| 272 int16_t *top_mv= s->motion_val[s->block_wrap[0]*(( b_y <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))]; | 272 int16_t *top_mv= s->current_picture.motion_val[0][s->block_wrap[0]*(( b_y <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))]; |
| 273 int16_t *bottom_mv= s->motion_val[s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (b_x<<(1-is_luma))]; | 273 int16_t *bottom_mv= s->current_picture.motion_val[0][s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (b_x<<(1-is_luma))]; |
| 274 | 274 |
| 275 if(!(top_damage||bottom_damage)) continue; // both undamaged | 275 if(!(top_damage||bottom_damage)) continue; // both undamaged |
| 276 | 276 |
| 277 if( (!top_intra) && (!bottom_intra) | 277 if( (!top_intra) && (!bottom_intra) |
| 278 && ABS(top_mv[0]-bottom_mv[0]) + ABS(top_mv[1]+bottom_mv[1]) < 2) continue; | 278 && ABS(top_mv[0]-bottom_mv[0]) + ABS(top_mv[1]+bottom_mv[1]) < 2) continue; |
| 378 int j; | 378 int j; |
| 379 int best_score=256*256*256*64; | 379 int best_score=256*256*256*64; |
| 380 int best_pred=0; | 380 int best_pred=0; |
| 381 const int mot_stride= mb_width*2+2; | 381 const int mot_stride= mb_width*2+2; |
| 382 const int mot_index= mb_x*2 + 1 + (mb_y*2+1)*mot_stride; | 382 const int mot_index= mb_x*2 + 1 + (mb_y*2+1)*mot_stride; |
| 383 int prev_x= s->motion_val[mot_index][0]; | 383 int prev_x= s->current_picture.motion_val[0][mot_index][0]; |
| 384 int prev_y= s->motion_val[mot_index][1]; | 384 int prev_y= s->current_picture.motion_val[0][mot_index][1]; |
| 385 | 385 |
| 386 if((mb_x^mb_y^pass)&1) continue; | 386 if((mb_x^mb_y^pass)&1) continue; |
| 387 | 387 |
| 388 if(fixed[mb_xy]==MV_FROZEN) continue; | 388 if(fixed[mb_xy]==MV_FROZEN) continue; |
| 389 assert(!IS_INTRA(s->current_picture.mb_type[mb_xy])); | 389 assert(!IS_INTRA(s->current_picture.mb_type[mb_xy])); |
| 404 if(j==0 && pass>1) continue; | 404 if(j==0 && pass>1) continue; |
| 405 | 405 |
| 406 none_left=0; | 406 none_left=0; |
| 407 | 407 |
| 408 if(mb_x>0 && fixed[mb_xy-1]){ | 408 if(mb_x>0 && fixed[mb_xy-1]){ |
| 409 mv_predictor[pred_count][0]= s->motion_val[mot_index - 2][0]; | 409 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - 2][0]; |
| 410 mv_predictor[pred_count][1]= s->motion_val[mot_index - 2][1]; | 410 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - 2][1]; |
| 411 pred_count++; | 411 pred_count++; |
| 412 } | 412 } |
| 413 if(mb_x+1<mb_width && fixed[mb_xy+1]){ | 413 if(mb_x+1<mb_width && fixed[mb_xy+1]){ |
| 414 mv_predictor[pred_count][0]= s->motion_val[mot_index + 2][0]; | 414 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + 2][0]; |
| 415 mv_predictor[pred_count][1]= s->motion_val[mot_index + 2][1]; | 415 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + 2][1]; |
| 416 pred_count++; | 416 pred_count++; |
| 417 } | 417 } |
| 418 if(mb_y>0 && fixed[mb_xy-mb_stride]){ | 418 if(mb_y>0 && fixed[mb_xy-mb_stride]){ |
| 419 mv_predictor[pred_count][0]= s->motion_val[mot_index - mot_stride*2][0]; | 419 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*2][0]; |
| 420 mv_predictor[pred_count][1]= s->motion_val[mot_index - mot_stride*2][1]; | 420 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*2][1]; |
| 421 pred_count++; | 421 pred_count++; |
| 422 } | 422 } |
| 423 if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ | 423 if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ |
| 424 mv_predictor[pred_count][0]= s->motion_val[mot_index + mot_stride*2][0]; | 424 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*2][0]; |
| 425 mv_predictor[pred_count][1]= s->motion_val[mot_index + mot_stride*2][1]; | 425 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*2][1]; |
| 426 pred_count++; | 426 pred_count++; |
| 427 } | 427 } |
| 428 if(pred_count==0) continue; | 428 if(pred_count==0) continue; |
| 429 | 429 |
| 430 if(pred_count>1){ | 430 if(pred_count>1){ |
| 465 | 465 |
| 466 /* zero MV */ | 466 /* zero MV */ |
| 467 pred_count++; | 467 pred_count++; |
| 468 | 468 |
| 469 /* last MV */ | 469 /* last MV */ |
| 470 mv_predictor[pred_count][0]= s->motion_val[mot_index][0]; | 470 mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index][0]; |
| 471 mv_predictor[pred_count][1]= s->motion_val[mot_index][1]; | 471 mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index][1]; |
| 472 pred_count++; | 472 pred_count++; |
| 473 | 473 |
| 474 s->mv_dir = MV_DIR_FORWARD; | 474 s->mv_dir = MV_DIR_FORWARD; |
| 475 s->mb_intra=0; | 475 s->mb_intra=0; |
| 476 s->mv_type = MV_TYPE_16X16; | 476 s->mv_type = MV_TYPE_16X16; |
| 483 | 483 |
| 484 for(j=0; j<pred_count; j++){ | 484 for(j=0; j<pred_count; j++){ |
| 485 int score=0; | 485 int score=0; |
| 486 uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; | 486 uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; |
| 487 | 487 |
| 488 s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0]; | 488 s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0]; |
| 489 s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1]; | 489 s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1]; |
| 490 | 490 |
| 491 decode_mb(s); | 491 decode_mb(s); |
| 492 | 492 |
| 493 if(mb_x>0 && fixed[mb_xy-1]){ | 493 if(mb_x>0 && fixed[mb_xy-1]){ |
| 494 int k; | 494 int k; |
| 515 best_score= score; | 515 best_score= score; |
| 516 best_pred= j; | 516 best_pred= j; |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 score_sum+= best_score; | 519 score_sum+= best_score; |
| 520 //FIXME no need to set s->motion_val[mot_index][0] explicit | 520 //FIXME no need to set s->current_picture.motion_val[0][mot_index][0] explicit |
| 521 s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0]; | 521 s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0]; |
| 522 s->motion_val[mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1]; | 522 s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1]; |
| 523 | 523 |
| 524 decode_mb(s); | 524 decode_mb(s); |
| 525 | 525 |
| 526 | 526 |
| 527 if(s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y){ | 527 if(s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y){ |
| 669 | 669 |
| 670 if(!s->error_resilience || s->error_count==0) return; | 670 if(!s->error_resilience || s->error_count==0) return; |
| 671 | 671 |
| 672 av_log(s->avctx, AV_LOG_INFO, "concealing errors\n"); | 672 av_log(s->avctx, AV_LOG_INFO, "concealing errors\n"); |
| 673 | 673 |
| 674 if(s->motion_val == NULL){ | 674 if(s->current_picture.motion_val[0] == NULL){ |
| 675 int size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); | 675 int size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); |
| 676 | 676 |
| 677 av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n"); | 677 av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n"); |
| 678 | 678 |
| 679 s->motion_val= av_mallocz(size * 2 * sizeof(int16_t)); | 679 s->current_picture.motion_val[0]= av_mallocz(size * 2 * sizeof(int16_t)); //FIXME |
| 680 } | 680 } |
| 681 | 681 |
| 682 if(s->avctx->debug&FF_DEBUG_ER){ | 682 if(s->avctx->debug&FF_DEBUG_ER){ |
| 683 for(mb_y=0; mb_y<s->mb_height; mb_y++){ | 683 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
| 684 for(mb_x=0; mb_x<s->mb_width; mb_x++){ | 684 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
| 841 if(IS_8X8(mb_type)){ | 841 if(IS_8X8(mb_type)){ |
| 842 int mb_index= mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0]; | 842 int mb_index= mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0]; |
| 843 int j; | 843 int j; |
| 844 s->mv_type = MV_TYPE_8X8; | 844 s->mv_type = MV_TYPE_8X8; |
| 845 for(j=0; j<4; j++){ | 845 for(j=0; j<4; j++){ |
| 846 s->mv[0][j][0] = s->motion_val[ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][0]; | 846 s->mv[0][j][0] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][0]; |
| 847 s->mv[0][j][1] = s->motion_val[ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][1]; | 847 s->mv[0][j][1] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][1]; |
| 848 } | 848 } |
| 849 }else{ | 849 }else{ |
| 850 s->mv_type = MV_TYPE_16X16; | 850 s->mv_type = MV_TYPE_16X16; |
| 851 s->mv[0][0][0] = s->motion_val[ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][0]; | 851 s->mv[0][0][0] = s->current_picture.motion_val[0][ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][0]; |
| 852 s->mv[0][0][1] = s->motion_val[ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][1]; | 852 s->mv[0][0][1] = s->current_picture.motion_val[0][ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][1]; |
| 853 } | 853 } |
| 854 | 854 |
| 855 s->dsp.clear_blocks(s->block[0]); | 855 s->dsp.clear_blocks(s->block[0]); |
| 856 | 856 |
| 857 s->mb_x= mb_x; | 857 s->mb_x= mb_x; |
| 880 | 880 |
| 881 if(s->pp_time){ | 881 if(s->pp_time){ |
| 882 int time_pp= s->pp_time; | 882 int time_pp= s->pp_time; |
| 883 int time_pb= s->pb_time; | 883 int time_pb= s->pb_time; |
| 884 | 884 |
| 885 s->mv[0][0][0] = s->motion_val[xy][0]*time_pb/time_pp; | 885 s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp; |
| 886 s->mv[0][0][1] = s->motion_val[xy][1]*time_pb/time_pp; | 886 s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp; |
| 887 s->mv[1][0][0] = s->motion_val[xy][0]*(time_pb - time_pp)/time_pp; | 887 s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp; |
| 888 s->mv[1][0][1] = s->motion_val[xy][1]*(time_pb - time_pp)/time_pp; | 888 s->mv[1][0][1] = s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp; |
| 889 }else{ | 889 }else{ |
| 890 s->mv[0][0][0]= 0; | 890 s->mv[0][0][0]= 0; |
| 891 s->mv[0][0][1]= 0; | 891 s->mv[0][0][1]= 0; |
| 892 s->mv[1][0][0]= 0; | 892 s->mv[1][0][0]= 0; |
| 893 s->mv[1][0][1]= 0; | 893 s->mv[1][0][1]= 0; |
