mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Fix CBF context init and use
This commit is contained in:
parent
db94ec1a84
commit
48b8898e53
|
@ -58,7 +58,7 @@ typedef struct
|
|||
cabac_ctx_t qt_split_flag_model[6]; //!< \brief qt split flag context models
|
||||
cabac_ctx_t intra_luma_mpm_flag_model; //!< \brief intra mode context models
|
||||
cabac_ctx_t intra_subpart_model[2]; //!< \brief intra sub part context models
|
||||
cabac_ctx_t chroma_pred_model[1];
|
||||
cabac_ctx_t chroma_pred_model;
|
||||
cabac_ctx_t inter_dir[5];
|
||||
cabac_ctx_t qt_cbf_model_luma[4];
|
||||
cabac_ctx_t qt_cbf_model_cr[2];
|
||||
|
|
|
@ -92,11 +92,11 @@ static const uint8_t INIT_INTRA_LUMA_PLANAR_MODE[4][2] = {
|
|||
{ 4, 5, },
|
||||
};
|
||||
|
||||
static const uint8_t INIT_CHROMA_PRED_MODE[4][1] = {
|
||||
{ 25, },
|
||||
{ 33, },
|
||||
{ 19, },
|
||||
{ 6, },
|
||||
static const uint8_t INIT_CHROMA_PRED_MODE[4] = {
|
||||
25,
|
||||
33,
|
||||
19,
|
||||
6,
|
||||
};
|
||||
|
||||
static const uint8_t INIT_CU_QP_DELTA_ABS[4][2] = {
|
||||
|
@ -355,7 +355,7 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
kvz_ctx_init(&cabac->ctx.multi_ref_line[0], QP, MULTI_REF_LINE_MODE[slice][0], MULTI_REF_LINE_MODE[3][0]);
|
||||
kvz_ctx_init(&cabac->ctx.multi_ref_line[1], QP, MULTI_REF_LINE_MODE[slice][1], MULTI_REF_LINE_MODE[3][1]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.chroma_pred_model[0], QP, INIT_CHROMA_PRED_MODE[slice][0], INIT_CHROMA_PRED_MODE[3][0]);
|
||||
kvz_ctx_init(&cabac->ctx.chroma_pred_model, QP, INIT_CHROMA_PRED_MODE[slice], INIT_CHROMA_PRED_MODE[3]);
|
||||
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
@ -384,10 +384,11 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
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]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cb[0], QP, INIT_QT_CBF[slice][5], INIT_QT_CBF[3][5]);
|
||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cb[0], QP, INIT_QT_CBF[slice][4], INIT_QT_CBF[3][4]);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cr[i], QP, INIT_QT_CBF[slice][i + 6], INIT_QT_CBF[3][i + 6]);
|
||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cr[i], QP, INIT_QT_CBF[slice][i + 5], INIT_QT_CBF[3][i + 5]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.cu_mvd_model[i], QP, INIT_MVD[slice][i], INIT_MVD[3][i]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_ref_pic_model[i], QP, INIT_REF_PIC[slice][i], INIT_REF_PIC[3][i]);
|
||||
kvz_ctx_init(&cabac->ctx.luma_planar_model[i], QP, INIT_INTRA_LUMA_PLANAR_MODE[slice][i], INIT_INTRA_LUMA_PLANAR_MODE[3][i]);
|
||||
|
|
|
@ -850,7 +850,7 @@ static void encode_transform_coeff(encoder_state_t * const state,
|
|||
if (!split) {
|
||||
if (true) {
|
||||
assert(tr_depth < 5);
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_cb[tr_depth]);
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_cb[0]);
|
||||
CABAC_BIN(cabac, cb_flag_u, "cbf_cb");
|
||||
}
|
||||
if (true) {
|
||||
|
@ -877,7 +877,7 @@ static void encode_transform_coeff(encoder_state_t * const state,
|
|||
// - we have chroma coefficients at this level
|
||||
// When it is not present, it is inferred to be 1.
|
||||
if (cur_cu->type == CU_INTRA || tr_depth > 0 || cb_flag_u || cb_flag_v) {
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_luma[!tr_depth]);
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_luma[0]);
|
||||
CABAC_BIN(cabac, cb_flag_y, "cbf_luma");
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ static void encode_intra_coding_unit(encoder_state_t * const state,
|
|||
int8_t luma_intra_dir = first_pu->intra.mode;
|
||||
|
||||
bool derived_mode = 1;// chroma_intra_dir == 70;
|
||||
cabac->cur_ctx = &(cabac->ctx.chroma_pred_model[0]);
|
||||
cabac->cur_ctx = &(cabac->ctx.chroma_pred_model);
|
||||
CABAC_BIN(cabac, derived_mode ? 0 : 1, "intra_chroma_pred_mode");
|
||||
|
||||
|
||||
|
@ -1478,11 +1478,11 @@ void kvz_encode_coding_tree(encoder_state_t * const state,
|
|||
// Get left and top block split_flags and if they are present and true, increase model number
|
||||
// ToDo: should use height and width to increase model, PU_GET_W() ?
|
||||
if (left_cu && GET_SPLITDATA(left_cu, depth) == 1) {
|
||||
//split_model++;
|
||||
split_model++;
|
||||
}
|
||||
|
||||
if (above_cu && GET_SPLITDATA(above_cu, depth) == 1) {
|
||||
//split_model++;
|
||||
split_model++;
|
||||
}
|
||||
|
||||
uint32_t split_num = 0;
|
||||
|
|
|
@ -686,7 +686,7 @@ double kvz_luma_mode_bits(const encoder_state_t *state, int8_t luma_mode, const
|
|||
|
||||
double kvz_chroma_mode_bits(const encoder_state_t *state, int8_t chroma_mode, int8_t luma_mode)
|
||||
{
|
||||
const cabac_ctx_t *ctx = &(state->cabac.ctx.chroma_pred_model[1]);
|
||||
const cabac_ctx_t *ctx = &(state->cabac.ctx.chroma_pred_model);
|
||||
double mode_bits;
|
||||
if (chroma_mode == luma_mode) {
|
||||
mode_bits = CTX_ENTROPY_FBITS(ctx, 0);
|
||||
|
|
Loading…
Reference in a new issue