summaryrefslogtreecommitdiff
path: root/vp8/encoder/firstpass.c
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2011-11-21 15:45:10 +0000
committerPaul Wilkins <paulwilkins@google.com>2011-11-22 08:42:33 +0000
commitd39b5d05462c4b0755dd93814e887bda22b7327c (patch)
tree09d47b006942401564bd7aebd638885303ed0105 /vp8/encoder/firstpass.c
parent9bac509ac505910a316bf3879ab57a2283920057 (diff)
downloadlibvpx-d39b5d05462c4b0755dd93814e887bda22b7327c.tar
libvpx-d39b5d05462c4b0755dd93814e887bda22b7327c.tar.gz
libvpx-d39b5d05462c4b0755dd93814e887bda22b7327c.tar.bz2
libvpx-d39b5d05462c4b0755dd93814e887bda22b7327c.zip
Removal of Qindex LUTS.
One of the problems arising when tweaking or adjusting the quantizer tables is that there are a lot of look up tables that depend on the QINDEX. Any adjustment to the link between QINDEX and real quantizer therefore tends to break aspects of for example the rate control. In this check in I have replaced several of the look up tables with functions that approximate the same results as the old Q luts but use a formulaic approach based on real Q values rather than QIndex. This should hopefully make it easier to experiment with changes to the Q tables without always having to go through and hand optimize a set of look up tables. Once things stabilize we may choose to re-instate luts for the sake of performance. Patch 2: Addressed Ronald's comments. vp8_init_me_luts() Added so luts only initialized once. Change-Id: Ic80db2212d2fd01e08e8cb5c7dca1fda1102be57
Diffstat (limited to 'vp8/encoder/firstpass.c')
-rw-r--r--vp8/encoder/firstpass.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index f2a1cd2d6..9c20f09db 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -26,6 +26,7 @@
#include "vp8/common/swapyv12buffer.h"
#include <stdio.h>
#include "rdopt.h"
+#include "ratectrl.h"
#include "vp8/common/quant_common.h"
#include "encodemv.h"
@@ -43,13 +44,6 @@ extern void vp8cx_frame_init_quantizer(VP8_COMP *cpi);
extern void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv);
extern void vp8_alloc_compressor_data(VP8_COMP *cpi);
-//#define GFQ_ADJUSTMENT (40 + ((15*Q)/10))
-//#define GFQ_ADJUSTMENT (80 + ((15*Q)/10))
-#define GFQ_ADJUSTMENT vp8_gf_boost_qadjustment[Q]
-extern int vp8_kf_boost_qadjustment[QINDEX_RANGE];
-
-extern const int vp8_gf_boost_qadjustment[QINDEX_RANGE];
-
#define IIFACTOR 1.5
#define IIKFACTOR1 1.40
#define IIKFACTOR2 1.5
@@ -849,7 +843,6 @@ void vp8_first_pass(VP8_COMP *cpi)
cm->current_video_frame++;
}
-extern const int vp8_bits_per_mb[2][QINDEX_RANGE];
#define BASE_ERRPERMB 150
static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh)
@@ -925,7 +918,7 @@ static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_
bits_per_mb_at_this_q = (int)(.5 + correction_factor
* speed_correction * cpi->twopass.est_max_qcorrection_factor
* cpi->twopass.section_max_qfactor
- * (double)vp8_bits_per_mb[INTER_FRAME][Q] / 1.0);
+ * (double)vp8_bits_per_mb(INTER_FRAME,Q) / 1.0);
if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
break;
@@ -996,7 +989,11 @@ static int estimate_q(VP8_COMP *cpi, double section_err, int section_target_band
else
correction_factor = corr_high;
- bits_per_mb_at_this_q = (int)(.5 + correction_factor * speed_correction * cpi->twopass.est_max_qcorrection_factor * (double)vp8_bits_per_mb[INTER_FRAME][Q] / 1.0);
+ bits_per_mb_at_this_q =
+ (int)(.5 + correction_factor *
+ speed_correction *
+ cpi->twopass.est_max_qcorrection_factor *
+ (double)vp8_bits_per_mb(INTER_FRAME,Q) / 1.0);
if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
break;
@@ -1075,7 +1072,10 @@ static int estimate_kf_group_q(VP8_COMP *cpi, double section_err, int section_ta
else
err_correction_factor = corr_high;
- bits_per_mb_at_this_q = (int)(.5 + err_correction_factor * combined_correction_factor * (double)vp8_bits_per_mb[INTER_FRAME][Q]);
+ bits_per_mb_at_this_q =
+ (int)(.5 + err_correction_factor *
+ combined_correction_factor *
+ (double)vp8_bits_per_mb(INTER_FRAME,Q) );
if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
break;
@@ -1164,7 +1164,7 @@ static int estimate_cq(VP8_COMP *cpi, double section_err, int section_target_ban
(int)( .5 + correction_factor *
speed_correction *
clip_iifactor *
- (double)vp8_bits_per_mb[INTER_FRAME][Q] / 1.0);
+ (double)vp8_bits_per_mb(INTER_FRAME,Q) / 1.0);
if (bits_per_mb_at_this_q <= target_norm_bits_per_mb)
break;
@@ -1815,9 +1815,9 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
// Boost for arf frame
#if NEW_BOOST
- Boost = (alt_boost * GFQ_ADJUSTMENT) / 100;
+ Boost = (alt_boost * vp8_gfboost_qadjust(Q)) / 100;
#else
- Boost = (cpi->gfu_boost * 3 * GFQ_ADJUSTMENT) / (2 * 100);
+ Boost = (cpi->gfu_boost * 3 * vp8_gfboost_qadjust(Q)) / (2 * 100);
#endif
Boost += (i * 50);
@@ -1982,9 +1982,9 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
if (cpi->source_alt_ref_pending && i == 0)
{
#if NEW_BOOST
- Boost = (alt_boost * GFQ_ADJUSTMENT) / 100;
+ Boost = (alt_boost * vp8_gfboost_qadjust(Q)) / 100;
#else
- Boost = (cpi->gfu_boost * 3 * GFQ_ADJUSTMENT) / (2 * 100);
+ Boost = (cpi->gfu_boost * 3 * vp8_gfboost_qadjust(Q)) / (2 * 100);
#endif
Boost += (cpi->baseline_gf_interval * 50);
@@ -2001,7 +2001,7 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
else
{
// boost based on inter / intra ratio of subsequent frames
- Boost = (cpi->gfu_boost * GFQ_ADJUSTMENT) / 100;
+ Boost = (cpi->gfu_boost * vp8_gfboost_qadjust(Q)) / 100;
// Set max and minimum boost and hence minimum allocation
if (Boost > (cpi->baseline_gf_interval * 150))
@@ -2866,9 +2866,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
kf_boost = (int)((double)kf_boost * 100.0) >> 4; // Scale 16 to 100
- // Adjustment to boost based on recent average q
- //kf_boost = kf_boost * vp8_kf_boost_qadjustment[cpi->ni_av_qi] / 100;
-
if (kf_boost < 250) // Min KF boost
kf_boost = 250;