Skip to content
Permalink
Browse files

vp9: Rename new_mt to row_mt

new_mt is a very generic name that will get obsolete soon enough.
Since this is exposed as a codec control, renaming it to row_mt to
signify row level paralellism. Also renaming the ETHREAD_BIT_MATCH
codec control to ROW_MT_BIT_EXACT.

Change-Id: Ic7872d78bb3b12fb4cf92ba028ec8e08eb3a9558
  • Loading branch information
vigneshvg committed Feb 27, 2017
1 parent 8121f85 commit 5881601488ef4278d7ca2b06e2ad4d44b3063620
@@ -39,8 +39,8 @@ class VPxFirstPassEncoderThreadTest
encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)) {
init_flags_ = VPX_CODEC_USE_PSNR;

new_mt_mode_ = 1;
bit_match_mode_ = 0;
row_mt_mode_ = 1;
bit_exact_mode_ = 0;
first_pass_only_ = true;
firstpass_stats_.buf = NULL;
firstpass_stats_.sz = 0;
@@ -83,9 +83,9 @@ class VPxFirstPassEncoderThreadTest
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 0);

if (encoding_mode_ == ::libvpx_test::kTwoPassGood)
encoder->Control(VP9E_SET_NEW_MT, new_mt_mode_);
encoder->Control(VP9E_SET_ROW_MT, row_mt_mode_);

encoder->Control(VP9E_ENABLE_THREAD_BIT_MATCH, bit_match_mode_);
encoder->Control(VP9E_ENABLE_ROW_MT_BIT_EXACT, bit_exact_mode_);

encoder_initialized_ = true;
}
@@ -111,8 +111,8 @@ class VPxFirstPassEncoderThreadTest
int tiles_;
::libvpx_test::TestMode encoding_mode_;
int set_cpu_used_;
int new_mt_mode_;
int bit_match_mode_;
int row_mt_mode_;
int bit_exact_mode_;
bool first_pass_only_;
vpx_fixed_buf_t firstpass_stats_;
};
@@ -152,16 +152,16 @@ static void compare_fp_stats_md5(vpx_fixed_buf_t *fp_stats) {
// stats are compared to check if the stats match.
uint8_t *stats1 = reinterpret_cast<uint8_t *>(fp_stats->buf);
uint8_t *stats2 = stats1 + fp_stats->sz / 2;
::libvpx_test::MD5 md5_new_mt_0, md5_new_mt_1;
::libvpx_test::MD5 md5_row_mt_0, md5_row_mt_1;

md5_new_mt_0.Add(stats1, fp_stats->sz / 2);
const char *md5_new_mt_0_str = md5_new_mt_0.Get();
md5_row_mt_0.Add(stats1, fp_stats->sz / 2);
const char *md5_row_mt_0_str = md5_row_mt_0.Get();

md5_new_mt_1.Add(stats2, fp_stats->sz / 2);
const char *md5_new_mt_1_str = md5_new_mt_1.Get();
md5_row_mt_1.Add(stats2, fp_stats->sz / 2);
const char *md5_row_mt_1_str = md5_row_mt_1.Get();

// Check md5 match.
ASSERT_STREQ(md5_new_mt_0_str, md5_new_mt_1_str)
ASSERT_STREQ(md5_row_mt_0_str, md5_row_mt_1_str)
<< "MD5 checksums don't match";

// Reset firstpass_stats_ to 0.
@@ -175,23 +175,23 @@ TEST_P(VPxFirstPassEncoderThreadTest, FirstPassStatsTest) {
first_pass_only_ = true;
cfg_.rc_target_bitrate = 1000;

// Test new_mt_mode: 0 vs 1 (threads = 1, tiles_ = 0)
bit_match_mode_ = 0;
// Test row_mt_mode: 0 vs 1 (threads = 1, tiles_ = 0)
bit_exact_mode_ = 0;
tiles_ = 0;
cfg_.g_threads = 1;

new_mt_mode_ = 0;
row_mt_mode_ = 0;
init_flags_ = VPX_CODEC_USE_PSNR;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));

new_mt_mode_ = 1;
row_mt_mode_ = 1;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));

// Compare to check if using or not using new-mt generates matching stats.
// Compare to check if using or not using row-mt generates matching stats.
compare_fp_stats(&firstpass_stats_);

// Test multi-threads: single thread vs 4 threads
new_mt_mode_ = 1;
row_mt_mode_ = 1;
tiles_ = 2;

cfg_.g_threads = 1;
@@ -204,19 +204,19 @@ TEST_P(VPxFirstPassEncoderThreadTest, FirstPassStatsTest) {
// Compare to check if single-thread and multi-thread stats matches.
compare_fp_stats(&firstpass_stats_);

// Test new_mt_mode: 0 vs 1 (threads = 8, tiles_ = 2)
bit_match_mode_ = 1;
// Test row_mt_mode: 0 vs 1 (threads = 8, tiles_ = 2)
bit_exact_mode_ = 1;
tiles_ = 2;
cfg_.g_threads = 8;

new_mt_mode_ = 0;
row_mt_mode_ = 0;
init_flags_ = VPX_CODEC_USE_PSNR;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));

new_mt_mode_ = 1;
row_mt_mode_ = 1;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));

// Compare to check if stats match with new-mt=0/1.
// Compare to check if stats match with row-mt=0/1.
compare_fp_stats_md5(&firstpass_stats_);
}

@@ -231,8 +231,8 @@ class VPxEncoderThreadTest
encoding_mode_(GET_PARAM(1)), set_cpu_used_(GET_PARAM(2)) {
init_flags_ = VPX_CODEC_USE_PSNR;
md5_.clear();
new_mt_mode_ = 1;
bit_match_mode_ = 0;
row_mt_mode_ = 1;
bit_exact_mode_ = 0;
psnr_ = 0.0;
nframes_ = 0;
}
@@ -275,11 +275,11 @@ class VPxEncoderThreadTest
encoder->Control(VP8E_SET_ARNR_TYPE, 3);
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 0);

