Mercurial > libavcodec.hg
comparison h263.c @ 1656:34b0e799aeb6 libavcodec
cleanup
author | michael |
---|---|
date | Thu, 04 Dec 2003 18:46:49 +0000 |
parents | c92147a61d97 |
children | 3075fc11a974 |
comparison
equal
deleted
inserted
replaced
1655:c92147a61d97 | 1656:34b0e799aeb6 |
---|---|
1234 } | 1234 } |
1235 } | 1235 } |
1236 } | 1236 } |
1237 #endif | 1237 #endif |
1238 | 1238 |
1239 int ff_h263_loop_filter(MpegEncContext * s){ | 1239 void ff_h263_loop_filter(MpegEncContext * s){ |
1240 int qp_c; | 1240 int qp_c; |
1241 const int linesize = s->linesize; | 1241 const int linesize = s->linesize; |
1242 const int uvlinesize= s->uvlinesize; | 1242 const int uvlinesize= s->uvlinesize; |
1243 const int xy = s->mb_y * s->mb_stride + s->mb_x; | 1243 const int xy = s->mb_y * s->mb_stride + s->mb_x; |
1244 uint8_t *dest_y = s->dest[0]; | 1244 uint8_t *dest_y = s->dest[0]; |
3570 if(cbpc & 4){ | 3570 if(cbpc & 4){ |
3571 s->current_picture.mb_type[xy]= MB_TYPE_INTRA; | 3571 s->current_picture.mb_type[xy]= MB_TYPE_INTRA; |
3572 }else{ | 3572 }else{ |
3573 get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); | 3573 get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); |
3574 if (cbpc & 8) { | 3574 if (cbpc & 8) { |
3575 skip_bits(&s->gb, 2); | 3575 if(s->modified_quant){ |
3576 if(get_bits1(&s->gb)) skip_bits(&s->gb, 1); | |
3577 else skip_bits(&s->gb, 5); | |
3578 }else | |
3579 skip_bits(&s->gb, 2); | |
3576 } | 3580 } |
3577 | 3581 |
3578 if ((cbpc & 16) == 0) { | 3582 if ((cbpc & 16) == 0) { |
3579 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; | 3583 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; |
3580 /* 16x16 motion prediction */ | 3584 /* 16x16 motion prediction */ |
3622 s->mb_x--; | 3626 s->mb_x--; |
3623 | 3627 |
3624 s->gb= gb; | 3628 s->gb= gb; |
3625 } | 3629 } |
3626 | 3630 |
3631 static void h263_decode_dquant(MpegEncContext *s){ | |
3632 static const int8_t quant_tab[4] = { -1, -2, 1, 2 }; | |
3633 | |
3634 if(s->modified_quant){ | |
3635 if(get_bits1(&s->gb)) | |
3636 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ]; | |
3637 else | |
3638 s->qscale= get_bits(&s->gb, 5); | |
3639 }else | |
3640 s->qscale += quant_tab[get_bits(&s->gb, 2)]; | |
3641 ff_set_qscale(s, s->qscale); | |
3642 } | |
3643 | |
3627 int ff_h263_decode_mb(MpegEncContext *s, | 3644 int ff_h263_decode_mb(MpegEncContext *s, |
3628 DCTELEM block[6][64]) | 3645 DCTELEM block[6][64]) |
3629 { | 3646 { |
3630 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; | 3647 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; |
3631 int16_t *mot_val; | 3648 int16_t *mot_val; |
3632 static int8_t quant_tab[4] = { -1, -2, 1, 2 }; | |
3633 const int xy= s->mb_x + s->mb_y * s->mb_stride; | 3649 const int xy= s->mb_x + s->mb_y * s->mb_stride; |
3634 | 3650 |
3635 assert(!s->h263_pred); | 3651 assert(!s->h263_pred); |
3636 | 3652 |
3637 if (s->pict_type == P_TYPE) { | 3653 if (s->pict_type == P_TYPE) { |
3666 if(s->alt_inter_vlc==0 || (cbpc & 3)!=3) | 3682 if(s->alt_inter_vlc==0 || (cbpc & 3)!=3) |
3667 cbpy ^= 0xF; | 3683 cbpy ^= 0xF; |
3668 | 3684 |
3669 cbp = (cbpc & 3) | (cbpy << 2); | 3685 cbp = (cbpc & 3) | (cbpy << 2); |
3670 if (dquant) { | 3686 if (dquant) { |
3671 if(s->modified_quant){ | 3687 h263_decode_dquant(s); |
3672 if(get_bits1(&s->gb)) | |
3673 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ]; | |
3674 else | |
3675 s->qscale= get_bits(&s->gb, 5); | |
3676 }else | |
3677 s->qscale += quant_tab[get_bits(&s->gb, 2)]; | |
3678 ff_set_qscale(s, s->qscale); | |
3679 } | 3688 } |
3680 | 3689 |
3681 s->mv_dir = MV_DIR_FORWARD; | 3690 s->mv_dir = MV_DIR_FORWARD; |
3682 if ((cbpc & 16) == 0) { | 3691 if ((cbpc & 16) == 0) { |
3683 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; | 3692 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; |
3781 cbp=0; | 3790 cbp=0; |
3782 | 3791 |
3783 assert(!s->mb_intra); | 3792 assert(!s->mb_intra); |
3784 | 3793 |
3785 if(IS_QUANT(mb_type)){ | 3794 if(IS_QUANT(mb_type)){ |
3786 if(s->modified_quant){ //FIXME factorize | 3795 h263_decode_dquant(s); |
3787 if(get_bits1(&s->gb)) | |
3788 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ]; | |
3789 else | |
3790 s->qscale= get_bits(&s->gb, 5); | |
3791 }else | |
3792 s->qscale += quant_tab[get_bits(&s->gb, 2)]; | |
3793 ff_set_qscale(s, s->qscale); | |
3794 } | 3796 } |
3795 | 3797 |
3796 if(IS_DIRECT(mb_type)){ | 3798 if(IS_DIRECT(mb_type)){ |
3797 s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; | 3799 s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; |
3798 mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0); | 3800 mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0); |
3855 av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); | 3857 av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); |
3856 return -1; | 3858 return -1; |
3857 } | 3859 } |
3858 cbp = (cbpc & 3) | (cbpy << 2); | 3860 cbp = (cbpc & 3) | (cbpy << 2); |
3859 if (dquant) { | 3861 if (dquant) { |
3860 if(s->modified_quant){ | 3862 h263_decode_dquant(s); |
3861 if(get_bits1(&s->gb)) | |
3862 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ]; | |
3863 else | |
3864 s->qscale= get_bits(&s->gb, 5); | |
3865 }else | |
3866 s->qscale += quant_tab[get_bits(&s->gb, 2)]; | |
3867 ff_set_qscale(s, s->qscale); | |
3868 } | 3863 } |
3869 } | 3864 } |
3870 | 3865 |
3871 /* decode each block */ | 3866 /* decode each block */ |
3872 for (i = 0; i < 6; i++) { | 3867 for (i = 0; i < 6; i++) { |