aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-04-02 09:57:34 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-04-02 09:57:34 +0000
commit4d2a48349d6f40a2357bb25b4f360f2a6e669ad4 (patch)
tree7ff32c6ab3f7e58dd201f2a05093f404cd35908c
parent1f9aea9b91c653c6ad95e84b2ff250738e352eec (diff)
downloadffmpeg-4d2a48349d6f40a2357bb25b4f360f2a6e669ad4.tar.gz
msmpeg4 2pass support & some related cleanup
Originally committed as revision 1724 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/h263.c36
-rw-r--r--libavcodec/mpeg12.c10
-rw-r--r--libavcodec/mpegvideo.h8
-rw-r--r--libavcodec/msmpeg4.c24
4 files changed, 37 insertions, 41 deletions
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 2e7e19e2a9..d6da47ad48 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -544,9 +544,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->misc_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->misc_bits+= get_bits_diff(s);
}
switch(mb_type)
@@ -589,9 +587,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->mv_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->mv_bits+= get_bits_diff(s);
}
/* encode each block */
@@ -600,9 +596,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->p_tex_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->p_tex_bits+= get_bits_diff(s);
}
}else{ /* s->pict_type==B_TYPE */
if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
@@ -673,9 +667,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->misc_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->misc_bits+= get_bits_diff(s);
}
/* motion vectors: 16x16 mode */
@@ -698,9 +690,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->misc_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->misc_bits+= get_bits_diff(s);
}
for(i=0; i<4; i++){
@@ -713,9 +703,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->mv_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->mv_bits+= get_bits_diff(s);
}
/* encode each block */
@@ -724,9 +712,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->p_tex_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->p_tex_bits+= get_bits_diff(s);
}
s->f_count++;
}
@@ -803,9 +789,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->misc_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->misc_bits+= get_bits_diff(s);
}
/* encode each block */
@@ -814,9 +798,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
}
if(interleaved_stats){
- bits= get_bit_count(&s->pb);
- s->i_tex_bits+= bits - s->last_bits;
- s->last_bits=bits;
+ s->i_tex_bits+= get_bits_diff(s);
}
s->i_count++;
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 95ce87edf3..019e29370b 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -80,16 +80,6 @@ static uint32_t uni_mpeg1_ac_vlc_bits[64*64*2];
static uint8_t uni_mpeg1_ac_vlc_len [64*64*2];
#endif
-static inline int get_bits_diff(MpegEncContext *s){
- int bits,ret;
-
- bits= get_bit_count(&s->pb);
- ret= bits - s->last_bits;
- s->last_bits=bits;
-
- return ret;
-}
-
static void init_2d_vlc_rl(RLTable *rl)
{
int i;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 050d991664..dbbc1bb0a7 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -662,6 +662,14 @@ static inline void ff_update_block_index(MpegEncContext *s){
s->block_index[5]++;
}
+static inline int get_bits_diff(MpegEncContext *s){
+ const int bits= get_bit_count(&s->pb);
+ const int last= s->last_bits;
+
+ s->last_bits = bits;
+
+ return bits - last;
+}
/* motion_est.c */
void ff_estimate_p_frame_motion(MpegEncContext * s,
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 115e71375f..9560aaf85d 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -549,6 +549,9 @@ void msmpeg4_encode_mb(MpegEncContext * s,
if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
/* skip macroblock */
put_bits(&s->pb, 1, 1);
+ s->last_bits++;
+ s->misc_bits++;
+
return;
}
if (s->use_skip_mb_code)
@@ -564,7 +567,9 @@ void msmpeg4_encode_mb(MpegEncContext * s,
put_bits(&s->pb,
cbpy_tab[coded_cbp>>2][1],
cbpy_tab[coded_cbp>>2][0]);
-
+
+ s->misc_bits += get_bits_diff(s);
+
h263_pred_motion(s, 0, &pred_x, &pred_y);
msmpeg4v2_encode_motion(s, motion_x - pred_x);
msmpeg4v2_encode_motion(s, motion_y - pred_y);
@@ -573,11 +578,20 @@ void msmpeg4_encode_mb(MpegEncContext * s,
table_mb_non_intra[cbp + 64][1],
table_mb_non_intra[cbp + 64][0]);
+ s->misc_bits += get_bits_diff(s);
+
/* motion vector */
h263_pred_motion(s, 0, &pred_x, &pred_y);
msmpeg4_encode_motion(s, motion_x - pred_x,
motion_y - pred_y);
}
+
+ s->mv_bits += get_bits_diff(s);
+
+ for (i = 0; i < 6; i++) {
+ msmpeg4_encode_block(s, block[i], i);
+ }
+ s->p_tex_bits += get_bits_diff(s);
} else {
/* compute cbp */
cbp = 0;
@@ -633,10 +647,12 @@ void msmpeg4_encode_mb(MpegEncContext * s,
put_bits(&s->pb, table_inter_intra[s->h263_aic_dir][1], table_inter_intra[s->h263_aic_dir][0]);
}
}
- }
+ s->misc_bits += get_bits_diff(s);
- for (i = 0; i < 6; i++) {
- msmpeg4_encode_block(s, block[i], i);
+ for (i = 0; i < 6; i++) {
+ msmpeg4_encode_block(s, block[i], i);
+ }
+ s->i_tex_bits += get_bits_diff(s);
}
}