Add fields in TPL stats to keep intra distortion error
Add the needed fields in the SW TPL stats to approximate HW stats.
BUG=b/257303751
Change-Id: I36c736f5ecad48a61173a65108b83b28897d2c20
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index e4e903f..ea3cfc0 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -569,6 +569,15 @@
}
}
+ int rate_cost = 1;
+ get_rate_distortion(&rate_cost, &recon_error, &pred_error, src_diff, coeff,
+ qcoeff, dqcoeff, cm, x, NULL, rec_buffer_pool,
+ rec_stride_pool, tx_size, best_mode, mi_row, mi_col,
+ use_y_only_rate_distortion, NULL);
+
+ tpl_stats->intra_dist = recon_error << TPL_DEP_COST_SCALE_LOG2;
+ tpl_stats->intra_sse = pred_error << TPL_DEP_COST_SCALE_LOG2;
+
if (cpi->third_pass_ctx &&
frame_offset < cpi->third_pass_ctx->frame_info_count &&
tpl_data->frame_idx < gf_group->size) {
@@ -889,7 +898,7 @@
? tpl_data->src_ref_frame[comp_ref_frames[best_cmp_rf_idx][1]]
: NULL,
};
- int rate_cost = 1;
+ rate_cost = 1;
get_rate_distortion(&rate_cost, &recon_error, &pred_error, src_diff, coeff,
qcoeff, dqcoeff, cm, x, ref_frame_ptr, rec_buffer_pool,
rec_stride_pool, tx_size, best_mode, mi_row, mi_col,
@@ -906,7 +915,7 @@
tpl_stats->srcrf_sse = pred_error << TPL_DEP_COST_SCALE_LOG2;
// Final encode
- int rate_cost = 0;
+ rate_cost = 0;
const YV12_BUFFER_CONFIG *ref_frame_ptr[2];
ref_frame_ptr[0] =
@@ -923,11 +932,12 @@
rec_stride_pool, tx_size, best_mode, mi_row, mi_col,
use_y_only_rate_distortion, tpl_txfm_stats);
- tpl_stats->recrf_dist = recon_error << (TPL_DEP_COST_SCALE_LOG2);
+ tpl_stats->recrf_dist = recon_error << TPL_DEP_COST_SCALE_LOG2;
+ tpl_stats->recrf_sse = pred_error << TPL_DEP_COST_SCALE_LOG2;
tpl_stats->recrf_rate = rate_cost;
if (!is_inter_mode(best_mode)) {
- tpl_stats->srcrf_dist = recon_error << (TPL_DEP_COST_SCALE_LOG2);
+ tpl_stats->srcrf_dist = recon_error << TPL_DEP_COST_SCALE_LOG2;
tpl_stats->srcrf_rate = rate_cost;
tpl_stats->srcrf_sse = pred_error << TPL_DEP_COST_SCALE_LOG2;
}
diff --git a/av1/encoder/tpl_model.h b/av1/encoder/tpl_model.h
index ec49ea5..ed98478 100644
--- a/av1/encoder/tpl_model.h
+++ b/av1/encoder/tpl_model.h
@@ -106,7 +106,10 @@
typedef struct TplDepStats {
int64_t srcrf_sse;
int64_t srcrf_dist;
+ int64_t recrf_sse;
int64_t recrf_dist;
+ int64_t intra_sse;
+ int64_t intra_dist;
int64_t cmp_recrf_dist[2];
int64_t mc_dep_rate;
int64_t mc_dep_dist;
diff --git a/av1/qmode_rc/ratectrl_qmode_interface.h b/av1/qmode_rc/ratectrl_qmode_interface.h
index d50b587..6e71207 100644
--- a/av1/qmode_rc/ratectrl_qmode_interface.h
+++ b/av1/qmode_rc/ratectrl_qmode_interface.h
@@ -67,16 +67,18 @@
};
struct TplBlockStats {
- int16_t height; // Pixel height.
- int16_t width; // Pixel width.
- int16_t row; // Pixel row of the top left corner.
- int16_t col; // Pixel col of the top left corner.
- int64_t intra_cost;
- int64_t inter_cost;
+ int16_t height; // Pixel height.
+ int16_t width; // Pixel width.
+ int16_t row; // Pixel row of the top left corner.
+ int16_t col; // Pixel col of the top left corner.
+ int64_t intra_cost; // Rd cost of the best intra mode.
+ int64_t inter_cost; // Rd cost of the best inter mode.
// Valid only if TplFrameStats::rate_dist_present is true:
- int64_t recrf_rate; // Bits when using recon as reference.
- int64_t recrf_dist; // Distortion when using recon as reference.
+ int64_t recrf_rate; // Bits when using recon as reference.
+ int64_t recrf_dist; // Distortion when using recon as reference.
+ int64_t intra_pred_err; // Prediction residual of the intra mode.
+ int64_t inter_pred_err; // Prediction residual of the inter mode.
std::array<MotionVector, kBlockRefCount> mv;
std::array<int, kBlockRefCount> ref_frame_index;