aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2005-12-29 15:46:23 +0000
committerMichael Niedermayer <michaelni@gmx.at>2005-12-29 15:46:23 +0000
commit88e51e1fb5b9ed342d77049330980279b1505e52 (patch)
tree9f2058ba9580237d2a74ce59708170a47db5e28a /libavcodec
parent58f7833e8e5972e5021319ae26b5a82d01a11be7 (diff)
downloadffmpeg-88e51e1fb5b9ed342d77049330980279b1505e52.tar.gz
second try of improved lambda/qp guessing for motion estimation RD in first pass
Originally committed as revision 4785 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpegvideo.c9
-rw-r--r--libavcodec/mpegvideo.h1
2 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 731a502c25..f08dbb8138 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1594,6 +1594,7 @@ void MPV_frame_end(MpegEncContext *s)
emms_c();
s->last_pict_type = s->pict_type;
+ s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality;
if(s->pict_type!=B_TYPE){
s->last_non_b_pict_type= s->pict_type;
}
@@ -2204,7 +2205,7 @@ static int estimate_best_b_count(MpegEncContext *s){
int is_p= i % (j+1) == j || i==s->max_b_frames;
input[i+1].pict_type= is_p ? P_TYPE : B_TYPE;
- input[i+1].quality= s->rc_context.last_qscale_for[input[i+1].pict_type];
+ input[i+1].quality= s->last_lambda_for[input[i+1].pict_type];
out_size = avcodec_encode_video(c, outbuf, outbuf_size, &input[i+1]);
rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
}
@@ -5398,12 +5399,10 @@ static void encode_picture(MpegEncContext *s, int picture_number)
estimate_qp(s, 1);
ff_get_2pass_fcode(s);
}else if(!(s->flags & CODEC_FLAG_QSCALE)){
- RateControlContext *rcc= &s->rc_context;
-
if(s->pict_type==B_TYPE)
- s->lambda= rcc->last_qscale_for[s->pict_type];
+ s->lambda= s->last_lambda_for[s->pict_type];
else
- s->lambda= rcc->last_qscale_for[rcc->last_non_b_pict_type];
+ s->lambda= s->last_lambda_for[s->last_non_b_pict_type];
update_qscale(s);
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index ce8e6e2939..b36133a639 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -374,6 +374,7 @@ typedef struct MpegEncContext {
int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol
int dropable;
int frame_rate_index;
+ int last_lambda_for[5]; ///< last lambda for a specific pict type
/* motion compensation */
int unrestricted_mv; ///< mv can point outside of the coded picture