summaryrefslogtreecommitdiff
path: root/vp8/encoder/firstpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder/firstpass.c')
-rw-r--r--vp8/encoder/firstpass.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index 0c79adee4..4d259c676 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -903,7 +903,7 @@ void vp8_first_pass(VP8_COMP *cpi)
}
extern const int vp8_bits_per_mb[2][QINDEX_RANGE];
-#define BASE_ERRPERMB 100
+#define BASE_ERRPERMB 150
static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh, int Height, int Width)
{
int Q;
@@ -989,6 +989,19 @@ static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_
//Q = cpi->oxcf.cq_target_quality;
}
+ // Adjust maxq_min_limit and maxq_max_limit limits based on
+ // averaga q observed in clip for non kf/gf.arf frames
+ // Give average a chance to settle though.
+ if ( (cpi->ni_frames >
+ ((unsigned int)cpi->total_stats->count >> 8)) &&
+ (cpi->ni_frames > 150) )
+ {
+ cpi->maxq_max_limit = ((cpi->ni_av_qi + 32) < cpi->worst_quality)
+ ? (cpi->ni_av_qi + 32) : cpi->worst_quality;
+ cpi->maxq_min_limit = ((cpi->ni_av_qi - 32) > cpi->best_quality)
+ ? (cpi->ni_av_qi - 32) : cpi->best_quality;
+ }
+
return Q;
}
static int estimate_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh, int Height, int Width)
@@ -2121,7 +2134,7 @@ void vp8_second_pass(VP8_COMP *cpi)
cpi->common.Width);
// Limit the maxq value returned subsequently.
- // This increases the risk of overspend if the initial
+ // This increases the risk of overspend or underspend if the initial
// estimate for the clip is bad, but helps prevent excessive
// variation in Q, especially near the end of a clip
// where for example a small overspend may cause Q to crash