Commit d11221f4 authored by Deb Mukherjee's avatar Deb Mukherjee
Browse files

Improves constant qual, constrained qual turned on

Adds modeled functions to decide the qp for altref frames in constant q
mode similar to other functions in use in bitrate mode.

Also turns on the constrained quality mode (end-usage=2) option which
was turned off before. Basic testing shows the mode works in principle,
to cap bitrate to the target-bitrate specified, while allowing lower
bitrate depending on the cq-level specified. The mode will need to be
improved over time.

Results for constant quality vs bitrate control mode:
derfraw300/fullderfraw: +3.0% at constant quality over bitrate control.
fullstdhdraw: +4.341%
stdhdraw250: +5.361%

Change-Id: If5027c9ec66c8e88d33e47062c6cb84a07b1cda9
parent 14330abd
......@@ -2093,14 +2093,19 @@ void vp9_second_pass(VP9_COMP *cpi) {
cpi->twopass.est_max_qcorrection_factor = 1.0;
// Set a cq_level in constrained quality mode.
// Commenting this code out for now since it does not seem to be
// working well.
/*
if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
int est_cq = estimate_cq(cpi, &cpi->twopass.total_left_stats,
section_target_bandwidth);
section_target_bandwidth);
cpi->cq_target_quality = cpi->oxcf.cq_level;
if (est_cq > cpi->cq_target_quality)
cpi->cq_target_quality = est_cq;
else
cpi->cq_target_quality = cpi->oxcf.cq_level;
}
*/
// guess at maxq needed in 2nd pass
cpi->twopass.maxq_max_limit = cpi->worst_quality;
......
......@@ -122,6 +122,8 @@ static int kf_high_motion_minq[QINDEX_RANGE];
static int gf_low_motion_minq[QINDEX_RANGE];
static int gf_high_motion_minq[QINDEX_RANGE];
static int inter_minq[QINDEX_RANGE];
static int afq_low_motion_minq[QINDEX_RANGE];
static int afq_high_motion_minq[QINDEX_RANGE];
static INLINE void Scale2Ratio(int mode, int *hr, int *hs) {
switch (mode) {
......@@ -205,7 +207,16 @@ static void init_minq_luts(void) {
-0.00113,
0.697,
0.0);
afq_low_motion_minq[i] = calculate_minq_index(maxq,
0.0000015,
-0.0009,
0.33,
0.0);
afq_high_motion_minq[i] = calculate_minq_index(maxq,
0.0000021,
-0.00125,
0.57,
0.0);
}
}
......@@ -2765,16 +2776,16 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
} else {
if (cpi->frames_since_key > 1) {
if (cpi->gfu_boost > high) {
cpi->active_best_quality = cpi->cq_target_quality * 6 / 16;
cpi->active_best_quality = afq_low_motion_minq[q];
} else if (cpi->gfu_boost < low) {
cpi->active_best_quality = cpi->cq_target_quality * 11 / 16;
cpi->active_best_quality = afq_high_motion_minq[q];
} else {
const int gap = high - low;
const int offset = high - cpi->gfu_boost;
const int qdiff = cpi->cq_target_quality * 5 / 16;
const int qdiff = afq_high_motion_minq[q] - afq_low_motion_minq[q];
const int adjustment = ((offset * qdiff) + (gap >> 1)) / gap;
cpi->active_best_quality = cpi->cq_target_quality * 6 / 16
+ adjustment;
cpi->active_best_quality = afq_low_motion_minq[q] + adjustment;
}
}
}
......@@ -3262,7 +3273,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// in this frame.
// update_base_skip_probs(cpi);
#if CONFIG_INTERNAL_STATS
#if 0 // CONFIG_INTERNAL_STATS
{
FILE *f = fopen("tmp.stt", cm->current_video_frame ? "a" : "w");
int recon_err;
......
......@@ -277,11 +277,9 @@ static vpx_codec_err_t set_vp9e_config(VP9_CONFIG *oxcf,
// CBR code has been deprectated for experimental phase.
// CQ mode not yet tested
oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;
/*
if (cfg.rc_end_usage == VPX_CQ)
oxcf->end_usage = USAGE_CONSTRAINED_QUALITY;
*/
if (cfg.rc_end_usage == VPX_Q)
else if (cfg.rc_end_usage == VPX_Q)
oxcf->end_usage = USAGE_CONSTANT_QUALITY;
oxcf->target_bandwidth = cfg.rc_target_bitrate;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment