mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Fix intra_chroma_pred_mode and cbf contexts
This commit is contained in:
parent
d15f58517f
commit
3bdc8ac8d3
|
@ -59,11 +59,11 @@ typedef struct
|
||||||
cabac_ctx_t bt_split_flag_model[12]; //!< \brief bt 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 intra_mode_model; //!< \brief intra mode context models
|
||||||
cabac_ctx_t intra_subpart_model[2]; //!< \brief intra sub part context models
|
cabac_ctx_t intra_subpart_model[2]; //!< \brief intra sub part context models
|
||||||
cabac_ctx_t chroma_pred_model[12];
|
cabac_ctx_t chroma_pred_model[3];
|
||||||
cabac_ctx_t inter_dir[5];
|
cabac_ctx_t inter_dir[5];
|
||||||
cabac_ctx_t trans_subdiv_model[3]; //!< \brief intra mode context models
|
cabac_ctx_t trans_subdiv_model[3]; //!< \brief intra mode context models
|
||||||
cabac_ctx_t qt_cbf_model_luma[5];
|
cabac_ctx_t qt_cbf_model_luma[4];
|
||||||
cabac_ctx_t qt_cbf_model_cr[5];
|
cabac_ctx_t qt_cbf_model_cr[2];
|
||||||
cabac_ctx_t qt_cbf_model_cb[5];
|
cabac_ctx_t qt_cbf_model_cb[5];
|
||||||
cabac_ctx_t cu_qp_delta_abs[4];
|
cabac_ctx_t cu_qp_delta_abs[4];
|
||||||
cabac_ctx_t part_size_model[4];
|
cabac_ctx_t part_size_model[4];
|
||||||
|
|
|
@ -117,10 +117,10 @@ static const uint8_t INIT_INTRA_SUBPART_MODE[3][2] = {
|
||||||
{ 152, 154, },
|
{ 152, 154, },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t INIT_CHROMA_PRED_MODE[3][12] = {
|
static const uint8_t INIT_CHROMA_PRED_MODE[3][3] = {
|
||||||
{ 139, 152, 139, 154, 154, 154, 154, 154, 154, 154, 154, 154, },
|
{ 137, 139, 140,},
|
||||||
{ 139, 152, 139, 154, 154, 154, 154, 154, 154, 154, 154, 154, },
|
{ 138, 139, 169,},
|
||||||
{ 139, 63, 139, 154, 154, 154, 154, 154, 154, 154, 154, 154, },
|
{ 154, 139, 154,},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t INIT_INTER_DIR[3][5] = {
|
static const uint8_t INIT_INTER_DIR[3][5] = {
|
||||||
|
@ -136,9 +136,9 @@ static const uint8_t INIT_TRANS_SUBDIV_FLAG[3][3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t INIT_QT_CBF[3][15] = {
|
static const uint8_t INIT_QT_CBF[3][15] = {
|
||||||
{ 153, 111, CNU, CNU, CNU, 149, 92, 167, 154, 154, 149, 149, CNU, CNU, CNU },
|
{ 141, 127, 139, 140, 163, 154, CNU, CNU, CNU, 161, 154,},
|
||||||
{ 153, 111, CNU, CNU, CNU, 149, 107, 167, 154, 154, 149, 149, CNU, CNU, CNU },
|
{ 142, 127, 139, 140, 164, 154, CNU, CNU, CNU, 192, 154,},
|
||||||
{ 111, 141, CNU, CNU, CNU, 94, 138, 182, 154, 154, 94, 94, CNU, CNU, CNU },
|
{ CNU, 111, 124, 111, 109, CNU, CNU, CNU, CNU, 151, 155,},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t INIT_CU_QP_DELTA_ABS[3][2] = {
|
static const uint8_t INIT_CU_QP_DELTA_ABS[3][2] = {
|
||||||
|
@ -320,7 +320,7 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
||||||
|
|
||||||
kvz_ctx_init(&cabac->ctx.intra_mode_model, QP, INIT_INTRA_PRED_MODE[slice]);
|
kvz_ctx_init(&cabac->ctx.intra_mode_model, QP, INIT_INTRA_PRED_MODE[slice]);
|
||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
kvz_ctx_init(&cabac->ctx.chroma_pred_model[i], QP, INIT_CHROMA_PRED_MODE[slice][i]);
|
kvz_ctx_init(&cabac->ctx.chroma_pred_model[i], QP, INIT_CHROMA_PRED_MODE[slice][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
||||||
kvz_ctx_init(&cabac->ctx.cu_qp_delta_abs[1], QP, INIT_CU_QP_DELTA_ABS[slice][1]);
|
kvz_ctx_init(&cabac->ctx.cu_qp_delta_abs[1], QP, INIT_CU_QP_DELTA_ABS[slice][1]);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
kvz_ctx_init(&cabac->ctx.qt_cbf_model_luma[i], QP, INIT_QT_CBF[slice][i]);
|
||||||
kvz_ctx_init(&cabac->ctx.part_size_model[i], QP, INIT_PART_SIZE[slice][i]);
|
kvz_ctx_init(&cabac->ctx.part_size_model[i], QP, INIT_PART_SIZE[slice][i]);
|
||||||
}
|
}
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
|
@ -347,13 +347,14 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
kvz_ctx_init(&cabac->ctx.trans_subdiv_model[i], QP, INIT_TRANS_SUBDIV_FLAG[slice][i]);
|
kvz_ctx_init(&cabac->ctx.trans_subdiv_model[i], QP, INIT_TRANS_SUBDIV_FLAG[slice][i]);
|
||||||
}
|
}
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_luma[i], QP, INIT_QT_CBF[slice][i]);
|
|
||||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cb[i], QP, INIT_QT_CBF[slice][i + 5]);
|
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cr[i], QP, INIT_QT_CBF[slice][i + 9]);
|
||||||
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cr[i], QP, INIT_QT_CBF[slice][i + 10]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
|
kvz_ctx_init(&cabac->ctx.qt_cbf_model_cb[i], QP, INIT_QT_CBF[slice][i + 4]);
|
||||||
|
|
||||||
kvz_ctx_init(&cabac->ctx.inter_dir[i], QP, INIT_INTER_DIR[slice][i]);
|
kvz_ctx_init(&cabac->ctx.inter_dir[i], QP, INIT_INTER_DIR[slice][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1127,7 +1127,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
|
* Table 9-37 - Assignment of ctxInc to syntax elements with context coded bins
|
||||||
* intra_chroma_pred_mode[][] = 0, bypass, bypass
|
* intra_chroma_pred_mode[][] = 0, bypass, bypass
|
||||||
*/
|
*/
|
||||||
cabac->cur_ctx = &(cabac->ctx.chroma_pred_model[1]);
|
cabac->cur_ctx = &(cabac->ctx.chroma_pred_model[0]);
|
||||||
if (pred_mode == 68) {
|
if (pred_mode == 68) {
|
||||||
CABAC_BIN(cabac, 0, "intra_chroma_pred_mode");
|
CABAC_BIN(cabac, 0, "intra_chroma_pred_mode");
|
||||||
} else {
|
} else {
|
||||||
|
|
47
src/intra.c
47
src/intra.c
|
@ -141,53 +141,6 @@ int8_t kvz_intra_get_dir_luma_predictor(
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if KVZ_SEL_ENCRYPTION
|
|
||||||
int8_t kvz_intra_get_dir_luma_predictor_encry(
|
|
||||||
const uint32_t x,
|
|
||||||
const uint32_t y,
|
|
||||||
int8_t *preds,
|
|
||||||
const cu_info_t *const cur_pu,
|
|
||||||
const cu_info_t *const left_pu,
|
|
||||||
const cu_info_t *const above_pu)
|
|
||||||
{
|
|
||||||
// The default mode if block is not coded yet is INTRA_DC.
|
|
||||||
int8_t left_intra_dir = 1;
|
|
||||||
if (left_pu && left_pu->type == CU_INTRA) {
|
|
||||||
left_intra_dir = left_pu->intra.mode_encry ;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t above_intra_dir = 1;
|
|
||||||
if (above_pu && above_pu->type == CU_INTRA && y % LCU_WIDTH != 0) {
|
|
||||||
above_intra_dir = above_pu->intra.mode_encry;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the predictions are the same, add new predictions
|
|
||||||
if (left_intra_dir == above_intra_dir) {
|
|
||||||
if (left_intra_dir > 1) { // angular modes
|
|
||||||
preds[0] = left_intra_dir;
|
|
||||||
preds[1] = ((left_intra_dir + 29) % 32) + 2;
|
|
||||||
preds[2] = ((left_intra_dir - 1 ) % 32) + 2;
|
|
||||||
} else { //non-angular
|
|
||||||
preds[0] = 0;//PLANAR_IDX;
|
|
||||||
preds[1] = 1;//DC_IDX;
|
|
||||||
preds[2] = 26;//VER_IDX;
|
|
||||||
}
|
|
||||||
} else { // If we have two distinct predictions
|
|
||||||
preds[0] = left_intra_dir;
|
|
||||||
preds[1] = above_intra_dir;
|
|
||||||
|
|
||||||
// add planar mode if it's not yet present
|
|
||||||
if (left_intra_dir && above_intra_dir ) {
|
|
||||||
preds[2] = 0; // PLANAR_IDX;
|
|
||||||
} else { // Add DC mode if it's not present, otherwise 26.
|
|
||||||
preds[2] = (left_intra_dir+above_intra_dir)<2? 26 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void intra_filter_reference(
|
static void intra_filter_reference(
|
||||||
int_fast8_t log2_width,
|
int_fast8_t log2_width,
|
||||||
kvz_intra_references *refs)
|
kvz_intra_references *refs)
|
||||||
|
|
|
@ -810,7 +810,7 @@ void kvz_search_cu_intra(encoder_state_t * const state,
|
||||||
|
|
||||||
kvz_intra_references refs;
|
kvz_intra_references refs;
|
||||||
|
|
||||||
int8_t candidate_modes[3];
|
int8_t candidate_modes[INTRA_MPM_COUNT];
|
||||||
|
|
||||||
cu_info_t *left_cu = 0;
|
cu_info_t *left_cu = 0;
|
||||||
cu_info_t *above_cu = 0;
|
cu_info_t *above_cu = 0;
|
||||||
|
|
Loading…
Reference in a new issue