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 (i = 0; i < BLOCK_SIZES; ++i) {
|
||||||
for (j = 0; j < MAX_MODES; ++j)
|
for (j = 0; j < MAX_MODES; ++j)
|
||||||
cpi->rd.thresh_freq_fact[i][j] = 32;
|
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, \
|
#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 threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES];
|
||||||
int thresh_freq_fact[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 comp_pred_diff[REFERENCE_MODES];
|
||||||
int64_t prediction_type_threshes[MAX_REF_FRAMES][REFERENCE_MODES];
|
int64_t prediction_type_threshes[MAX_REF_FRAMES][REFERENCE_MODES];
|
||||||
|
@ -260,16 +260,18 @@ static void set_block_thresholds(VP9_COMP *cpi) {
|
|||||||
const int t = q * rd_thresh_block_size_factor[bsize];
|
const int t = q * rd_thresh_block_size_factor[bsize];
|
||||||
const int thresh_max = INT_MAX / t;
|
const int thresh_max = INT_MAX / t;
|
||||||
|
|
||||||
for (i = 0; i < MAX_MODES; ++i)
|
if (bsize >= BLOCK_8X8) {
|
||||||
rd->threshes[segment_id][bsize][i] =
|
for (i = 0; i < MAX_MODES; ++i)
|
||||||
rd->thresh_mult[i] < thresh_max ? rd->thresh_mult[i] * t / 4
|
rd->threshes[segment_id][bsize][i] =
|
||||||
: INT_MAX;
|
rd->thresh_mult[i] < thresh_max
|
||||||
|
? rd->thresh_mult[i] * t / 4
|
||||||
for (i = 0; i < MAX_REFS; ++i) {
|
: INT_MAX;
|
||||||
rd->thresh_sub8x8[segment_id][bsize][i] =
|
} else {
|
||||||
rd->thresh_mult_sub8x8[i] < thresh_max
|
for (i = 0; i < MAX_REFS; ++i)
|
||||||
? rd->thresh_mult_sub8x8[i] * t / 4
|
rd->threshes[segment_id][bsize][i] =
|
||||||
: INT_MAX;
|
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];
|
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,
|
int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||||
const TileInfo *const tile,
|
const TileInfo *const tile,
|
||||||
int mi_row, int mi_col,
|
int mi_row, int mi_col,
|
||||||
@ -3324,10 +3354,9 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Test best rd so far against threshold for trying this mode.
|
// Test best rd so far against threshold for trying this mode.
|
||||||
if (best_rd < ((int64_t)rd_threshes[mode_index] *
|
if (rd_less_than_thresh(best_rd, rd_threshes[mode_index],
|
||||||
rd_thresh_freq_fact[mode_index] >> 5) ||
|
rd_thresh_freq_fact[mode_index]))
|
||||||
rd_threshes[mode_index] == INT_MAX)
|
continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
this_mode = vp9_mode_order[mode_index].mode;
|
this_mode = vp9_mode_order[mode_index].mode;
|
||||||
ref_frame = vp9_mode_order[mode_index].ref_frame[0];
|
ref_frame = vp9_mode_order[mode_index].ref_frame[0];
|
||||||
@ -3680,23 +3709,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
(cm->interp_filter == best_mbmode.interp_filter) ||
|
(cm->interp_filter == best_mbmode.interp_filter) ||
|
||||||
!is_inter_block(&best_mbmode));
|
!is_inter_block(&best_mbmode));
|
||||||
|
|
||||||
// Updating rd_thresh_freq_fact[] here means that the different
|
update_rd_thresh_fact(cpi, bsize, best_mode_index);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// macroblock modes
|
// macroblock modes
|
||||||
*mbmi = best_mbmode;
|
*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.
|
// Test best rd so far against threshold for trying this mode.
|
||||||
if ((best_rd <
|
if (rd_less_than_thresh(best_rd,
|
||||||
((int64_t)rd_opt->thresh_sub8x8[segment_id][bsize][mode_index] *
|
rd_opt->threshes[segment_id][bsize][mode_index],
|
||||||
rd_opt->thresh_freq_sub8x8[bsize][mode_index] >> 5)) ||
|
rd_opt->thresh_freq_fact[bsize][mode_index]))
|
||||||
rd_opt->thresh_sub8x8[segment_id][bsize][mode_index] == INT_MAX)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ref_frame > INTRA_FRAME &&
|
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;
|
int uv_skippable;
|
||||||
|
|
||||||
this_rd_thresh = (ref_frame == LAST_FRAME) ?
|
this_rd_thresh = (ref_frame == LAST_FRAME) ?
|
||||||
rd_opt->thresh_sub8x8[segment_id][bsize][THR_LAST] :
|
rd_opt->threshes[segment_id][bsize][THR_LAST] :
|
||||||
rd_opt->thresh_sub8x8[segment_id][bsize][THR_ALTR];
|
rd_opt->threshes[segment_id][bsize][THR_ALTR];
|
||||||
this_rd_thresh = (ref_frame == GOLDEN_FRAME) ?
|
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;
|
rd_opt->mask_filter = 0;
|
||||||
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
|
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i)
|
||||||
rd_opt->filter_cache[i] = INT64_MAX;
|
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) ||
|
(cm->interp_filter == best_mbmode.interp_filter) ||
|
||||||
!is_inter_block(&best_mbmode));
|
!is_inter_block(&best_mbmode));
|
||||||
|
|
||||||
// Updating rd_thresh_freq_fact[] here means that the different
|
update_rd_thresh_fact(cpi, bsize, best_mode_index);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// macroblock modes
|
// macroblock modes
|
||||||
*mbmi = best_mbmode;
|
*mbmi = best_mbmode;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user