Unfork rd_thresh sub8x8.
Remove duplicate rd_thresh code introduced when vp9_rd_pick_inter_mode_sub8x8() was forked from vp9_rd_pick_inter_mode_sb(). Change-Id: I3c9b7143d182e1f28b29c16518eaca81dc2ecfed
This commit is contained in:
parent
b59e37e1aa
commit
0d8e4f91a2
@ -1226,8 +1226,6 @@ VP9_COMP *vp9_create_compressor(VP9_CONFIG *oxcf) {
|
||||
for (i = 0; i < BLOCK_SIZES; ++i) {
|
||||
for (j = 0; j < MAX_MODES; ++j)
|
||||
cpi->rd.thresh_freq_fact[i][j] = 32;
|
||||
for (j = 0; j < MAX_REFS; ++j)
|
||||
cpi->rd.thresh_freq_sub8x8[i][j] = 32;
|
||||
}
|
||||
|
||||
#define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SVFHH, SVFHV, SVFHHV, \
|
||||
|
@ -298,8 +298,6 @@ typedef struct RD_OPT {
|
||||
|
||||
int threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES];
|
||||
int thresh_freq_fact[BLOCK_SIZES][MAX_MODES];
|
||||
int thresh_sub8x8[MAX_SEGMENTS][BLOCK_SIZES][MAX_REFS];
|
||||
int thresh_freq_sub8x8[BLOCK_SIZES][MAX_REFS];
|
||||
|
||||
int64_t comp_pred_diff[REFERENCE_MODES];
|
||||
int64_t prediction_type_threshes[MAX_REF_FRAMES][REFERENCE_MODES];
|
||||
|
@ -260,13 +260,15 @@ static void set_block_thresholds(VP9_COMP *cpi) {
|
||||
const int t = q * rd_thresh_block_size_factor[bsize];
|
||||
const int thresh_max = INT_MAX / t;
|
||||
|
||||
if (bsize >= BLOCK_8X8) {
|
||||
for (i = 0; i < MAX_MODES; ++i)
|
||||
rd->threshes[segment_id][bsize][i] =
|
||||
rd->thresh_mult[i] < thresh_max ? rd->thresh_mult[i] * t / 4
|
||||
rd->thresh_mult[i] < thresh_max
|
||||
? rd->thresh_mult[i] * t / 4
|
||||
: INT_MAX;
|
||||
|
||||
for (i = 0; i < MAX_REFS; ++i) {
|
||||
rd->thresh_sub8x8[segment_id][bsize][i] =
|
||||
} else {
|
||||
for (i = 0; i < MAX_REFS; ++i)
|
||||
rd->threshes[segment_id][bsize][i] =
|
||||
rd->thresh_mult_sub8x8[i] < thresh_max
|
||||
? rd->thresh_mult_sub8x8[i] * t / 4
|
||||
: INT_MAX;
|
||||
@ -3115,6 +3117,34 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
ctx->mic = *xd->mi[0];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Updating rd_thresh_freq_fact[] here means that the different
|
||||
// partition/block sizes are handled independently based on the best
|
||||
// choice for the current partition. It may well be better to keep a scaled
|
||||
// best rd so far value and update rd_thresh_freq_fact based on the mode/size
|
||||
// combination that wins out.
|
||||
static void update_rd_thresh_fact(VP9_COMP *cpi, int bsize,
|
||||
int best_mode_index) {
|
||||
if (cpi->sf.adaptive_rd_thresh) {
|
||||
const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES;
|
||||
int mode_index;
|
||||
for (mode_index = 0; mode_index < top_mode; ++mode_index) {
|
||||
int *const fact = &cpi->rd.thresh_freq_fact[bsize][mode_index];
|
||||
|
||||
if (mode_index == best_mode_index) {
|
||||
*fact -= (*fact >> 3);
|
||||
} else {
|
||||
*fact = MIN(*fact + RD_THRESH_INC,
|
||||
cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
const TileInfo *const tile,
|
||||
int mi_row, int mi_col,
|
||||
@ -3324,9 +3354,8 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
continue;
|
||||
|
||||
// Test best rd so far against threshold for trying this mode.
|
||||
if (best_rd < ((int64_t)rd_threshes[mode_index] *
|
||||
rd_thresh_freq_fact[mode_index] >> 5) ||
|
||||
rd_threshes[mode_index] == INT_MAX)
|
||||
if (rd_less_than_thresh(best_rd, rd_threshes[mode_index],
|
||||
rd_thresh_freq_fact[mode_index]))
|
||||
continue;
|
||||
|
||||
this_mode = vp9_mode_order[mode_index].mode;
|
||||
@ -3680,23 +3709,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
(cm->interp_filter == best_mbmode.interp_filter) ||
|
||||
!is_inter_block(&best_mbmode));
|
||||
|
||||
// Updating rd_thresh_freq_fact[] here means that the different
|
||||
// partition/block sizes are handled independently based on the best
|
||||
// choice for the current partition. It may well be better to keep a scaled
|
||||
// best rd so far value and update rd_thresh_freq_fact based on the mode/size
|
||||
// combination that wins out.
|
||||
if (cpi->sf.adaptive_rd_thresh) {
|
||||
for (mode_index = 0; mode_index < MAX_MODES; ++mode_index) {
|
||||
int *const fact = &rd_opt->thresh_freq_fact[bsize][mode_index];
|
||||
|
||||
if (mode_index == best_mode_index) {
|
||||
*fact -= (*fact >> 3);
|
||||
} else {
|
||||
*fact = MIN(*fact + RD_THRESH_INC,
|
||||
cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_rd_thresh_fact(cpi, bsize, best_mode_index);
|
||||
|
||||
// macroblock modes
|
||||
*mbmi = best_mbmode;
|
||||
@ -3880,10 +3893,9 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
}
|
||||
|
||||
// Test best rd so far against threshold for trying this mode.
|
||||
if ((best_rd <
|
||||
((int64_t)rd_opt->thresh_sub8x8[segment_id][bsize][mode_index] *
|
||||
rd_opt->thresh_freq_sub8x8[bsize][mode_index] >> 5)) ||
|
||||
rd_opt->thresh_sub8x8[segment_id][bsize][mode_index] == INT_MAX)
|
||||
if (rd_less_than_thresh(best_rd,
|
||||
rd_opt->threshes[segment_id][bsize][mode_index],
|
||||
rd_opt->thresh_freq_fact[bsize][mode_index]))
|
||||
continue;
|
||||
|
||||
if (ref_frame > INTRA_FRAME &&
|
||||
@ -4013,10 +4025,10 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
int uv_skippable;
|
||||
|
||||
this_rd_thresh = (ref_frame == LAST_FRAME) ?
|
||||
rd_opt->thresh_sub8x8[segment_id][bsize][THR_LAST] :
|
||||
rd_opt->thresh_sub8x8[segment_id][bsize][THR_ALTR];
|
||||
rd_opt->threshes[segment_id][bsize][THR_LAST] :
|
||||
rd_opt->threshes[segment_id][bsize][THR_ALTR];
|
||||
this_rd_thresh = (ref_frame == GOLDEN_FRAME) ?
|
||||
rd_opt->thresh_sub8x8[segment_id][bsize][THR_GOLD] : this_rd_thresh;
|
||||
rd_opt->threshes[segment_id][bsize][THR_GOLD] : this_rd_thresh;
|
||||
rd_opt->mask_filter = 0;
|
||||
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
|
||||
rd_opt->filter_cache[i] = INT64_MAX;
|
||||
@ -4346,23 +4358,7 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
(cm->interp_filter == best_mbmode.interp_filter) ||
|
||||
!is_inter_block(&best_mbmode));
|
||||
|
||||
// Updating rd_thresh_freq_fact[] here means that the different
|
||||
// partition/block sizes are handled independently based on the best
|
||||
// choice for the current partition. It may well be better to keep a scaled
|
||||
// best rd so far value and update rd_thresh_freq_fact based on the mode/size
|
||||
// combination that wins out.
|
||||
if (cpi->sf.adaptive_rd_thresh) {
|
||||
for (mode_index = 0; mode_index < MAX_REFS; ++mode_index) {
|
||||
int *const fact = &rd_opt->thresh_freq_sub8x8[bsize][mode_index];
|
||||
|
||||
if (mode_index == best_mode_index) {
|
||||
*fact -= (*fact >> 3);
|
||||
} else {
|
||||
*fact = MIN(*fact + RD_THRESH_INC,
|
||||
cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
|
||||
}
|
||||
}
|
||||
}
|
||||
update_rd_thresh_fact(cpi, bsize, best_mode_index);
|
||||
|
||||
// macroblock modes
|
||||
*mbmi = best_mbmode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user