mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-12-18 03:04:06 +00:00
Use correct pred_mode cabac models -> fixes inter cabac bits
This commit is contained in:
parent
5798eea6f8
commit
26f4f45c6d
14
src/cabac.h
14
src/cabac.h
|
@ -75,7 +75,7 @@ typedef struct
|
|||
cabac_ctx_t cu_ctx_last_y_chroma[3];
|
||||
cabac_ctx_t cu_ctx_last_x_luma[20];
|
||||
cabac_ctx_t cu_ctx_last_x_chroma[3];
|
||||
cabac_ctx_t cu_pred_mode_model;
|
||||
cabac_ctx_t cu_pred_mode_model[2];
|
||||
cabac_ctx_t cu_skip_flag_model[3];
|
||||
cabac_ctx_t cu_merge_idx_ext_model;
|
||||
cabac_ctx_t cu_merge_flag_ext_model;
|
||||
|
@ -153,8 +153,8 @@ extern uint32_t kvz_cabac_bins_count;
|
|||
extern bool kvz_cabac_bins_verbose;
|
||||
#define CABAC_BIN(data, value, name) { \
|
||||
uint32_t prev_state = CTX_STATE(data->cur_ctx); \
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) printf("%d %d [%d:%d] %s = %u, range = %u LPS = %u state = %u -> ", \
|
||||
kvz_cabac_bins_count++, (data)->range, (data)->range-CTX_LPS(data->cur_ctx,(data)->range), CTX_LPS(data->cur_ctx,(data)->range), (name), (uint32_t)(value), (data)->range, CTX_LPS(data->cur_ctx,(data)->range), prev_state); \
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) {printf("%d %d [%d:%d] %s = %u, range = %u LPS = %u state = %u -> ", \
|
||||
kvz_cabac_bins_count++, (data)->range, (data)->range-CTX_LPS(data->cur_ctx,(data)->range), CTX_LPS(data->cur_ctx,(data)->range), (name), (uint32_t)(value), (data)->range, CTX_LPS(data->cur_ctx,(data)->range), prev_state); }\
|
||||
kvz_cabac_encode_bin((data), (value)); \
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) printf("%u\n", CTX_STATE(data->cur_ctx)); }
|
||||
|
||||
|
@ -162,14 +162,14 @@ extern bool kvz_cabac_bins_verbose;
|
|||
#define CABAC_BINS_EP(data, value, bins, name) { \
|
||||
uint32_t prev_state = CTX_STATE(data->cur_ctx); \
|
||||
kvz_cabac_encode_bins_ep((data), (value), (bins)); \
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) printf("%d %s = %u(%u bins), state = %u -> %u\n", \
|
||||
kvz_cabac_bins_count, (name), (uint32_t)(value), (bins), prev_state, CTX_STATE(data->cur_ctx)); kvz_cabac_bins_count+=bins;}
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) { printf("%d %s = %u(%u bins), state = %u -> %u\n", \
|
||||
kvz_cabac_bins_count, (name), (uint32_t)(value), (bins), prev_state, CTX_STATE(data->cur_ctx)); kvz_cabac_bins_count+=bins;}}
|
||||
|
||||
#define CABAC_BIN_EP(data, value, name) { \
|
||||
uint32_t prev_state = CTX_STATE(data->cur_ctx); \
|
||||
kvz_cabac_encode_bin_ep((data), (value)); \
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) printf("%d %s = %u, state = %u -> %u\n", \
|
||||
kvz_cabac_bins_count++, (name), (uint32_t)(value), prev_state, CTX_STATE(data->cur_ctx)); }
|
||||
if(kvz_cabac_bins_verbose && !data->only_count) {printf("%d %s = %u, state = %u -> %u\n", \
|
||||
kvz_cabac_bins_count++, (name), (uint32_t)(value), prev_state, CTX_STATE(data->cur_ctx)); }}
|
||||
#else
|
||||
#define CABAC_BIN(data, value, name) \
|
||||
kvz_cabac_encode_bin((data), (value));
|
||||
|
|
|
@ -343,7 +343,7 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
|
||||
kvz_ctx_init(&cabac->ctx.cu_merge_flag_ext_model, QP, INIT_MERGE_FLAG_EXT[slice][0], INIT_MERGE_FLAG_EXT[3][0]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_merge_idx_ext_model, QP, INIT_MERGE_IDX_EXT[slice][0], INIT_MERGE_IDX_EXT[3][0]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_pred_mode_model, QP, INIT_PRED_MODE[slice][0], INIT_PRED_MODE[3][0]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.cu_transquant_bypass, QP, INIT_CU_TRANSQUANT_BYPASS[slice][0], INIT_CU_TRANSQUANT_BYPASS[3][0]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.intra_luma_mpm_flag_model, QP, INIT_INTRA_LUMA_MPM_FLAG[slice], INIT_INTRA_LUMA_MPM_FLAG[3]);
|
||||
|
@ -383,6 +383,9 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
|
||||
|
||||
//TODO: ignore P/B contexts on intra frame
|
||||
kvz_ctx_init(&cabac->ctx.cu_pred_mode_model[0], QP, INIT_PRED_MODE[slice][0], INIT_PRED_MODE[3][0]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_pred_mode_model[1], QP, INIT_PRED_MODE[slice][1], INIT_PRED_MODE[3][1]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.cu_qt_root_cbf_model, QP, INIT_QT_ROOT_CBF[slice][0], INIT_QT_ROOT_CBF[3][0]);
|
||||
kvz_ctx_init(&cabac->ctx.mvp_idx_model, QP, INIT_MVP_IDX[slice][0], INIT_MVP_IDX[3][0]);
|
||||
|
||||
|
|
|
@ -1010,7 +1010,14 @@ void kvz_encode_coding_tree(encoder_state_t * const state,
|
|||
|
||||
// Prediction mode
|
||||
if (state->frame->slicetype != KVZ_SLICE_I) {
|
||||
cabac->cur_ctx = &(cabac->ctx.cu_pred_mode_model);
|
||||
|
||||
int8_t ctx_predmode = 0;
|
||||
|
||||
if ((left_cu && left_cu->type == CU_INTRA) || (above_cu && above_cu->type == CU_INTRA)) {
|
||||
ctx_predmode=1;
|
||||
}
|
||||
|
||||
cabac->cur_ctx = &(cabac->ctx.cu_pred_mode_model[ctx_predmode]);
|
||||
CABAC_BIN(cabac, (cur_cu->type == CU_INTRA), "PredMode");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue