From 50c6f6cd4c1754d52bd093f3a7bd7585b17547a0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 22 Dec 2005 14:17:54 +0000 Subject: [PATCH] improved lambda/qp guessing for motion estimation RD in first pass this only affects encoding with bframes and rate control Originally committed as revision 4765 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/mpegvideo.c | 8 ++++++++ tests/ffmpeg.regression.ref | 14 +++++++------- tests/rotozoom.regression.ref | 14 +++++++------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index cc884dbae8..729cfdd89d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -5300,7 +5300,15 @@ static void encode_picture(MpegEncContext *s, int picture_number) if(s->flags & CODEC_FLAG_PASS2) estimate_qp(s, 1); + 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]; + else + s->lambda= rcc->last_qscale_for[rcc->last_non_b_pict_type]; + update_qscale(s); + } s->mb_intra=0; //for the rate distortion & bit compare functions for(i=1; iavctx->thread_count; i++){ diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 1a2f5910b8..1a7dbc5e22 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -59,18 +59,18 @@ stddev: 7.99 PSNR:30.06 bytes:7602176 7932708 ./data/a-huffyuv.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -24f8d8a1c15c078f1f1e443b85688444 *./data/a-mpeg4-rc.avi -820964 ./data/a-mpeg4-rc.avi -8458b4ddaca643a3ec1264c1ee2f4986 *./data/out.yuv +fc4c71c330fd3f95e05c398c6a7584de *./data/a-mpeg4-rc.avi +824306 ./data/a-mpeg4-rc.avi +fb0a9af6dd83b2f1a3ba752b848038f7 *./data/out.yuv stddev: 10.41 PSNR:27.77 bytes:7602176 81078d7852dfd6041ff17b5dc8ed0ffc *./data/a-mpeg4-adv.avi 600240 ./data/a-mpeg4-adv.avi 0b7935cee2070f3b838478cea6dc4b3c *./data/out.yuv stddev: 10.25 PSNR:27.90 bytes:7602176 -c5478162c76db62162b082594c4e7ee1 *./data/a-mpeg4-thread.avi -756550 ./data/a-mpeg4-thread.avi -7e4e2cf2659aa158f5ffed2be45a9c3d *./data/out.yuv -stddev: 12.31 PSNR:26.31 bytes:7602176 +5da70c628af00fc6d2dba685d24341b6 *./data/a-mpeg4-thread.avi +764920 ./data/a-mpeg4-thread.avi +6e3cc8569fd1f39a3657045a8249dbc6 *./data/out.yuv +stddev: 12.32 PSNR:26.30 bytes:7602176 50867a2530035615152f1e068c989bfc *./data/a-mpeg4-Q.avi 899514 ./data/a-mpeg4-Q.avi cdb77818e108eab89c9ac4bcaf350e19 *./data/out.yuv diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 9adb98c9bd..f1b16d79f9 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -59,18 +59,18 @@ stddev: 5.34 PSNR:33.56 bytes:7602176 6454196 ./data/a-huffyuv.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -540bdc49a339db675d12cffc9fce2454 *./data/a-mpeg4-rc.avi -228094 ./data/a-mpeg4-rc.avi -764d5da4f1c8eda9bd554179ed1ea283 *./data/out.yuv +95e95dfe42fce9cdbe72688e821022ca *./data/a-mpeg4-rc.avi +227834 ./data/a-mpeg4-rc.avi +2e02fa0261c21268d568ddde74f9431e *./data/out.yuv stddev: 4.26 PSNR:35.51 bytes:7602176 6844785bcca74b4b9dc77ce6d21a3871 *./data/a-mpeg4-adv.avi 172538 ./data/a-mpeg4-adv.avi 49fecc1105d25ff1c2fc9c0d4cb821b0 *./data/out.yuv stddev: 4.84 PSNR:34.41 bytes:7602176 -d5f2da1edcf1979d71bec183e461b5aa *./data/a-mpeg4-thread.avi -253098 ./data/a-mpeg4-thread.avi -da1a5a3301ad2bdf5806a51ffa74d4fb *./data/out.yuv -stddev: 4.06 PSNR:35.93 bytes:7602176 +9f7f5a7da720ba720aa35d72ed062959 *./data/a-mpeg4-thread.avi +253448 ./data/a-mpeg4-thread.avi +672eff5de3b19df7b82ed3e6bed8642d *./data/out.yuv +stddev: 4.05 PSNR:35.96 bytes:7602176 ddcb9476113fac71ee609018984353ce *./data/a-mpeg4-Q.avi 165016 ./data/a-mpeg4-Q.avi 94d8bd3897ac20bb3bef9cf384f9abd0 *./data/out.yuv