comparison h263.c @ 1164:0e3c0c4a7b3d libavcodec

msmpeg4 2pass support & some related cleanup
author michaelni
date Wed, 02 Apr 2003 09:57:34 +0000
parents 8c15d82c1893
children a39d55237445
comparison
equal deleted inserted replaced
1163:0951691c4225 1164:0e3c0c4a7b3d
542 if(mb_type) // not diect mode 542 if(mb_type) // not diect mode
543 put_bits(&s->pb, 1, 0); // no interlaced ME yet 543 put_bits(&s->pb, 1, 0); // no interlaced ME yet
544 } 544 }
545 545
546 if(interleaved_stats){ 546 if(interleaved_stats){
547 bits= get_bit_count(&s->pb); 547 s->misc_bits+= get_bits_diff(s);
548 s->misc_bits+= bits - s->last_bits;
549 s->last_bits=bits;
550 } 548 }
551 549
552 switch(mb_type) 550 switch(mb_type)
553 { 551 {
554 case 0: /* direct */ 552 case 0: /* direct */
587 printf("unknown mb type\n"); 585 printf("unknown mb type\n");
588 return; 586 return;
589 } 587 }
590 588
591 if(interleaved_stats){ 589 if(interleaved_stats){
592 bits= get_bit_count(&s->pb); 590 s->mv_bits+= get_bits_diff(s);
593 s->mv_bits+= bits - s->last_bits;
594 s->last_bits=bits;
595 } 591 }
596 592
597 /* encode each block */ 593 /* encode each block */
598 for (i = 0; i < 6; i++) { 594 for (i = 0; i < 6; i++) {
599 mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, &s->pb); 595 mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, &s->pb);
600 } 596 }
601 597
602 if(interleaved_stats){ 598 if(interleaved_stats){
603 bits= get_bit_count(&s->pb); 599 s->p_tex_bits+= get_bits_diff(s);
604 s->p_tex_bits+= bits - s->last_bits;
605 s->last_bits=bits;
606 } 600 }
607 }else{ /* s->pict_type==B_TYPE */ 601 }else{ /* s->pict_type==B_TYPE */
608 if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) { 602 if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
609 /* check if the B frames can skip it too, as we must skip it if we skip here 603 /* check if the B frames can skip it too, as we must skip it if we skip here
610 why didnt they just compress the skip-mb bits instead of reusing them ?! */ 604 why didnt they just compress the skip-mb bits instead of reusing them ?! */
671 put_bits(pb2, 1, s->interlaced_dct); 665 put_bits(pb2, 1, s->interlaced_dct);
672 put_bits(pb2, 1, 0); // no interlaced ME yet 666 put_bits(pb2, 1, 0); // no interlaced ME yet
673 } 667 }
674 668
675 if(interleaved_stats){ 669 if(interleaved_stats){
676 bits= get_bit_count(&s->pb); 670 s->misc_bits+= get_bits_diff(s);
677 s->misc_bits+= bits - s->last_bits;
678 s->last_bits=bits;
679 } 671 }
680 672
681 /* motion vectors: 16x16 mode */ 673 /* motion vectors: 16x16 mode */
682 h263_pred_motion(s, 0, &pred_x, &pred_y); 674 h263_pred_motion(s, 0, &pred_x, &pred_y);
683 675
696 if(cbp) 688 if(cbp)
697 put_bits(pb2, 1, s->interlaced_dct); 689 put_bits(pb2, 1, s->interlaced_dct);
698 } 690 }
699 691
700 if(interleaved_stats){ 692 if(interleaved_stats){
701 bits= get_bit_count(&s->pb); 693 s->misc_bits+= get_bits_diff(s);
702 s->misc_bits+= bits - s->last_bits;
703 s->last_bits=bits;
704 } 694 }
705 695
706 for(i=0; i<4; i++){ 696 for(i=0; i<4; i++){
707 /* motion vectors: 8x8 mode*/ 697 /* motion vectors: 8x8 mode*/
708 h263_pred_motion(s, i, &pred_x, &pred_y); 698 h263_pred_motion(s, i, &pred_x, &pred_y);
711 h263_encode_motion(s, s->motion_val[ s->block_index[i] ][1] - pred_y, s->f_code); 701 h263_encode_motion(s, s->motion_val[ s->block_index[i] ][1] - pred_y, s->f_code);
712 } 702 }
713 } 703 }
714 704
715 if(interleaved_stats){ 705 if(interleaved_stats){
716 bits= get_bit_count(&s->pb); 706 s->mv_bits+= get_bits_diff(s);
717 s->mv_bits+= bits - s->last_bits;
718 s->last_bits=bits;
719 } 707 }
720 708
721 /* encode each block */ 709 /* encode each block */
722 for (i = 0; i < 6; i++) { 710 for (i = 0; i < 6; i++) {
723 mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, tex_pb); 711 mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, tex_pb);
724 } 712 }
725 713
726 if(interleaved_stats){ 714 if(interleaved_stats){
727 bits= get_bit_count(&s->pb); 715 s->p_tex_bits+= get_bits_diff(s);
728 s->p_tex_bits+= bits - s->last_bits;
729 s->last_bits=bits;
730 } 716 }
731 s->f_count++; 717 s->f_count++;
732 } 718 }
733 } else { 719 } else {
734 int cbp; 720 int cbp;
801 if(!s->progressive_sequence){ 787 if(!s->progressive_sequence){
802 put_bits(dc_pb, 1, s->interlaced_dct); 788 put_bits(dc_pb, 1, s->interlaced_dct);
803 } 789 }
804 790
805 if(interleaved_stats){ 791 if(interleaved_stats){
806 bits= get_bit_count(&s->pb); 792 s->misc_bits+= get_bits_diff(s);
807 s->misc_bits+= bits - s->last_bits;
808 s->last_bits=bits;
809 } 793 }
810 794
811 /* encode each block */ 795 /* encode each block */
812 for (i = 0; i < 6; i++) { 796 for (i = 0; i < 6; i++) {
813 mpeg4_encode_block(s, block[i], i, dc_diff[i], scan_table[i], dc_pb, tex_pb); 797 mpeg4_encode_block(s, block[i], i, dc_diff[i], scan_table[i], dc_pb, tex_pb);
814 } 798 }
815 799
816 if(interleaved_stats){ 800 if(interleaved_stats){
817 bits= get_bit_count(&s->pb); 801 s->i_tex_bits+= get_bits_diff(s);
818 s->i_tex_bits+= bits - s->last_bits;
819 s->last_bits=bits;
820 } 802 }
821 s->i_count++; 803 s->i_count++;
822 804
823 /* restore ac coeffs & last_index stuff if we messed them up with the prediction */ 805 /* restore ac coeffs & last_index stuff if we messed them up with the prediction */
824 if(s->ac_pred){ 806 if(s->ac_pred){