mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Remove instrumentation code
This commit is contained in:
parent
1ae5ecdec5
commit
352d6750f5
|
@ -37,8 +37,6 @@
|
|||
#include "extras/crypto.h"
|
||||
#include "kvazaar.h"
|
||||
|
||||
FILE* bit_cost_file = NULL;
|
||||
|
||||
const uint8_t kvz_g_auc_next_state_mps[128] =
|
||||
{
|
||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
|
@ -107,7 +105,6 @@ void kvz_cabac_encode_bin(cabac_data_t * const data, const uint32_t bin_value)
|
|||
{
|
||||
uint32_t lps;
|
||||
|
||||
if (!(data)->only_count) bits_written += CTX_ENTROPY_FBITS((data)->cur_ctx, (bin_value));
|
||||
lps = kvz_g_auc_lpst_table[CTX_STATE(data->cur_ctx)][(data->range >> 6) & 3];
|
||||
data->range -= lps;
|
||||
|
||||
|
|
14
src/cabac.h
14
src/cabac.h
|
@ -42,8 +42,6 @@
|
|||
|
||||
#include "bitstream.h"
|
||||
|
||||
extern FILE* bit_cost_file;
|
||||
|
||||
struct encoder_state_t;
|
||||
|
||||
// Types
|
||||
|
@ -139,7 +137,6 @@ extern const float kvz_f_entropy_bits[128];
|
|||
CABAC_BIN((cabac), (val), (name));\
|
||||
} \
|
||||
} while(0)
|
||||
extern double bits_written;
|
||||
|
||||
// Macros
|
||||
#define CTX_STATE(ctx) ((ctx)->uc_state >> 1)
|
||||
|
@ -147,30 +144,23 @@ extern double bits_written;
|
|||
#define CTX_UPDATE_LPS(ctx) { (ctx)->uc_state = kvz_g_auc_next_state_lps[ (ctx)->uc_state ]; }
|
||||
#define CTX_UPDATE_MPS(ctx) { (ctx)->uc_state = kvz_g_auc_next_state_mps[ (ctx)->uc_state ]; }
|
||||
|
||||
#ifdef VERBOSE
|
||||
#define FILE_BITS(bits, x, y, depth, name) fprintf(bit_cost_file, "%s\t%d\t%d\t%d\t%f\n", (name), (x), (y), (depth), (bits))
|
||||
#else
|
||||
#define FILE_BITS(bits, x, y, depth, name) {}
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
#define CABAC_BIN(data, value, name) { \
|
||||
uint32_t prev_state = (data)->cur_ctx->uc_state; \
|
||||
kvz_cabac_encode_bin((data), (value)); \
|
||||
if(!(data)->only_count) printf("%s = %u, state = %u -> %u MPS = %u bits = %f\n", \
|
||||
(name), (uint32_t)(value), prev_state, (data)->cur_ctx->uc_state, CTX_MPS((data)->cur_ctx), bits_written); }
|
||||
if(!(data)->only_count) printf("%s = %u, state = %u -> %u MPS = %u\n", \
|
||||
(name), (uint32_t)(value), prev_state, (data)->cur_ctx->uc_state, CTX_MPS((data)->cur_ctx)); }
|
||||
|
||||
#define CABAC_BINS_EP(data, value, bins, name) { \
|
||||
uint32_t prev_state = (data)->cur_ctx->uc_state; \
|
||||
kvz_cabac_encode_bins_ep((data), (value), (bins)); \
|
||||
if(!(data)->only_count) bits_written += (bins); \
|
||||
if(!(data)->only_count) printf("%s = %u(%u bins), state = %u -> %u\n", \
|
||||
(name), (uint32_t)(value), (bins), prev_state, (data)->cur_ctx->uc_state); }
|
||||
|
||||
#define CABAC_BIN_EP(data, value, name) { \
|
||||
uint32_t prev_state = (data)->cur_ctx->uc_state; \
|
||||
kvz_cabac_encode_bin_ep((data), (value)); \
|
||||
if(!(data)->only_count) bits_written += 1; \
|
||||
if(!(data)->only_count) printf("%s = %u, state = %u -> %u\n", \
|
||||
(name), (uint32_t)(value), prev_state, (data)->cur_ctx->uc_state); }
|
||||
#else
|
||||
|
|
|
@ -943,13 +943,6 @@ end:
|
|||
if (is_last_cu_in_qg(state, x, y, depth)) {
|
||||
state->last_qp = cur_cu->qp;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if((x % 64 != 0 && y % 64 != 0) || 1) {
|
||||
fprintf(stderr, "%f\t%d\t%d\t%d\n", bits_written, x, y, depth);
|
||||
bits_written = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
double kvz_mock_encode_coding_unit(
|
||||
|
|
|
@ -1661,11 +1661,9 @@ static void _encode_one_frame_add_bitstream_deps(const encoder_state_t * const s
|
|||
}
|
||||
}
|
||||
|
||||
double bits_written;
|
||||
|
||||
void kvz_encode_one_frame(encoder_state_t * const state, kvz_picture* frame)
|
||||
{
|
||||
bits_written = 0;
|
||||
encoder_state_init_new_frame(state, frame);
|
||||
encoder_state_encode(state);
|
||||
|
||||
|
|
|
@ -510,7 +510,6 @@ static void sao_search_best_mode(const encoder_state_t * const state, const kvz_
|
|||
if (state->encoder_control->cfg.sao_type & 1){
|
||||
sao_search_edge_sao(state, data, recdata, block_width, block_height, buf_cnt, &edge_sao, sao_top, sao_left);
|
||||
float mode_bits = sao_mode_bits_edge(state, edge_sao.eo_class, edge_sao.offsets, sao_top, sao_left, buf_cnt);
|
||||
FILE_BITS(mode_bits, 0, 0, 0, "sao mode bits");
|
||||
int ddistortion = (int)(mode_bits * state->lambda + 0.5);
|
||||
unsigned buf_i;
|
||||
|
||||
|
@ -557,7 +556,6 @@ static void sao_search_best_mode(const encoder_state_t * const state, const kvz_
|
|||
{
|
||||
float mode_bits_none = sao_mode_bits_none(state, sao_top, sao_left);
|
||||
int cost_of_nothing = (int)(mode_bits_none * state->lambda + 0.5);
|
||||
FILE_BITS(mode_bits_none, 0, 0, 0, "Sao cost of nothing");
|
||||
if (sao_out->ddistortion >= cost_of_nothing) {
|
||||
sao_out->type = SAO_TYPE_NONE;
|
||||
merge_cost[0] = cost_of_nothing;
|
||||
|
@ -574,7 +572,6 @@ static void sao_search_best_mode(const encoder_state_t * const state, const kvz_
|
|||
if (merge_cand) {
|
||||
unsigned buf_i;
|
||||
float mode_bits = sao_mode_bits_merge(state, i + 1);
|
||||
FILE_BITS(mode_bits, 0, 0, 0, (i == 0 ? "sao merge ""left" : "sao merge ""top"));
|
||||
int ddistortion = (int)(mode_bits * state->lambda + 0.5);
|
||||
|
||||
switch (merge_cand->type) {
|
||||
|
|
60
src/search.c
60
src/search.c
|
@ -241,8 +241,7 @@ static double cu_zero_coeff_cost(const encoder_state_t *state, lcu_t *work_tree,
|
|||
double kvz_cu_rd_cost_luma(const encoder_state_t *const state,
|
||||
const int x_px, const int y_px, const int depth,
|
||||
const cu_info_t *const pred_cu,
|
||||
lcu_t *const lcu,
|
||||
double *bit_cost)
|
||||
lcu_t *const lcu)
|
||||
{
|
||||
const int width = LCU_WIDTH >> depth;
|
||||
const int skip_residual_coding = pred_cu->skipped || (pred_cu->type == CU_INTER && pred_cu->cbf == 0);
|
||||
|
@ -278,17 +277,16 @@ double kvz_cu_rd_cost_luma(const encoder_state_t *const state,
|
|||
{
|
||||
cabac_ctx_t *ctx = &(cabac->ctx.trans_subdiv_model[5 - (6 - depth)]);
|
||||
CABAC_FBITS_UPDATE(cabac, ctx, tr_depth > 0, tr_tree_bits, "tr_split_search");
|
||||
*bit_cost += tr_tree_bits;
|
||||
}
|
||||
|
||||
if (tr_depth > 0) {
|
||||
int offset = width / 2;
|
||||
double sum = 0;
|
||||
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px, y_px, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px + offset, y_px, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px, y_px + offset, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px + offset, y_px + offset, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px, y_px, depth + 1, pred_cu, lcu);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px + offset, y_px, depth + 1, pred_cu, lcu);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px, y_px + offset, depth + 1, pred_cu, lcu);
|
||||
sum += kvz_cu_rd_cost_luma(state, x_px + offset, y_px + offset, depth + 1, pred_cu, lcu);
|
||||
|
||||
return sum + tr_tree_bits * state->lambda;
|
||||
}
|
||||
|
@ -322,7 +320,6 @@ double kvz_cu_rd_cost_luma(const encoder_state_t *const state,
|
|||
int is_set = cbf_is_set(pred_cu->cbf, depth, COLOR_Y);
|
||||
|
||||
CABAC_FBITS_UPDATE(cabac, ctx, is_set, tr_tree_bits, "cbf_y_search");
|
||||
*bit_cost += tr_tree_bits;
|
||||
}
|
||||
|
||||
// SSD between reconstruction and original
|
||||
|
@ -340,7 +337,6 @@ double kvz_cu_rd_cost_luma(const encoder_state_t *const state,
|
|||
const coeff_t *coeffs = &lcu->coeff.y[xy_to_zorder(LCU_WIDTH, x_px, y_px)];
|
||||
|
||||
coeff_bits += kvz_get_coeff_cost(state, coeffs, width, 0, luma_scan_mode);
|
||||
*bit_cost += coeff_bits;
|
||||
}
|
||||
|
||||
double bits = tr_tree_bits + coeff_bits;
|
||||
|
@ -351,8 +347,7 @@ double kvz_cu_rd_cost_luma(const encoder_state_t *const state,
|
|||
double kvz_cu_rd_cost_chroma(const encoder_state_t *const state,
|
||||
const int x_px, const int y_px, const int depth,
|
||||
const cu_info_t *const pred_cu,
|
||||
lcu_t *const lcu,
|
||||
double *bit_cost)
|
||||
lcu_t *const lcu)
|
||||
{
|
||||
const vector2d_t lcu_px = { x_px / 2, y_px / 2 };
|
||||
const int width = (depth <= MAX_DEPTH) ? LCU_WIDTH >> (depth + 1) : LCU_WIDTH >> depth;
|
||||
|
@ -385,17 +380,16 @@ double kvz_cu_rd_cost_chroma(const encoder_state_t *const state,
|
|||
int v_is_set = cbf_is_set(pred_cu->cbf, depth, COLOR_V);
|
||||
CABAC_FBITS_UPDATE(cabac, ctx, v_is_set, tr_tree_bits, "cbf_cb_search");
|
||||
}
|
||||
*bit_cost += tr_tree_bits;
|
||||
}
|
||||
|
||||
if (tr_cu->tr_depth > depth) {
|
||||
int offset = LCU_WIDTH >> (depth + 1);
|
||||
double sum = 0;
|
||||
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px, y_px, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px + offset, y_px, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px, y_px + offset, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px + offset, y_px + offset, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px, y_px, depth + 1, pred_cu, lcu);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px + offset, y_px, depth + 1, pred_cu, lcu);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px, y_px + offset, depth + 1, pred_cu, lcu);
|
||||
sum += kvz_cu_rd_cost_chroma(state, x_px + offset, y_px + offset, depth + 1, pred_cu, lcu);
|
||||
|
||||
return sum + tr_tree_bits * state->lambda;
|
||||
}
|
||||
|
@ -420,7 +414,6 @@ double kvz_cu_rd_cost_chroma(const encoder_state_t *const state,
|
|||
|
||||
coeff_bits += kvz_get_coeff_cost(state, &lcu->coeff.u[index], width, 2, scan_order);
|
||||
coeff_bits += kvz_get_coeff_cost(state, &lcu->coeff.v[index], width, 2, scan_order);
|
||||
*bit_cost += coeff_bits;
|
||||
}
|
||||
|
||||
double bits = tr_tree_bits + coeff_bits;
|
||||
|
@ -430,8 +423,7 @@ double kvz_cu_rd_cost_chroma(const encoder_state_t *const state,
|
|||
static double cu_rd_cost_tr_split_accurate(const encoder_state_t* const state,
|
||||
const int x_px, const int y_px, const int depth,
|
||||
const cu_info_t* const pred_cu,
|
||||
lcu_t* const lcu,
|
||||
double* bit_cost) {
|
||||
lcu_t* const lcu) {
|
||||
const int width = LCU_WIDTH >> depth;
|
||||
|
||||
const int skip_residual_coding = pred_cu->skipped || (pred_cu->type == CU_INTER && pred_cu->cbf == 0);
|
||||
|
@ -492,12 +484,11 @@ static double cu_rd_cost_tr_split_accurate(const encoder_state_t* const state,
|
|||
if (tr_depth > 0) {
|
||||
int offset = LCU_WIDTH >> (depth + 1);
|
||||
double sum = 0;
|
||||
*bit_cost += tr_tree_bits;
|
||||
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px, y_px, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px + offset, y_px, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px, y_px + offset, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px + offset, y_px + offset, depth + 1, pred_cu, lcu, bit_cost);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px, y_px, depth + 1, pred_cu, lcu);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px + offset, y_px, depth + 1, pred_cu, lcu);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px, y_px + offset, depth + 1, pred_cu, lcu);
|
||||
sum += cu_rd_cost_tr_split_accurate(state, x_px + offset, y_px + offset, depth + 1, pred_cu, lcu);
|
||||
return sum + tr_tree_bits * state->lambda;
|
||||
}
|
||||
const int cb_flag_y = cbf_is_set(tr_cu->cbf, depth, COLOR_Y) ;
|
||||
|
@ -514,7 +505,6 @@ static double cu_rd_cost_tr_split_accurate(const encoder_state_t* const state,
|
|||
|
||||
CABAC_FBITS_UPDATE(cabac, ctx, cb_flag_y, tr_tree_bits, "cbf_y_search");
|
||||
}
|
||||
*bit_cost += tr_tree_bits;
|
||||
// SSD between reconstruction and original
|
||||
unsigned luma_ssd = 0;
|
||||
if (!state->encoder_control->cfg.lossless) {
|
||||
|
@ -554,7 +544,7 @@ static double cu_rd_cost_tr_split_accurate(const encoder_state_t* const state,
|
|||
coeff_bits += kvz_get_coeff_cost(state, &lcu->coeff.v[index], chroma_width, 2, scan_order);
|
||||
}
|
||||
}
|
||||
*bit_cost += coeff_bits;
|
||||
|
||||
double bits = tr_tree_bits + coeff_bits;
|
||||
return luma_ssd * KVZ_LUMA_MULT + chroma_ssd * KVZ_CHROMA_MULT + bits * state->lambda;
|
||||
}
|
||||
|
@ -895,12 +885,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
|
||||
cost = bits * state->lambda;
|
||||
|
||||
cost += cu_rd_cost_tr_split_accurate(state, x_local, y_local, depth, cur_cu, lcu, &bits);
|
||||
//if (state->encoder_control->chroma_format != KVZ_CSP_400) {
|
||||
// cost += kvz_cu_rd_cost_chroma(state, x_local, y_local, depth, cur_cu, lcu, & bits);
|
||||
//}
|
||||
|
||||
FILE_BITS(bits, x, y, depth, "final rd bits");
|
||||
cost += cu_rd_cost_tr_split_accurate(state, x_local, y_local, depth, cur_cu, lcu);
|
||||
|
||||
if (ctrl->cfg.zero_coeff_rdo && inter_zero_coeff_cost <= cost) {
|
||||
cost = inter_zero_coeff_cost;
|
||||
|
@ -958,7 +943,6 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
cabac_ctx_t *ctx = &(state->search_cabac.ctx.part_size_model[0]);
|
||||
CABAC_FBITS_UPDATE(&state->search_cabac, ctx, 0, split_bits, "split_search");
|
||||
}
|
||||
FILE_BITS(split_bits, x, y, depth, "split");
|
||||
state->search_cabac.update = 0;
|
||||
split_cost += split_bits * state->lambda;
|
||||
|
||||
|
@ -1023,12 +1007,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
double mode_bits = calc_mode_bits(state, lcu, cur_cu, x, y) + bits;
|
||||
cost += mode_bits * state->lambda;
|
||||
|
||||
cost += kvz_cu_rd_cost_luma(state, x_local, y_local, depth, cur_cu, lcu, &bits);
|
||||
if (has_chroma) {
|
||||
cost += kvz_cu_rd_cost_chroma(state, x_local, y_local, depth, cur_cu, lcu, &bits);
|
||||
}
|
||||
|
||||
FILE_BITS(bits, x, y, depth, "merged intra bits");
|
||||
cost += cu_rd_cost_tr_split_accurate(state, x_local, y_local, depth, cur_cu, lcu);
|
||||
|
||||
memcpy(&post_seach_cabac, &state->search_cabac, sizeof(post_seach_cabac));
|
||||
memcpy(&state->search_cabac, &temp_cabac, sizeof(temp_cabac));
|
||||
|
@ -1200,9 +1179,6 @@ static void copy_lcu_to_cu_data(const encoder_state_t * const state, int x_px, i
|
|||
*/
|
||||
void kvz_search_lcu(encoder_state_t * const state, const int x, const int y, const yuv_t * const hor_buf, const yuv_t * const ver_buf)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
if (bit_cost_file == NULL) bit_cost_file = fopen("bits_file.txt", "w");
|
||||
#endif
|
||||
memcpy(&state->search_cabac, &state->cabac, sizeof(cabac_data_t));
|
||||
state->search_cabac.only_count = 1;
|
||||
assert(x % LCU_WIDTH == 0);
|
||||
|
|
|
@ -81,11 +81,11 @@ void kvz_search_lcu(encoder_state_t *state, int x, int y, const yuv_t *hor_buf,
|
|||
double kvz_cu_rd_cost_luma(const encoder_state_t *const state,
|
||||
const int x_px, const int y_px, const int depth,
|
||||
const cu_info_t *const pred_cu,
|
||||
lcu_t *const lcu, double *bits);
|
||||
lcu_t *const lcu);
|
||||
double kvz_cu_rd_cost_chroma(const encoder_state_t *const state,
|
||||
const int x_px, const int y_px, const int depth,
|
||||
const cu_info_t *const pred_cu,
|
||||
lcu_t *const lcu, double* bits);
|
||||
lcu_t *const lcu);
|
||||
void kvz_lcu_fill_trdepth(lcu_t *lcu, int x_px, int y_px, int depth, int tr_depth);
|
||||
|
||||
void kvz_intra_recon_lcu_luma(encoder_state_t * const state, int x, int y, int depth, int8_t intra_mode, cu_info_t *cur_cu, lcu_t *lcu);
|
||||
|
|
|
@ -2121,11 +2121,10 @@ void kvz_cu_cost_inter_rd2(encoder_state_t * const state,
|
|||
|
||||
int cbf = cbf_is_set_any(cur_cu->cbf, depth);
|
||||
|
||||
double temp_bits = 0;
|
||||
if(cbf) {
|
||||
*inter_cost = kvz_cu_rd_cost_luma(state, x_px, y_px, depth, cur_cu, lcu, &temp_bits);
|
||||
*inter_cost = kvz_cu_rd_cost_luma(state, x_px, y_px, depth, cur_cu, lcu);
|
||||
if (reconstruct_chroma) {
|
||||
*inter_cost += kvz_cu_rd_cost_chroma(state, x_px, y_px, depth, cur_cu, lcu, &temp_bits);
|
||||
*inter_cost += kvz_cu_rd_cost_chroma(state, x_px, y_px, depth, cur_cu, lcu);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -2136,8 +2135,6 @@ void kvz_cu_cost_inter_rd2(encoder_state_t * const state,
|
|||
return;
|
||||
}
|
||||
|
||||
FILE_BITS(bits, x, y, depth, "inter rd 2 bits");
|
||||
|
||||
*inter_cost += (bits)* state->lambda;
|
||||
*inter_bitcost = bits;
|
||||
|
||||
|
@ -2246,7 +2243,6 @@ void kvz_search_cu_inter(encoder_state_t * const state,
|
|||
if (*inter_cost < MAX_DOUBLE && cur_pu->inter.mv_dir & 2) {
|
||||
assert(fracmv_within_tile(&info, cur_pu->inter.mv[1][0], cur_pu->inter.mv[1][1]));
|
||||
}
|
||||
FILE_BITS((double)*inter_bitcost, x, y, depth, "regular inter bitcost");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -179,8 +179,7 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
int x_px, int y_px, int depth, int max_depth,
|
||||
int intra_mode, int cost_treshold,
|
||||
cu_info_t *const pred_cu,
|
||||
lcu_t *const lcu,
|
||||
double *bit_cost)
|
||||
lcu_t *const lcu)
|
||||
{
|
||||
assert(depth >= 0 && depth <= MAX_PU_DEPTH);
|
||||
|
||||
|
@ -202,7 +201,6 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
|
||||
double split_cost = INT32_MAX;
|
||||
double nosplit_cost = INT32_MAX;
|
||||
double nosplit_bits = 0;
|
||||
|
||||
if (depth > 0) {
|
||||
tr_cu->tr_depth = depth;
|
||||
|
@ -223,9 +221,9 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
intra_mode, chroma_mode,
|
||||
pred_cu, lcu);
|
||||
|
||||
nosplit_cost += kvz_cu_rd_cost_luma(state, lcu_px.x, lcu_px.y, depth, pred_cu, lcu, &nosplit_bits);
|
||||
nosplit_cost += kvz_cu_rd_cost_luma(state, lcu_px.x, lcu_px.y, depth, pred_cu, lcu);
|
||||
if (reconstruct_chroma) {
|
||||
nosplit_cost += kvz_cu_rd_cost_chroma(state, lcu_px.x, lcu_px.y, depth, pred_cu, lcu, &nosplit_bits);
|
||||
nosplit_cost += kvz_cu_rd_cost_chroma(state, lcu_px.x, lcu_px.y, depth, pred_cu, lcu);
|
||||
}
|
||||
|
||||
// Early stop codition for the recursive search.
|
||||
|
@ -252,15 +250,15 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
if (depth < max_depth && depth < MAX_PU_DEPTH) {
|
||||
split_cost = 0;
|
||||
|
||||
split_cost += search_intra_trdepth(state, x_px, y_px, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu, bit_cost);
|
||||
split_cost += search_intra_trdepth(state, x_px, y_px, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu);
|
||||
if (split_cost < nosplit_cost) {
|
||||
split_cost += search_intra_trdepth(state, x_px + offset, y_px, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu, bit_cost);
|
||||
split_cost += search_intra_trdepth(state, x_px + offset, y_px, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu);
|
||||
}
|
||||
if (split_cost < nosplit_cost) {
|
||||
split_cost += search_intra_trdepth(state, x_px, y_px + offset, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu, bit_cost);
|
||||
split_cost += search_intra_trdepth(state, x_px, y_px + offset, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu);
|
||||
}
|
||||
if (split_cost < nosplit_cost) {
|
||||
split_cost += search_intra_trdepth(state, x_px + offset, y_px + offset, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu, bit_cost);
|
||||
split_cost += search_intra_trdepth(state, x_px + offset, y_px + offset, depth + 1, max_depth, intra_mode, nosplit_cost, pred_cu, lcu);
|
||||
}
|
||||
|
||||
double tr_split_bit = 0.0;
|
||||
|
@ -271,7 +269,6 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
if (depth >= 1 && depth <= 3) {
|
||||
cabac_ctx_t *ctx = &(state->search_cabac.ctx.trans_subdiv_model[5 - (6 - depth)]);
|
||||
CABAC_FBITS_UPDATE(&state->search_cabac, ctx, 1, tr_split_bit, "tr_split");
|
||||
*bit_cost += tr_split_bit;
|
||||
}
|
||||
|
||||
// Add cost of cbf chroma bits on transform tree.
|
||||
|
@ -290,7 +287,6 @@ static double search_intra_trdepth(encoder_state_t * const state,
|
|||
if (tr_depth == 0 || cbf_is_set(pred_cu->cbf, depth - 1, COLOR_V)) {
|
||||
CABAC_FBITS_UPDATE(&state->search_cabac, ctx, cbf_is_set(pred_cu->cbf, depth, COLOR_V), cbf_bits, "cbf_cr");
|
||||
}
|
||||
*bit_cost += cbf_bits;
|
||||
}
|
||||
|
||||
double bits = tr_split_bit + cbf_bits;
|
||||
|
@ -614,8 +610,7 @@ static int8_t search_intra_rdo(encoder_state_t * const state,
|
|||
// Reset transform split data in lcu.cu for this area.
|
||||
kvz_lcu_fill_trdepth(lcu, x_px, y_px, depth, depth);
|
||||
|
||||
double bit_costs = 0;
|
||||
double mode_cost = search_intra_trdepth(state, x_px, y_px, depth, tr_depth, modes[rdo_mode], MAX_INT, &pred_cu, lcu, &bit_costs);
|
||||
double mode_cost = search_intra_trdepth(state, x_px, y_px, depth, tr_depth, modes[rdo_mode], MAX_INT, &pred_cu, lcu);
|
||||
costs[rdo_mode] += mode_cost;
|
||||
|
||||
// Early termination if no coefficients has to be coded
|
||||
|
@ -640,9 +635,7 @@ static int8_t search_intra_rdo(encoder_state_t * const state,
|
|||
pred_cu.intra.mode = modes[0];
|
||||
pred_cu.intra.mode_chroma = modes[0];
|
||||
FILL(pred_cu.cbf, 0);
|
||||
double bit_cost = 0;
|
||||
search_intra_trdepth(state, x_px, y_px, depth, tr_depth, modes[0], MAX_INT, &pred_cu, lcu, &bit_cost);
|
||||
FILE_BITS(bit_cost, x_px, y_px, depth, "tr_depth bits");
|
||||
search_intra_trdepth(state, x_px, y_px, depth, tr_depth, modes[0], MAX_INT, &pred_cu, lcu);
|
||||
}
|
||||
|
||||
return modes_to_check;
|
||||
|
@ -738,7 +731,7 @@ int8_t kvz_search_intra_chroma_rdo(encoder_state_t * const state,
|
|||
-1, chroma.mode, // skip luma
|
||||
NULL, lcu);
|
||||
double bits = 0;
|
||||
chroma.cost = kvz_cu_rd_cost_chroma(state, lcu_px.x, lcu_px.y, depth, tr_cu, lcu, &bits);
|
||||
chroma.cost = kvz_cu_rd_cost_chroma(state, lcu_px.x, lcu_px.y, depth, tr_cu, lcu);
|
||||
|
||||
double mode_bits = kvz_chroma_mode_bits(state, chroma.mode, intra_mode);
|
||||
bits += mode_bits;
|
||||
|
|
Loading…
Reference in a new issue