[cleanup] Fix MSVC warnings about type conversion and signed/unsigned comparison

This commit is contained in:
Marko Viitanen 2022-06-17 11:27:19 +03:00
parent 4a80e71135
commit fb17bbc1ca
40 changed files with 479 additions and 507 deletions

View file

@ -124,7 +124,7 @@ endif()
# For visual studio / windows we also need our own pthread implementation and getopt # For visual studio / windows we also need our own pthread implementation and getopt
if(MSVC) if(MSVC)
list(APPEND LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/extras/getopt.c ${CMAKE_CURRENT_SOURCE_DIR}/src/threadwrapper/src/pthread.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/threadwrapper/src/semaphore.cpp) list(APPEND LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/extras/getopt.c ${CMAKE_CURRENT_SOURCE_DIR}/src/threadwrapper/src/pthread.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/threadwrapper/src/semaphore.cpp)
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32 -DWIN32 -DWIN64) add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32 -DWIN32 -DWIN64 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif() endif()
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)

View file

@ -156,7 +156,7 @@ static void set_ey_from_clip(const alf_covariance *cov, const int* clip, double
y[k] = cov->y[k][clip[k]]; y[k] = cov->y[k][clip[k]];
for (int l = 0; l < size; l++) for (int l = 0; l < size; l++)
{ {
ee[k][l] = cov->ee[k][l][clip[k]][clip[l]]; ee[k][l] = (double)cov->ee[k][l][clip[k]][clip[l]];
} }
} }
} }
@ -346,8 +346,8 @@ static double optimize_filter(const alf_covariance *cov, int* clip, double *f, b
ky[k] = cov->y[k][clip[k]]; ky[k] = cov->y[k][clip[k]];
for (int l = 0; l < size; l++) for (int l = 0; l < size; l++)
{ {
ke[k][l] = cov->ee[k][l][clip[k]][clip[l]]; ke[k][l] = (double)cov->ee[k][l][clip[k]][clip[l]];
ke[l][k] = cov->ee[l][k][clip[l]][clip[k]]; ke[l][k] = (double)cov->ee[l][k][clip[l]][clip[k]];
} }
gns_solve_by_chol(ke, ky, f, size); gns_solve_by_chol(ke, ky, f, size);
@ -367,8 +367,8 @@ static double optimize_filter(const alf_covariance *cov, int* clip, double *f, b
ky[k] = cov->y[k][clip[k]]; ky[k] = cov->y[k][clip[k]];
for (int l = 0; l < size; l++) for (int l = 0; l < size; l++)
{ {
ke[k][l] = cov->ee[k][l][clip[k]][clip[l]]; ke[k][l] = (double)cov->ee[k][l][clip[k]][clip[l]];
ke[l][k] = cov->ee[l][k][clip[l]][clip[k]]; ke[l][k] = (double)cov->ee[l][k][clip[l]][clip[k]];
} }
gns_solve_by_chol(ke, ky, f, size); gns_solve_by_chol(ke, ky, f, size);
@ -386,8 +386,8 @@ static double optimize_filter(const alf_covariance *cov, int* clip, double *f, b
ky[k] = cov->y[k][clip[k]]; ky[k] = cov->y[k][clip[k]];
for (int l = 0; l < size; l++) for (int l = 0; l < size; l++)
{ {
ke[k][l] = cov->ee[k][l][clip[k]][clip[l]]; ke[k][l] = (double)cov->ee[k][l][clip[k]][clip[l]];
ke[l][k] = cov->ee[l][k][clip[l]][clip[k]]; ke[l][k] = (double)cov->ee[l][k][clip[l]][clip[k]];
} }
} }
@ -398,8 +398,8 @@ static double optimize_filter(const alf_covariance *cov, int* clip, double *f, b
ky[idx_min] = cov->y[idx_min][clip[idx_min]]; ky[idx_min] = cov->y[idx_min][clip[idx_min]];
for (int l = 0; l < size; l++) for (int l = 0; l < size; l++)
{ {
ke[idx_min][l] = cov->ee[idx_min][l][clip[idx_min]][clip[l]]; ke[idx_min][l] = (double)cov->ee[idx_min][l][clip[idx_min]][clip[l]];
ke[l][idx_min] = cov->ee[l][idx_min][clip[l]][clip[idx_min]]; ke[l][idx_min] = (double)cov->ee[l][idx_min][clip[l]][clip[idx_min]];
} }
} }
else else
@ -1274,11 +1274,11 @@ static void code_alf_ctu_alternative_ctu(encoder_state_t * const state,
uint8_t* ctb_alf_alternative = state->tile->frame->alf_info->ctu_alternative[comp_idx]; uint8_t* ctb_alf_alternative = state->tile->frame->alf_info->ctu_alternative[comp_idx];
unsigned num_ones = ctb_alf_alternative[ctu_rs_addr]; unsigned num_ones = ctb_alf_alternative[ctu_rs_addr];
assert(ctb_alf_alternative[ctu_rs_addr] < num_alts); assert(ctb_alf_alternative[ctu_rs_addr] < num_alts);
for (int i = 0; i < num_ones; ++i) { for (uint32_t i = 0; i < num_ones; ++i) {
cabac->cur_ctx = &cabac->ctx.alf_ctb_alternatives[comp_idx - 1]; cabac->cur_ctx = &cabac->ctx.alf_ctb_alternatives[comp_idx - 1];
CABAC_BIN(cabac, 1, "alf_ctb_alternatives"); CABAC_BIN(cabac, 1, "alf_ctb_alternatives");
} }
if (num_ones < num_alts - 1) { if ((int32_t)num_ones < num_alts - 1) {
cabac->cur_ctx = &cabac->ctx.alf_ctb_alternatives[comp_idx - 1]; cabac->cur_ctx = &cabac->ctx.alf_ctb_alternatives[comp_idx - 1];
CABAC_BIN(cabac, 0, "alf_ctb_alternatives"); CABAC_BIN(cabac, 0, "alf_ctb_alternatives");
} }
@ -1295,7 +1295,7 @@ static void code_alf_ctu_alternatives_component(encoder_state_t * const state,
return; return;
uint32_t num_ctus = state->tile->frame->width_in_lcu * state->tile->frame->height_in_lcu; uint32_t num_ctus = state->tile->frame->width_in_lcu * state->tile->frame->height_in_lcu;
bool* ctb_alf_flag = state->tile->frame->alf_info->ctu_enable_flag[comp_id]; bool* ctb_alf_flag = state->tile->frame->alf_info->ctu_enable_flag[comp_id];
for (int ctu_idx = 0; ctu_idx < num_ctus; ctu_idx++) for (uint32_t ctu_idx = 0; ctu_idx < num_ctus; ctu_idx++)
{ {
if (ctb_alf_flag[ctu_idx]) if (ctb_alf_flag[ctu_idx])
{ {
@ -1916,7 +1916,7 @@ static void derive_cc_alf_filter_coeff(alf_covariance *alf_covariance_frame_cc_a
ky[k] = alf_covariance_frame_cc_alf[filter_idx].y[k][0]; ky[k] = alf_covariance_frame_cc_alf[filter_idx].y[k][0];
for (int l = 0; l < size; l++) for (int l = 0; l < size; l++)
{ {
k_e[k][l] = alf_covariance_frame_cc_alf[filter_idx].ee[k][l][0][0]; k_e[k][l] = (double)alf_covariance_frame_cc_alf[filter_idx].ee[k][l][0][0];
} }
} }
@ -2312,7 +2312,7 @@ static void derive_cc_alf_filter(encoder_state_t * const state, alf_component_id
// compute cost of not filtering // compute cost of not filtering
uint64_t unfiltered_distortion = 0; uint64_t unfiltered_distortion = 0;
for (int ctb_idx = 0; ctb_idx < num_ctus_in_pic; ctb_idx++) for (uint32_t ctb_idx = 0; ctb_idx < num_ctus_in_pic; ctb_idx++)
{ {
unfiltered_distortion += (uint64_t)alf_covariance_cc_alf[ctb_idx].pix_acc; unfiltered_distortion += (uint64_t)alf_covariance_cc_alf[ctb_idx].pix_acc;
} }
@ -2495,7 +2495,7 @@ static void derive_cc_alf_filter(encoder_state_t * const state, alf_component_id
// save best coeff and control // save best coeff and control
bool atleast_one_block_undergoes_fitlering = false; bool atleast_one_block_undergoes_fitlering = false;
for (int controlIdx = 0; best_filter_count > 0 && controlIdx < num_ctus_in_pic; controlIdx++) for (uint32_t controlIdx = 0; best_filter_count > 0 && controlIdx < num_ctus_in_pic; controlIdx++)
{ {
if (best_filter_control[controlIdx]) if (best_filter_control[controlIdx])
{ {
@ -2523,7 +2523,7 @@ static void derive_cc_alf_filter(encoder_state_t * const state, alf_component_id
uint8_t cur_filter_idc = best_map_filter_idx_to_filter_idc[filter_idx]; uint8_t cur_filter_idc = best_map_filter_idx_to_filter_idc[filter_idx];
if (best_filter_idx_enabled[filter_idx]) if (best_filter_idx_enabled[filter_idx])
{ {
for (int control_idx = 0; control_idx < num_ctus_in_pic; control_idx++) for (uint32_t control_idx = 0; control_idx < num_ctus_in_pic; control_idx++)
{ {
if (filter_control[control_idx] == (filter_idx + 1)) if (filter_control[control_idx] == (filter_idx + 1))
{ {
@ -2710,11 +2710,11 @@ static void get_blk_stats_cc_alf(encoder_state_t * const state,
{ {
if (0 /*g_alf_wssd*/) if (0 /*g_alf_wssd*/)
{ {
alf_covariance->ee[k][l][b0][b1] += weight * (e_local[k][b0] * (double)e_local[l][b1]); alf_covariance->ee[k][l][b0][b1] += (int64_t)(weight * (e_local[k][b0] * (double)e_local[l][b1]));
} }
else else
{ {
alf_covariance->ee[k][l][b0][b1] += e_local[k][b0] * (double)e_local[l][b1]; alf_covariance->ee[k][l][b0][b1] += (int64_t)(e_local[k][b0] * (double)e_local[l][b1]);
} }
} }
} }
@ -2723,11 +2723,11 @@ static void get_blk_stats_cc_alf(encoder_state_t * const state,
{ {
if (0 /*g_alf_wssd*/) if (0 /*g_alf_wssd*/)
{ {
alf_covariance->y[k][b] += weight * (e_local[k][b] * (double)y_local); alf_covariance->y[k][b] += (int32_t)(weight * (e_local[k][b] * (double)y_local));
} }
else else
{ {
alf_covariance->y[k][b] += e_local[k][b] * (double)y_local; alf_covariance->y[k][b] += (int32_t)(e_local[k][b] * (double)y_local);
} }
} }
} }
@ -5221,7 +5221,7 @@ void uvg_alf_enc_process(encoder_state_t *const state)
bool chroma_scale_x = (chroma_fmt == UVG_CSP_444) ? 0 : 1; bool chroma_scale_x = (chroma_fmt == UVG_CSP_444) ? 0 : 1;
bool chroma_scale_y = (chroma_fmt != UVG_CSP_420) ? 0 : 1; bool chroma_scale_y = (chroma_fmt != UVG_CSP_420) ? 0 : 1;
int8_t uvg_bit_depth = state->encoder_control->bitdepth; int8_t uvg_bit_depth = state->encoder_control->bitdepth;
const int32_t num_ctus_in_pic = state->tile->frame->width_in_lcu * state->tile->frame->height_in_lcu; const uint32_t num_ctus_in_pic = state->tile->frame->width_in_lcu * state->tile->frame->height_in_lcu;
const int8_t input_bitdepth = state->encoder_control->bitdepth; const int8_t input_bitdepth = state->encoder_control->bitdepth;
double lambda_chroma_weight = 0.0; double lambda_chroma_weight = 0.0;
@ -5307,7 +5307,7 @@ void uvg_alf_enc_process(encoder_state_t *const state)
// get CTB stats for filtering // get CTB stats for filtering
alf_derive_stats_for_filtering(state, arr_vars.alf_clipping_values); alf_derive_stats_for_filtering(state, arr_vars.alf_clipping_values);
for (int ctb_iIdx = 0; ctb_iIdx < num_ctus_in_pic; ctb_iIdx++) for (uint32_t ctb_iIdx = 0; ctb_iIdx < num_ctus_in_pic; ctb_iIdx++)
{ {
alf_info->alf_ctb_filter_index[ctb_iIdx] = ALF_NUM_FIXED_FILTER_SETS; alf_info->alf_ctb_filter_index[ctb_iIdx] = ALF_NUM_FIXED_FILTER_SETS;
} }

View file

@ -204,7 +204,7 @@ void uvg_cabac_encode_trunc_bin(cabac_data_t * const data, const uint32_t bin_va
int thresh; int thresh;
int symbol = bin_value; int symbol = bin_value;
if (max_value > 256) { if (max_value > 256) {
int threshVal = 1 << 8; uint32_t threshVal = 1 << 8;
thresh = 8; thresh = 8;
while (threshVal <= max_value) { while (threshVal <= max_value) {
thresh++; thresh++;
@ -329,11 +329,11 @@ void uvg_cabac_write_coeff_remain(cabac_data_t * const cabac, const uint32_t rem
unsigned prefix_length = 0; unsigned prefix_length = 0;
unsigned code_value = (bins >> rice_param) - cutoff; unsigned code_value = (bins >> rice_param) - cutoff;
unsigned suffix_length; unsigned suffix_length;
if (code_value >= ((1 << max_prefix_length) - 1)) { if ((int32_t)code_value >= ((1 << max_prefix_length) - 1)) {
prefix_length = max_prefix_length; prefix_length = max_prefix_length;
suffix_length = 15 /*max_log2_tr_dynamic_range*/; suffix_length = 15 /*max_log2_tr_dynamic_range*/;
} else { } else {
while (code_value > ((2 << prefix_length) - 2)) { while ((int32_t)code_value > ((2 << prefix_length) - 2)) {
prefix_length++; prefix_length++;
} }
suffix_length = prefix_length + rice_param + 1; suffix_length = prefix_length + rice_param + 1;

View file

@ -1477,18 +1477,18 @@ void uvg_config_process_lp_gop(uvg_config *cfg)
// Initialize modulos for testing depth. // Initialize modulos for testing depth.
// The picture belong to the lowest depth in which (poc % modulo) == 0. // The picture belong to the lowest depth in which (poc % modulo) == 0.
unsigned depth_modulos[8] = { 0 }; unsigned depth_modulos[8] = { 0 };
for (int d = 0; d < gop.d; ++d) { for (uint32_t d = 0; d < gop.d; ++d) {
depth_modulos[gop.d - 1 - d] = 1 << d; depth_modulos[gop.d - 1 - d] = 1 << d;
} }
depth_modulos[0] = gop.g; depth_modulos[0] = gop.g;
cfg->gop_lowdelay = 1; cfg->gop_lowdelay = 1;
cfg->gop_len = gop.g; cfg->gop_len = gop.g;
for (int g = 1; g <= gop.g; ++g) { for (uint32_t g = 1; g <= gop.g; ++g) {
uvg_gop_config *gop_pic = &cfg->gop[g - 1]; uvg_gop_config *gop_pic = &cfg->gop[g - 1];
// Find gop depth for picture. // Find gop depth for picture.
int gop_layer = 1; uint32_t gop_layer = 1;
while (gop_layer < gop.d && (g % depth_modulos[gop_layer - 1])) { while (gop_layer < gop.d && (g % depth_modulos[gop_layer - 1])) {
++gop_layer; ++gop_layer;
} }
@ -1541,7 +1541,7 @@ void uvg_config_process_lp_gop(uvg_config *cfg)
gop_pic->qp_factor = 0.4624; // from HM gop_pic->qp_factor = 0.4624; // from HM
} }
for (int g = 0; g < gop.g; ++g) { for (uint32_t g = 0; g < gop.g; ++g) {
uvg_gop_config *gop_pic = &cfg->gop[g]; uvg_gop_config *gop_pic = &cfg->gop[g];
if (!gop_pic->is_ref) { if (!gop_pic->is_ref) {
gop_pic->qp_factor = 0.68 * 1.31; // derived from HM gop_pic->qp_factor = 0.68 * 1.31; // derived from HM
@ -1915,7 +1915,7 @@ static int validate_hevc_level(uvg_config *const cfg) {
cfg->max_bitrate = LEVEL_CONSTRAINTS[lvl_idx].main_bitrate * 1000; cfg->max_bitrate = LEVEL_CONSTRAINTS[lvl_idx].main_bitrate * 1000;
} }
if (cfg->target_bitrate > cfg->max_bitrate) { if (cfg->target_bitrate > (int32_t)cfg->max_bitrate) {
fprintf(stderr, "%s: target bitrate exceeds %i, which is the maximum %s tier level %g bitrate\n", fprintf(stderr, "%s: target bitrate exceeds %i, which is the maximum %s tier level %g bitrate\n",
level_err_prefix, cfg->max_bitrate, cfg->high_tier?"high":"main", lvl); level_err_prefix, cfg->max_bitrate, cfg->high_tier?"high":"main", lvl);
level_error = 1; level_error = 1;
@ -1934,14 +1934,14 @@ static int validate_hevc_level(uvg_config *const cfg) {
uint32_t max_dimension_squared = 8 * max_lps; uint32_t max_dimension_squared = 8 * max_lps;
// check maximum dimensions // check maximum dimensions
if (cfg->width * cfg->width > max_dimension_squared) { if (cfg->width * cfg->width > (int32_t)max_dimension_squared) {
uint32_t max_dim = sqrtf(max_dimension_squared); uint32_t max_dim = (uint32_t)sqrtf((float)max_dimension_squared);
fprintf(stderr, "%s: picture width of %i is too large for this level (%g), maximum dimension is %i\n", fprintf(stderr, "%s: picture width of %i is too large for this level (%g), maximum dimension is %i\n",
level_err_prefix, cfg->width, lvl, max_dim); level_err_prefix, cfg->width, lvl, max_dim);
level_error = 1; level_error = 1;
} }
if (cfg->height * cfg->height > max_dimension_squared) { if (cfg->height * cfg->height > (int32_t)max_dimension_squared) {
uint32_t max_dim = sqrtf(max_dimension_squared); uint32_t max_dim = (uint32_t)sqrtf((float)max_dimension_squared);
fprintf(stderr, "%s: picture height of %i is too large for this level (%g), maximum dimension is %i\n", fprintf(stderr, "%s: picture height of %i is too large for this level (%g), maximum dimension is %i\n",
level_err_prefix, cfg->height, lvl, max_dim); level_err_prefix, cfg->height, lvl, max_dim);
level_error = 1; level_error = 1;

View file

@ -638,7 +638,7 @@ uint32_t uvg_context_get_sig_coeff_group_ts(uint32_t* sig_coeff_group_flag,
* \param temp_sum temporary output value used in the next steps * \param temp_sum temporary output value used in the next steps
* \returns context index for current scan position * \returns context index for current scan position
*/ */
uint32_t uvg_context_get_sig_ctx_idx_abs(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, uint32_t uvg_context_get_sig_ctx_idx_abs(const coeff_t* coeff, uint32_t pos_x, uint32_t pos_y,
uint32_t height, uint32_t width, int8_t type, uint32_t height, uint32_t width, int8_t type,
int32_t* temp_diag, int32_t* temp_sum) int32_t* temp_diag, int32_t* temp_sum)
{ {
@ -796,7 +796,7 @@ unsigned uvg_lrg1_ctx_id_abs_ts(const coeff_t* coeff, int32_t pos_x, int32_t pos
* \param height height of the block * \param height height of the block
* \returns context go rice parameter * \returns context go rice parameter
*/ */
uint32_t uvg_abs_sum(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, uint32_t uvg_abs_sum(const coeff_t* coeff, uint32_t pos_x, uint32_t pos_y,
uint32_t height, uint32_t width, uint32_t baselevel) uint32_t height, uint32_t width, uint32_t baselevel)
{ {
#define UPDATE(x) sum+=abs(x)/*-(x?1:0)*/ #define UPDATE(x) sum+=abs(x)/*-(x?1:0)*/
@ -838,35 +838,9 @@ uint32_t uvg_abs_sum(const coeff_t* coeff, int32_t pos_x, int32_t pos_y,
* \param height height of the block * \param height height of the block
* \returns context go rice parameter * \returns context go rice parameter
*/ */
uint32_t uvg_go_rice_par_abs(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, uint32_t uvg_go_rice_par_abs(const coeff_t* coeff, uint32_t pos_x, uint32_t pos_y,
uint32_t height, uint32_t width, uint32_t baselevel) uint32_t height, uint32_t width, uint32_t baselevel)
{ {
//#define UPDATE(x) sum+=abs(x)/*-(x?1:0)*/
//
// const coeff_t* data = coeff + pos_x + pos_y * width;
// int sum = 0;
// if (pos_x < width - 1)
// {
// UPDATE(data[1]);
// if (pos_x < width - 2)
// {
// UPDATE(data[2]);
// }
// if (pos_y < height - 1)
// {
// UPDATE(data[width + 1]);
// }
// }
// if (pos_y < height - 1)
// {
// UPDATE(data[width]);
// if (pos_y < height - 2)
// {
// UPDATE(data[width << 1]);
// }
// }
//#undef UPDATE
uint32_t check = uvg_abs_sum(coeff, pos_x, pos_y, height, width, baselevel); uint32_t check = uvg_abs_sum(coeff, pos_x, pos_y, height, width, baselevel);
return g_go_rice_pars[check]; return g_go_rice_pars[check];
/*return g_go_rice_pars[uvg_abs_sum(coeff, pos_x, pos_y, height, width, baselevel)];*/
} }

View file

@ -51,7 +51,7 @@ void uvg_context_copy(encoder_state_t * target_state, const encoder_state_t * so
uint32_t uvg_context_get_sig_coeff_group( uint32_t *sig_coeff_group_flag,uint32_t pos_x, uint32_t pos_y,int32_t width); uint32_t uvg_context_get_sig_coeff_group( uint32_t *sig_coeff_group_flag,uint32_t pos_x, uint32_t pos_y,int32_t width);
uint32_t uvg_context_get_sig_coeff_group_ts(uint32_t* sig_coeff_group_flag, uint32_t pos_x, uint32_t pos_y, int32_t width); uint32_t uvg_context_get_sig_coeff_group_ts(uint32_t* sig_coeff_group_flag, uint32_t pos_x, uint32_t pos_y, int32_t width);
uint32_t uvg_context_get_sig_ctx_idx_abs(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, uint32_t uvg_context_get_sig_ctx_idx_abs(const coeff_t* coeff, uint32_t pos_x, uint32_t pos_y,
uint32_t height, uint32_t width, int8_t type, uint32_t height, uint32_t width, int8_t type,
int32_t* temp_diag, int32_t* temp_sum); int32_t* temp_diag, int32_t* temp_sum);
@ -62,10 +62,10 @@ int32_t uvg_derive_mod_coeff(int rightPixel, int belowPixel, coeff_t absCoeff, i
unsigned uvg_lrg1_ctx_id_abs_ts(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, int32_t width, int bdpcm); unsigned uvg_lrg1_ctx_id_abs_ts(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, int32_t width, int bdpcm);
uint32_t uvg_abs_sum(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, uint32_t uvg_abs_sum(const coeff_t* coeff, uint32_t pos_x, uint32_t pos_y,
uint32_t height, uint32_t width, uint32_t baselevel); uint32_t height, uint32_t width, uint32_t baselevel);
uint32_t uvg_go_rice_par_abs(const coeff_t* coeff, int32_t pos_x, int32_t pos_y, uint32_t uvg_go_rice_par_abs(const coeff_t* coeff, uint32_t pos_x, uint32_t pos_y,
uint32_t height, uint32_t width, uint32_t baselevel); uint32_t height, uint32_t width, uint32_t baselevel);
#define CNU 35 #define CNU 35

View file

@ -50,9 +50,9 @@
static bool is_mts_allowed(encoder_state_t * const state, cu_info_t *const pred_cu) static bool is_mts_allowed(encoder_state_t * const state, cu_info_t *const pred_cu)
{ {
uint32_t ts_max_size = 1 << 2; //cu.cs->sps->getLog2MaxTransformSkipBlockSize(); uint32_t ts_max_size = 1 << 2; //cu.cs->sps->getLog2MaxTransformSkipBlockSize();
const int max_size = 32; // CU::isIntra(cu) ? MTS_INTRA_MAX_CU_SIZE : MTS_INTER_MAX_CU_SIZE; const uint32_t max_size = 32; // CU::isIntra(cu) ? MTS_INTRA_MAX_CU_SIZE : MTS_INTER_MAX_CU_SIZE;
const int cu_width = LCU_WIDTH >> pred_cu->depth; const uint32_t cu_width = LCU_WIDTH >> pred_cu->depth;
const int cu_height = LCU_WIDTH >> pred_cu->depth; const uint32_t cu_height = LCU_WIDTH >> pred_cu->depth;
//bool mts_allowed = cu.chType == CHANNEL_TYPE_LUMA && compID == COMPONENT_Y; //bool mts_allowed = cu.chType == CHANNEL_TYPE_LUMA && compID == COMPONENT_Y;
uint8_t mts_type = state->encoder_control->cfg.mts; uint8_t mts_type = state->encoder_control->cfg.mts;
@ -109,7 +109,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
int8_t scan_mode) { int8_t scan_mode) {
//const encoder_control_t * const encoder = state->encoder_control; //const encoder_control_t * const encoder = state->encoder_control;
//int c1 = 1; //int c1 = 1;
int32_t i; uint32_t i;
int32_t blk_pos; int32_t blk_pos;
// ToDo: large block support in VVC? // ToDo: large block support in VVC?
uint32_t sig_coeffgroup_flag[32 * 32] = { 0 }; uint32_t sig_coeffgroup_flag[32 * 32] = { 0 };
@ -132,7 +132,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
unsigned scan_cg_last = (unsigned )-1; unsigned scan_cg_last = (unsigned )-1;
//unsigned scan_pos_last = (unsigned )-1; //unsigned scan_pos_last = (unsigned )-1;
for (int i = 0; i < width * width; i++) { for (i = 0; i < width * width; i++) {
if (coeff[scan[i]]) { if (coeff[scan[i]]) {
//scan_pos_last = i; //scan_pos_last = i;
sig_coeffgroup_flag[scan_cg[i >> log2_cg_size]] = 1; sig_coeffgroup_flag[scan_cg[i >> log2_cg_size]] = 1;
@ -227,8 +227,8 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
} }
int cutoffVal = 2; uint32_t cutoffVal = 2;
int numGtBins = 4; uint32_t numGtBins = 4;
for (int scanPos = firstSigPos; scanPos <= min_sub_pos && maxCtxBins >= 4; scanPos++) for (int scanPos = firstSigPos; scanPos <= min_sub_pos && maxCtxBins >= 4; scanPos++)
{ {
blk_pos = scan[scanPos]; blk_pos = scan[scanPos];
@ -239,7 +239,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
belowPixel = pos_y > 0 ? coeff[pos_x + (pos_y - 1) * width] : 0; belowPixel = pos_y > 0 ? coeff[pos_x + (pos_y - 1) * width] : 0;
absLevel = uvg_derive_mod_coeff(rightPixel, belowPixel, abs(coeff[blk_pos]), 0); absLevel = uvg_derive_mod_coeff(rightPixel, belowPixel, abs(coeff[blk_pos]), 0);
cutoffVal = 2; cutoffVal = 2;
for (int i = 0; i < numGtBins; i++) for (i = 0; i < numGtBins; i++)
{ {
if (absLevel >= cutoffVal) if (absLevel >= cutoffVal)
{ {

View file

@ -981,7 +981,7 @@ static void encoder_state_entry_points_explore(const encoder_state_t * const sta
int i; int i;
for (i = 0; state->children[i].encoder_control; ++i) { for (i = 0; state->children[i].encoder_control; ++i) {
if (state->children[i].is_leaf) { if (state->children[i].is_leaf) {
const int my_length = uvg_bitstream_tell(&state->children[i].stream)/8; const int my_length = (const int)uvg_bitstream_tell(&state->children[i].stream)/8;
++(*r_count); ++(*r_count);
if (my_length > *r_max_length) { if (my_length > *r_max_length) {
*r_max_length = my_length; *r_max_length = my_length;
@ -996,7 +996,7 @@ static void encoder_state_write_bitstream_entry_points_write(bitstream_t * const
int i; int i;
for (i = 0; state->children[i].encoder_control; ++i) { for (i = 0; state->children[i].encoder_control; ++i) {
if (state->children[i].is_leaf) { if (state->children[i].is_leaf) {
const int my_length = uvg_bitstream_tell(&state->children[i].stream)/8; const int my_length = (const int)uvg_bitstream_tell(&state->children[i].stream)/8;
++(*r_count); ++(*r_count);
//Don't write the last one //Don't write the last one
if (*r_count < num_entry_points) { if (*r_count < num_entry_points) {
@ -1144,9 +1144,9 @@ static void uvg_encoder_state_write_bitstream_ref_pic_list(
struct bitstream_t* const stream, struct bitstream_t* const stream,
struct encoder_state_t* const state) struct encoder_state_t* const state)
{ {
int j; uint32_t j;
int ref_negative = 0; uint32_t ref_negative = 0;
int ref_positive = 0; uint32_t ref_positive = 0;
const encoder_control_t* const encoder = state->encoder_control; const encoder_control_t* const encoder = state->encoder_control;
if (encoder->cfg.gop_len) { if (encoder->cfg.gop_len) {
for (j = 0; j < state->frame->ref->used_size; j++) { for (j = 0; j < state->frame->ref->used_size; j++) {
@ -1176,7 +1176,7 @@ static void uvg_encoder_state_write_bitstream_ref_pic_list(
int8_t found = 0; int8_t found = 0;
do { do {
delta_poc = encoder->cfg.gop[state->frame->gop_offset].ref_neg[j + poc_shift]; delta_poc = encoder->cfg.gop[state->frame->gop_offset].ref_neg[j + poc_shift];
for (int i = 0; i < state->frame->ref->used_size; i++) { for (uint32_t i = 0; i < state->frame->ref->used_size; i++) {
if (state->frame->ref->pocs[i] == state->frame->poc - delta_poc) { if (state->frame->ref->pocs[i] == state->frame->poc - delta_poc) {
found = 1; found = 1;
break; break;
@ -1213,7 +1213,7 @@ static void uvg_encoder_state_write_bitstream_ref_pic_list(
int8_t found = 0; int8_t found = 0;
do { do {
delta_poc = encoder->cfg.gop[state->frame->gop_offset].ref_pos[j + poc_shift]; delta_poc = encoder->cfg.gop[state->frame->gop_offset].ref_pos[j + poc_shift];
for (int i = 0; i < state->frame->ref->used_size; i++) { for (uint32_t i = 0; i < state->frame->ref->used_size; i++) {
if (state->frame->ref->pocs[i] == state->frame->poc + delta_poc) { if (state->frame->ref->pocs[i] == state->frame->poc + delta_poc) {
found = 1; found = 1;
break; break;
@ -1336,7 +1336,7 @@ void uvg_encoder_state_write_bitstream_slice_header(
int ref_positive = 0; int ref_positive = 0;
const encoder_control_t* const encoder = state->encoder_control; const encoder_control_t* const encoder = state->encoder_control;
if (encoder->cfg.gop_len) { if (encoder->cfg.gop_len) {
for (int j = 0; j < state->frame->ref->used_size; j++) { for (uint32_t j = 0; j < state->frame->ref->used_size; j++) {
if (state->frame->ref->pocs[j] < state->frame->poc) { if (state->frame->ref->pocs[j] < state->frame->poc) {
ref_negative++; ref_negative++;
} }
@ -1573,7 +1573,7 @@ static void encoder_state_write_bitstream_main(encoder_state_t * const state)
//Get bitstream length for stats //Get bitstream length for stats
uint64_t newpos = uvg_bitstream_tell(stream); uint64_t newpos = uvg_bitstream_tell(stream);
state->stats_bitstream_length = (newpos >> 3) - (curpos >> 3); state->stats_bitstream_length = (uint32_t)((newpos >> 3) - (curpos >> 3));
if (state->frame->num > 0) { if (state->frame->num > 0) {
state->frame->total_bits_coded = state->previous_encoder_state->frame->total_bits_coded; state->frame->total_bits_coded = state->previous_encoder_state->frame->total_bits_coded;

View file

@ -362,7 +362,7 @@ int uvg_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
//Create sub-encoders //Create sub-encoders
{ {
const encoder_control_t * const encoder = child_state->encoder_control; const encoder_control_t * const encoder = child_state->encoder_control;
int child_count = 0; uint32_t child_count = 0;
//We first check the type of this element. //We first check the type of this element.
//If it's a MAIN, it can allow both slices or tiles as child //If it's a MAIN, it can allow both slices or tiles as child
//If it's a TILE, it can allow slices as child, if its parent is not a slice, or wavefront rows if there is no other children //If it's a TILE, it can allow slices as child, if its parent is not a slice, or wavefront rows if there is no other children
@ -493,7 +493,7 @@ int uvg_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
//Fix children parent (since we changed the address), except for the last one which is not ready yet //Fix children parent (since we changed the address), except for the last one which is not ready yet
{ {
int i, j; uint32_t i, j;
for (i = 0; child_state->children[i].encoder_control && i < child_count; ++i) { for (i = 0; child_state->children[i].encoder_control && i < child_count; ++i) {
for (j = 0; child_state->children[i].children[j].encoder_control; ++j) { for (j = 0; child_state->children[i].children[j].encoder_control; ++j) {
child_state->children[i].children[j].parent = &child_state->children[i]; child_state->children[i].children[j].parent = &child_state->children[i];
@ -579,7 +579,6 @@ int uvg_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
//Remark: this could be optimized, but since it's run only once, it's better to do it in a understandable way. //Remark: this could be optimized, but since it's run only once, it's better to do it in a understandable way.
//By default, the full tile //By default, the full tile
int i;
int lcu_id; int lcu_id;
int lcu_start = 0; int lcu_start = 0;
//End is the element AFTER the end (iterate < lcu_end) //End is the element AFTER the end (iterate < lcu_end)
@ -599,7 +598,7 @@ int uvg_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
child_state->lcu_order = MALLOC(lcu_order_element_t, child_state->lcu_order_count); child_state->lcu_order = MALLOC(lcu_order_element_t, child_state->lcu_order_count);
assert(child_state->lcu_order); assert(child_state->lcu_order);
for (i = 0; i < child_state->lcu_order_count; ++i) { for (uint32_t i = 0; i < child_state->lcu_order_count; ++i) {
lcu_id = lcu_start + i; lcu_id = lcu_start + i;
child_state->lcu_order[i].encoder_state = child_state; child_state->lcu_order[i].encoder_state = child_state;
child_state->lcu_order[i].id = lcu_id; child_state->lcu_order[i].id = lcu_id;
@ -623,11 +622,11 @@ int uvg_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
if (!child_state->lcu_order[i].first_row) { if (!child_state->lcu_order[i].first_row) {
//Find LCU above //Find LCU above
if (child_state->type == ENCODER_STATE_TYPE_WAVEFRONT_ROW) { if (child_state->type == ENCODER_STATE_TYPE_WAVEFRONT_ROW) {
int j; uint32_t j;
//For all previous wavefront rows //For all previous wavefront rows
for (j=0; &child_state->parent->children[j] != child_state && child_state->parent->children[j].encoder_control; ++j) { for (j=0; &child_state->parent->children[j] != child_state && child_state->parent->children[j].encoder_control; ++j) {
if (child_state->parent->children[j].wfrow->lcu_offset_y == child_state->wfrow->lcu_offset_y - 1) { if (child_state->parent->children[j].wfrow->lcu_offset_y == child_state->wfrow->lcu_offset_y - 1) {
int k; uint32_t k;
for (k=0; k < child_state->parent->children[j].lcu_order_count; ++k) { for (k=0; k < child_state->parent->children[j].lcu_order_count; ++k) {
if (child_state->parent->children[j].lcu_order[k].position.x == child_state->lcu_order[i].position.x) { if (child_state->parent->children[j].lcu_order[k].position.x == child_state->lcu_order[i].position.x) {
assert(child_state->parent->children[j].lcu_order[k].position.y == child_state->lcu_order[i].position.y - 1); assert(child_state->parent->children[j].lcu_order[k].position.y == child_state->lcu_order[i].position.y - 1);

View file

@ -817,7 +817,7 @@ static void encoder_state_worker_encode_lcu_bitstream(void * opaque)
pthread_mutex_lock(&state->frame->rc_lock); pthread_mutex_lock(&state->frame->rc_lock);
const uint32_t bits = uvg_bitstream_tell(&state->stream) - existing_bits; const uint32_t bits = (const uint32_t)(uvg_bitstream_tell(&state->stream) - existing_bits);
state->frame->cur_frame_bits_coded += bits; state->frame->cur_frame_bits_coded += bits;
// This variable is used differently by intra and inter frames and shouldn't // This variable is used differently by intra and inter frames and shouldn't
// be touched in intra frames here // be touched in intra frames here
@ -902,7 +902,7 @@ static void encoder_state_encode_leaf(encoder_state_t * const state)
// Encode every LCU in order and perform SAO reconstruction after every // Encode every LCU in order and perform SAO reconstruction after every
// frame is encoded. Deblocking and SAO search is done during LCU encoding. // frame is encoded. Deblocking and SAO search is done during LCU encoding.
for (int i = 0; i < state->lcu_order_count; ++i) { for (uint32_t i = 0; i < state->lcu_order_count; ++i) {
encoder_state_worker_encode_lcu_search(&state->lcu_order[i]); encoder_state_worker_encode_lcu_search(&state->lcu_order[i]);
// Without alf we can code the bitstream right after each LCU to update cabac contexts // Without alf we can code the bitstream right after each LCU to update cabac contexts
if (encoder->cfg.alf_type == 0) { if (encoder->cfg.alf_type == 0) {
@ -916,7 +916,7 @@ static void encoder_state_encode_leaf(encoder_state_t * const state)
// If ALF was used the bitstream coding was simulated in search, reset the cabac/stream // If ALF was used the bitstream coding was simulated in search, reset the cabac/stream
// And write the actual bitstream // And write the actual bitstream
encoder_state_init_children_after_simulation(state); encoder_state_init_children_after_simulation(state);
for (int i = 0; i < state->lcu_order_count; ++i) { for (uint32_t i = 0; i < state->lcu_order_count; ++i) {
encoder_state_worker_encode_lcu_bitstream(&state->lcu_order[i]); encoder_state_worker_encode_lcu_bitstream(&state->lcu_order[i]);
} }
} }
@ -952,7 +952,7 @@ static void encoder_state_encode_leaf(encoder_state_t * const state)
ref_state = state->previous_encoder_state; ref_state = state->previous_encoder_state;
} }
for (int i = 0; i < state->lcu_order_count; ++i) { for (uint32_t i = 0; i < state->lcu_order_count; ++i) {
const lcu_order_element_t * const lcu = &state->lcu_order[i]; const lcu_order_element_t * const lcu = &state->lcu_order[i];
uvg_threadqueue_free_job(&state->tile->wf_jobs[lcu->id]); uvg_threadqueue_free_job(&state->tile->wf_jobs[lcu->id]);
@ -1261,7 +1261,7 @@ void uvg_encoder_create_ref_lists(const encoder_state_t *const state)
int num_positive = 0; int num_positive = 0;
// Add positive references to L1 list // Add positive references to L1 list
for (int i = 0; i < state->frame->ref->used_size; i++) { for (uint32_t i = 0; i < state->frame->ref->used_size; i++) {
if (state->frame->ref->pocs[i] > state->frame->poc) { if (state->frame->ref->pocs[i] > state->frame->poc) {
state->frame->ref_LX[1][state->frame->ref_LX_size[1]] = i; state->frame->ref_LX[1][state->frame->ref_LX_size[1]] = i;
state->frame->ref_LX_size[1] += 1; state->frame->ref_LX_size[1] += 1;
@ -1275,7 +1275,7 @@ void uvg_encoder_create_ref_lists(const encoder_state_t *const state)
(cfg->bipred && (cfg->gop_len == 0 || cfg->gop_lowdelay)); (cfg->bipred && (cfg->gop_len == 0 || cfg->gop_lowdelay));
// Add negative references to L0 and L1 lists. // Add negative references to L0 and L1 lists.
for (int i = 0; i < state->frame->ref->used_size; i++) { for (uint32_t i = 0; i < state->frame->ref->used_size; i++) {
if (state->frame->ref->pocs[i] < state->frame->poc) { if (state->frame->ref->pocs[i] < state->frame->poc) {
state->frame->ref_LX[0][state->frame->ref_LX_size[0]] = i; state->frame->ref_LX[0][state->frame->ref_LX_size[0]] = i;
state->frame->ref_LX_size[0] += 1; state->frame->ref_LX_size[0] += 1;
@ -1517,7 +1517,7 @@ static void init_erp_aqp_roi(const encoder_control_t *encoder, uvg_picture *fram
// Normalize. // Normalize.
lcu_weight = (lcu_weight * frame_height) / (total_weight * lcu_height); lcu_weight = (lcu_weight * frame_height) / (total_weight * lcu_height);
int8_t qp_delta = round(-ERP_AQP_STRENGTH * log2(lcu_weight)); int8_t qp_delta = (int8_t)(round(-ERP_AQP_STRENGTH * log2(lcu_weight)));
if (orig_roi) { if (orig_roi) {
// If a ROI array already exists, we copy the existing values to the // If a ROI array already exists, we copy the existing values to the
@ -1595,7 +1595,7 @@ static void next_roi_frame_from_file(uvg_picture *frame, FILE *file, enum uvg_ro
frame->roi.roi_array = dqp_array; frame->roi.roi_array = dqp_array;
if (format == UVG_ROI_TXT) { if (format == UVG_ROI_TXT) {
for (int i = 0; i < size; ++i) { for (uint32_t i = 0; i < size; ++i) {
int number; // Need a pointer to int for fscanf int number; // Need a pointer to int for fscanf
if (fscanf(file, "%d", &number) != 1) { if (fscanf(file, "%d", &number) != 1) {
fprintf(stderr, "Reading ROI file failed.\n"); fprintf(stderr, "Reading ROI file failed.\n");
@ -1663,8 +1663,8 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, uvg_pict
unsigned y_lim = state->tile->frame->height_in_lcu; unsigned y_lim = state->tile->frame->height_in_lcu;
unsigned id = 0; unsigned id = 0;
for (int y = 0; y < y_lim; ++y) { for (uint32_t y = 0; y < y_lim; ++y) {
for (int x = 0; x < x_lim; ++x) { for (uint32_t x = 0; x < x_lim; ++x) {
uvg_pixel tmp[LCU_LUMA_SIZE]; uvg_pixel tmp[LCU_LUMA_SIZE];
int pxl_x = x * LCU_WIDTH; int pxl_x = x * LCU_WIDTH;
int pxl_y = y * LCU_WIDTH; int pxl_y = y * LCU_WIDTH;

View file

@ -35,7 +35,7 @@
#include "encoderstate.h" #include "encoderstate.h"
// Note: Assumes that costs are non-negative, for pretty obvious reasons // Note: Assumes that costs are non-negative, for pretty obvious reasons
static uint16_t to_q88(float f) static uint16_t to_q88(double f)
{ {
return (uint16_t)(f * 256.0f + 0.5f); return (uint16_t)(f * 256.0f + 0.5f);
} }

View file

@ -241,17 +241,17 @@ static INLINE void uvg_filter_deblock_chroma(const encoder_control_t * const enc
if (part_P_nofilter) { if (part_P_nofilter) {
if (large_boundary) { if (large_boundary) {
src[-offset * 3] = m1; src[-offset * 3] = (uvg_pixel)m1;
src[-offset * 2] = m2; src[-offset * 2] = (uvg_pixel)m2;
} }
src[-offset * 1] = m3; src[-offset * 1] = (uvg_pixel)m3;
} }
if (part_Q_nofilter) { if (part_Q_nofilter) {
if (large_boundary) { if (large_boundary) {
src[offset * 1] = m5; src[offset * 1] = (uvg_pixel)m5;
src[offset * 2] = m6; src[offset * 2] = (uvg_pixel)m6;
} }
src[0] = m4; src[0] = (uvg_pixel)m4;
} }
} }

View file

@ -186,13 +186,13 @@ int uvg_image_list_rem(image_list_t * const list, const unsigned n)
} }
list->used_size--; list->used_size--;
} else { } else {
int i = n; uint32_t i = n;
// Shift all following pics one backward in the list // Shift all following pics one backward in the list
for (i = n; i < list->used_size - 1; ++i) { for (i = n; i < list->used_size - 1; ++i) {
list->images[i] = list->images[i + 1]; list->images[i] = list->images[i + 1];
list->cu_arrays[i] = list->cu_arrays[i + 1]; list->cu_arrays[i] = list->cu_arrays[i + 1];
list->pocs[i] = list->pocs[i + 1]; list->pocs[i] = list->pocs[i + 1];
for (int j = 0; j < 16; j++) { for (uint32_t j = 0; j < 16; j++) {
list->ref_LXs[i][0][j] = list->ref_LXs[i + 1][0][j]; list->ref_LXs[i][0][j] = list->ref_LXs[i + 1][0][j];
list->ref_LXs[i][1][j] = list->ref_LXs[i + 1][1][j]; list->ref_LXs[i][1][j] = list->ref_LXs[i + 1][1][j];
} }

View file

@ -162,12 +162,12 @@ uvg_picture* uvg_encoder_feed_frame(input_frame_buffer_t *buf,
if (!cfg->open_gop && cfg->intra_period > 0) { if (!cfg->open_gop && cfg->intra_period > 0) {
// Offset the GOP position for each extra I-frame added to the structure // Offset the GOP position for each extra I-frame added to the structure
// in closed gop case // in closed gop case
int num_extra_frames = (buf->num_out - 1) / (cfg->intra_period + 1); int32_t num_extra_frames = (int32_t)((buf->num_out - 1) / (cfg->intra_period + 1));
gop_offset = (buf->num_out - 1 - num_extra_frames) % cfg->gop_len; gop_offset = (buf->num_out - 1 - num_extra_frames) % cfg->gop_len;
} }
// Index of the first picture in the GOP that is being output. // Index of the first picture in the GOP that is being output.
int gop_start_idx = buf->num_out - 1 - gop_offset; int32_t gop_start_idx = (int32_t)(buf->num_out - 1 - gop_offset);
// Skip pictures until we find an available one. // Skip pictures until we find an available one.
gop_offset += buf->gop_skipped; gop_offset += buf->gop_skipped;
@ -179,7 +179,7 @@ uvg_picture* uvg_encoder_feed_frame(input_frame_buffer_t *buf,
for (;;) { for (;;) {
assert(gop_offset < cfg->gop_len + is_closed_gop ? 1 : 0); assert(gop_offset < cfg->gop_len + is_closed_gop ? 1 : 0);
idx_out = gop_start_idx + cfg->gop[gop_offset].poc_offset - 1; idx_out = gop_start_idx + cfg->gop[gop_offset].poc_offset - 1;
if (idx_out < buf->num_in - 1) { if (idx_out < (int64_t)buf->num_in - 1) {
// An available picture found. // An available picture found.
break; break;
} }
@ -191,10 +191,10 @@ uvg_picture* uvg_encoder_feed_frame(input_frame_buffer_t *buf,
if (buf->num_out < cfg->gop_len - 1) { if (buf->num_out < cfg->gop_len - 1) {
// This picture needs a DTS that is less than the PTS of the first // This picture needs a DTS that is less than the PTS of the first
// frame so the delay must be applied. // frame so the delay must be applied.
int dts_idx = buf->num_out - 1; int32_t dts_idx = (int32_t)(buf->num_out - 1);
dts_out = buf->pts_buffer[dts_idx % gop_buf_size] + buf->delay; dts_out = buf->pts_buffer[dts_idx % gop_buf_size] + buf->delay;
} else { } else {
int dts_idx = buf->num_out - (cfg->gop_len - 1); int32_t dts_idx = (int32_t)(buf->num_out - (cfg->gop_len - 1));
dts_out = buf->pts_buffer[dts_idx % gop_buf_size] - 1; dts_out = buf->pts_buffer[dts_idx % gop_buf_size] - 1;
} }
} }

View file

@ -890,8 +890,8 @@ static void get_temporal_merge_candidates(const encoder_state_t * const state,
cu_array_t *ref_cu_array = state->frame->ref->cu_arrays[colocated_ref]; cu_array_t *ref_cu_array = state->frame->ref->cu_arrays[colocated_ref];
int cu_per_width = ref_cu_array->width / SCU_WIDTH; int cu_per_width = ref_cu_array->width / SCU_WIDTH;
uint32_t xColBr = x + width; int32_t xColBr = x + width;
uint32_t yColBr = y + height; int32_t yColBr = y + height;
// C0 must be available // C0 must be available
if (xColBr < state->encoder_control->in.width && if (xColBr < state->encoder_control->in.width &&
@ -911,8 +911,8 @@ static void get_temporal_merge_candidates(const encoder_state_t * const state,
} }
} }
} }
uint32_t xColCtr = x + (width / 2); int32_t xColCtr = x + (width / 2);
uint32_t yColCtr = y + (height / 2); int32_t yColCtr = y + (height / 2);
// C1 must be inside the LCU, in the center position of current CU // C1 must be inside the LCU, in the center position of current CU
if (xColCtr < state->encoder_control->in.width && yColCtr < state->encoder_control->in.height) { if (xColCtr < state->encoder_control->in.width && yColCtr < state->encoder_control->in.height) {
@ -1222,7 +1222,7 @@ static bool add_temporal_candidate(const encoder_state_t *state,
// uvg266 always sets collocated_from_l0_flag so the list is L1 when // uvg266 always sets collocated_from_l0_flag so the list is L1 when
// there are future references. // there are future references.
int col_list = reflist; int col_list = reflist;
for (int i = 0; i < state->frame->ref->used_size; i++) { for (uint32_t i = 0; i < state->frame->ref->used_size; i++) {
if (state->frame->ref->pocs[i] > state->frame->poc) { if (state->frame->ref->pocs[i] > state->frame->poc) {
col_list = 1; col_list = 1;
break; break;
@ -1778,7 +1778,7 @@ uint8_t uvg_inter_get_merge_cand(const encoder_state_t * const state,
mv_cand[candidates].mv[reflist][0] = avg_mv[0]; mv_cand[candidates].mv[reflist][0] = avg_mv[0];
mv_cand[candidates].mv[reflist][1] = avg_mv[1]; mv_cand[candidates].mv[reflist][1] = avg_mv[1];
mv_cand[candidates].ref[reflist] = ref_i; mv_cand[candidates].ref[reflist] = (uint8_t)ref_i;
} }
// only one MV is valid, take the only one MV // only one MV is valid, take the only one MV
else if (ref_i != -1) else if (ref_i != -1)
@ -1787,7 +1787,7 @@ uint8_t uvg_inter_get_merge_cand(const encoder_state_t * const state,
mv_cand[candidates].mv[reflist][0] = mv_i[0]; mv_cand[candidates].mv[reflist][0] = mv_i[0];
mv_cand[candidates].mv[reflist][1] = mv_i[1]; mv_cand[candidates].mv[reflist][1] = mv_i[1];
mv_cand[candidates].ref[reflist] = ref_i; mv_cand[candidates].ref[reflist] = (uint8_t)ref_i;
} }
else if (ref_j != -1) else if (ref_j != -1)
{ {
@ -1795,7 +1795,7 @@ uint8_t uvg_inter_get_merge_cand(const encoder_state_t * const state,
mv_cand[candidates].mv[reflist][0] = mv_j[0]; mv_cand[candidates].mv[reflist][0] = mv_j[0];
mv_cand[candidates].mv[reflist][1] = mv_j[1]; mv_cand[candidates].mv[reflist][1] = mv_j[1];
mv_cand[candidates].ref[reflist] = ref_j; mv_cand[candidates].ref[reflist] = (uint8_t)ref_j;
} }
} }
@ -1812,10 +1812,9 @@ uint8_t uvg_inter_get_merge_cand(const encoder_state_t * const state,
int num_ref = state->frame->ref->used_size; int num_ref = state->frame->ref->used_size;
if (candidates < max_num_cands && state->frame->slicetype == UVG_SLICE_B) { if (candidates < max_num_cands && state->frame->slicetype == UVG_SLICE_B) {
int j;
int ref_negative = 0; int ref_negative = 0;
int ref_positive = 0; int ref_positive = 0;
for (j = 0; j < state->frame->ref->used_size; j++) { for (uint32_t j = 0; j < state->frame->ref->used_size; j++) {
if (state->frame->ref->pocs[j] < state->frame->poc) { if (state->frame->ref->pocs[j] < state->frame->poc) {
ref_negative++; ref_negative++;
} else { } else {

View file

@ -43,7 +43,7 @@ int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 19428.0; *p_nb_iter = 19428.0;
*p_nb_bad = 1740.0; *p_nb_bad = 1740.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_0 <= 9.1015) else if (p_features->sub_variance_0 <= 9.1015)
{ {
@ -51,36 +51,36 @@ int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1166.0; *p_nb_iter = 1166.0;
*p_nb_bad = 358.0; *p_nb_bad = 358.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1049.0; *p_nb_iter = 1049.0;
*p_nb_bad = 392.0; *p_nb_bad = 392.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 9371.0; *p_nb_iter = 9371.0;
*p_nb_bad = 1805.0; *p_nb_bad = 1805.0;
return -1.0000; return -1;
} }
} }
else if (p_features->sub_variance_2 <= 23.3193) else if (p_features->sub_variance_2 <= 23.3193)
{ {
*p_nb_iter = 1059.0; *p_nb_iter = 1059.0;
*p_nb_bad = 329.0; *p_nb_bad = 329.0;
return 1.0000; return 1;
} }
else if (p_features->sub_variance_1 <= 30.7348) else if (p_features->sub_variance_1 <= 30.7348)
{ {
*p_nb_iter = 1042.0; *p_nb_iter = 1042.0;
*p_nb_bad = 395.0; *p_nb_bad = 395.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1756.0; *p_nb_iter = 1756.0;
*p_nb_bad = 588.0; *p_nb_bad = 588.0;
return -1.0000; return -1;
} }
} }
else if (p_features->merge_variance <= 857.8047) else if (p_features->merge_variance <= 857.8047)
@ -91,7 +91,7 @@ int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 2006.0; *p_nb_iter = 2006.0;
*p_nb_bad = 374.0; *p_nb_bad = 374.0;
return 1.0000; return 1;
} }
else if (p_features->neigh_variance_C <= 646.8204) else if (p_features->neigh_variance_C <= 646.8204)
{ {
@ -103,60 +103,60 @@ int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1208.0; *p_nb_iter = 1208.0;
*p_nb_bad = 399.0; *p_nb_bad = 399.0;
return 1.0000; return 1;
} }
else if (p_features->var_of_sub_var <= 11832.6635) else if (p_features->var_of_sub_var <= 11832.6635)
{ {
*p_nb_iter = 8701.0; *p_nb_iter = 8701.0;
*p_nb_bad = 3037.0; *p_nb_bad = 3037.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_A <= 142.298) else if (p_features->neigh_variance_A <= 142.298)
{ {
*p_nb_iter = 1025.0; *p_nb_iter = 1025.0;
*p_nb_bad = 290.0; *p_nb_bad = 290.0;
return 1.0000; return 1;
} }
else if (p_features->variance <= 394.4839) else if (p_features->variance <= 394.4839)
{ {
*p_nb_iter = 1156.0; *p_nb_iter = 1156.0;
*p_nb_bad = 489.0; *p_nb_bad = 489.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1150.0; *p_nb_iter = 1150.0;
*p_nb_bad = 503.0; *p_nb_bad = 503.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1777.0; *p_nb_iter = 1777.0;
*p_nb_bad = 558.0; *p_nb_bad = 558.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 1587.0; *p_nb_iter = 1587.0;
*p_nb_bad = 411.0; *p_nb_bad = 411.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 1980.0; *p_nb_iter = 1980.0;
*p_nb_bad = 474.0; *p_nb_bad = 474.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 3613.0; *p_nb_iter = 3613.0;
*p_nb_bad = 475.0; *p_nb_bad = 475.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 20926.0; *p_nb_iter = 20926.0;
*p_nb_bad = 1873.0; *p_nb_bad = 1873.0;
return 1.0000; return 1;
} }
} }
@ -172,30 +172,30 @@ int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 29253.0; *p_nb_iter = 29253.0;
*p_nb_bad = 3837.0; *p_nb_bad = 3837.0;
return -1.0000; return -1;
} }
else if (p_features->variance <= 20.8711) else if (p_features->variance <= 20.8711)
{ {
*p_nb_iter = 1292.0; *p_nb_iter = 1292.0;
*p_nb_bad = 458.0; *p_nb_bad = 458.0;
return 2.0000; return 2;
} }
else { else {
*p_nb_iter = 1707.0; *p_nb_iter = 1707.0;
*p_nb_bad = 399.0; *p_nb_bad = 399.0;
return -1.0000; return -1;
} }
} }
else if (p_features->var_of_sub_var <= 3300.4034) else if (p_features->var_of_sub_var <= 3300.4034)
{ {
*p_nb_iter = 1554.0; *p_nb_iter = 1554.0;
*p_nb_bad = 675.0; *p_nb_bad = 675.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1540.0; *p_nb_iter = 1540.0;
*p_nb_bad = 429.0; *p_nb_bad = 429.0;
return 2.0000; return 2;
} }
} }
else if (p_features->merge_variance <= 696.1989) else if (p_features->merge_variance <= 696.1989)
@ -206,7 +206,7 @@ int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 3473.0; *p_nb_iter = 3473.0;
*p_nb_bad = 768.0; *p_nb_bad = 768.0;
return 2.0000; return 2;
} }
else if (p_features->neigh_variance_C <= 571.5329) else if (p_features->neigh_variance_C <= 571.5329)
{ {
@ -216,7 +216,7 @@ int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1887.0; *p_nb_iter = 1887.0;
*p_nb_bad = 588.0; *p_nb_bad = 588.0;
return 2.0000; return 2;
} }
else if (p_features->neigh_variance_A <= 380.5927) else if (p_features->neigh_variance_A <= 380.5927)
{ {
@ -224,48 +224,48 @@ int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1686.0; *p_nb_iter = 1686.0;
*p_nb_bad = 721.0; *p_nb_bad = 721.0;
return 2.0000; return 2;
} }
else if (p_features->neigh_variance_A <= 66.6749) else if (p_features->neigh_variance_A <= 66.6749)
{ {
*p_nb_iter = 1440.0; *p_nb_iter = 1440.0;
*p_nb_bad = 631.0; *p_nb_bad = 631.0;
return 2.0000; return 2;
} }
else { else {
*p_nb_iter = 5772.0; *p_nb_iter = 5772.0;
*p_nb_bad = 2031.0; *p_nb_bad = 2031.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1791.0; *p_nb_iter = 1791.0;
*p_nb_bad = 619.0; *p_nb_bad = 619.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 1624.0; *p_nb_iter = 1624.0;
*p_nb_bad = 494.0; *p_nb_bad = 494.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 1298.0; *p_nb_iter = 1298.0;
*p_nb_bad = 312.0; *p_nb_bad = 312.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 4577.0; *p_nb_iter = 4577.0;
*p_nb_bad = 892.0; *p_nb_bad = 892.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 21106.0; *p_nb_iter = 21106.0;
*p_nb_bad = 2744.0; *p_nb_bad = 2744.0;
return 2.0000; return 2;
} }
} }
@ -279,12 +279,12 @@ int uvg_tree_predict_merge_depth_3(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 29806.0; *p_nb_iter = 29806.0;
*p_nb_bad = 3603.0; *p_nb_bad = 3603.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1003.0; *p_nb_iter = 1003.0;
*p_nb_bad = 421.0; *p_nb_bad = 421.0;
return 3.0000; return 3;
} }
} }
else if (p_features->merge_variance <= 351.8138) else if (p_features->merge_variance <= 351.8138)
@ -301,48 +301,48 @@ int uvg_tree_predict_merge_depth_3(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1290.0; *p_nb_iter = 1290.0;
*p_nb_bad = 525.0; *p_nb_bad = 525.0;
return 3.0000; return 3;
} }
else if (p_features->neigh_variance_B <= 16.9287) else if (p_features->neigh_variance_B <= 16.9287)
{ {
*p_nb_iter = 1045.0; *p_nb_iter = 1045.0;
*p_nb_bad = 499.0; *p_nb_bad = 499.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 6901.0; *p_nb_iter = 6901.0;
*p_nb_bad = 2494.0; *p_nb_bad = 2494.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1332.0; *p_nb_iter = 1332.0;
*p_nb_bad = 408.0; *p_nb_bad = 408.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 2929.0; *p_nb_iter = 2929.0;
*p_nb_bad = 842.0; *p_nb_bad = 842.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 2239.0; *p_nb_iter = 2239.0;
*p_nb_bad = 572.0; *p_nb_bad = 572.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 2777.0; *p_nb_iter = 2777.0;
*p_nb_bad = 714.0; *p_nb_bad = 714.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 30678.0; *p_nb_iter = 30678.0;
*p_nb_bad = 5409.0; *p_nb_bad = 5409.0;
return 3.0000; return 3;
} }
} }
@ -368,54 +368,54 @@ int uvg_tree_predict_merge_depth_4(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 27398.0; *p_nb_iter = 27398.0;
*p_nb_bad = 4665.0; *p_nb_bad = 4665.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1676.0; *p_nb_iter = 1676.0;
*p_nb_bad = 795.0; *p_nb_bad = 795.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 1405.0; *p_nb_iter = 1405.0;
*p_nb_bad = 566.0; *p_nb_bad = 566.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 2827.0; *p_nb_iter = 2827.0;
*p_nb_bad = 1173.0; *p_nb_bad = 1173.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 8871.0; *p_nb_iter = 8871.0;
*p_nb_bad = 822.0; *p_nb_bad = 822.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 3162.0; *p_nb_iter = 3162.0;
*p_nb_bad = 718.0; *p_nb_bad = 718.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 6154.0; *p_nb_iter = 6154.0;
*p_nb_bad = 1397.0; *p_nb_bad = 1397.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 9385.0; *p_nb_iter = 9385.0;
*p_nb_bad = 1609.0; *p_nb_bad = 1609.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 19122.0; *p_nb_iter = 19122.0;
*p_nb_bad = 2960.0; *p_nb_bad = 2960.0;
return 4.0000; return 4;
} }
} }
@ -429,13 +429,13 @@ int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 25155.0; *p_nb_iter = 25155.0;
*p_nb_bad = 2959.0; *p_nb_bad = 2959.0;
return 0.0000; return 0;
} }
else if (p_features->sub_variance_2 <= 13.2892) else if (p_features->sub_variance_2 <= 13.2892)
{ {
*p_nb_iter = 1080.0; *p_nb_iter = 1080.0;
*p_nb_bad = 383.0; *p_nb_bad = 383.0;
return -1.0000; return -1;
} }
else if (p_features->variance <= 564.1738) else if (p_features->variance <= 564.1738)
{ {
@ -443,7 +443,7 @@ int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 6067.0; *p_nb_iter = 6067.0;
*p_nb_bad = 1699.0; *p_nb_bad = 1699.0;
return 0.0000; return 0;
} }
else if (p_features->var_of_sub_mean <= 46.2388) else if (p_features->var_of_sub_mean <= 46.2388)
{ {
@ -451,30 +451,30 @@ int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1088.0; *p_nb_iter = 1088.0;
*p_nb_bad = 377.0; *p_nb_bad = 377.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_3 <= 61.4213) else if (p_features->sub_variance_3 <= 61.4213)
{ {
*p_nb_iter = 1183.0; *p_nb_iter = 1183.0;
*p_nb_bad = 498.0; *p_nb_bad = 498.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 3416.0; *p_nb_iter = 3416.0;
*p_nb_bad = 1373.0; *p_nb_bad = 1373.0;
return 0.0000; return 0;
} }
} }
else { else {
*p_nb_iter = 3769.0; *p_nb_iter = 3769.0;
*p_nb_bad = 1093.0; *p_nb_bad = 1093.0;
return 0.0000; return 0;
} }
} }
else { else {
*p_nb_iter = 1036.0; *p_nb_iter = 1036.0;
*p_nb_bad = 434.0; *p_nb_bad = 434.0;
return -1.0000; return -1;
} }
} }
else if (p_features->var_of_sub_var <= 98333.8279) else if (p_features->var_of_sub_var <= 98333.8279)
@ -487,42 +487,42 @@ int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1323.0; *p_nb_iter = 1323.0;
*p_nb_bad = 301.0; *p_nb_bad = 301.0;
return -1.0000; return -1;
} }
else if (p_features->var_of_sub_var <= 17347.3971) else if (p_features->var_of_sub_var <= 17347.3971)
{ {
*p_nb_iter = 1215.0; *p_nb_iter = 1215.0;
*p_nb_bad = 550.0; *p_nb_bad = 550.0;
return 0.0000; return 0;
} }
else if (p_features->qp <= 22) else if (p_features->qp <= 22)
{ {
*p_nb_iter = 1000.0; *p_nb_iter = 1000.0;
*p_nb_bad = 493.0; *p_nb_bad = 493.0;
return 0.0000; return 0;
} }
else { else {
*p_nb_iter = 2640.0; *p_nb_iter = 2640.0;
*p_nb_bad = 1121.0; *p_nb_bad = 1121.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 5188.0; *p_nb_iter = 5188.0;
*p_nb_bad = 1248.0; *p_nb_bad = 1248.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 2323.0; *p_nb_iter = 2323.0;
*p_nb_bad = 274.0; *p_nb_bad = 274.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 21357.0; *p_nb_iter = 21357.0;
*p_nb_bad = 1829.0; *p_nb_bad = 1829.0;
return -1.0000; return -1;
} }
} }
@ -533,7 +533,7 @@ int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 32445.0; *p_nb_iter = 32445.0;
*p_nb_bad = 4580.0; *p_nb_bad = 4580.0;
return 1.0000; return 1;
} }
else if (p_features->var_of_sub_var <= 27289.2117) else if (p_features->var_of_sub_var <= 27289.2117)
{ {
@ -541,7 +541,7 @@ int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1900.0; *p_nb_iter = 1900.0;
*p_nb_bad = 401.0; *p_nb_bad = 401.0;
return -1.0000; return -1;
} }
else if (p_features->var_of_sub_var <= 5841.4773) else if (p_features->var_of_sub_var <= 5841.4773)
{ {
@ -549,25 +549,25 @@ int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1000.0; *p_nb_iter = 1000.0;
*p_nb_bad = 356.0; *p_nb_bad = 356.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_A <= 633.8163) else if (p_features->neigh_variance_A <= 633.8163)
{ {
*p_nb_iter = 5279.0; *p_nb_iter = 5279.0;
*p_nb_bad = 1961.0; *p_nb_bad = 1961.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1176.0; *p_nb_iter = 1176.0;
*p_nb_bad = 527.0; *p_nb_bad = 527.0;
return -1.0000; return -1;
} }
} }
else if (p_features->sub_variance_0 <= 38.3035) else if (p_features->sub_variance_0 <= 38.3035)
{ {
*p_nb_iter = 1251.0; *p_nb_iter = 1251.0;
*p_nb_bad = 293.0; *p_nb_bad = 293.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_B <= 664.9494) else if (p_features->neigh_variance_B <= 664.9494)
{ {
@ -575,7 +575,7 @@ int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1276.0; *p_nb_iter = 1276.0;
*p_nb_bad = 471.0; *p_nb_bad = 471.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_3 <= 404.3086) else if (p_features->sub_variance_3 <= 404.3086)
{ {
@ -583,36 +583,36 @@ int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1005.0; *p_nb_iter = 1005.0;
*p_nb_bad = 435.0; *p_nb_bad = 435.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_0 <= 282.3064) else if (p_features->sub_variance_0 <= 282.3064)
{ {
*p_nb_iter = 1370.0; *p_nb_iter = 1370.0;
*p_nb_bad = 539.0; *p_nb_bad = 539.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1013.0; *p_nb_iter = 1013.0;
*p_nb_bad = 495.0; *p_nb_bad = 495.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1000.0; *p_nb_iter = 1000.0;
*p_nb_bad = 379.0; *p_nb_bad = 379.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 2270.0; *p_nb_iter = 2270.0;
*p_nb_bad = 679.0; *p_nb_bad = 679.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 29015.0; *p_nb_iter = 29015.0;
*p_nb_bad = 3950.0; *p_nb_bad = 3950.0;
return -1.0000; return -1;
} }
} }
@ -625,13 +625,13 @@ int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 23216.0; *p_nb_iter = 23216.0;
*p_nb_bad = 1560.0; *p_nb_bad = 1560.0;
return 2.0000; return 2;
} }
else if (p_features->merge_variance <= 259.6952) else if (p_features->merge_variance <= 259.6952)
{ {
*p_nb_iter = 7470.0; *p_nb_iter = 7470.0;
*p_nb_bad = 1902.0; *p_nb_bad = 1902.0;
return 2.0000; return 2;
} }
else if (p_features->qp <= 27) else if (p_features->qp <= 27)
{ {
@ -639,18 +639,18 @@ int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1138.0; *p_nb_iter = 1138.0;
*p_nb_bad = 486.0; *p_nb_bad = 486.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1619.0; *p_nb_iter = 1619.0;
*p_nb_bad = 716.0; *p_nb_bad = 716.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 2425.0; *p_nb_iter = 2425.0;
*p_nb_bad = 861.0; *p_nb_bad = 861.0;
return 2.0000; return 2;
} }
} }
else if (p_features->var_of_sub_var <= 60850.5208) else if (p_features->var_of_sub_var <= 60850.5208)
@ -663,7 +663,7 @@ int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1796.0; *p_nb_iter = 1796.0;
*p_nb_bad = 586.0; *p_nb_bad = 586.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_A <= 493.5849) else if (p_features->neigh_variance_A <= 493.5849)
{ {
@ -671,42 +671,42 @@ int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1326.0; *p_nb_iter = 1326.0;
*p_nb_bad = 557.0; *p_nb_bad = 557.0;
return -1.0000; return -1;
} }
else if (p_features->variance <= 156.4014) else if (p_features->variance <= 156.4014)
{ {
*p_nb_iter = 1210.0; *p_nb_iter = 1210.0;
*p_nb_bad = 563.0; *p_nb_bad = 563.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1920.0; *p_nb_iter = 1920.0;
*p_nb_bad = 817.0; *p_nb_bad = 817.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 1106.0; *p_nb_iter = 1106.0;
*p_nb_bad = 437.0; *p_nb_bad = 437.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1001.0; *p_nb_iter = 1001.0;
*p_nb_bad = 278.0; *p_nb_bad = 278.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 13068.0; *p_nb_iter = 13068.0;
*p_nb_bad = 3612.0; *p_nb_bad = 3612.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 22705.0; *p_nb_iter = 22705.0;
*p_nb_bad = 2687.0; *p_nb_bad = 2687.0;
return -1.0000; return -1;
} }
} }
@ -720,7 +720,7 @@ int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 20568.0; *p_nb_iter = 20568.0;
*p_nb_bad = 767.0; *p_nb_bad = 767.0;
return 3.0000; return 3;
} }
else if (p_features->qp <= 27) else if (p_features->qp <= 27)
{ {
@ -728,24 +728,24 @@ int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1255.0; *p_nb_iter = 1255.0;
*p_nb_bad = 206.0; *p_nb_bad = 206.0;
return 3.0000; return 3;
} }
else if (p_features->merge_variance <= 375.2185) else if (p_features->merge_variance <= 375.2185)
{ {
*p_nb_iter = 3999.0; *p_nb_iter = 3999.0;
*p_nb_bad = 1321.0; *p_nb_bad = 1321.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 1786.0; *p_nb_iter = 1786.0;
*p_nb_bad = 817.0; *p_nb_bad = 817.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 5286.0; *p_nb_iter = 5286.0;
*p_nb_bad = 737.0; *p_nb_bad = 737.0;
return 3.0000; return 3;
} }
} }
else if (p_features->var_of_sub_var <= 37332.3018) else if (p_features->var_of_sub_var <= 37332.3018)
@ -760,7 +760,7 @@ int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1114.0; *p_nb_iter = 1114.0;
*p_nb_bad = 346.0; *p_nb_bad = 346.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_B <= 221.5469) else if (p_features->neigh_variance_B <= 221.5469)
{ {
@ -768,53 +768,53 @@ int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, do
{ {
*p_nb_iter = 1539.0; *p_nb_iter = 1539.0;
*p_nb_bad = 606.0; *p_nb_bad = 606.0;
return 3.0000; return 3;
} }
else if (p_features->variance <= 155.5974) else if (p_features->variance <= 155.5974)
{ {
*p_nb_iter = 1298.0; *p_nb_iter = 1298.0;
*p_nb_bad = 634.0; *p_nb_bad = 634.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 1076.0; *p_nb_iter = 1076.0;
*p_nb_bad = 456.0; *p_nb_bad = 456.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1644.0; *p_nb_iter = 1644.0;
*p_nb_bad = 639.0; *p_nb_bad = 639.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 2401.0; *p_nb_iter = 2401.0;
*p_nb_bad = 713.0; *p_nb_bad = 713.0;
return -1.0000; return -1;
} }
} }
else if (p_features->merge_variance <= 281.9509) else if (p_features->merge_variance <= 281.9509)
{ {
*p_nb_iter = 1020.0; *p_nb_iter = 1020.0;
*p_nb_bad = 262.0; *p_nb_bad = 262.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 1278.0; *p_nb_iter = 1278.0;
*p_nb_bad = 594.0; *p_nb_bad = 594.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 10507.0; *p_nb_iter = 10507.0;
*p_nb_bad = 2943.0; *p_nb_bad = 2943.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 25229.0; *p_nb_iter = 25229.0;
*p_nb_bad = 3060.0; *p_nb_bad = 3060.0;
return -1.0000; return -1;
} }
} }

View file

@ -43,7 +43,7 @@ static int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 19428.0; *p_nb_iter = 19428.0;
*p_nb_bad = 1740.0; *p_nb_bad = 1740.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_0 <= 9.1015) else if (p_features->sub_variance_0 <= 9.1015)
{ {
@ -51,36 +51,36 @@ static int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1166.0; *p_nb_iter = 1166.0;
*p_nb_bad = 358.0; *p_nb_bad = 358.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1049.0; *p_nb_iter = 1049.0;
*p_nb_bad = 392.0; *p_nb_bad = 392.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 9371.0; *p_nb_iter = 9371.0;
*p_nb_bad = 1805.0; *p_nb_bad = 1805.0;
return -1.0000; return -1;
} }
} }
else if (p_features->sub_variance_2 <= 23.3193) else if (p_features->sub_variance_2 <= 23.3193)
{ {
*p_nb_iter = 1059.0; *p_nb_iter = 1059.0;
*p_nb_bad = 329.0; *p_nb_bad = 329.0;
return 1.0000; return 1;
} }
else if (p_features->sub_variance_1 <= 30.7348) else if (p_features->sub_variance_1 <= 30.7348)
{ {
*p_nb_iter = 1042.0; *p_nb_iter = 1042.0;
*p_nb_bad = 395.0; *p_nb_bad = 395.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1756.0; *p_nb_iter = 1756.0;
*p_nb_bad = 588.0; *p_nb_bad = 588.0;
return -1.0000; return -1;
} }
} }
else if (p_features->merge_variance <= 857.8047) else if (p_features->merge_variance <= 857.8047)
@ -91,7 +91,7 @@ static int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 2006.0; *p_nb_iter = 2006.0;
*p_nb_bad = 374.0; *p_nb_bad = 374.0;
return 1.0000; return 1;
} }
else if (p_features->neigh_variance_C <= 646.8204) else if (p_features->neigh_variance_C <= 646.8204)
{ {
@ -103,60 +103,60 @@ static int uvg_tree_predict_merge_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1208.0; *p_nb_iter = 1208.0;
*p_nb_bad = 399.0; *p_nb_bad = 399.0;
return 1.0000; return 1;
} }
else if (p_features->var_of_sub_var <= 11832.6635) else if (p_features->var_of_sub_var <= 11832.6635)
{ {
*p_nb_iter = 8701.0; *p_nb_iter = 8701.0;
*p_nb_bad = 3037.0; *p_nb_bad = 3037.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_A <= 142.298) else if (p_features->neigh_variance_A <= 142.298)
{ {
*p_nb_iter = 1025.0; *p_nb_iter = 1025.0;
*p_nb_bad = 290.0; *p_nb_bad = 290.0;
return 1.0000; return 1;
} }
else if (p_features->variance <= 394.4839) else if (p_features->variance <= 394.4839)
{ {
*p_nb_iter = 1156.0; *p_nb_iter = 1156.0;
*p_nb_bad = 489.0; *p_nb_bad = 489.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1150.0; *p_nb_iter = 1150.0;
*p_nb_bad = 503.0; *p_nb_bad = 503.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1777.0; *p_nb_iter = 1777.0;
*p_nb_bad = 558.0; *p_nb_bad = 558.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 1587.0; *p_nb_iter = 1587.0;
*p_nb_bad = 411.0; *p_nb_bad = 411.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 1980.0; *p_nb_iter = 1980.0;
*p_nb_bad = 474.0; *p_nb_bad = 474.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 3613.0; *p_nb_iter = 3613.0;
*p_nb_bad = 475.0; *p_nb_bad = 475.0;
return 1.0000; return 1;
} }
} }
else { else {
*p_nb_iter = 20926.0; *p_nb_iter = 20926.0;
*p_nb_bad = 1873.0; *p_nb_bad = 1873.0;
return 1.0000; return 1;
} }
} }
@ -171,30 +171,30 @@ static int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 29253.0; *p_nb_iter = 29253.0;
*p_nb_bad = 3837.0; *p_nb_bad = 3837.0;
return -1.0000; return -1;
} }
else if (p_features->variance <= 20.8711) else if (p_features->variance <= 20.8711)
{ {
*p_nb_iter = 1292.0; *p_nb_iter = 1292.0;
*p_nb_bad = 458.0; *p_nb_bad = 458.0;
return 2.0000; return 2;
} }
else { else {
*p_nb_iter = 1707.0; *p_nb_iter = 1707.0;
*p_nb_bad = 399.0; *p_nb_bad = 399.0;
return -1.0000; return -1;
} }
} }
else if (p_features->var_of_sub_var <= 3300.4034) else if (p_features->var_of_sub_var <= 3300.4034)
{ {
*p_nb_iter = 1554.0; *p_nb_iter = 1554.0;
*p_nb_bad = 675.0; *p_nb_bad = 675.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1540.0; *p_nb_iter = 1540.0;
*p_nb_bad = 429.0; *p_nb_bad = 429.0;
return 2.0000; return 2;
} }
} }
else if (p_features->merge_variance <= 696.1989) else if (p_features->merge_variance <= 696.1989)
@ -205,7 +205,7 @@ static int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 3473.0; *p_nb_iter = 3473.0;
*p_nb_bad = 768.0; *p_nb_bad = 768.0;
return 2.0000; return 2;
} }
else if (p_features->neigh_variance_C <= 571.5329) else if (p_features->neigh_variance_C <= 571.5329)
{ {
@ -215,7 +215,7 @@ static int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1887.0; *p_nb_iter = 1887.0;
*p_nb_bad = 588.0; *p_nb_bad = 588.0;
return 2.0000; return 2;
} }
else if (p_features->neigh_variance_A <= 380.5927) else if (p_features->neigh_variance_A <= 380.5927)
{ {
@ -223,48 +223,48 @@ static int uvg_tree_predict_merge_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1686.0; *p_nb_iter = 1686.0;
*p_nb_bad = 721.0; *p_nb_bad = 721.0;
return 2.0000; return 2;
} }
else if (p_features->neigh_variance_A <= 66.6749) else if (p_features->neigh_variance_A <= 66.6749)
{ {
*p_nb_iter = 1440.0; *p_nb_iter = 1440.0;
*p_nb_bad = 631.0; *p_nb_bad = 631.0;
return 2.0000; return 2;
} }
else { else {
*p_nb_iter = 5772.0; *p_nb_iter = 5772.0;
*p_nb_bad = 2031.0; *p_nb_bad = 2031.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1791.0; *p_nb_iter = 1791.0;
*p_nb_bad = 619.0; *p_nb_bad = 619.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 1624.0; *p_nb_iter = 1624.0;
*p_nb_bad = 494.0; *p_nb_bad = 494.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 1298.0; *p_nb_iter = 1298.0;
*p_nb_bad = 312.0; *p_nb_bad = 312.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 4577.0; *p_nb_iter = 4577.0;
*p_nb_bad = 892.0; *p_nb_bad = 892.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 21106.0; *p_nb_iter = 21106.0;
*p_nb_bad = 2744.0; *p_nb_bad = 2744.0;
return 2.0000; return 2;
} }
} }
@ -278,12 +278,12 @@ static int uvg_tree_predict_merge_depth_3(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 29806.0; *p_nb_iter = 29806.0;
*p_nb_bad = 3603.0; *p_nb_bad = 3603.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1003.0; *p_nb_iter = 1003.0;
*p_nb_bad = 421.0; *p_nb_bad = 421.0;
return 3.0000; return 3;
} }
} }
else if (p_features->merge_variance <= 351.8138) else if (p_features->merge_variance <= 351.8138)
@ -300,48 +300,48 @@ static int uvg_tree_predict_merge_depth_3(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1290.0; *p_nb_iter = 1290.0;
*p_nb_bad = 525.0; *p_nb_bad = 525.0;
return 3.0000; return 3;
} }
else if (p_features->neigh_variance_B <= 16.9287) else if (p_features->neigh_variance_B <= 16.9287)
{ {
*p_nb_iter = 1045.0; *p_nb_iter = 1045.0;
*p_nb_bad = 499.0; *p_nb_bad = 499.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 6901.0; *p_nb_iter = 6901.0;
*p_nb_bad = 2494.0; *p_nb_bad = 2494.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1332.0; *p_nb_iter = 1332.0;
*p_nb_bad = 408.0; *p_nb_bad = 408.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 2929.0; *p_nb_iter = 2929.0;
*p_nb_bad = 842.0; *p_nb_bad = 842.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 2239.0; *p_nb_iter = 2239.0;
*p_nb_bad = 572.0; *p_nb_bad = 572.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 2777.0; *p_nb_iter = 2777.0;
*p_nb_bad = 714.0; *p_nb_bad = 714.0;
return 3.0000; return 3;
} }
} }
else { else {
*p_nb_iter = 30678.0; *p_nb_iter = 30678.0;
*p_nb_bad = 5409.0; *p_nb_bad = 5409.0;
return 3.0000; return 3;
} }
} }
@ -367,54 +367,54 @@ static int uvg_tree_predict_merge_depth_4(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 27398.0; *p_nb_iter = 27398.0;
*p_nb_bad = 4665.0; *p_nb_bad = 4665.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1676.0; *p_nb_iter = 1676.0;
*p_nb_bad = 795.0; *p_nb_bad = 795.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 1405.0; *p_nb_iter = 1405.0;
*p_nb_bad = 566.0; *p_nb_bad = 566.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 2827.0; *p_nb_iter = 2827.0;
*p_nb_bad = 1173.0; *p_nb_bad = 1173.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 8871.0; *p_nb_iter = 8871.0;
*p_nb_bad = 822.0; *p_nb_bad = 822.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 3162.0; *p_nb_iter = 3162.0;
*p_nb_bad = 718.0; *p_nb_bad = 718.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 6154.0; *p_nb_iter = 6154.0;
*p_nb_bad = 1397.0; *p_nb_bad = 1397.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 9385.0; *p_nb_iter = 9385.0;
*p_nb_bad = 1609.0; *p_nb_bad = 1609.0;
return 4.0000; return 4;
} }
} }
else { else {
*p_nb_iter = 19122.0; *p_nb_iter = 19122.0;
*p_nb_bad = 2960.0; *p_nb_bad = 2960.0;
return 4.0000; return 4;
} }
} }
@ -428,13 +428,13 @@ static int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 25155.0; *p_nb_iter = 25155.0;
*p_nb_bad = 2959.0; *p_nb_bad = 2959.0;
return 0.0000; return 0;
} }
else if (p_features->sub_variance_2 <= 13.2892) else if (p_features->sub_variance_2 <= 13.2892)
{ {
*p_nb_iter = 1080.0; *p_nb_iter = 1080.0;
*p_nb_bad = 383.0; *p_nb_bad = 383.0;
return -1.0000; return -1;
} }
else if (p_features->variance <= 564.1738) else if (p_features->variance <= 564.1738)
{ {
@ -442,7 +442,7 @@ static int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 6067.0; *p_nb_iter = 6067.0;
*p_nb_bad = 1699.0; *p_nb_bad = 1699.0;
return 0.0000; return 0;
} }
else if (p_features->var_of_sub_mean <= 46.2388) else if (p_features->var_of_sub_mean <= 46.2388)
{ {
@ -450,30 +450,30 @@ static int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1088.0; *p_nb_iter = 1088.0;
*p_nb_bad = 377.0; *p_nb_bad = 377.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_3 <= 61.4213) else if (p_features->sub_variance_3 <= 61.4213)
{ {
*p_nb_iter = 1183.0; *p_nb_iter = 1183.0;
*p_nb_bad = 498.0; *p_nb_bad = 498.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 3416.0; *p_nb_iter = 3416.0;
*p_nb_bad = 1373.0; *p_nb_bad = 1373.0;
return 0.0000; return 0;
} }
} }
else { else {
*p_nb_iter = 3769.0; *p_nb_iter = 3769.0;
*p_nb_bad = 1093.0; *p_nb_bad = 1093.0;
return 0.0000; return 0;
} }
} }
else { else {
*p_nb_iter = 1036.0; *p_nb_iter = 1036.0;
*p_nb_bad = 434.0; *p_nb_bad = 434.0;
return -1.0000; return -1;
} }
} }
else if (p_features->var_of_sub_var <= 98333.8279) else if (p_features->var_of_sub_var <= 98333.8279)
@ -486,42 +486,42 @@ static int uvg_tree_predict_split_depth_0(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1323.0; *p_nb_iter = 1323.0;
*p_nb_bad = 301.0; *p_nb_bad = 301.0;
return -1.0000; return -1;
} }
else if (p_features->var_of_sub_var <= 17347.3971) else if (p_features->var_of_sub_var <= 17347.3971)
{ {
*p_nb_iter = 1215.0; *p_nb_iter = 1215.0;
*p_nb_bad = 550.0; *p_nb_bad = 550.0;
return 0.0000; return 0;
} }
else if (p_features->qp <= 22) else if (p_features->qp <= 22)
{ {
*p_nb_iter = 1000.0; *p_nb_iter = 1000.0;
*p_nb_bad = 493.0; *p_nb_bad = 493.0;
return 0.0000; return 0;
} }
else { else {
*p_nb_iter = 2640.0; *p_nb_iter = 2640.0;
*p_nb_bad = 1121.0; *p_nb_bad = 1121.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 5188.0; *p_nb_iter = 5188.0;
*p_nb_bad = 1248.0; *p_nb_bad = 1248.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 2323.0; *p_nb_iter = 2323.0;
*p_nb_bad = 274.0; *p_nb_bad = 274.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 21357.0; *p_nb_iter = 21357.0;
*p_nb_bad = 1829.0; *p_nb_bad = 1829.0;
return -1.0000; return -1;
} }
} }
@ -532,7 +532,7 @@ static int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 32445.0; *p_nb_iter = 32445.0;
*p_nb_bad = 4580.0; *p_nb_bad = 4580.0;
return 1.0000; return 1;
} }
else if (p_features->var_of_sub_var <= 27289.2117) else if (p_features->var_of_sub_var <= 27289.2117)
{ {
@ -540,7 +540,7 @@ static int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1900.0; *p_nb_iter = 1900.0;
*p_nb_bad = 401.0; *p_nb_bad = 401.0;
return -1.0000; return -1;
} }
else if (p_features->var_of_sub_var <= 5841.4773) else if (p_features->var_of_sub_var <= 5841.4773)
{ {
@ -548,25 +548,25 @@ static int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1000.0; *p_nb_iter = 1000.0;
*p_nb_bad = 356.0; *p_nb_bad = 356.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_A <= 633.8163) else if (p_features->neigh_variance_A <= 633.8163)
{ {
*p_nb_iter = 5279.0; *p_nb_iter = 5279.0;
*p_nb_bad = 1961.0; *p_nb_bad = 1961.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1176.0; *p_nb_iter = 1176.0;
*p_nb_bad = 527.0; *p_nb_bad = 527.0;
return -1.0000; return -1;
} }
} }
else if (p_features->sub_variance_0 <= 38.3035) else if (p_features->sub_variance_0 <= 38.3035)
{ {
*p_nb_iter = 1251.0; *p_nb_iter = 1251.0;
*p_nb_bad = 293.0; *p_nb_bad = 293.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_B <= 664.9494) else if (p_features->neigh_variance_B <= 664.9494)
{ {
@ -574,7 +574,7 @@ static int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1276.0; *p_nb_iter = 1276.0;
*p_nb_bad = 471.0; *p_nb_bad = 471.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_3 <= 404.3086) else if (p_features->sub_variance_3 <= 404.3086)
{ {
@ -582,36 +582,36 @@ static int uvg_tree_predict_split_depth_1(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1005.0; *p_nb_iter = 1005.0;
*p_nb_bad = 435.0; *p_nb_bad = 435.0;
return -1.0000; return -1;
} }
else if (p_features->sub_variance_0 <= 282.3064) else if (p_features->sub_variance_0 <= 282.3064)
{ {
*p_nb_iter = 1370.0; *p_nb_iter = 1370.0;
*p_nb_bad = 539.0; *p_nb_bad = 539.0;
return 1.0000; return 1;
} }
else { else {
*p_nb_iter = 1013.0; *p_nb_iter = 1013.0;
*p_nb_bad = 495.0; *p_nb_bad = 495.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1000.0; *p_nb_iter = 1000.0;
*p_nb_bad = 379.0; *p_nb_bad = 379.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 2270.0; *p_nb_iter = 2270.0;
*p_nb_bad = 679.0; *p_nb_bad = 679.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 29015.0; *p_nb_iter = 29015.0;
*p_nb_bad = 3950.0; *p_nb_bad = 3950.0;
return -1.0000; return -1;
} }
} }
@ -624,13 +624,13 @@ static int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 23216.0; *p_nb_iter = 23216.0;
*p_nb_bad = 1560.0; *p_nb_bad = 1560.0;
return 2.0000; return 2;
} }
else if (p_features->merge_variance <= 259.6952) else if (p_features->merge_variance <= 259.6952)
{ {
*p_nb_iter = 7470.0; *p_nb_iter = 7470.0;
*p_nb_bad = 1902.0; *p_nb_bad = 1902.0;
return 2.0000; return 2;
} }
else if (p_features->qp <= 27) else if (p_features->qp <= 27)
{ {
@ -638,18 +638,18 @@ static int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1138.0; *p_nb_iter = 1138.0;
*p_nb_bad = 486.0; *p_nb_bad = 486.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1619.0; *p_nb_iter = 1619.0;
*p_nb_bad = 716.0; *p_nb_bad = 716.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 2425.0; *p_nb_iter = 2425.0;
*p_nb_bad = 861.0; *p_nb_bad = 861.0;
return 2.0000; return 2;
} }
} }
else if (p_features->var_of_sub_var <= 60850.5208) else if (p_features->var_of_sub_var <= 60850.5208)
@ -662,7 +662,7 @@ static int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1796.0; *p_nb_iter = 1796.0;
*p_nb_bad = 586.0; *p_nb_bad = 586.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_A <= 493.5849) else if (p_features->neigh_variance_A <= 493.5849)
{ {
@ -670,42 +670,42 @@ static int uvg_tree_predict_split_depth_2(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1326.0; *p_nb_iter = 1326.0;
*p_nb_bad = 557.0; *p_nb_bad = 557.0;
return -1.0000; return -1;
} }
else if (p_features->variance <= 156.4014) else if (p_features->variance <= 156.4014)
{ {
*p_nb_iter = 1210.0; *p_nb_iter = 1210.0;
*p_nb_bad = 563.0; *p_nb_bad = 563.0;
return -1.0000; return -1;
} }
else { else {
*p_nb_iter = 1920.0; *p_nb_iter = 1920.0;
*p_nb_bad = 817.0; *p_nb_bad = 817.0;
return 2.0000; return 2;
} }
} }
else { else {
*p_nb_iter = 1106.0; *p_nb_iter = 1106.0;
*p_nb_bad = 437.0; *p_nb_bad = 437.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1001.0; *p_nb_iter = 1001.0;
*p_nb_bad = 278.0; *p_nb_bad = 278.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 13068.0; *p_nb_iter = 13068.0;
*p_nb_bad = 3612.0; *p_nb_bad = 3612.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 22705.0; *p_nb_iter = 22705.0;
*p_nb_bad = 2687.0; *p_nb_bad = 2687.0;
return -1.0000; return -1;
} }
} }
@ -719,7 +719,7 @@ static int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 20568.0; *p_nb_iter = 20568.0;
*p_nb_bad = 767.0; *p_nb_bad = 767.0;
return 3.0000; return 3;
} }
else if (p_features->qp <= 27) else if (p_features->qp <= 27)
{ {
@ -727,24 +727,24 @@ static int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1255.0; *p_nb_iter = 1255.0;
*p_nb_bad = 206.0; *p_nb_bad = 206.0;
return 3.0000; return 3;
} }
else if (p_features->merge_variance <= 375.2185) else if (p_features->merge_variance <= 375.2185)
{ {
*p_nb_iter = 3999.0; *p_nb_iter = 3999.0;
*p_nb_bad = 1321.0; *p_nb_bad = 1321.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 1786.0; *p_nb_iter = 1786.0;
*p_nb_bad = 817.0; *p_nb_bad = 817.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 5286.0; *p_nb_iter = 5286.0;
*p_nb_bad = 737.0; *p_nb_bad = 737.0;
return 3.0000; return 3;
} }
} }
else if (p_features->var_of_sub_var <= 37332.3018) else if (p_features->var_of_sub_var <= 37332.3018)
@ -759,7 +759,7 @@ static int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1114.0; *p_nb_iter = 1114.0;
*p_nb_bad = 346.0; *p_nb_bad = 346.0;
return -1.0000; return -1;
} }
else if (p_features->neigh_variance_B <= 221.5469) else if (p_features->neigh_variance_B <= 221.5469)
{ {
@ -767,54 +767,54 @@ static int uvg_tree_predict_split_depth_3(features_s* p_features, double* p_nb_i
{ {
*p_nb_iter = 1539.0; *p_nb_iter = 1539.0;
*p_nb_bad = 606.0; *p_nb_bad = 606.0;
return 3.0000; return 3;
} }
else if (p_features->variance <= 155.5974) else if (p_features->variance <= 155.5974)
{ {
*p_nb_iter = 1298.0; *p_nb_iter = 1298.0;
*p_nb_bad = 634.0; *p_nb_bad = 634.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 1076.0; *p_nb_iter = 1076.0;
*p_nb_bad = 456.0; *p_nb_bad = 456.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 1644.0; *p_nb_iter = 1644.0;
*p_nb_bad = 639.0; *p_nb_bad = 639.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 2401.0; *p_nb_iter = 2401.0;
*p_nb_bad = 713.0; *p_nb_bad = 713.0;
return -1.0000; return -1;
} }
} }
else if (p_features->merge_variance <= 281.9509) else if (p_features->merge_variance <= 281.9509)
{ {
*p_nb_iter = 1020.0; *p_nb_iter = 1020.0;
*p_nb_bad = 262.0; *p_nb_bad = 262.0;
return 3.0000; return 3;
} }
else { else {
*p_nb_iter = 1278.0; *p_nb_iter = 1278.0;
*p_nb_bad = 594.0; *p_nb_bad = 594.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 10507.0; *p_nb_iter = 10507.0;
*p_nb_bad = 2943.0; *p_nb_bad = 2943.0;
return -1.0000; return -1;
} }
} }
else { else {
*p_nb_iter = 25229.0; *p_nb_iter = 25229.0;
*p_nb_bad = 3060.0; *p_nb_bad = 3060.0;
return -1.0000; return -1;
} }
} }
@ -965,7 +965,7 @@ static INLINE double vect_variance_blck_int8(const uvg_pixel* _mat_src, size_t _
*/ */
static INLINE void features_var_avg_blck(uvg_pixel* arr_luma_px, uint32_t i_xLcu, uint32_t i_yLcu, static INLINE void features_var_avg_blck(uvg_pixel* arr_luma_px, uint32_t i_xLcu, uint32_t i_yLcu,
uint32_t i_xBlck, uint32_t i_yBlck, uint8_t i_blockSize, uint32_t i_xBlck, uint32_t i_yBlck, uint8_t i_blockSize,
int32_t i_width, int32_t i_height, uint32_t i_width, uint32_t i_height,
double* p_average, double* p_variance) double* p_average, double* p_variance)
{ {
uint32_t iXMax = CR_XMAX(i_xLcu, i_blockSize + i_xBlck, i_width); uint32_t iXMax = CR_XMAX(i_xLcu, i_blockSize + i_xBlck, i_width);

View file

@ -148,7 +148,7 @@ void uvg_free_rc_data() {
* \param[in,out] beta beta parameter to update * \param[in,out] beta beta parameter to update
*/ */
static void update_parameters(uint32_t bits, static void update_parameters(uint32_t bits,
uint32_t pixels, uint64_t pixels,
double lambda_real, double lambda_real,
double *alpha, double *alpha,
double *beta) double *beta)
@ -392,7 +392,7 @@ static double pic_allocate_bits(encoder_state_t * const state)
static int8_t lambda_to_qp(const double lambda) static int8_t lambda_to_qp(const double lambda)
{ {
const int8_t qp = 4.2005 * log(lambda) + 13.7223 + 0.5; const int8_t qp = (const int8_t)(4.2005 * log(lambda) + 13.7223 + 0.5);
return CLIP_TO_QP(qp); return CLIP_TO_QP(qp);
} }
@ -613,21 +613,21 @@ static double get_ctu_bits(encoder_state_t * const state, vector2d_t pos) {
pthread_mutex_lock(&state->frame->rc_lock); pthread_mutex_lock(&state->frame->rc_lock);
double bits_left = state->frame->cur_pic_target_bits - state->frame->cur_frame_bits_coded; double bits_left = state->frame->cur_pic_target_bits - state->frame->cur_frame_bits_coded;
double weighted_bits_left = (bits_left * window + (bits_left - state->frame->i_bits_left)*cus_left) / window; double weighted_bits_left = (bits_left * window + (bits_left - state->frame->i_bits_left)*cus_left) / window;
avg_bits = mad * weighted_bits_left / state->frame->remaining_weight; avg_bits = (int32_t)(mad * weighted_bits_left / state->frame->remaining_weight);
state->frame->remaining_weight -= mad; state->frame->remaining_weight -= mad;
state->frame->i_bits_left -= state->frame->cur_pic_target_bits * mad / state->frame->icost; state->frame->i_bits_left -= state->frame->cur_pic_target_bits * mad / state->frame->icost;
pthread_mutex_unlock(&state->frame->rc_lock); pthread_mutex_unlock(&state->frame->rc_lock);
} }
else { else {
avg_bits = state->frame->cur_pic_target_bits * ((double)state->frame->lcu_stats[index].pixels / avg_bits = (int32_t)(state->frame->cur_pic_target_bits * ((double)state->frame->lcu_stats[index].pixels /
(state->encoder_control->in.height * state->encoder_control->in.width)); (state->encoder_control->in.height * state->encoder_control->in.width)));
} }
} }
else { else {
double total_weight = 0; double total_weight = 0;
// In case wpp is used only the ctus of the current frame are safe to use // In case wpp is used only the ctus of the current frame are safe to use
const int used_ctu_count = MIN(4, (encoder->cfg.wpp ? (pos.y + 1) * encoder->in.width_in_lcu : num_ctu) - index); const int used_ctu_count = MIN(4, (encoder->cfg.wpp ? (pos.y + 1) * encoder->in.width_in_lcu : num_ctu) - index);
int target_bits = 0; int32_t target_bits = 0;
double best_lambda = 0.0; double best_lambda = 0.0;
double temp_lambda = state->frame->lambda; double temp_lambda = state->frame->lambda;
double taylor_e3 = 0.0; double taylor_e3 = 0.0;
@ -635,12 +635,12 @@ static double get_ctu_bits(encoder_state_t * const state, vector2d_t pos) {
int last_ctu = index + used_ctu_count; int last_ctu = index + used_ctu_count;
for (int i = index; i < last_ctu; i++) { for (int i = index; i < last_ctu; i++) {
target_bits += state->frame->lcu_stats[i].weight; target_bits += (int32_t)state->frame->lcu_stats[i].weight;
} }
pthread_mutex_lock(&state->frame->rc_lock); pthread_mutex_lock(&state->frame->rc_lock);
total_weight = state->frame->remaining_weight; total_weight = state->frame->remaining_weight;
target_bits = MAX(target_bits + state->frame->cur_pic_target_bits - state->frame->cur_frame_bits_coded - (int)total_weight, 10); target_bits = (int32_t)MAX(target_bits + state->frame->cur_pic_target_bits - state->frame->cur_frame_bits_coded - (int)total_weight, 10);
pthread_mutex_unlock(&state->frame->rc_lock); pthread_mutex_unlock(&state->frame->rc_lock);
//just similar with the process at frame level, details can refer to the function uvg_estimate_pic_lambda //just similar with the process at frame level, details can refer to the function uvg_estimate_pic_lambda
@ -812,8 +812,8 @@ static double qp_to_lambda(encoder_state_t* const state, int qp)
pos.x + state->tile->lcu_offset_x, pos.x + state->tile->lcu_offset_x,
pos.y + state->tile->lcu_offset_y pos.y + state->tile->lcu_offset_y
}; };
int id = lcu.x + lcu.y * state->tile->frame->width_in_lcu; int32_t id = lcu.x + lcu.y * state->tile->frame->width_in_lcu;
int aq_offset = round(state->frame->aq_offsets[id]); int32_t aq_offset = (int32_t)round(state->frame->aq_offsets[id]);
state->qp += aq_offset; state->qp += aq_offset;
// Maximum delta QP is clipped according to ITU T-REC-H.265 specification chapter 7.4.9.10 Transform unit semantics // Maximum delta QP is clipped according to ITU T-REC-H.265 specification chapter 7.4.9.10 Transform unit semantics
// Clipping range is a function of bit depth // Clipping range is a function of bit depth
@ -916,7 +916,7 @@ void uvg_update_after_picture(encoder_state_t * const state) {
if (state->frame->is_irap && encoder->cfg.intra_bit_allocation) { if (state->frame->is_irap && encoder->cfg.intra_bit_allocation) {
double lnbpp = log(pow(state->frame->icost / pixels, BETA1)); double lnbpp = log(pow(state->frame->icost / pixels, BETA1));
pthread_mutex_lock(&state->frame->new_ratecontrol->intra_lock); pthread_mutex_lock(&state->frame->new_ratecontrol->intra_lock);
double diff_lambda = state->frame->new_ratecontrol->intra_beta * log(state->frame->cur_frame_bits_coded) - log(state->frame->cur_pic_target_bits); double diff_lambda = (double)(state->frame->new_ratecontrol->intra_beta * log((double)state->frame->cur_frame_bits_coded) - log((double)state->frame->cur_pic_target_bits));
diff_lambda = CLIP(-0.125, 0.125, 0.25*diff_lambda); diff_lambda = CLIP(-0.125, 0.125, 0.25*diff_lambda);
@ -1162,8 +1162,8 @@ void uvg_set_lcu_lambda_and_qp(encoder_state_t * const state,
pos.x + state->tile->lcu_offset_x, pos.x + state->tile->lcu_offset_x,
pos.y + state->tile->lcu_offset_y pos.y + state->tile->lcu_offset_y
}; };
int id = lcu_pos.x + lcu_pos.y * state->tile->frame->width_in_lcu; int32_t id = lcu_pos.x + lcu_pos.y * state->tile->frame->width_in_lcu;
int aq_offset = round(state->frame->aq_offsets[id]); int32_t aq_offset = (int32_t)round(state->frame->aq_offsets[id]);
state->qp += aq_offset; state->qp += aq_offset;
// Maximum delta QP is clipped according to ITU T-REC-H.265 specification chapter 7.4.9.10 Transform unit semantics // Maximum delta QP is clipped according to ITU T-REC-H.265 specification chapter 7.4.9.10 Transform unit semantics
// Clipping range is a function of bit depth // Clipping range is a function of bit depth

View file

@ -453,7 +453,7 @@ INLINE int32_t uvg_get_ic_rate(encoder_state_t * const state,
{ {
uint32_t symbol = (abs_level == 0 ? go_rice_zero : abs_level <= go_rice_zero ? abs_level - 1 : abs_level); uint32_t symbol = (abs_level == 0 ? go_rice_zero : abs_level <= go_rice_zero ? abs_level - 1 : abs_level);
uint32_t length; uint32_t length;
const int threshold = COEF_REMAIN_BIN_REDUCTION; const uint32_t threshold = COEF_REMAIN_BIN_REDUCTION;
if (symbol < (threshold << abs_go_rice)) if (symbol < (threshold << abs_go_rice))
{ {
length = symbol >> abs_go_rice; length = symbol >> abs_go_rice;
@ -464,7 +464,7 @@ INLINE int32_t uvg_get_ic_rate(encoder_state_t * const state,
uint32_t prefixLength = 0; uint32_t prefixLength = 0;
uint32_t suffix = (symbol >> abs_go_rice) - COEF_REMAIN_BIN_REDUCTION; uint32_t suffix = (symbol >> abs_go_rice) - COEF_REMAIN_BIN_REDUCTION;
while ((prefixLength < maximumPrefixLength) && (suffix > ((2 << prefixLength) - 2))) while ((prefixLength < maximumPrefixLength) && ((int32_t)suffix > ((2 << prefixLength) - 2)))
{ {
prefixLength++; prefixLength++;
} }
@ -476,7 +476,7 @@ INLINE int32_t uvg_get_ic_rate(encoder_state_t * const state,
else { else {
length = abs_go_rice; length = abs_go_rice;
symbol = symbol - (threshold << abs_go_rice); symbol = symbol - (threshold << abs_go_rice);
while (symbol >= (1 << length)) while ((int32_t)symbol >= (1 << length))
{ {
symbol -= (1 << (length++)); symbol -= (1 << (length++));
} }
@ -498,7 +498,7 @@ INLINE int32_t uvg_get_ic_rate(encoder_state_t * const state,
uint32_t prefixLength = 0; uint32_t prefixLength = 0;
uint32_t suffix = (symbol >> abs_go_rice) - COEF_REMAIN_BIN_REDUCTION; uint32_t suffix = (symbol >> abs_go_rice) - COEF_REMAIN_BIN_REDUCTION;
while ((prefixLength < maximumPrefixLength) && (suffix > ((2 << prefixLength) - 2))) while ((prefixLength < maximumPrefixLength) && ((int32_t)suffix > ((2 << prefixLength) - 2)))
{ {
prefixLength++; prefixLength++;
} }
@ -689,7 +689,7 @@ void uvg_rdoq_sign_hiding(
// This somehow scales quant_delta into fractional bits. Instead of the bits // This somehow scales quant_delta into fractional bits. Instead of the bits
// being multiplied by lambda, the residual is divided by it, or something // being multiplied by lambda, the residual is divided by it, or something
// like that. // like that.
const int64_t rd_factor = (inv_quant * inv_quant * (1 << (2 * (qp_scaled / 6))) const int64_t rd_factor = (const int64_t)(inv_quant * inv_quant * (1 << (2 * (qp_scaled / 6)))
/ lambda / 16 / (1 << (2 * (ctrl->bitdepth - 8))) + 0.5); / lambda / 16 / (1 << (2 * (ctrl->bitdepth - 8))) + 0.5);
const int last_cg = (last_pos - 1) >> LOG2_SCAN_SET_SIZE; const int last_cg = (last_pos - 1) >> LOG2_SCAN_SET_SIZE;
@ -858,7 +858,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
uint32_t length; uint32_t length;
const int threshold = COEF_REMAIN_BIN_REDUCTION; const int threshold = COEF_REMAIN_BIN_REDUCTION;
if (symbol < (threshold << rice_par)) if ((int32_t)symbol < (threshold << rice_par))
{ {
length = symbol >> rice_par; length = symbol >> rice_par;
rate += (length + 1 + rice_par) << CTX_FRAC_BITS; rate += (length + 1 + rice_par) << CTX_FRAC_BITS;
@ -870,7 +870,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
uint32_t prefixLength = 0; uint32_t prefixLength = 0;
uint32_t suffix = (symbol >> rice_par) - COEF_REMAIN_BIN_REDUCTION; uint32_t suffix = (symbol >> rice_par) - COEF_REMAIN_BIN_REDUCTION;
while ((prefixLength < maximumPrefixLength) && (suffix > ((2 << prefixLength) - 2))) while ((prefixLength < maximumPrefixLength) && ((int32_t)suffix > ((2 << prefixLength) - 2)))
{ {
prefixLength++; prefixLength++;
} }
@ -883,7 +883,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
{ {
length = rice_par; length = rice_par;
symbol = symbol - (threshold << rice_par); symbol = symbol - (threshold << rice_par);
while (symbol >= (1 << length)) while ((int32_t)symbol >= (1 << length))
{ {
symbol -= (1 << (length++)); symbol -= (1 << (length++));
} }
@ -906,14 +906,14 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
(*num_ctx_bins) += 2; (*num_ctx_bins) += 2;
int cutoffVal = 2; uint32_t cutoffVal = 2;
if (abs_level >= cutoffVal) if (abs_level >= cutoffVal)
{ {
uint32_t symbol = (abs_level - cutoffVal) >> 1; uint32_t symbol = (abs_level - cutoffVal) >> 1;
uint32_t length; uint32_t length;
const int threshold = COEF_REMAIN_BIN_REDUCTION; const int threshold = COEF_REMAIN_BIN_REDUCTION;
if (symbol < (threshold << rice_par)) if ((int32_t)symbol < (threshold << rice_par))
{ {
length = symbol >> rice_par; length = symbol >> rice_par;
rate += (length + 1 + rice_par) << CTX_FRAC_BITS; rate += (length + 1 + rice_par) << CTX_FRAC_BITS;
@ -925,7 +925,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
uint32_t prefixLength = 0; uint32_t prefixLength = 0;
uint32_t suffix = (symbol >> rice_par) - COEF_REMAIN_BIN_REDUCTION; uint32_t suffix = (symbol >> rice_par) - COEF_REMAIN_BIN_REDUCTION;
while ((prefixLength < maximumPrefixLength) && (suffix > ((2 << prefixLength) - 2))) while ((prefixLength < maximumPrefixLength) && ((int32_t)suffix > ((2 << prefixLength) - 2)))
{ {
prefixLength++; prefixLength++;
} }
@ -938,7 +938,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
{ {
length = rice_par; length = rice_par;
symbol = symbol - (threshold << rice_par); symbol = symbol - (threshold << rice_par);
while (symbol >= (1 << length)) while ((int32_t)symbol >= (1 << length))
{ {
symbol -= (1 << (length++)); symbol -= (1 << (length++));
} }
@ -969,7 +969,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
rate += CTX_ENTROPY_BITS(frac_bits_sign, (abs_level - 2) & 1); // frac_bits_par.intBits[(abs_level - 2) & 1]; rate += CTX_ENTROPY_BITS(frac_bits_sign, (abs_level - 2) & 1); // frac_bits_par.intBits[(abs_level - 2) & 1];
num_ctx_bins += 2; num_ctx_bins += 2;
int cutoffVal = 2; uint32_t cutoffVal = 2;
const int numGtBins = 4; const int numGtBins = 4;
for (int i = 0; i < numGtBins; i++) for (int i = 0; i < numGtBins; i++)
{ {
@ -977,7 +977,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
{ {
const uint16_t ctxGtX = cutoffVal >> 1; const uint16_t ctxGtX = cutoffVal >> 1;
// const BinFracBits* fracBitsGtX = fracBitsAccess.getFracBitsArray(ctxGtX); // const BinFracBits* fracBitsGtX = fracBitsAccess.getFracBitsArray(ctxGtX);
unsigned gtX = (abs_level >= (cutoffVal + 2)); unsigned gtX = ((int32_t)abs_level >= (cutoffVal + 2));
rate += CTX_ENTROPY_BITS(&frac_bits_gtx_ctx[ctxGtX], gtX);// fracBitsGtX.intBits[gtX]; rate += CTX_ENTROPY_BITS(&frac_bits_gtx_ctx[ctxGtX], gtX);// fracBitsGtX.intBits[gtX];
num_ctx_bins++; num_ctx_bins++;
} }
@ -988,7 +988,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
{ {
uint32_t symbol = (abs_level - cutoffVal) >> 1; uint32_t symbol = (abs_level - cutoffVal) >> 1;
uint32_t length; uint32_t length;
const int threshold = COEF_REMAIN_BIN_REDUCTION; const uint32_t threshold = COEF_REMAIN_BIN_REDUCTION;
if (symbol < (threshold << rice_par)) if (symbol < (threshold << rice_par))
{ {
length = symbol >> rice_par; length = symbol >> rice_par;
@ -1001,7 +1001,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
uint32_t prefixLength = 0; uint32_t prefixLength = 0;
uint32_t suffix = (symbol >> rice_par) - COEF_REMAIN_BIN_REDUCTION; uint32_t suffix = (symbol >> rice_par) - COEF_REMAIN_BIN_REDUCTION;
while ((prefixLength < maximumPrefixLength) && (suffix > ((2 << prefixLength) - 2))) while ((prefixLength < maximumPrefixLength) && ((int32_t)suffix > ((2 << prefixLength) - 2)))
{ {
prefixLength++; prefixLength++;
} }
@ -1014,7 +1014,7 @@ static INLINE int x_get_ic_rate_ts(const uint32_t abs_level,
{ {
length = rice_par; length = rice_par;
symbol = symbol - (threshold << rice_par); symbol = symbol - (threshold << rice_par);
while (symbol >= (1 << length)) while ((int32_t)symbol >= (1 << length))
{ {
symbol -= (1 << (length++)); symbol -= (1 << (length++));
} }
@ -1202,7 +1202,7 @@ int uvg_ts_rdoq(encoder_state_t* const state, coeff_t* src_coeff, coeff_t* dest_
int rem_reg_bins = (width * height * 7) >> 2; int rem_reg_bins = (width * height * 7) >> 2;
for (int sbId = 0; sbId < cg_num; sbId++) for (uint32_t sbId = 0; sbId < cg_num; sbId++)
{ {
uint32_t cg_blkpos = scan_cg[sbId]; uint32_t cg_blkpos = scan_cg[sbId];
@ -1223,7 +1223,7 @@ int uvg_ts_rdoq(encoder_state_t* const state, coeff_t* src_coeff, coeff_t* dest_
// set coeff // set coeff
const int64_t tmp_level = (int64_t)(abs(src_coeff[blkpos])) * quant_coeff; const int64_t tmp_level = (int64_t)(abs(src_coeff[blkpos])) * quant_coeff;
const int level_double = MIN(tmp_level, MAX_INT64 - (1ll << ((long long)q_bits - 1ll))); const int level_double = (const int)MIN(tmp_level, MAX_INT64 - (1ll << ((long long)q_bits - 1ll)));
uint32_t roundAbsLevel = MIN((uint32_t)(entropy_coding_maximum), (uint32_t)((level_double + ((1) << (q_bits - 1))) >> q_bits)); uint32_t roundAbsLevel = MIN((uint32_t)(entropy_coding_maximum), (uint32_t)((level_double + ((1) << (q_bits - 1))) >> q_bits));
uint32_t min_abs_level = (roundAbsLevel > 1 ? roundAbsLevel - 1 : 1); uint32_t min_abs_level = (roundAbsLevel > 1 ? roundAbsLevel - 1 : 1);

View file

@ -124,9 +124,9 @@ void uvg_calc_seq_stats(struct encoder_state_t* const state, const videoframe_t*
int32_t m_binNum = PIC_CODE_CW_BINS; int32_t m_binNum = PIC_CODE_CW_BINS;
uvg_pixel* picY = &frame->source->y[0]; uvg_pixel* picY = &frame->source->y[0];
const int width = frame->source->width; const uint32_t width = frame->source->width;
const int height = frame->source->height; const uint32_t height = frame->source->height;
const int stride = frame->source->stride; const uint32_t stride = frame->source->stride;
uint32_t winLens = (aps->m_binNum == PIC_CODE_CW_BINS) ? (MIN(height, width) / 240) : 2; uint32_t winLens = (aps->m_binNum == PIC_CODE_CW_BINS) ? (MIN(height, width) / 240) : 2;
winLens = winLens > 0 ? winLens : 1; winLens = winLens > 0 ? winLens : 1;
@ -336,9 +336,9 @@ void uvg_calc_seq_stats(struct encoder_state_t* const state, const videoframe_t*
picY = &frame->source->y[CU_TO_PIXEL(0, 0, 0, frame->source->stride)]; picY = &frame->source->y[CU_TO_PIXEL(0, 0, 0, frame->source->stride)];
double avgY = 0.0; double avgY = 0.0;
double varY = 0.0; double varY = 0.0;
for (int y = 0; y < height; y++) for (uint32_t y = 0; y < height; y++)
{ {
for (int x = 0; x < width; x++) for (uint32_t x = 0; x < width; x++)
{ {
avgY += picY[x]; avgY += picY[x];
varY += (double)picY[x] * (double)picY[x]; varY += (double)picY[x] * (double)picY[x];
@ -1083,9 +1083,9 @@ void uvg_lmcs_preanalyzer(struct encoder_state_t* const state, const videoframe_
{ {
aps->m_binNum = PIC_CODE_CW_BINS; aps->m_binNum = PIC_CODE_CW_BINS;
uvg_pixel* picY = &frame->source->y[0]; uvg_pixel* picY = &frame->source->y[0];
const int width = frame->source->width; const uint32_t width = frame->source->width;
const int height = frame->source->height; const uint32_t height = frame->source->height;
const int stride = frame->source->stride; const uint32_t stride = frame->source->stride;
uint32_t binCnt[PIC_CODE_CW_BINS] = { 0 }; uint32_t binCnt[PIC_CODE_CW_BINS] = { 0 };
uvg_init_lmcs_seq_stats(&aps->m_srcSeqStats, aps->m_binNum); uvg_init_lmcs_seq_stats(&aps->m_srcSeqStats, aps->m_binNum);
@ -1109,9 +1109,9 @@ void uvg_lmcs_preanalyzer(struct encoder_state_t* const state, const videoframe_
double avgY = 0.0; double avgY = 0.0;
double varY = 0.0; double varY = 0.0;
picY = &frame->source->y[0]; picY = &frame->source->y[0];
for (int y = 0; y < height; y++) for (uint32_t y = 0; y < height; y++)
{ {
for (int x = 0; x < width; x++) for (uint32_t x = 0; x < width; x++)
{ {
avgY += picY[x]; avgY += picY[x];
varY += (double)picY[x] * (double)picY[x]; varY += (double)picY[x] * (double)picY[x];
@ -1128,14 +1128,14 @@ void uvg_lmcs_preanalyzer(struct encoder_state_t* const state, const videoframe_
uvg_pixel* picU = &frame->source->u[0]; uvg_pixel* picU = &frame->source->u[0];
uvg_pixel* picV = &frame->source->v[0]; uvg_pixel* picV = &frame->source->v[0];
const int widthC = frame->source->width>>1; const uint32_t widthC = frame->source->width>>1;
const int heightC = frame->source->height>>1; const uint32_t heightC = frame->source->height>>1;
const int strideC = frame->source->stride>>1; const uint32_t strideC = frame->source->stride>>1;
double avgU = 0.0, avgV = 0.0; double avgU = 0.0, avgV = 0.0;
double varU = 0.0, varV = 0.0; double varU = 0.0, varV = 0.0;
for (int y = 0; y < heightC; y++) for (uint32_t y = 0; y < heightC; y++)
{ {
for (int x = 0; x < widthC; x++) for (uint32_t x = 0; x < widthC; x++)
{ {
avgU += picU[x]; avgU += picU[x];
avgV += picV[x]; avgV += picV[x];
@ -1188,7 +1188,7 @@ static void adjust_lmcs_pivot(lmcs_aps* aps)
aps->m_reshapePivot[i + 1] = aps->m_reshapePivot[i] + aps->m_binCW[i]; aps->m_reshapePivot[i + 1] = aps->m_reshapePivot[i] + aps->m_binCW[i];
} }
int segIdxMax = (aps->m_reshapePivot[aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1] >> log2SegSize); int segIdxMax = (aps->m_reshapePivot[aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1] >> log2SegSize);
for (int i = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++) for (uint32_t i = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
{ {
aps->m_reshapePivot[i + 1] = aps->m_reshapePivot[i] + aps->m_binCW[i]; aps->m_reshapePivot[i + 1] = aps->m_reshapePivot[i] + aps->m_binCW[i];
int segIdxCurr = (aps->m_reshapePivot[i] >> log2SegSize); int segIdxCurr = (aps->m_reshapePivot[i] >> log2SegSize);
@ -1199,7 +1199,7 @@ static void adjust_lmcs_pivot(lmcs_aps* aps)
if (segIdxCurr == segIdxMax) if (segIdxCurr == segIdxMax)
{ {
aps->m_reshapePivot[i] = aps->m_reshapePivot[aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1]; aps->m_reshapePivot[i] = aps->m_reshapePivot[aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1];
for (int j = i; j <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; j++) for (uint32_t j = i; j <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; j++)
{ {
aps->m_reshapePivot[j + 1] = aps->m_reshapePivot[i]; aps->m_reshapePivot[j + 1] = aps->m_reshapePivot[i];
aps->m_binCW[j] = 0; aps->m_binCW[j] = 0;
@ -1213,7 +1213,7 @@ static void adjust_lmcs_pivot(lmcs_aps* aps)
aps->m_reshapePivot[i + 1] += adjustVal; aps->m_reshapePivot[i + 1] += adjustVal;
aps->m_binCW[i] += adjustVal; aps->m_binCW[i] += adjustVal;
for (int j = i + 1; j <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; j++) for (uint32_t j = i + 1; j <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; j++)
{ {
if (aps->m_binCW[j] < (adjustVal + (orgCW >> 3))) if (aps->m_binCW[j] < (adjustVal + (orgCW >> 3)))
{ {
@ -1246,7 +1246,7 @@ static void adjust_lmcs_pivot(lmcs_aps* aps)
static int get_pwl_idx_inv(lmcs_aps* aps,int lumaVal) static int get_pwl_idx_inv(lmcs_aps* aps,int lumaVal)
{ {
int idxS = 0; uint32_t idxS = 0;
for (idxS = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; (idxS <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx); idxS++) for (idxS = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; (idxS <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx); idxS++)
{ {
if (lumaVal < aps->m_reshapePivot[idxS + 1]) break; if (lumaVal < aps->m_reshapePivot[idxS + 1]) break;
@ -1304,7 +1304,7 @@ void uvg_construct_reshaper_lmcs(lmcs_aps* aps)
adjust_lmcs_pivot(aps); adjust_lmcs_pivot(aps);
int maxAbsDeltaCW = 0, absDeltaCW = 0, deltaCW = 0; int maxAbsDeltaCW = 0, absDeltaCW = 0, deltaCW = 0;
for (int i = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++) for (uint32_t i = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
{ {
deltaCW = (int)aps->m_binCW[i] - (int)aps->m_initCW; deltaCW = (int)aps->m_binCW[i] - (int)aps->m_initCW;
aps->m_sliceReshapeInfo.reshaperModelBinCWDelta[i] = deltaCW; aps->m_sliceReshapeInfo.reshaperModelBinCWDelta[i] = deltaCW;
@ -1365,7 +1365,7 @@ static void code_lmcs_aps(encoder_state_t* const state, lmcs_aps* aps)
assert(aps->m_sliceReshapeInfo.maxNbitsNeededDeltaCW > 0); assert(aps->m_sliceReshapeInfo.maxNbitsNeededDeltaCW > 0);
WRITE_UE(stream, aps->m_sliceReshapeInfo.maxNbitsNeededDeltaCW - 1, "lmcs_delta_cw_prec_minus1"); WRITE_UE(stream, aps->m_sliceReshapeInfo.maxNbitsNeededDeltaCW - 1, "lmcs_delta_cw_prec_minus1");
for (int i = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++) for (uint32_t i = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
{ {
int deltaCW = aps->m_sliceReshapeInfo.reshaperModelBinCWDelta[i]; int deltaCW = aps->m_sliceReshapeInfo.reshaperModelBinCWDelta[i];
int signCW = (deltaCW < 0) ? 1 : 0; int signCW = (deltaCW < 0) ? 1 : 0;
@ -1425,7 +1425,7 @@ void uvg_encode_lmcs_adaptive_parameter_set(encoder_state_t* const state)
*/ */
static int getPWLIdxInv(lmcs_aps* aps, int lumaVal) static int getPWLIdxInv(lmcs_aps* aps, int lumaVal)
{ {
int idxS = 0; uint32_t idxS = 0;
for (idxS = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; (idxS <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx); idxS++) for (idxS = aps->m_sliceReshapeInfo.reshaperModelMinBinIdx; (idxS <= aps->m_sliceReshapeInfo.reshaperModelMaxBinIdx); idxS++)
{ {
if (lumaVal < aps->m_reshapePivot[idxS + 1]) break; if (lumaVal < aps->m_reshapePivot[idxS + 1]) break;
@ -1491,7 +1491,7 @@ int uvg_calculate_lmcs_chroma_adj_vpdu_nei(encoder_state_t* const state, lmcs_ap
{ {
for (int i = 0; i < numNeighbor; i++) for (int i = 0; i < numNeighbor; i++)
{ {
int k = (yPos + i) >= picH ? (picH - yPos - 1) : i; int k = (yPos + i) >= (int32_t)picH ? (picH - yPos - 1) : i;
recLuma += recSrc0[-1 + k * strideY]; recLuma += recSrc0[-1 + k * strideY];
pelnum++; pelnum++;
} }
@ -1500,7 +1500,7 @@ int uvg_calculate_lmcs_chroma_adj_vpdu_nei(encoder_state_t* const state, lmcs_ap
{ {
for (int i = 0; i < numNeighbor; i++) for (int i = 0; i < numNeighbor; i++)
{ {
int k = (xPos + i) >= picW ? (picW - xPos - 1) : i; int k = (xPos + i) >= (int32_t)picW ? (picW - xPos - 1) : i;
recLuma += recSrc0[-strideY + k]; recLuma += recSrc0[-strideY + k];
pelnum++; pelnum++;
} }

View file

@ -423,8 +423,8 @@ static void sao_search_edge_sao(const encoder_state_t * const state,
} }
{ {
float mode_bits = sao_mode_bits_edge(state, edge_class, edge_offset, sao_top, sao_left, buf_cnt); double mode_bits = sao_mode_bits_edge(state, edge_class, edge_offset, sao_top, sao_left, buf_cnt);
sum_ddistortion += (int)((double)mode_bits*state->lambda +0.5); sum_ddistortion += (int)(mode_bits*state->lambda +0.5);
} }
// SAO is not applied for category 0. // SAO is not applied for category 0.
edge_offset[SAO_EO_CAT0] = 0; edge_offset[SAO_EO_CAT0] = 0;
@ -456,7 +456,7 @@ static void sao_search_band_sao(const encoder_state_t * const state, const uvg_p
int sao_bands[2][32]; int sao_bands[2][32];
int temp_offsets[10]; int temp_offsets[10];
int ddistortion = 0; int ddistortion = 0;
float temp_rate = 0.0; double temp_rate = 0.0;
for (i = 0; i < buf_cnt; ++i) { for (i = 0; i < buf_cnt; ++i) {
FILL(sao_bands, 0); FILL(sao_bands, 0);
@ -468,7 +468,7 @@ static void sao_search_band_sao(const encoder_state_t * const state, const uvg_p
} }
temp_rate = sao_mode_bits_band(state, sao_out->band_position, temp_offsets, sao_top, sao_left, buf_cnt); temp_rate = sao_mode_bits_band(state, sao_out->band_position, temp_offsets, sao_top, sao_left, buf_cnt);
ddistortion += (int)((double)temp_rate*state->lambda + 0.5); ddistortion += (int)(temp_rate*state->lambda + 0.5);
// Select band sao over edge sao when distortion is lower // Select band sao over edge sao when distortion is lower
if (ddistortion < sao_out->ddistortion) { if (ddistortion < sao_out->ddistortion) {
@ -509,7 +509,7 @@ static void sao_search_best_mode(const encoder_state_t * const state, const uvg_
if (state->encoder_control->cfg.sao_type & 1){ 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); 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); double mode_bits = sao_mode_bits_edge(state, edge_sao.eo_class, edge_sao.offsets, sao_top, sao_left, buf_cnt);
int ddistortion = (int)(mode_bits * state->lambda + 0.5); int ddistortion = (int)(mode_bits * state->lambda + 0.5);
unsigned buf_i; unsigned buf_i;
@ -527,7 +527,7 @@ static void sao_search_best_mode(const encoder_state_t * const state, const uvg_
if (state->encoder_control->cfg.sao_type & 2){ if (state->encoder_control->cfg.sao_type & 2){
sao_search_band_sao(state, data, recdata, block_width, block_height, buf_cnt, &band_sao, sao_top, sao_left); sao_search_band_sao(state, data, recdata, block_width, block_height, buf_cnt, &band_sao, sao_top, sao_left);
float mode_bits = sao_mode_bits_band(state, band_sao.band_position, band_sao.offsets, sao_top, sao_left, buf_cnt); double mode_bits = sao_mode_bits_band(state, band_sao.band_position, band_sao.offsets, sao_top, sao_left, buf_cnt);
int ddistortion = (int)(mode_bits * state->lambda + 0.5); int ddistortion = (int)(mode_bits * state->lambda + 0.5);
unsigned buf_i; unsigned buf_i;
@ -554,7 +554,7 @@ static void sao_search_best_mode(const encoder_state_t * const state, const uvg_
// Choose between SAO and doing nothing, taking into account the // Choose between SAO and doing nothing, taking into account the
// rate-distortion cost of coding do nothing. // rate-distortion cost of coding do nothing.
{ {
float mode_bits_none = sao_mode_bits_none(state, sao_top, sao_left); double mode_bits_none = sao_mode_bits_none(state, sao_top, sao_left);
int cost_of_nothing = (int)(mode_bits_none * state->lambda + 0.5); int cost_of_nothing = (int)(mode_bits_none * state->lambda + 0.5);
if (sao_out->ddistortion >= cost_of_nothing) { if (sao_out->ddistortion >= cost_of_nothing) {
sao_out->type = SAO_TYPE_NONE; sao_out->type = SAO_TYPE_NONE;
@ -571,7 +571,7 @@ static void sao_search_best_mode(const encoder_state_t * const state, const uvg_
if (merge_cand) { if (merge_cand) {
unsigned buf_i; unsigned buf_i;
float mode_bits = sao_mode_bits_merge(state, i + 1); double mode_bits = sao_mode_bits_merge(state, i + 1);
int ddistortion = (int)(mode_bits * state->lambda + 0.5); int ddistortion = (int)(mode_bits * state->lambda + 0.5);
switch (merge_cand->type) { switch (merge_cand->type) {

View file

@ -129,7 +129,7 @@ void uvg_lcu_fill_trdepth(lcu_t *lcu, int x_px, int y_px, int depth, int tr_dept
{ {
const int x_local = SUB_SCU(x_px); const int x_local = SUB_SCU(x_px);
const int y_local = SUB_SCU(y_px); const int y_local = SUB_SCU(y_px);
const int width = LCU_WIDTH >> depth; const uint32_t width = LCU_WIDTH >> depth;
for (unsigned y = 0; y < width; y += SCU_WIDTH) { for (unsigned y = 0; y < width; y += SCU_WIDTH) {
for (unsigned x = 0; x < width; x += SCU_WIDTH) { for (unsigned x = 0; x < width; x += SCU_WIDTH) {
@ -183,7 +183,7 @@ static void lcu_fill_inter(lcu_t *lcu, int x_local, int y_local, int cu_width)
} }
} }
static void lcu_fill_cbf(lcu_t *lcu, int x_local, int y_local, int width, cu_info_t *cur_cu) static void lcu_fill_cbf(lcu_t *lcu, uint32_t x_local, uint32_t y_local, uint32_t width, cu_info_t *cur_cu)
{ {
const uint32_t tr_split = cur_cu->tr_depth - cur_cu->depth; const uint32_t tr_split = cur_cu->tr_depth - cur_cu->depth;
const uint32_t mask = ~((width >> tr_split)-1); const uint32_t mask = ~((width >> tr_split)-1);

View file

@ -313,11 +313,11 @@ static void select_starting_point(inter_search_info_t *info,
} }
// Go through candidates // Go through candidates
for (unsigned i = 0; i < info->num_merge_cand; ++i) { for (int32_t i = 0; i < info->num_merge_cand; ++i) {
if (info->merge_cand[i].dir == 3) continue; if (info->merge_cand[i].dir == 3) continue;
int x = (info->merge_cand[i].mv[info->merge_cand[i].dir - 1][0] + (1 << (INTERNAL_MV_PREC - 1)) ) >> INTERNAL_MV_PREC; int32_t x = (info->merge_cand[i].mv[info->merge_cand[i].dir - 1][0] + (1 << (INTERNAL_MV_PREC - 1)) ) >> INTERNAL_MV_PREC;
int y = (info->merge_cand[i].mv[info->merge_cand[i].dir - 1][1] + (1 << (INTERNAL_MV_PREC - 1)) ) >> INTERNAL_MV_PREC; int32_t y = (info->merge_cand[i].mv[info->merge_cand[i].dir - 1][1] + (1 << (INTERNAL_MV_PREC - 1)) ) >> INTERNAL_MV_PREC;
if (x == 0 && y == 0) continue; if (x == 0 && y == 0) continue;
@ -1063,7 +1063,7 @@ static void search_frac(inter_search_info_t *info,
tmp_pic, tmp_stride, tmp_pic, tmp_stride,
ext_origin + ext_s + 1, ext_s); ext_origin + ext_s + 1, ext_s);
costs[0] += info->mvd_cost_func(state, costs[0] += (uint32_t)info->mvd_cost_func(state,
mv.x, mv.y, INTERNAL_MV_PREC, mv.x, mv.y, INTERNAL_MV_PREC,
info->mv_cand, info->mv_cand,
NULL, NULL,
@ -1120,7 +1120,7 @@ static void search_frac(inter_search_info_t *info,
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
if (within_tile[j]) { if (within_tile[j]) {
costs[j] += info->mvd_cost_func( costs[j] += (uint32_t)info->mvd_cost_func(
state, state,
mv.x + pattern[j]->x, mv.x + pattern[j]->x,
mv.y + pattern[j]->y, mv.y + pattern[j]->y,
@ -1315,7 +1315,7 @@ static void search_pu_inter_ref(inter_search_info_t *info,
// Kvazaar always sets collocated_from_l0_flag so the list is L1 when // Kvazaar always sets collocated_from_l0_flag so the list is L1 when
// there are future references. // there are future references.
int col_list = ref_list; int col_list = ref_list;
for (int i = 0; i < info->state->frame->ref->used_size; i++) { for (uint32_t i = 0; i < info->state->frame->ref->used_size; i++) {
if (info->state->frame->ref->pocs[i] > info->state->frame->poc) { if (info->state->frame->ref->pocs[i] > info->state->frame->poc) {
col_list = 1; col_list = 1;
break; break;
@ -1469,7 +1469,7 @@ static void search_pu_inter_bipred(inter_search_info_t *info,
inter_merge_cand_t *merge_cand = info->merge_cand; inter_merge_cand_t *merge_cand = info->merge_cand;
for (int32_t idx = 0; idx < num_cand_pairs; idx++) { for (uint32_t idx = 0; idx < num_cand_pairs; idx++) {
uint8_t i = priorityList0[idx]; uint8_t i = priorityList0[idx];
uint8_t j = priorityList1[idx]; uint8_t j = priorityList1[idx];
if (i >= info->num_merge_cand || j >= info->num_merge_cand) break; if (i >= info->num_merge_cand || j >= info->num_merge_cand) break;
@ -1810,12 +1810,12 @@ static void search_pu_inter(encoder_state_t * const state,
amvp[2].size = 0; amvp[2].size = 0;
for (int mv_dir = 1; mv_dir < 4; ++mv_dir) { for (int mv_dir = 1; mv_dir < 4; ++mv_dir) {
for (int i = 0; i < state->frame->ref->used_size; ++i) { for (uint32_t i = 0; i < state->frame->ref->used_size; ++i) {
amvp[mv_dir - 1].cost[i] = MAX_DOUBLE; amvp[mv_dir - 1].cost[i] = MAX_DOUBLE;
} }
} }
for (int ref_idx = 0; ref_idx < state->frame->ref->used_size; ref_idx++) { for (uint32_t ref_idx = 0; ref_idx < state->frame->ref->used_size; ref_idx++) {
info->ref_idx = ref_idx; info->ref_idx = ref_idx;
info->ref = state->frame->ref->images[ref_idx]; info->ref = state->frame->ref->images[ref_idx];

View file

@ -260,7 +260,7 @@ static double search_intra_trdepth(
int y_px, int y_px,
int depth, int depth,
int max_depth, int max_depth,
int cost_treshold, double cost_treshold,
intra_search_data_t *const search_data, intra_search_data_t *const search_data,
lcu_t *const lcu) lcu_t *const lcu)
{ {
@ -631,8 +631,8 @@ static int16_t search_intra_rough(
if (mode + i * offset <= 66) { if (mode + i * offset <= 66) {
costs[modes_selected] = costs_out[i]; costs[modes_selected] = costs_out[i];
modes[modes_selected] = mode + i * offset; modes[modes_selected] = mode + i * offset;
min_cost = MIN(min_cost, costs[modes_selected]); min_cost = (int32_t)MIN(min_cost, costs[modes_selected]);
max_cost = MAX(max_cost, costs[modes_selected]); max_cost = (int32_t)MAX(max_cost, costs[modes_selected]);
++modes_selected; ++modes_selected;
} }
} }
@ -1219,7 +1219,7 @@ void uvg_search_cu_intra(
number_of_modes_to_search = 0; number_of_modes_to_search = 0;
} }
if(!skip_rough_search) { if(!skip_rough_search) {
sort_modes(search_data, number_of_modes); sort_modes(search_data, (uint8_t)number_of_modes);
} }
for(int pred_mode = 0; pred_mode < INTRA_MPM_COUNT; ++pred_mode) { for(int pred_mode = 0; pred_mode < INTRA_MPM_COUNT; ++pred_mode) {

View file

@ -144,7 +144,7 @@ static void uvg_angular_pred_avx2(
uvg_pixel temp_side[2 * 128 + 3 + 33 * MAX_REF_LINE_IDX] = { 0 }; uvg_pixel temp_side[2 * 128 + 3 + 33 * MAX_REF_LINE_IDX] = { 0 };
const int_fast32_t width = 1 << log2_width; const int_fast32_t width = 1 << log2_width;
uint32_t pred_mode = intra_mode; // ToDo: handle WAIP int32_t pred_mode = intra_mode; // ToDo: handle WAIP
// Whether to swap references to always project on the left reference row. // Whether to swap references to always project on the left reference row.
const bool vertical_mode = intra_mode >= 34; const bool vertical_mode = intra_mode >= 34;

View file

@ -715,7 +715,7 @@ static void uvg_filter_hpel_blocks_hor_ver_luma_avx2(const encoder_control_t * e
x = 0; x = 0;
int16_t sample = 64 * col_pos2[y + 1 + UVG_LUMA_FILTER_OFFSET] >> shift2; int16_t sample = 64 * col_pos2[y + 1 + UVG_LUMA_FILTER_OFFSET] >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
out_l[y * dst_stride + x] = sample; out_l[y * dst_stride + x] = (uvg_pixel)sample;
} }
// Top // Top
@ -782,7 +782,7 @@ static void uvg_filter_hpel_blocks_diag_luma_avx2(const encoder_control_t * enco
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_avx2(fir2, &col_pos2[y]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_avx2(fir2, &col_pos2[y]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
out_tl[y * dst_stride + x] = sample; out_tl[y * dst_stride + x] = (uvg_pixel)sample;
for (x = 1; x < width; ++x) out_tl[y * dst_stride + x] = out_tr[y * dst_stride + x - 1]; for (x = 1; x < width; ++x) out_tl[y * dst_stride + x] = out_tr[y * dst_stride + x - 1];
} }
@ -813,7 +813,7 @@ static void uvg_filter_hpel_blocks_diag_luma_avx2(const encoder_control_t * enco
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_avx2(fir2, &col_pos2[(y + 1)]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_avx2(fir2, &col_pos2[(y + 1)]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
out_bl[y * dst_stride + x] = sample; out_bl[y * dst_stride + x] = (uvg_pixel)sample;
} }
static void uvg_filter_qpel_blocks_hor_ver_luma_avx2(const encoder_control_t * encoder, static void uvg_filter_qpel_blocks_hor_ver_luma_avx2(const encoder_control_t * encoder,

View file

@ -823,7 +823,7 @@ static INLINE void bipred_average_px_px_template_avx2(uvg_pixel *dst,
assert(!(pu_w == 2 && pu_h == 8) && "Branch for 2x8 not yet implemented."); assert(!(pu_w == 2 && pu_h == 8) && "Branch for 2x8 not yet implemented.");
if (has_pow2_width && area_mod_32 == 0) { if (has_pow2_width && area_mod_32 == 0) {
for (int i = 0; i < pu_w * pu_h; i += 32) { for (uint32_t i = 0; i < pu_w * pu_h; i += 32) {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -844,10 +844,10 @@ static INLINE void bipred_average_px_px_template_avx2(uvg_pixel *dst,
} }
} }
} else if (area_mod_32 == 0) { } else if (area_mod_32 == 0) {
for (int i = 0; i < pu_w * pu_h; i += 24) { for (uint32_t i = 0; i < pu_w * pu_h; i += 24) {
int y = i / pu_w; uint32_t y = i / pu_w;
int x = i % pu_w; uint32_t x = i % pu_w;
// Last 64 bits of the 256 are not used to simplify the loop // Last 64 bits of the 256 are not used to simplify the loop
__m256i mask = _mm256_setr_epi64x(-1, -1, -1, 0); __m256i mask = _mm256_setr_epi64x(-1, -1, -1, 0);
@ -869,7 +869,7 @@ static INLINE void bipred_average_px_px_template_avx2(uvg_pixel *dst,
switch (pu_w) { switch (pu_w) {
__m128i sample_L0, sample_L1, avg; __m128i sample_L0, sample_L1, avg;
case 8: // 8x2, 8x6 case 8: // 8x2, 8x6
for (int i = 0; i < pu_w * pu_h; i += 16) { for (uint32_t i = 0; i < pu_w * pu_h; i += 16) {
int y = i / pu_w; int y = i / pu_w;
@ -881,7 +881,7 @@ static INLINE void bipred_average_px_px_template_avx2(uvg_pixel *dst,
} }
break; break;
case 6: // 6x8 case 6: // 6x8
for (int i = 0; i < pu_w * pu_h; i += 12) { for (uint32_t i = 0; i < pu_w * pu_h; i += 12) {
int y = i / pu_w; int y = i / pu_w;
@ -935,7 +935,7 @@ static INLINE void bipred_average_px_px_avx2(uvg_pixel *dst,
int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines
int32_t offset = 1 << (shift - 1); int32_t offset = 1 << (shift - 1);
for (int i = 0; i < pu_w * pu_h; ++i) for (uint32_t i = 0; i < pu_w * pu_h; ++i)
{ {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -964,7 +964,7 @@ static INLINE void bipred_average_im_im_template_avx2(uvg_pixel *dst,
assert(!(pu_w == 2 && pu_h == 8) && "Branch for 2x8 not yet implemented."); assert(!(pu_w == 2 && pu_h == 8) && "Branch for 2x8 not yet implemented.");
if (has_pow2_width && area_mod_32 == 0) { if (has_pow2_width && area_mod_32 == 0) {
for (int i = 0; i < pu_w * pu_h; i += 32) { for (uint32_t i = 0; i < pu_w * pu_h; i += 32) {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -1011,7 +1011,7 @@ static INLINE void bipred_average_im_im_template_avx2(uvg_pixel *dst,
} }
} }
} else if (area_mod_32 == 0) { } else if (area_mod_32 == 0) {
for (int i = 0; i < pu_w * pu_h; i += 24) { for (uint32_t i = 0; i < pu_w * pu_h; i += 24) {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -1062,7 +1062,7 @@ static INLINE void bipred_average_im_im_template_avx2(uvg_pixel *dst,
// 8x2, 8x6, 6x8 blocks (and maybe 2x8 in the future) // 8x2, 8x6, 6x8 blocks (and maybe 2x8 in the future)
switch (pu_w) { switch (pu_w) {
case 8: // 8x2, 8x6 case 8: // 8x2, 8x6
for (int i = 0; i < pu_w * pu_h; i += 16) { for (uint32_t i = 0; i < pu_w * pu_h; i += 16) {
int y = i / pu_w; int y = i / pu_w;
@ -1092,7 +1092,7 @@ static INLINE void bipred_average_im_im_template_avx2(uvg_pixel *dst,
} }
break; break;
case 6: // 6x8 case 6: // 6x8
for (int i = 0; i < pu_w * pu_h; i += 12) { for (uint32_t i = 0; i < pu_w * pu_h; i += 12) {
int y = i / pu_w; int y = i / pu_w;
@ -1163,7 +1163,7 @@ static void bipred_average_im_im_avx2(uvg_pixel *dst,
int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines
int32_t offset = 1 << (shift - 1); int32_t offset = 1 << (shift - 1);
for (int i = 0; i < pu_w * pu_h; ++i) for (uint32_t i = 0; i < pu_w * pu_h; ++i)
{ {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -1192,7 +1192,7 @@ static INLINE void bipred_average_px_im_template_avx2(uvg_pixel *dst,
assert(!(pu_w == 2 && pu_h == 8) && "Branch for 2x8 not yet implemented."); assert(!(pu_w == 2 && pu_h == 8) && "Branch for 2x8 not yet implemented.");
if (has_pow2_width && area_mod_32 == 0) { if (has_pow2_width && area_mod_32 == 0) {
for (int i = 0; i < pu_w * pu_h; i += 32) { for (uint32_t i = 0; i < pu_w * pu_h; i += 32) {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -1242,7 +1242,7 @@ static INLINE void bipred_average_px_im_template_avx2(uvg_pixel *dst,
} }
} }
} else if (area_mod_32 == 0) { } else if (area_mod_32 == 0) {
for (int i = 0; i < pu_w * pu_h; i += 24) { for (uint32_t i = 0; i < pu_w * pu_h; i += 24) {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -1297,7 +1297,7 @@ static INLINE void bipred_average_px_im_template_avx2(uvg_pixel *dst,
// 8x2, 8x6, 6x8 blocks (and maybe 2x8 in the future) // 8x2, 8x6, 6x8 blocks (and maybe 2x8 in the future)
switch (pu_w) { switch (pu_w) {
case 8: // 8x2, 8x6 case 8: // 8x2, 8x6
for (int i = 0; i < pu_w * pu_h; i += 16) { for (uint32_t i = 0; i < pu_w * pu_h; i += 16) {
int y = i / pu_w; int y = i / pu_w;
@ -1329,7 +1329,7 @@ static INLINE void bipred_average_px_im_template_avx2(uvg_pixel *dst,
} }
break; break;
case 6: // 6x8 case 6: // 6x8
for (int i = 0; i < pu_w * pu_h; i += 12) { for (uint32_t i = 0; i < pu_w * pu_h; i += 12) {
int y = i / pu_w; int y = i / pu_w;
@ -1404,7 +1404,7 @@ static void bipred_average_px_im_avx2(uvg_pixel *dst,
int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines
int32_t offset = 1 << (shift - 1); int32_t offset = 1 << (shift - 1);
for (int i = 0; i < pu_w * pu_h; ++i) for (uint32_t i = 0; i < pu_w * pu_h; ++i)
{ {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;

View file

@ -364,7 +364,7 @@ static INLINE unsigned uvg_math_floor_log2(unsigned value)
for (int i = 4; i >= 0; --i) { for (int i = 4; i >= 0; --i) {
unsigned bits = 1ull << i; unsigned bits = 1ull << i;
unsigned shift = value >= (1 << bits) ? bits : 0; unsigned shift = value >= (unsigned)(1 << bits) ? bits : 0;
result += shift; result += shift;
value >>= shift; value >>= shift;
} }

View file

@ -192,7 +192,7 @@ static INLINE void store_border_bytes( uint8_t *buf,
const int32_t width_rest, const int32_t width_rest,
uint32_t data) uint32_t data)
{ {
for (uint32_t i = 0; i < width_rest; i++) { for (int32_t i = 0; i < width_rest; i++) {
uint8_t currb = data & 0xff; uint8_t currb = data & 0xff;
buf[start_pos + i] = currb; buf[start_pos + i] = currb;
data >>= 8; data >>= 8;
@ -291,11 +291,11 @@ static int32_t sao_edge_ddistortion_avx2(const uint8_t *orig_data,
int32_t eo_class, int32_t eo_class,
const int32_t offsets[NUM_SAO_EDGE_CATEGORIES]) const int32_t offsets[NUM_SAO_EDGE_CATEGORIES])
{ {
int32_t y, x; uint32_t y, x;
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0]; vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1]; vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
int32_t scan_width = block_width - 2; uint32_t scan_width = block_width - 2;
uint32_t width_db32 = scan_width & ~31; uint32_t width_db32 = scan_width & ~31;
uint32_t width_db4 = scan_width & ~3; uint32_t width_db4 = scan_width & ~3;
uint32_t width_rest = scan_width & 3; uint32_t width_rest = scan_width & 3;
@ -330,7 +330,7 @@ static int32_t sao_edge_ddistortion_avx2(const uint8_t *orig_data,
__m256i offsets_256 = broadcast_xmm2ymm (offsets_8b); __m256i offsets_256 = broadcast_xmm2ymm (offsets_8b);
__m256i sum = _mm256_setzero_si256(); __m256i sum = _mm256_setzero_si256();
for (y = 1; y < block_height - 1; y++) { for (y = 1; y < (uint32_t)block_height - 1; y++) {
for (x = 1; x < width_db32 + 1; x += 32) { for (x = 1; x < width_db32 + 1; x += 32) {
uint32_t c_pos = y * block_width + x; uint32_t c_pos = y * block_width + x;
uint32_t a_pos = (y + a_ofs.y) * block_width + x + a_ofs.x; uint32_t a_pos = (y + a_ofs.y) * block_width + x + a_ofs.x;
@ -630,7 +630,7 @@ static INLINE void reconstruct_color_band(const encoder_control_t *encoder,
int32_t block_height, int32_t block_height,
color_t color_i) color_t color_i)
{ {
const uint32_t width_db32 = block_width & ~31; const int32_t width_db32 = block_width & ~31;
const uint32_t width_db4 = block_width & ~3; const uint32_t width_db4 = block_width & ~3;
const uint32_t width_rest = block_width & 3; const uint32_t width_rest = block_width & 3;
@ -644,8 +644,8 @@ static INLINE void reconstruct_color_band(const encoder_control_t *encoder,
__m256i offsets[16]; __m256i offsets[16];
calc_sao_offset_array_avx2(encoder, sao, offsets, color_i); calc_sao_offset_array_avx2(encoder, sao, offsets, color_i);
for (uint32_t y = 0; y < block_height; y++) { for (int32_t y = 0; y < block_height; y++) {
uint32_t x = 0; int32_t x = 0;
for (; x < width_db32; x += 32) { for (; x < width_db32; x += 32) {
const uint32_t curr_srcpos = y * stride + x; const uint32_t curr_srcpos = y * stride + x;
const uint32_t curr_dstpos = y * new_stride + x; const uint32_t curr_dstpos = y * new_stride + x;
@ -721,7 +721,7 @@ static INLINE void reconstruct_color_other(const encoder_control_t *encoder,
const vector2d_t a_ofs = g_sao_edge_offsets[sao->eo_class][0]; const vector2d_t a_ofs = g_sao_edge_offsets[sao->eo_class][0];
const vector2d_t b_ofs = g_sao_edge_offsets[sao->eo_class][1]; const vector2d_t b_ofs = g_sao_edge_offsets[sao->eo_class][1];
const uint32_t width_db32 = block_width & ~31; const int32_t width_db32 = block_width & ~31;
const uint32_t width_db4 = block_width & ~3; const uint32_t width_db4 = block_width & ~3;
const uint32_t width_rest = block_width & 3; const uint32_t width_rest = block_width & 3;
@ -738,8 +738,8 @@ static INLINE void reconstruct_color_other(const encoder_control_t *encoder,
const __m256i sao_offs = broadcast_xmm2ymm(sao_offs_16); const __m256i sao_offs = broadcast_xmm2ymm(sao_offs_16);
for (uint32_t y = 0; y < block_height; y++) { for (int32_t y = 0; y < block_height; y++) {
uint32_t x; int32_t x;
for (x = 0; x < width_db32; x += 32) { for (x = 0; x < width_db32; x += 32) {
const uint32_t src_pos = y * stride + x; const uint32_t src_pos = y * stride + x;
const uint32_t dst_pos = y * new_stride + x; const uint32_t dst_pos = y * new_stride + x;
@ -857,8 +857,8 @@ static int32_t sao_band_ddistortion_avx2(const encoder_state_t *state,
const __m256i threes = _mm256_set1_epi8 (3); const __m256i threes = _mm256_set1_epi8 (3);
__m256i sum = _mm256_setzero_si256(); __m256i sum = _mm256_setzero_si256();
for (uint32_t y = 0; y < block_height; y++) { for (int32_t y = 0; y < block_height; y++) {
for (uint32_t x = 0; x < block_width; x += 32) { for (int32_t x = 0; x < block_width; x += 32) {
const int32_t curr_pos = y * block_width + x; const int32_t curr_pos = y * block_width + x;
__m256i rd = _mm256_loadu_si256((const __m256i *)( rec_data + curr_pos)); __m256i rd = _mm256_loadu_si256((const __m256i *)( rec_data + curr_pos));

View file

@ -945,11 +945,11 @@ static void alf_get_blk_stats_generic(encoder_state_t* const state,
{ {
if (0/*m_alfWSSD*/) if (0/*m_alfWSSD*/)
{ {
alf_covariance[class_idx].ee[k][l][b0][b1] += weight * (e_local[k][b0] * (double)e_local[l][b1]); alf_covariance[class_idx].ee[k][l][b0][b1] += (int64_t)(weight * (e_local[k][b0] * (double)e_local[l][b1]));
} }
else else
{ {
alf_covariance[class_idx].ee[k][l][b0][b1] += e_local[k][b0] * (double)e_local[l][b1]; alf_covariance[class_idx].ee[k][l][b0][b1] += (int32_t)(e_local[k][b0] * (double)e_local[l][b1]);
} }
} }
} }
@ -958,11 +958,11 @@ static void alf_get_blk_stats_generic(encoder_state_t* const state,
{ {
if (0/*m_alfWSSD*/) if (0/*m_alfWSSD*/)
{ {
alf_covariance[class_idx].y[k][b] += weight * (e_local[k][b] * (double)y_local); alf_covariance[class_idx].y[k][b] += (int32_t)(weight * (e_local[k][b] * (double)y_local));
} }
else else
{ {
alf_covariance[class_idx].y[k][b] += e_local[k][b] * (double)y_local; alf_covariance[class_idx].y[k][b] += (int32_t)(e_local[k][b] * (double)y_local);
} }
} }
} }

View file

@ -305,7 +305,7 @@ void uvg_filter_hpel_blocks_hor_ver_luma_generic(const encoder_control_t * encod
int xpos = x; int xpos = x;
int16_t sample = uvg_eight_tap_filter_ver_generic(fir2, &src[src_stride*ypos + xpos + 1], src_stride) >> shift1; int16_t sample = uvg_eight_tap_filter_ver_generic(fir2, &src[src_stride*ypos + xpos + 1], src_stride) >> shift1;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[2][y * dst_stride + x] = sample; filtered[2][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -321,7 +321,7 @@ void uvg_filter_hpel_blocks_hor_ver_luma_generic(const encoder_control_t * encod
int xpos = x; int xpos = x;
int16_t sample = uvg_eight_tap_filter_ver_generic(fir2, &src[src_stride*(ypos + 1) + xpos + 1], src_stride) >> shift1; int16_t sample = uvg_eight_tap_filter_ver_generic(fir2, &src[src_stride*(ypos + 1) + xpos + 1], src_stride) >> shift1;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[3][y * dst_stride + x] = sample; filtered[3][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -360,7 +360,7 @@ void uvg_filter_hpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
for (x = 0; x < width; ++x) { for (x = 0; x < width; ++x) {
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(fir2, &hor_intermediate[1][y * hor_stride + x], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(fir2, &hor_intermediate[1][y * hor_stride + x], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[1][y * dst_stride + x] = sample; filtered[1][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -376,7 +376,7 @@ void uvg_filter_hpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(fir2, &col_pos2[y]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(fir2, &col_pos2[y]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[0][y * dst_stride + x] = sample; filtered[0][y * dst_stride + x] = (uvg_pixel)sample;
for (x = 1; x < width; ++x) filtered[0][y * dst_stride + x] = filtered[1][y * dst_stride + x - 1]; for (x = 1; x < width; ++x) filtered[0][y * dst_stride + x] = filtered[1][y * dst_stride + x - 1];
} }
@ -389,7 +389,7 @@ void uvg_filter_hpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
for (x = 0; x < width; ++x) { for (x = 0; x < width; ++x) {
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(fir2, &hor_intermediate[1][(y + 1) * hor_stride + x], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(fir2, &hor_intermediate[1][(y + 1) * hor_stride + x], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[3][y * dst_stride + x] = sample; filtered[3][y * dst_stride + x] = (uvg_pixel)sample;
} }
// Bottom-left // Bottom-left
@ -403,7 +403,7 @@ void uvg_filter_hpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(fir2, &col_pos2[(y + 1)]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(fir2, &col_pos2[(y + 1)]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[2][y * dst_stride + x] = sample; filtered[2][y * dst_stride + x] = (uvg_pixel)sample;
} }
void uvg_filter_qpel_blocks_hor_ver_luma_generic(const encoder_control_t * encoder, void uvg_filter_qpel_blocks_hor_ver_luma_generic(const encoder_control_t * encoder,
@ -502,14 +502,14 @@ void uvg_filter_qpel_blocks_hor_ver_luma_generic(const encoder_control_t * encod
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_l, &col_pos_l[y + sample_off_y]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_l, &col_pos_l[y + sample_off_y]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[0][y * dst_stride + x] = sample; filtered[0][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !off_x_fir_l; x < width; ++x) { for (x = !off_x_fir_l; x < width; ++x) {
int ypos = y + sample_off_y; int ypos = y + sample_off_y;
int xpos = x - !off_x_fir_l; int xpos = x - !off_x_fir_l;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_l, &hor_pos_l[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_l, &hor_pos_l[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[0][y * dst_stride + x] = sample; filtered[0][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -519,14 +519,14 @@ void uvg_filter_qpel_blocks_hor_ver_luma_generic(const encoder_control_t * encod
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_r, &col_pos_r[y + sample_off_y]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_r, &col_pos_r[y + sample_off_y]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[1][y * dst_stride + x] = sample; filtered[1][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !off_x_fir_r; x < width; ++x) { for (x = !off_x_fir_r; x < width; ++x) {
int ypos = y + sample_off_y; int ypos = y + sample_off_y;
int xpos = x - !off_x_fir_r; int xpos = x - !off_x_fir_r;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_r, &hor_pos_r[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_r, &hor_pos_r[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[1][y * dst_stride + x] = sample; filtered[1][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -537,14 +537,14 @@ void uvg_filter_qpel_blocks_hor_ver_luma_generic(const encoder_control_t * encod
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_t, &col_pos_hor[y + off_y_fir_t]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_t, &col_pos_hor[y + off_y_fir_t]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[2][y * dst_stride + x] = sample; filtered[2][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !sample_off_x; x < width; ++x) { for (x = !sample_off_x; x < width; ++x) {
int ypos = y + off_y_fir_t; int ypos = y + off_y_fir_t;
int xpos = x - !sample_off_x; int xpos = x - !sample_off_x;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_t, &hor_hpel_pos[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_t, &hor_hpel_pos[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[2][y * dst_stride + x] = sample; filtered[2][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -554,14 +554,14 @@ void uvg_filter_qpel_blocks_hor_ver_luma_generic(const encoder_control_t * encod
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_b, &col_pos_hor[y + off_y_fir_b]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_b, &col_pos_hor[y + off_y_fir_b]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[3][y * dst_stride + x] = sample; filtered[3][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !sample_off_x; x < width; ++x) { for (x = !sample_off_x; x < width; ++x) {
int ypos = y + off_y_fir_b; int ypos = y + off_y_fir_b;
int xpos = x - !sample_off_x; int xpos = x - !sample_off_x;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_b, &hor_hpel_pos[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_b, &hor_hpel_pos[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[3][y * dst_stride + x] = sample; filtered[3][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
} }
@ -615,14 +615,14 @@ void uvg_filter_qpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_t, &col_pos_l[y + off_y_fir_t]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_t, &col_pos_l[y + off_y_fir_t]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[0][y * dst_stride + x] = sample; filtered[0][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !off_x_fir_l; x < width; ++x) { for (x = !off_x_fir_l; x < width; ++x) {
int ypos = y + off_y_fir_t; int ypos = y + off_y_fir_t;
int xpos = x - !off_x_fir_l; int xpos = x - !off_x_fir_l;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_t, &hor_pos_l[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_t, &hor_pos_l[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[0][y * dst_stride + x] = sample; filtered[0][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -632,14 +632,14 @@ void uvg_filter_qpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_t, &col_pos_r[y + off_y_fir_t]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_t, &col_pos_r[y + off_y_fir_t]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[1][y * dst_stride + x] = sample; filtered[1][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !off_x_fir_r; x < width; ++x) { for (x = !off_x_fir_r; x < width; ++x) {
int ypos = y + off_y_fir_t; int ypos = y + off_y_fir_t;
int xpos = x - !off_x_fir_r; int xpos = x - !off_x_fir_r;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_t, &hor_pos_r[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_t, &hor_pos_r[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[1][y * dst_stride + x] = sample; filtered[1][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -649,14 +649,14 @@ void uvg_filter_qpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_b, &col_pos_l[y + off_y_fir_b]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_b, &col_pos_l[y + off_y_fir_b]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[2][y * dst_stride + x] = sample; filtered[2][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !off_x_fir_l; x < width; ++x) { for (x = !off_x_fir_l; x < width; ++x) {
int ypos = y + off_y_fir_b; int ypos = y + off_y_fir_b;
int xpos = x - !off_x_fir_l; int xpos = x - !off_x_fir_l;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_b, &hor_pos_l[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_b, &hor_pos_l[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[2][y * dst_stride + x] = sample; filtered[2][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
@ -666,14 +666,14 @@ void uvg_filter_qpel_blocks_diag_luma_generic(const encoder_control_t * encoder,
x = 0; x = 0;
int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_b, &col_pos_r[y + off_y_fir_b]) >> shift2; int16_t sample = uvg_eight_tap_filter_hor_16bit_generic(ver_fir_b, &col_pos_r[y + off_y_fir_b]) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[3][y * dst_stride + x] = sample; filtered[3][y * dst_stride + x] = (uvg_pixel)sample;
} }
for (x = !off_x_fir_r; x < width; ++x) { for (x = !off_x_fir_r; x < width; ++x) {
int ypos = y + off_y_fir_b; int ypos = y + off_y_fir_b;
int xpos = x - !off_x_fir_r; int xpos = x - !off_x_fir_r;
int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_b, &hor_pos_r[ypos * hor_stride + xpos], hor_stride) >> shift2; int16_t sample = uvg_eight_tap_filter_ver_16bit_generic(ver_fir_b, &hor_pos_r[ypos * hor_stride + xpos], hor_stride) >> shift2;
sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1); sample = uvg_fast_clip_16bit_to_pixel((sample + wp_offset1) >> wp_shift1);
filtered[3][y * dst_stride + x] = sample; filtered[3][y * dst_stride + x] = (uvg_pixel)sample;
} }
} }
} }

View file

@ -52,7 +52,7 @@ static void array_md5_generic(const uvg_pixel* data,
uint32_t width_modN = width % N; uint32_t width_modN = width % N;
uint32_t width_less_modN = width - width_modN; uint32_t width_less_modN = width - width_modN;
for (uint32_t y = 0; y < height; y++) for (uint32_t y = 0; y < (uint32_t)height; y++)
{ {
for (uint32_t x = 0; x < width_less_modN; x += N) for (uint32_t x = 0; x < width_less_modN; x += N)
{ {

View file

@ -49,10 +49,10 @@ uvg_pixel uvg_fast_clip_16bit_to_pixel(int16_t value)
#if UVG_BIT_DEPTH == 10 #if UVG_BIT_DEPTH == 10
temp &= PIXEL_MAX; temp &= PIXEL_MAX;
#endif #endif
return temp; return (uvg_pixel)temp;
} }
else { else {
return value; return (uvg_pixel)value;
} }
#else #else
return CLIP(PIXEL_MIN, PIXEL_MAX, value); return CLIP(PIXEL_MIN, PIXEL_MAX, value);
@ -557,7 +557,7 @@ static void bipred_average_px_px(uvg_pixel *dst,
int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines
int32_t offset = 1 << (shift - 1); int32_t offset = 1 << (shift - 1);
for (int i = 0; i < pu_w * pu_h; ++i) for (uint32_t i = 0; i < pu_w * pu_h; ++i)
{ {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -578,7 +578,7 @@ static void bipred_average_im_im(uvg_pixel *dst,
int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines
int32_t offset = 1 << (shift - 1); int32_t offset = 1 << (shift - 1);
for (int i = 0; i < pu_w * pu_h; ++i) for (uint32_t i = 0; i < pu_w * pu_h; ++i)
{ {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -599,7 +599,7 @@ static void bipred_average_px_im(uvg_pixel *dst,
int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines int32_t shift = 15 - UVG_BIT_DEPTH; // TODO: defines
int32_t offset = 1 << (shift - 1); int32_t offset = 1 << (shift - 1);
for (int i = 0; i < pu_w * pu_h; ++i) for (uint32_t i = 0; i < pu_w * pu_h; ++i)
{ {
int y = i / pu_w; int y = i / pu_w;
int x = i % pu_w; int x = i % pu_w;
@ -755,7 +755,7 @@ static double pixel_var_generic(const uvg_pixel *arr, const uint32_t len)
double arr_mean = 0; double arr_mean = 0;
// Calculate array mean // Calculate array mean
int i = 0; uint32_t i = 0;
double sum = 0; double sum = 0;
for (; i < len; ++i) { for (; i < len; ++i) {

View file

@ -77,7 +77,7 @@ void uvg_quant_generic(const encoder_state_t * const state, coeff_t *coef, coeff
sign = (level < 0 ? -1 : 1); sign = (level < 0 ? -1 : 1);
int32_t curr_quant_coeff = quant_coeff[n]; int32_t curr_quant_coeff = quant_coeff[n];
level = (abs_level * curr_quant_coeff + add) >> q_bits; level = (int32_t)((abs_level * curr_quant_coeff + add) >> q_bits);
ac_sum += level; ac_sum += level;
level *= sign; level *= sign;
@ -95,7 +95,7 @@ void uvg_quant_generic(const encoder_state_t * const state, coeff_t *coef, coeff
int64_t abs_level = (int64_t)abs(level); int64_t abs_level = (int64_t)abs(level);
int32_t curr_quant_coeff = quant_coeff[n]; int32_t curr_quant_coeff = quant_coeff[n];
level = (abs_level * curr_quant_coeff + add) >> q_bits; level = (int32_t)((abs_level * curr_quant_coeff + add) >> q_bits);
delta_u[n] = (int32_t)((abs_level * curr_quant_coeff - (level << q_bits)) >> q_bits8); delta_u[n] = (int32_t)((abs_level * curr_quant_coeff - (level << q_bits)) >> q_bits8);
} }

View file

@ -61,7 +61,7 @@ static unsigned reg_sad_sse2(const uint8_t * const data1, const uint8_t * const
} }
} }
_mm_storeu_si128((__m128i*) sse_inc_array, sse_inc); _mm_storeu_si128((__m128i*) sse_inc_array, sse_inc);
sad += sse_inc_array[0] + sse_inc_array[1]; sad += (uint32_t)(sse_inc_array[0] + sse_inc_array[1]);
return sad; return sad;
} }

View file

@ -909,7 +909,7 @@ static INLINE uint32_t hor_sad_sse41_arbitrary(const uint8_t *pic_data, const ui
__m128i borderpx_vec_f = _mm_set1_epi8(ref_data[(int32_t)((y + 2) * ref_stride + border_off)]); __m128i borderpx_vec_f = _mm_set1_epi8(ref_data[(int32_t)((y + 2) * ref_stride + border_off)]);
__m128i borderpx_vec_h = _mm_set1_epi8(ref_data[(int32_t)((y + 3) * ref_stride + border_off)]); __m128i borderpx_vec_h = _mm_set1_epi8(ref_data[(int32_t)((y + 3) * ref_stride + border_off)]);
for (x = 0; x < outside_vecs; x++) { for (x = 0; x < (int32_t)outside_vecs; x++) {
__m128i a = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 0) * pic_stride + outvec_offset)); __m128i a = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 0) * pic_stride + outvec_offset));
__m128i c = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 1) * pic_stride + outvec_offset)); __m128i c = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 1) * pic_stride + outvec_offset));
__m128i e = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 2) * pic_stride + outvec_offset)); __m128i e = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 2) * pic_stride + outvec_offset));
@ -996,7 +996,7 @@ static INLINE uint32_t hor_sad_sse41_arbitrary(const uint8_t *pic_data, const ui
if (height_residual_lines) { if (height_residual_lines) {
for (; y < height; y++) { for (; y < height; y++) {
__m128i borderpx_vec = _mm_set1_epi8(ref_data[(int32_t)((y + 0) * ref_stride + border_off)]); __m128i borderpx_vec = _mm_set1_epi8(ref_data[(int32_t)((y + 0) * ref_stride + border_off)]);
for (x = 0; x < outside_vecs; x++) { for (x = 0; x < (int32_t)outside_vecs; x++) {
__m128i a = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 0) * pic_stride + outvec_offset)); __m128i a = _mm_loadu_si128((__m128i *)(pic_data + x * vec_width + (y + 0) * pic_stride + outvec_offset));
__m128i startoffs = _mm_set1_epi8 ((x + inside_vecs) << vec_width_log2); __m128i startoffs = _mm_set1_epi8 ((x + inside_vecs) << vec_width_log2);

View file

@ -281,7 +281,7 @@ static void* strategyselector_choose_for(const strategy_list_t * const strategie
int max_priority_i = -1; int max_priority_i = -1;
char buffer[256]; char buffer[256];
char *override = NULL; char *override = NULL;
int i = 0; uint32_t i = 0;
// Because VS doesn't support snprintf, let's assert that there is // Because VS doesn't support snprintf, let's assert that there is
// enough room in the buffer. Max length for strategy type is // enough room in the buffer. Max length for strategy type is
@ -369,7 +369,7 @@ static INLINE int get_cpuid(unsigned level, unsigned sublevel, cpuid_t *cpu_info
__cpuidex(vendor_info, 0, 0); __cpuidex(vendor_info, 0, 0);
// Check highest supported function. // Check highest supported function.
if (level > vendor_info[0]) return 0; if ((int32_t)level > vendor_info[0]) return 0;
int ms_cpu_info[4] = { cpu_info->eax, cpu_info->ebx, cpu_info->ecx, cpu_info->edx }; int ms_cpu_info[4] = { cpu_info->eax, cpu_info->ebx, cpu_info->ecx, cpu_info->edx };
__cpuidex(ms_cpu_info, level, sublevel); __cpuidex(ms_cpu_info, level, sublevel);

View file

@ -135,7 +135,7 @@ static uvg_encoder * uvg266_open(const uvg_config *cfg)
encoder->states[i].frame->QP = (int8_t)cfg->qp; encoder->states[i].frame->QP = (int8_t)cfg->qp;
} }
for (int i = 0; i < encoder->num_encoder_states; ++i) { for (uint32_t i = 0; i < encoder->num_encoder_states; ++i) {
if (i == 0) { if (i == 0) {
encoder->states[i].previous_encoder_state = &encoder->states[encoder->num_encoder_states - 1]; encoder->states[i].previous_encoder_state = &encoder->states[encoder->num_encoder_states - 1];
} else { } else {
@ -190,7 +190,7 @@ static int uvg266_headers(uvg_encoder *enc,
uvg_encoder_state_write_parameter_sets(&stream, &enc->states[enc->cur_state_num]); uvg_encoder_state_write_parameter_sets(&stream, &enc->states[enc->cur_state_num]);
// Get stream length before taking chunks since that clears the stream. // Get stream length before taking chunks since that clears the stream.
if (len_out) *len_out = uvg_bitstream_tell(&stream) / 8; if (len_out) *len_out = (uint32_t)(uvg_bitstream_tell(&stream) / 8);
if (data_out) *data_out = uvg_bitstream_take_chunks(&stream); if (data_out) *data_out = uvg_bitstream_take_chunks(&stream);
uvg_bitstream_finalize(&stream); uvg_bitstream_finalize(&stream);
@ -213,25 +213,25 @@ static int yuv_io_extract_field(const uvg_picture *frame_in, unsigned source_sca
if ((source_scan_type != 1) && (source_scan_type != 2)) return 0; if ((source_scan_type != 1) && (source_scan_type != 2)) return 0;
if ((field_parity != 0) && (field_parity != 1)) return 0; if ((field_parity != 0) && (field_parity != 1)) return 0;
unsigned offset = 0; int32_t offset = 0;
if (source_scan_type == 1) offset = field_parity ? 1 : 0; if (source_scan_type == 1) offset = field_parity ? 1 : 0;
else if (source_scan_type == 2) offset = field_parity ? 0 : 1; else if (source_scan_type == 2) offset = field_parity ? 0 : 1;
//Luma //Luma
for (int i = 0; i < field_out->height; ++i){ for (int32_t i = 0; i < field_out->height; ++i){
uvg_pixel *row_in = frame_in->y + MIN(frame_in->height - 1, 2 * i + offset) * frame_in->stride; uvg_pixel *row_in = frame_in->y + MIN(frame_in->height - 1, 2 * i + offset) * frame_in->stride;
uvg_pixel *row_out = field_out->y + i * field_out->stride; uvg_pixel *row_out = field_out->y + i * field_out->stride;
memcpy(row_out, row_in, sizeof(uvg_pixel) * frame_in->stride); memcpy(row_out, row_in, sizeof(uvg_pixel) * frame_in->stride);
} }
//Chroma //Chroma
for (int i = 0; i < field_out->height / 2; ++i){ for (int32_t i = 0; i < field_out->height / 2; ++i) {
uvg_pixel *row_in = frame_in->u + MIN(frame_in->height / 2 - 1, 2 * i + offset) * frame_in->stride / 2; uvg_pixel *row_in = frame_in->u + MIN(frame_in->height / 2 - 1, 2 * i + offset) * frame_in->stride / 2;
uvg_pixel *row_out = field_out->u + i * field_out->stride / 2; uvg_pixel *row_out = field_out->u + i * field_out->stride / 2;
memcpy(row_out, row_in, sizeof(uvg_pixel) * frame_in->stride / 2); memcpy(row_out, row_in, sizeof(uvg_pixel) * frame_in->stride / 2);
} }
for (int i = 0; i < field_out->height / 2; ++i){ for (int32_t i = 0; i < field_out->height / 2; ++i) {
uvg_pixel *row_in = frame_in->v + MIN(frame_in->height / 2 - 1, 2 * i + offset) * frame_in->stride / 2; uvg_pixel *row_in = frame_in->v + MIN(frame_in->height / 2 - 1, 2 * i + offset) * frame_in->stride / 2;
uvg_pixel *row_out = field_out->v + i * field_out->stride / 2; uvg_pixel *row_out = field_out->v + i * field_out->stride / 2;
memcpy(row_out, row_in, sizeof(uvg_pixel) * frame_in->stride / 2); memcpy(row_out, row_in, sizeof(uvg_pixel) * frame_in->stride / 2);
@ -297,7 +297,7 @@ static int uvg266_encode(uvg_encoder *enc,
uvg_threadqueue_free_job(&output_state->tqj_bitstream_written); uvg_threadqueue_free_job(&output_state->tqj_bitstream_written);
// Get stream length before taking chunks since that clears the stream. // Get stream length before taking chunks since that clears the stream.
if (len_out) *len_out = uvg_bitstream_tell(&output_state->stream) / 8; if (len_out) *len_out = (uint32_t)(uvg_bitstream_tell(&output_state->stream) / 8);
if (data_out) *data_out = uvg_bitstream_take_chunks(&output_state->stream); if (data_out) *data_out = uvg_bitstream_take_chunks(&output_state->stream);
if (pic_out) *pic_out = uvg_image_copy_ref(output_state->tile->frame->rec); if (pic_out) *pic_out = uvg_image_copy_ref(output_state->tile->frame->rec);
if (src_out) *src_out = uvg_image_copy_ref(output_state->tile->frame->source); if (src_out) *src_out = uvg_image_copy_ref(output_state->tile->frame->source);

View file

@ -48,7 +48,7 @@ static INLINE unsigned uvg_math_floor_log2(unsigned value)
for (int i = 4; i >= 0; --i) { for (int i = 4; i >= 0; --i) {
unsigned bits = 1ull << i; unsigned bits = 1ull << i;
unsigned shift = value >= (1 << bits) ? bits : 0; unsigned shift = (int32_t)value >= (1 << bits) ? bits : 0;
result += shift; result += shift;
value >>= shift; value >>= shift;
} }

View file

@ -148,7 +148,7 @@ static bool machine_is_big_endian()
static void mask_to_bitdepth(uvg_pixel *buf, unsigned length, unsigned bitdepth) static void mask_to_bitdepth(uvg_pixel *buf, unsigned length, unsigned bitdepth)
{ {
uvg_pixel bitdepth_mask = (1 << bitdepth) - 1; uvg_pixel bitdepth_mask = (1 << bitdepth) - 1;
for (int i = 0; i < length; ++i) { for (uint32_t i = 0; i < length; ++i) {
buf[i] = buf[i] & bitdepth_mask; buf[i] = buf[i] & bitdepth_mask;
} }
} }
@ -340,16 +340,16 @@ int yuv_io_write(FILE* file,
unsigned output_width, unsigned output_height) unsigned output_width, unsigned output_height)
{ {
const int stride = img->stride; const int stride = img->stride;
for (int y = 0; y < output_height; ++y) { for (uint32_t y = 0; y < output_height; ++y) {
fwrite(&img->y[y * stride], sizeof(*img->y), output_width, file); fwrite(&img->y[y * stride], sizeof(*img->y), output_width, file);
// TODO: Check that fwrite succeeded. // TODO: Check that fwrite succeeded.
} }
if (img->chroma_format != UVG_CSP_400) { if (img->chroma_format != UVG_CSP_400) {
for (int y = 0; y < output_height / 2; ++y) { for (uint32_t y = 0; y < output_height / 2; ++y) {
fwrite(&img->u[y * stride / 2], sizeof(*img->u), output_width / 2, file); fwrite(&img->u[y * stride / 2], sizeof(*img->u), output_width / 2, file);
} }
for (int y = 0; y < output_height / 2; ++y) { for (uint32_t y = 0; y < output_height / 2; ++y) {
fwrite(&img->v[y * stride / 2], sizeof(*img->v), output_width / 2, file); fwrite(&img->v[y * stride / 2], sizeof(*img->v), output_width / 2, file);
} }
} }