Revision 4d2a4834

View differences:

libavcodec/h263.c
544 544
            }
545 545

  
546 546
            if(interleaved_stats){
547
                bits= get_bit_count(&s->pb);
548
                s->misc_bits+= bits - s->last_bits;
549
                s->last_bits=bits;
547
                s->misc_bits+= get_bits_diff(s);
550 548
            }
551 549

  
552 550
            switch(mb_type)
......
589 587
            }
590 588

  
591 589
            if(interleaved_stats){
592
                bits= get_bit_count(&s->pb);
593
                s->mv_bits+= bits - s->last_bits;
594
                s->last_bits=bits;
590
                s->mv_bits+= get_bits_diff(s);
595 591
            }
596 592

  
597 593
            /* encode each block */
......
600 596
            }
601 597

  
602 598
            if(interleaved_stats){
603
                bits= get_bit_count(&s->pb);
604
                s->p_tex_bits+= bits - s->last_bits;
605
                s->last_bits=bits;
599
                s->p_tex_bits+= get_bits_diff(s);
606 600
            }
607 601
        }else{ /* s->pict_type==B_TYPE */
608 602
            if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
......
673 667
                }
674 668
                    
675 669
                if(interleaved_stats){
676
                    bits= get_bit_count(&s->pb);
677
                    s->misc_bits+= bits - s->last_bits;
678
                    s->last_bits=bits;
670
                    s->misc_bits+= get_bits_diff(s);
679 671
                }
680 672

  
681 673
                /* motion vectors: 16x16 mode */
......
698 690
                }
699 691
    
700 692
                if(interleaved_stats){
701
                    bits= get_bit_count(&s->pb);
702
                    s->misc_bits+= bits - s->last_bits;
703
                    s->last_bits=bits;
693
                    s->misc_bits+= get_bits_diff(s);
704 694
                }
705 695

  
706 696
                for(i=0; i<4; i++){
......
713 703
            }
714 704

  
715 705
            if(interleaved_stats){ 
716
                bits= get_bit_count(&s->pb);
717
                s->mv_bits+= bits - s->last_bits;
718
                s->last_bits=bits;
706
                s->mv_bits+= get_bits_diff(s);
719 707
            }
720 708

  
721 709
            /* encode each block */
......
724 712
            }
725 713

  
726 714
            if(interleaved_stats){
727
                bits= get_bit_count(&s->pb);
728
                s->p_tex_bits+= bits - s->last_bits;
729
                s->last_bits=bits;
715
                s->p_tex_bits+= get_bits_diff(s);
730 716
            }
731 717
            s->f_count++;
732 718
        }
......
803 789
        }
804 790

  
805 791
        if(interleaved_stats){
806
            bits= get_bit_count(&s->pb);
807
            s->misc_bits+= bits - s->last_bits;
808
            s->last_bits=bits;
792
            s->misc_bits+= get_bits_diff(s);
809 793
        }
810 794

  
811 795
        /* encode each block */
......
814 798
        }
815 799

  
816 800
        if(interleaved_stats){
817
            bits= get_bit_count(&s->pb);
818
            s->i_tex_bits+= bits - s->last_bits;
819
            s->last_bits=bits;
801
            s->i_tex_bits+= get_bits_diff(s);
820 802
        }
821 803
        s->i_count++;
822 804

  
libavcodec/mpeg12.c
80 80
static uint8_t  uni_mpeg1_ac_vlc_len [64*64*2];
81 81
#endif
82 82

  
83
static inline int get_bits_diff(MpegEncContext *s){
84
    int bits,ret;
85
    
86
    bits= get_bit_count(&s->pb);
87
    ret= bits - s->last_bits;
88
    s->last_bits=bits;
89
    
90
    return ret;
91
}
92

  
93 83
static void init_2d_vlc_rl(RLTable *rl)
94 84
{
95 85
    int i;
libavcodec/mpegvideo.h
662 662
    s->block_index[5]++;
663 663
}
664 664

  
665
static inline int get_bits_diff(MpegEncContext *s){
666
    const int bits= get_bit_count(&s->pb);
667
    const int last= s->last_bits;
668

  
669
    s->last_bits = bits;
670

  
671
    return bits - last;
672
}
665 673

  
666 674
/* motion_est.c */
667 675
void ff_estimate_p_frame_motion(MpegEncContext * s,
libavcodec/msmpeg4.c
549 549
	if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
550 550
	    /* skip macroblock */
551 551
	    put_bits(&s->pb, 1, 1);
552
            s->last_bits++;
553
	    s->misc_bits++;
554

  
552 555
	    return;
553 556
	}
554 557
        if (s->use_skip_mb_code)
......
564 567
            put_bits(&s->pb, 
565 568
                     cbpy_tab[coded_cbp>>2][1], 
566 569
                     cbpy_tab[coded_cbp>>2][0]);
567
                        
570

  
571
            s->misc_bits += get_bits_diff(s);
572

  
568 573
            h263_pred_motion(s, 0, &pred_x, &pred_y);
569 574
            msmpeg4v2_encode_motion(s, motion_x - pred_x);
570 575
            msmpeg4v2_encode_motion(s, motion_y - pred_y);
......
573 578
                     table_mb_non_intra[cbp + 64][1], 
574 579
                     table_mb_non_intra[cbp + 64][0]);
575 580

  
581
            s->misc_bits += get_bits_diff(s);
582

  
576 583
            /* motion vector */
577 584
            h263_pred_motion(s, 0, &pred_x, &pred_y);
578 585
            msmpeg4_encode_motion(s, motion_x - pred_x, 
579 586
                                  motion_y - pred_y);
580 587
        }
588

  
589
        s->mv_bits += get_bits_diff(s);
590

  
591
        for (i = 0; i < 6; i++) {
592
            msmpeg4_encode_block(s, block[i], i);
593
        }
594
        s->p_tex_bits += get_bits_diff(s);
581 595
    } else {
582 596
	/* compute cbp */
583 597
	cbp = 0;
......
633 647
                put_bits(&s->pb, table_inter_intra[s->h263_aic_dir][1], table_inter_intra[s->h263_aic_dir][0]);
634 648
            }
635 649
        }
636
    }
650
        s->misc_bits += get_bits_diff(s);
637 651

  
638
    for (i = 0; i < 6; i++) {
639
        msmpeg4_encode_block(s, block[i], i);
652
        for (i = 0; i < 6; i++) {
653
            msmpeg4_encode_block(s, block[i], i);
654
        }
655
        s->i_tex_bits += get_bits_diff(s);
640 656
    }
641 657
}
642 658

  

Also available in: Unified diff