encoder->Control(VP9E_SET_NEW_MT, new_mt_mode_);
// While new_mt = 1/0(with/without row-based multi-threading), several
encoder->Control(VP9E_SET_ROW_MT, row_mt_mode_);
// While row_mt = 1/0(with/without row-based multi-threading), several
// speed features that would adaptively adjust encoding parameters have
// to be disabled to guarantee the bit match of the resulted bitstream.
encoder->Control(VP9E_ENABLE_THREAD_BIT_MATCH, bit_match_mode_);
encoder->Control(VP9E_ENABLE_ROW_MT_BIT_EXACT, bit_exact_mode_);
} else {
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
encoder->Control(VP9E_SET_AQ_MODE, 3);
@@ -318,8 +318,8 @@ class VPxEncoderThreadTest
int threads_;
::libvpx_test::TestMode encoding_mode_;
int set_cpu_used_;
int new_mt_mode_;
int bit_match_mode_;
int row_mt_mode_;
int bit_exact_mode_;
double psnr_;
unsigned int nframes_;
std::vector<std::string> md5_;
@@ -331,8 +331,8 @@ TEST_P(VPxEncoderThreadTest, EncoderResultTest) {

// Part 1: Bit exact test for new_mt_mode_ = 0.
// This part keeps original unit tests done before new-mt code is checked in.
new_mt_mode_ = 0;
bit_match_mode_ = 0;
row_mt_mode_ = 0;
bit_exact_mode_ = 0;

// Encode using single thread.
cfg_.g_threads = 1;
@@ -351,8 +351,8 @@ TEST_P(VPxEncoderThreadTest, EncoderResultTest) {
ASSERT_EQ(single_thr_md5, multi_thr_md5);

// Part 2: new_mt_mode_ = 0 vs new_mt_mode_ = 1 single thread bit exact test.
new_mt_mode_ = 1;
bit_match_mode_ = 0;
row_mt_mode_ = 1;
bit_exact_mode_ = 0;

// Encode using single thread
cfg_.g_threads = 1;
@@ -364,8 +364,8 @@ TEST_P(VPxEncoderThreadTest, EncoderResultTest) {
ASSERT_EQ(single_thr_md5, new_mt_single_thr_md5);

// Part 3: Bit exact test with new-mt on
new_mt_mode_ = 1;
bit_match_mode_ = 1;
row_mt_mode_ = 1;
bit_exact_mode_ = 1;
new_mt_single_thr_md5.clear();

// Encode using single thread.
@@ -385,8 +385,8 @@ TEST_P(VPxEncoderThreadTest, EncoderResultTest) {
ASSERT_EQ(new_mt_single_thr_md5, new_mt_multi_thr_md5);

// Part 4: PSNR test with bit_match_mode_ = 0
new_mt_mode_ = 1;
bit_match_mode_ = 0;
row_mt_mode_ = 1;
bit_exact_mode_ = 0;

// Encode using single thread.
cfg_.g_threads = 1;
@@ -4341,7 +4341,7 @@ static void encode_frame_internal(VP9_COMP *cpi) {
}
#endif

if (!cpi->new_mt) {
if (!cpi->row_mt) {
cpi->row_mt_sync_read_ptr = vp9_row_mt_sync_read_dummy;
cpi->row_mt_sync_write_ptr = vp9_row_mt_sync_write_dummy;
// If allowed, encoding tiles in parallel with one thread handling one
@@ -1575,7 +1575,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
highbd_set_var_fns(cpi);
#endif

vp9_set_new_mt(cpi);
vp9_set_row_mt(cpi);
}

#ifndef M_LOG2_E
@@ -5223,16 +5223,16 @@ void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags) {
}
}

void vp9_set_new_mt(VP9_COMP *cpi) {
void vp9_set_row_mt(VP9_COMP *cpi) {
// Enable row based multi-threading for supported modes of encoding
cpi->new_mt = 0;
cpi->row_mt = 0;
if (((cpi->oxcf.mode == GOOD || cpi->oxcf.mode == BEST) &&
cpi->oxcf.speed < 5 && cpi->oxcf.pass == 1) &&
cpi->oxcf.new_mt && !cpi->use_svc)
cpi->new_mt = 1;
cpi->oxcf.row_mt && !cpi->use_svc)
cpi->row_mt = 1;

if (cpi->oxcf.mode == GOOD && cpi->oxcf.speed < 5 &&
(cpi->oxcf.pass == 0 || cpi->oxcf.pass == 2) && cpi->oxcf.new_mt &&
(cpi->oxcf.pass == 0 || cpi->oxcf.pass == 2) && cpi->oxcf.row_mt &&
!cpi->use_svc)
cpi->new_mt = 1;
cpi->row_mt = 1;
}
@@ -267,8 +267,8 @@ typedef struct VP9EncoderConfig {
int render_height;
VP9E_TEMPORAL_LAYERING_MODE temporal_layering_mode;

int new_mt;
unsigned int ethread_bit_match;
int row_mt;
unsigned int row_mt_bit_exact;
} VP9EncoderConfig;

static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) {
@@ -691,7 +691,7 @@ typedef struct VP9_COMP {
void (*row_mt_sync_read_ptr)(VP9RowMTSync *const, int, int);
void (*row_mt_sync_write_ptr)(VP9RowMTSync *const, int, int, const int);
ARNRFilterData arnr_filter_data;
int new_mt;
int row_mt;

// Previous Partition Info
BLOCK_SIZE *prev_partition;
@@ -909,7 +909,7 @@ VP9_LEVEL vp9_get_level(const Vp9LevelSpec *const level_spec);

void vp9_new_framerate(VP9_COMP *cpi, double framerate);

void vp9_set_new_mt(VP9_COMP *cpi);
void vp9_set_row_mt(VP9_COMP *cpi);

#define LAYER_IDS_TO_IDX(sl, tl, num_tl) ((sl) * (num_tl) + (tl))

@@ -979,12 +979,12 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
if (log_intra < 10.0) {
mb_intra_factor = 1.0 + ((10.0 - log_intra) * 0.05);
fp_acc_data->intra_factor += mb_intra_factor;
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
cpi->twopass.fp_mb_float_stats[mb_index].frame_mb_intra_factor =
mb_intra_factor;
} else {
fp_acc_data->intra_factor += 1.0;
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
cpi->twopass.fp_mb_float_stats[mb_index].frame_mb_intra_factor = 1.0;
}

@@ -999,12 +999,12 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
if ((level_sample < DARK_THRESH) && (log_intra < 9.0)) {
mb_brightness_factor = 1.0 + (0.01 * (DARK_THRESH - level_sample));
fp_acc_data->brightness_factor += mb_brightness_factor;
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
cpi->twopass.fp_mb_float_stats[mb_index].frame_mb_brightness_factor =
mb_brightness_factor;
} else {
fp_acc_data->brightness_factor += 1.0;
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
cpi->twopass.fp_mb_float_stats[mb_index].frame_mb_brightness_factor =
1.0;
}
@@ -1166,7 +1166,7 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
if (((this_error - intrapenalty) * 9 <= motion_error * 10) &&
(this_error < (2 * intrapenalty))) {
fp_acc_data->neutral_count += 1.0;
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
cpi->twopass.fp_mb_float_stats[mb_index].frame_mb_neutral_count =
1.0;
// Also track cases where the intra is not much worse than the inter
@@ -1176,7 +1176,7 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
mb_neutral_count =
(double)motion_error / DOUBLE_DIVIDE_CHECK((double)this_error);
fp_acc_data->neutral_count += mb_neutral_count;
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
cpi->twopass.fp_mb_float_stats[mb_index].frame_mb_neutral_count =
mb_neutral_count;
}
@@ -1297,7 +1297,7 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
recon_uvoffset += uv_mb_height;

// Accumulate row level stats to the corresponding tile stats
if (cpi->new_mt && mb_col == (tile.mi_col_end >> 1) - 1)
if (cpi->row_mt && mb_col == (tile.mi_col_end >> 1) - 1)
accumulate_fp_mb_row_stat(tile_data, fp_acc_data);

(*(cpi->row_mt_sync_write_ptr))(&tile_data->row_mt_sync, mb_row, c,
@@ -1424,15 +1424,15 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {

cm->log2_tile_rows = 0;

if (cpi->oxcf.ethread_bit_match && cpi->twopass.fp_mb_float_stats == NULL)
if (cpi->oxcf.row_mt_bit_exact && cpi->twopass.fp_mb_float_stats == NULL)
CHECK_MEM_ERROR(
cm, cpi->twopass.fp_mb_float_stats,
vpx_calloc(cm->MBs * sizeof(*cpi->twopass.fp_mb_float_stats), 1));

{
FIRSTPASS_STATS fps;
TileDataEnc *first_tile_col;
if (!cpi->new_mt) {
if (!cpi->row_mt) {
cm->log2_tile_cols = 0;
cpi->row_mt_sync_read_ptr = vp9_row_mt_sync_read_dummy;
cpi->row_mt_sync_write_ptr = vp9_row_mt_sync_write_dummy;
@@ -1441,13 +1441,13 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) {
} else {
cpi->row_mt_sync_read_ptr = vp9_row_mt_sync_read;
cpi->row_mt_sync_write_ptr = vp9_row_mt_sync_write;
if (cpi->oxcf.ethread_bit_match) {
if (cpi->oxcf.row_mt_bit_exact) {
cm->log2_tile_cols = 0;
vp9_zero_array(cpi->twopass.fp_mb_float_stats, cm->MBs);
}
vp9_encode_fp_row_mt(cpi);
first_tile_col = &cpi->tile_data[0];
if (cpi->oxcf.ethread_bit_match)
if (cpi->oxcf.row_mt_bit_exact)
accumulate_floating_point_stats(cpi, first_tile_col);
first_pass_stat_calc(cpi, &fps, &(first_tile_col->fp_data));
}
@@ -3576,7 +3576,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, TileDataEnc *tile_data,
if (best_mode_index < 0 || best_rd >= best_rd_so_far) {
// If adaptive interp filter is enabled, then the current leaf node of 8x8
// data is needed for sub8x8. Hence preserve the context.
if (cpi->new_mt && bsize == BLOCK_8X8) ctx->mic = *xd->mi[0];
if (cpi->row_mt && bsize == BLOCK_8X8) ctx->mic = *xd->mi[0];
rd_cost->rate = INT_MAX;
rd_cost->rdcost = INT64_MAX;
return;
@@ -591,7 +591,7 @@ void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) {
// With row based multi-threading, the following speed features
// have to be disabled to guarantee that bitstreams encoded with single thread
// and multiple threads match
if (cpi->oxcf.ethread_bit_match) {
if (cpi->oxcf.row_mt_bit_exact) {
sf->adaptive_rd_thresh = 0;
sf->allow_exhaustive_searches = 0;
sf->adaptive_pred_interp_filter = 0;
@@ -762,7 +762,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) {
// With row based multi-threading, the following speed features
// have to be disabled to guarantee that bitstreams encoded with single thread
// and multiple threads match
if (cpi->oxcf.ethread_bit_match) {
if (cpi->oxcf.row_mt_bit_exact) {
sf->adaptive_rd_thresh = 0;
sf->allow_exhaustive_searches = 0;
sf->adaptive_pred_interp_filter = 0;
@@ -766,7 +766,7 @@ void vp9_temporal_filter(VP9_COMP *cpi, int distance) {
set_error_per_bit(&cpi->td.mb, rdmult);
vp9_initialize_me_consts(cpi, &cpi->td.mb, ARNR_FILT_QINDEX);

if (!cpi->new_mt)
if (!cpi->row_mt)
temporal_filter_iterate_c(cpi);
else
vp9_temporal_filter_row_mt(cpi);

0 comments on commit 5881601

Please sign in to comment.