diff --git a/src/cabac.h b/src/cabac.h index 9a35990f..4311b132 100644 --- a/src/cabac.h +++ b/src/cabac.h @@ -56,7 +56,7 @@ typedef struct cabac_ctx_t split_flag_model[5]; //!< \brief split flag context models cabac_ctx_t bt_split_flag_model[12]; //!< \brief bt split flag context models cabac_ctx_t intra_mode_model; //!< \brief intra mode context models - cabac_ctx_t chroma_pred_model[2]; + cabac_ctx_t chroma_pred_model[12]; cabac_ctx_t inter_dir[5]; cabac_ctx_t trans_subdiv_model[3]; //!< \brief intra mode context models cabac_ctx_t qt_cbf_model_luma[5]; diff --git a/src/context.c b/src/context.c index 18e9bc47..2ec8fcd7 100644 --- a/src/context.c +++ b/src/context.c @@ -104,10 +104,10 @@ static const uint8_t INIT_INTRA_PRED_MODE[3] = { 183, 154, 184 }; -static const uint8_t INIT_CHROMA_PRED_MODE[3][2] = { - { 152, 139 }, - { 152, 139 }, - { 63, 139 }, +static const uint8_t INIT_CHROMA_PRED_MODE[3][12] = { + { 139, 152, 139, 154, 154, 154, 154, 154, 154, 154, 154, 154, }, + { 139, 152, 139, 154, 154, 154, 154, 154, 154, 154, 154, 154, }, + { 139, 63, 139, 154, 154, 154, 154, 154, 154, 154, 154, 154, }, }; static const uint8_t INIT_INTER_DIR[3][5] = { @@ -281,23 +281,15 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice) kvz_ctx_init(&cabac->ctx.split_flag_model[4], QP, INIT_SPLIT_FLAG[slice][4]); // BT split flag init - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[0], QP, INIT_BT_SPLIT_FLAG[slice][0]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[1], QP, INIT_BT_SPLIT_FLAG[slice][1]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[2], QP, INIT_BT_SPLIT_FLAG[slice][2]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[3], QP, INIT_BT_SPLIT_FLAG[slice][3]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[4], QP, INIT_BT_SPLIT_FLAG[slice][4]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[5], QP, INIT_BT_SPLIT_FLAG[slice][5]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[6], QP, INIT_BT_SPLIT_FLAG[slice][6]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[7], QP, INIT_BT_SPLIT_FLAG[slice][7]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[8], QP, INIT_BT_SPLIT_FLAG[slice][8]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[9], QP, INIT_BT_SPLIT_FLAG[slice][9]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[10], QP, INIT_BT_SPLIT_FLAG[slice][10]); - kvz_ctx_init(&cabac->ctx.bt_split_flag_model[11], QP, INIT_BT_SPLIT_FLAG[slice][11]); + for (i = 0; i < 12; i++) { + kvz_ctx_init(&cabac->ctx.bt_split_flag_model[i], QP, INIT_BT_SPLIT_FLAG[slice][i]); + } kvz_ctx_init(&cabac->ctx.intra_mode_model, QP, INIT_INTRA_PRED_MODE[slice]); - kvz_ctx_init(&cabac->ctx.chroma_pred_model[0], QP, INIT_CHROMA_PRED_MODE[slice][0]); - kvz_ctx_init(&cabac->ctx.chroma_pred_model[1], QP, INIT_CHROMA_PRED_MODE[slice][1]); + for (i = 0; i < 12; i++) { + kvz_ctx_init(&cabac->ctx.chroma_pred_model[i], QP, INIT_CHROMA_PRED_MODE[slice][i]); + } //TODO: ignore P/B contexts on intra frame kvz_ctx_init(&cabac->ctx.cu_qt_root_cbf_model, QP, INIT_QT_ROOT_CBF[slice][0]); diff --git a/src/encode_coding_tree.c b/src/encode_coding_tree.c index 144fd1f7..ca8a41d8 100644 --- a/src/encode_coding_tree.c +++ b/src/encode_coding_tree.c @@ -867,7 +867,7 @@ static void encode_intra_coding_unit(encoder_state_t * const state, * Table 9-37 - Assignment of ctxInc to syntax elements with context coded bins * intra_chroma_pred_mode[][] = 0, bypass, bypass */ - cabac->cur_ctx = &(cabac->ctx.chroma_pred_model[0]); + cabac->cur_ctx = &(cabac->ctx.chroma_pred_model[1]); if (pred_mode == 4) { CABAC_BIN(cabac, 0, "intra_chroma_pred_mode"); } else { diff --git a/src/search_intra.c b/src/search_intra.c index cfcb3cea..4d0d4a1c 100644 --- a/src/search_intra.c +++ b/src/search_intra.c @@ -677,7 +677,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[0]); + const cabac_ctx_t *ctx = &(state->cabac.ctx.chroma_pred_model[1]); double mode_bits; if (chroma_mode == luma_mode) { mode_bits = CTX_ENTROPY_FBITS(ctx, 0);