summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_pickmode.c22
-rw-r--r--vp9/encoder/vp9_rd.c45
-rw-r--r--vp9/encoder/vp9_rd.h8
-rw-r--r--vp9/encoder/vp9_rdopt.c32
-rw-r--r--vp9/encoder/vp9_speed_features.c9
-rw-r--r--vp9/encoder/vp9_speed_features.h4
6 files changed, 57 insertions, 63 deletions
diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c
index 1e4c9b140..6928338ee 100644
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -450,7 +450,8 @@ static void estimate_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
args->dist += dist;
}
-static const THR_MODES mode_idx[MAX_REF_FRAMES - 1][INTER_MODES] = {
+static const THR_MODES mode_idx[MAX_REF_FRAMES][4] = {
+ {THR_DC, THR_H_PRED, THR_V_PRED},
{THR_NEARESTMV, THR_NEARMV, THR_ZEROMV, THR_NEWMV},
{THR_NEARESTG, THR_NEARG, THR_ZEROG, THR_NEWG},
{THR_NEARESTA, THR_NEARA, THR_ZEROA, THR_NEWA},
@@ -558,7 +559,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
EIGHTTAP : cm->interp_filter;
mbmi->segment_id = segment_id;
- for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
+ for (ref_frame = LAST_FRAME; ref_frame <= GOLDEN_FRAME; ++ref_frame) {
PREDICTION_MODE this_mode;
x->pred_mv_sad[ref_frame] = INT_MAX;
frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
@@ -610,8 +611,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
continue;
mode_rd_thresh =
- rd_threshes[mode_idx[ref_frame -
- LAST_FRAME][INTER_OFFSET(this_mode)]];
+ rd_threshes[mode_idx[ref_frame][INTER_OFFSET(this_mode)]];
if (rd_less_than_thresh(best_rdc.rdcost, mode_rd_thresh,
rd_thresh_freq_fact[this_mode]))
continue;
@@ -757,10 +757,9 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
if (x->skip)
break;
}
- // If the current reference frame is valid and we found a usable mode,
- // we are done.
- if (best_rdc.rdcost < INT64_MAX && ref_frame == GOLDEN_FRAME)
- break;
+
+ // Check that a prediction mode has been selected.
+ assert(best_rdc.rdcost < INT64_MAX);
}
// If best prediction is not in dst buf, then copy the prediction block from
@@ -836,5 +835,12 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
pd->dst = orig_dst;
}
+ if (is_inter_block(mbmi))
+ vp9_update_rd_thresh_fact(cpi, tile_data, bsize,
+ mode_idx[ref_frame][INTER_OFFSET(mbmi->mode)]);
+ else
+ vp9_update_rd_thresh_fact(cpi, tile_data, bsize,
+ mode_idx[ref_frame][mbmi->mode]);
+
*rd_cost = best_rdc;
}
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c
index d758430c3..13e317d6d 100644
--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -594,21 +594,38 @@ void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) {
const SPEED_FEATURES *const sf = &cpi->sf;
RD_OPT *const rd = &cpi->rd;
int i;
+ static const int thresh_mult[2][MAX_REFS] =
+ {{2500, 2500, 2500, 4500, 4500, 2500},
+ {2000, 2000, 2000, 4000, 4000, 2000}};
+
+ for (i = 0; i < MAX_REFS; ++i) {
+ rd->thresh_mult_sub8x8[i] =
+ (sf->disable_split_mask & (1 << i)) ?
+ INT_MAX : thresh_mult[cpi->oxcf.mode == BEST][i];
+ }
+}
- for (i = 0; i < MAX_REFS; ++i)
- rd->thresh_mult_sub8x8[i] = cpi->oxcf.mode == BEST ? -500 : 0;
-
- rd->thresh_mult_sub8x8[THR_LAST] += 2500;
- rd->thresh_mult_sub8x8[THR_GOLD] += 2500;
- rd->thresh_mult_sub8x8[THR_ALTR] += 2500;
- rd->thresh_mult_sub8x8[THR_INTRA] += 2500;
- rd->thresh_mult_sub8x8[THR_COMP_LA] += 4500;
- rd->thresh_mult_sub8x8[THR_COMP_GA] += 4500;
-
- // Check for masked out split cases.
- for (i = 0; i < MAX_REFS; ++i)
- if (sf->disable_split_mask & (1 << i))
- rd->thresh_mult_sub8x8[i] = INT_MAX;
+// TODO(jingning) Refactor this function. Use targeted smaller struct as inputs.
+void vp9_update_rd_thresh_fact(VP9_COMP *cpi, TileDataEnc *tile_data,
+ int bsize, int best_mode_index) {
+ if (cpi->sf.adaptive_rd_thresh > 0) {
+ const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES;
+ int mode;
+ for (mode = 0; mode < top_mode; ++mode) {
+ const BLOCK_SIZE min_size = MAX(bsize - 1, BLOCK_4X4);
+ const BLOCK_SIZE max_size = MIN(bsize + 2, BLOCK_64X64);
+ BLOCK_SIZE bs;
+ for (bs = min_size; bs <= max_size; ++bs) {
+ int *const fact = &tile_data->thresh_freq_fact[bs][mode];
+ if (mode == best_mode_index) {
+ *fact -= (*fact >> 4);
+ } else {
+ *fact = MIN(*fact + RD_THRESH_INC,
+ cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
+ }
+ }
+ }
+ }
}
int vp9_get_intra_cost_penalty(int qindex, int qdelta,
diff --git a/vp9/encoder/vp9_rd.h b/vp9/encoder/vp9_rd.h
index 1aa52663a..aecca0b43 100644
--- a/vp9/encoder/vp9_rd.h
+++ b/vp9/encoder/vp9_rd.h
@@ -36,6 +36,9 @@ extern "C" {
#define MAX_MODES 30
#define MAX_REFS 6
+#define RD_THRESH_MAX_FACT 64
+#define RD_THRESH_INC 1
+
// This enumerator type needs to be kept aligned with the mode order in
// const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code.
typedef enum {
@@ -129,6 +132,7 @@ void vp9_rd_cost_reset(RD_COST *rd_cost);
void vp9_rd_cost_init(RD_COST *rd_cost);
struct TileInfo;
+struct TileDataEnc;
struct VP9_COMP;
struct macroblock;
@@ -158,6 +162,10 @@ void vp9_set_rd_speed_thresholds(struct VP9_COMP *cpi);
void vp9_set_rd_speed_thresholds_sub8x8(struct VP9_COMP *cpi);
+void vp9_update_rd_thresh_fact(struct VP9_COMP *cpi,
+ struct TileDataEnc *tile_data,
+ int bsize, int best_mode_index);
+
static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
int thresh_fact) {
return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX;
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 68afbc075..e80f345e8 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -38,9 +38,6 @@
#include "vp9/encoder/vp9_rdopt.h"
#include "vp9/encoder/vp9_variance.h"
-#define RD_THRESH_MAX_FACT 64
-#define RD_THRESH_INC 1
-
#define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
(1 << INTRA_FRAME))
#define GOLDEN_FRAME_MODE_MASK ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | \
@@ -2766,29 +2763,6 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist);
}
-// TODO(jingning) Refactor this function. Use targeted smaller struct as inputs.
-static void update_rd_thresh_fact(VP9_COMP *cpi, TileDataEnc *tile_data,
- int bsize, int best_mode_index) {
- if (cpi->sf.adaptive_rd_thresh > 0) {
- const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES;
- int mode;
- for (mode = 0; mode < top_mode; ++mode) {
- const BLOCK_SIZE min_size = MAX(bsize - 1, BLOCK_4X4);
- const BLOCK_SIZE max_size = MIN(bsize + 2, BLOCK_64X64);
- BLOCK_SIZE bs;
- for (bs = min_size; bs <= max_size; ++bs) {
- int *const fact = &tile_data->thresh_freq_fact[bs][mode];
- if (mode == best_mode_index) {
- *fact -= (*fact >> 4);
- } else {
- *fact = MIN(*fact + RD_THRESH_INC,
- cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
- }
- }
- }
- }
-}
-
void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
TileDataEnc *tile_data,
MACROBLOCK *x,
@@ -3424,7 +3398,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
!is_inter_block(&best_mbmode));
if (!cpi->rc.is_src_frame_alt_ref)
- update_rd_thresh_fact(cpi, tile_data, bsize, best_mode_index);
+ vp9_update_rd_thresh_fact(cpi, tile_data, bsize, best_mode_index);
// macroblock modes
*mbmi = best_mbmode;
@@ -3579,7 +3553,7 @@ void vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi,
assert((cm->interp_filter == SWITCHABLE) ||
(cm->interp_filter == mbmi->interp_filter));
- update_rd_thresh_fact(cpi, tile_data, bsize, THR_ZEROMV);
+ vp9_update_rd_thresh_fact(cpi, tile_data, bsize, THR_ZEROMV);
vp9_zero(best_pred_diff);
vp9_zero(best_filter_diff);
@@ -4154,7 +4128,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
(cm->interp_filter == best_mbmode.interp_filter) ||
!is_inter_block(&best_mbmode));
- update_rd_thresh_fact(cpi, tile_data, bsize, best_ref_index);
+ vp9_update_rd_thresh_fact(cpi, tile_data, bsize, best_ref_index);
// macroblock modes
*mbmi = best_mbmode;
diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c
index e148bf903..3315aa6a1 100644
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -257,8 +257,6 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
: STRICT_NEIGHBORING_MIN_MAX;
sf->max_partition_size = BLOCK_32X32;
sf->min_partition_size = BLOCK_8X8;
- sf->partition_check =
- (frames_since_key % sf->last_partitioning_redo_frequency == 1);
sf->force_frame_boost = is_keyframe ||
(frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1);
sf->max_delta_qindex = is_keyframe ? 20 : 15;
@@ -269,7 +267,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST_NEW_ZERO;
sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST_NEW_ZERO;
sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST_NEW_ZERO;
-
+ sf->adaptive_rd_thresh = 2;
// This feature is only enabled when partition search is disabled.
sf->reuse_inter_pred_sby = 1;
@@ -292,12 +290,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
sf->partition_search_type = VAR_BASED_PARTITION;
sf->search_type_check_frequency = 50;
sf->mv.search_method = NSTEP;
-
sf->tx_size_search_method = is_keyframe ? USE_LARGESTALL : USE_TX_8X8;
-
- // Increase mode checking threshold for NEWMV.
- sf->elevate_newmv_thresh = 1000;
-
sf->mv.reduce_first_step_size = 1;
}
diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h
index 1712f873f..a314f6040 100644
--- a/vp9/encoder/vp9_speed_features.h
+++ b/vp9/encoder/vp9_speed_features.h
@@ -319,10 +319,6 @@ typedef struct SPEED_FEATURES {
// Fast quantization process path
int use_quant_fp;
- // Search through variable block partition types in non-RD mode decision
- // encoding process for RTC.
- int partition_check;
-
// Use finer quantizer in every other few frames that run variable block
// partition type search.
int force_frame_boost;