summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2014-07-17 07:01:31 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-07-17 07:01:31 -0700
commit93960c869ec590e2cd527fa0fbf5692d3825065e (patch)
tree0d0822b1aeb6843fb99f9ed2bfeb31479217bfc1 /vp9
parent42a68e6701f277abdbdb8cd02364d8130cf4e4f8 (diff)
parentb691230deaa7a771c35a6de2fd75e093ea31ba75 (diff)
downloadlibvpx-93960c869ec590e2cd527fa0fbf5692d3825065e.tar
libvpx-93960c869ec590e2cd527fa0fbf5692d3825065e.tar.gz
libvpx-93960c869ec590e2cd527fa0fbf5692d3825065e.tar.bz2
libvpx-93960c869ec590e2cd527fa0fbf5692d3825065e.zip
Merge "Changes to rd balance and multi-arf bug fix."
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encoder.c23
-rw-r--r--vp9/encoder/vp9_firstpass.c8
-rw-r--r--vp9/encoder/vp9_firstpass.h1
-rw-r--r--vp9/encoder/vp9_rd.c29
4 files changed, 34 insertions, 27 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 59a83785c..d3e0e17bc 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -748,9 +748,6 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf) {
cm->current_video_frame = 0;
- // Set reference frame sign bias for ALTREF frame to 1 (for now)
- cm->ref_frame_sign_bias[ALTREF_FRAME] = 1;
-
cpi->gold_is_last = 0;
cpi->alt_is_last = 0;
cpi->gold_is_alt = 0;
@@ -2085,6 +2082,22 @@ static void configure_skippable_frame(VP9_COMP *cpi) {
twopass->stats_in->pcnt_inter - twopass->stats_in->pcnt_motion == 1);
}
+static void set_arf_sign_bias(VP9_COMP *cpi) {
+ VP9_COMMON *const cm = &cpi->common;
+ int arf_sign_bias;
+
+ if ((cpi->pass == 2) && cpi->multi_arf_allowed) {
+ const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
+ arf_sign_bias = cpi->rc.source_alt_ref_active &&
+ (!cpi->refresh_alt_ref_frame ||
+ (gf_group->rf_level[gf_group->index] == GF_ARF_LOW));
+ } else {
+ arf_sign_bias =
+ (cpi->rc.source_alt_ref_active && !cpi->refresh_alt_ref_frame);
+ }
+ cm->ref_frame_sign_bias[ALTREF_FRAME] = arf_sign_bias;
+}
+
static void encode_frame_to_data_rate(VP9_COMP *cpi,
size_t *size,
uint8_t *dest,
@@ -2117,8 +2130,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->zbin_mode_boost = 0;
cpi->zbin_mode_boost_enabled = 0;
- // Current default encoder behavior for the altref sign bias.
- cm->ref_frame_sign_bias[ALTREF_FRAME] = cpi->rc.source_alt_ref_active;
+ // Set the arf sign bias for this frame.
+ set_arf_sign_bias(cpi);
// Set default state for segment based loop filter update flags.
cm->lf.mode_ref_delta_update = 0;
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 2a5f594e9..4715df72c 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2206,14 +2206,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
cpi->refresh_golden_frame = 1;
}
- {
- FIRSTPASS_STATS next_frame;
- if (lookup_next_frame_stats(twopass, &next_frame) != EOF) {
- twopass->next_iiratio = (int)(next_frame.intra_error /
- DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
- }
- }
-
configure_buffer_updates(cpi);
target_rate = twopass->gf_group.bit_allocation[twopass->gf_group.index];
diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h
index 714a67fd8..aad7312b9 100644
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -69,7 +69,6 @@ typedef struct {
typedef struct {
unsigned int section_intra_rating;
- unsigned int next_iiratio;
FIRSTPASS_STATS total_stats;
FIRSTPASS_STATS this_frame_stats;
const FIRSTPASS_STATS *stats_in;
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c
index 27e81b6bd..d26ac2366 100644
--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -92,13 +92,6 @@ static void fill_token_costs(vp9_coeff_cost *c,
}
}
-static const uint8_t rd_iifactor[32] = {
- 4, 4, 3, 2, 1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
// Values are now correlated to quantizer.
static int sad_per_bit16lut[QINDEX_RANGE];
static int sad_per_bit4lut[QINDEX_RANGE];
@@ -116,15 +109,25 @@ void vp9_init_me_luts() {
}
}
+static const int rd_boost_factor[16] = {
+ 64, 32, 32, 32, 24, 16, 12, 12,
+ 8, 8, 4, 4, 2, 2, 1, 0
+};
+static const int rd_frame_type_factor[FRAME_UPDATE_TYPES] = {
+128, 144, 128, 128, 144
+};
+
int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) {
const int q = vp9_dc_quant(qindex, 0);
- // TODO(debargha): Adjust the function below.
- int rdmult = 88 * q * q / 25;
+ int rdmult = 88 * q * q / 24;
+
if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
- if (cpi->twopass.next_iiratio > 31)
- rdmult += (rdmult * rd_iifactor[31]) >> 4;
- else
- rdmult += (rdmult * rd_iifactor[cpi->twopass.next_iiratio]) >> 4;
+ const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
+ const FRAME_UPDATE_TYPE frame_type = gf_group->update_type[gf_group->index];
+ const int boost_index = MIN(15, (cpi->rc.gfu_boost / 100));
+
+ rdmult = (rdmult * rd_frame_type_factor[frame_type]) >> 7;
+ rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7);
}
return rdmult;
}