comparison h261.c @ 2330:380b62dce6ec libavcodec

simplify
author michael
date Thu, 28 Oct 2004 17:34:14 +0000
parents bae9c6de090b
children 5690ce009ebd
comparison
equal deleted inserted replaced
2329:bae9c6de090b 2330:380b62dce6ec
594 return v; 594 return v;
595 } 595 }
596 596
597 static int h261_decode_mb(H261Context *h){ 597 static int h261_decode_mb(H261Context *h){
598 MpegEncContext * const s = &h->s; 598 MpegEncContext * const s = &h->s;
599 int i, cbp, xy, old_mtype; 599 int i, cbp, xy;
600 600
601 cbp = 63; 601 cbp = 63;
602 // Read mba 602 // Read mba
603 do{ 603 do{
604 h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2); 604 h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2);
632 ff_init_block_index(s); 632 ff_init_block_index(s);
633 ff_update_block_index(s); 633 ff_update_block_index(s);
634 s->dsp.clear_blocks(s->block[0]); 634 s->dsp.clear_blocks(s->block[0]);
635 635
636 // Read mtype 636 // Read mtype
637 old_mtype = h->mtype;
638 h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2); 637 h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
639 h->mtype = h261_mtype_map[h->mtype]; 638 h->mtype = h261_mtype_map[h->mtype];
640 639
641 // Read mquant 640 // Read mquant
642 if ( IS_QUANT ( h->mtype ) ){ 641 if ( IS_QUANT ( h->mtype ) ){
652 // following three situations: 651 // following three situations:
653 // 1) evaluating MVD for macroblocks 1, 12 and 23; 652 // 1) evaluating MVD for macroblocks 1, 12 and 23;
654 // 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1; 653 // 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1;
655 // 3) MTYPE of the previous macroblock was not MC. 654 // 3) MTYPE of the previous macroblock was not MC.
656 if ( ( h->current_mba == 1 ) || ( h->current_mba == 12 ) || ( h->current_mba == 23 ) || 655 if ( ( h->current_mba == 1 ) || ( h->current_mba == 12 ) || ( h->current_mba == 23 ) ||
657 ( h->mba_diff != 1) || ( !IS_16X16 ( old_mtype ) )) 656 ( h->mba_diff != 1))
658 { 657 {
659 h->current_mv_x = 0; 658 h->current_mv_x = 0;
660 h->current_mv_y = 0; 659 h->current_mv_y = 0;
661 } 660 }
662 661
663 h->current_mv_x= decode_mv_component(&s->gb, h->current_mv_x); 662 h->current_mv_x= decode_mv_component(&s->gb, h->current_mv_x);
664 h->current_mv_y= decode_mv_component(&s->gb, h->current_mv_y); 663 h->current_mv_y= decode_mv_component(&s->gb, h->current_mv_y);
664 }else{
665 h->current_mv_x = 0;
666 h->current_mv_y = 0;
665 } 667 }
666 668
667 // Read cbp 669 // Read cbp
668 if ( HAS_CBP( h->mtype ) ){ 670 if ( HAS_CBP( h->mtype ) ){
669 cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1; 671 cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1;
676 678
677 //set motion vectors 679 //set motion vectors
678 s->mv_dir = MV_DIR_FORWARD; 680 s->mv_dir = MV_DIR_FORWARD;
679 s->mv_type = MV_TYPE_16X16; 681 s->mv_type = MV_TYPE_16X16;
680 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; 682 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
681 if(IS_16X16 ( h->mtype )){ 683 s->mv[0][0][0] = h->current_mv_x * 2;//gets divided by 2 in motion compensation
682 s->mv[0][0][0] = h->current_mv_x * 2;//gets divided by 2 in motion compensation 684 s->mv[0][0][1] = h->current_mv_y * 2;
683 s->mv[0][0][1] = h->current_mv_y * 2;
684 }
685 else{
686 h->current_mv_x = s->mv[0][0][0] = 0;
687 h->current_mv_x = s->mv[0][0][1] = 0;
688 }
689 685
690 intra: 686 intra:
691 /* decode each block */ 687 /* decode each block */
692 if(s->mb_intra || HAS_CBP(h->mtype)){ 688 if(s->mb_intra || HAS_CBP(h->mtype)){
693 for (i = 0; i < 6; i++) { 689 for (i = 0; i < 6; i++) {