mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Minor fixes to header writing. Added contexts for multi_ref_line and BDPCM. Functions added for writing both in bitstream, but they are both disabled for now.
This commit is contained in:
parent
3339e12169
commit
4768ba0628
|
@ -86,6 +86,8 @@ typedef struct
|
|||
cabac_ctx_t cu_qt_root_cbf_model;
|
||||
cabac_ctx_t sig_coeff_group_model[8];
|
||||
cabac_ctx_t luma_planar_model[2];
|
||||
cabac_ctx_t multi_ref_line[3];
|
||||
cabac_ctx_t bdpcm_mode[2];
|
||||
} ctx;
|
||||
} cabac_data_t;
|
||||
|
||||
|
|
|
@ -74,6 +74,13 @@ static const uint8_t INIT_PRED_MODE[4][2] = {
|
|||
{ 5, 2, },
|
||||
};
|
||||
|
||||
static const uint8_t MULTI_REF_LINE_MODE[4][3] = {
|
||||
{ 90, 212, CNU, },
|
||||
{ 118, 212, CNU, },
|
||||
{ 134, 169, CNU, },
|
||||
{ 8, 8, DWS, },
|
||||
};
|
||||
|
||||
static const uint8_t INIT_INTRA_PRED_MODE[4] = {
|
||||
154, 154, 170, 6
|
||||
};
|
||||
|
@ -143,6 +150,13 @@ static const uint8_t INIT_QT_CBF[4][11] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static const uint8_t BDPCM_MODE_INIT[4][2] = {
|
||||
{ 148, 154, },
|
||||
{ 0, 140, },
|
||||
{ 40, 169, },
|
||||
{ 1, 4, },
|
||||
};
|
||||
|
||||
static const uint8_t INIT_SIG_COEFF_GROUP[4][8] = {
|
||||
{ 105, 170, 105, 155, CNU, CNU, CNU, CNU, },
|
||||
{ 106, 156, 105, 155, CNU, CNU, CNU, CNU, },
|
||||
|
@ -332,6 +346,7 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
for (i = 0; i < 3; i++) {
|
||||
kvz_ctx_init(&cabac->ctx.cu_skip_flag_model[i], QP, INIT_SKIP_FLAG[slice][i], INIT_SKIP_FLAG[3][i]);
|
||||
kvz_ctx_init(&cabac->ctx.chroma_pred_model[i], QP, INIT_CHROMA_PRED_MODE[slice][i], INIT_CHROMA_PRED_MODE[3][i]);
|
||||
kvz_ctx_init(&cabac->ctx.multi_ref_line[i], QP, MULTI_REF_LINE_MODE[slice][i], MULTI_REF_LINE_MODE[3][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
|
@ -357,7 +372,7 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
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.mvp_idx_model[i], QP, INIT_MVP_IDX[slice][i], INIT_MVP_IDX[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]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.bdpcm_mode[i], QP, BDPCM_MODE_INIT[slice][i], BDPCM_MODE_INIT[3][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
@ -368,8 +383,8 @@ void kvz_init_contexts(encoder_state_t *state, int8_t QP, int8_t slice)
|
|||
|
||||
kvz_ctx_init(&cabac->ctx.part_size_model[i], QP, INIT_PART_SIZE[slice][i], INIT_PART_SIZE[3][i]);
|
||||
|
||||
kvz_ctx_init(&cabac->ctx.cu_ctx_last_y_chroma[i], QP, INIT_LAST_X[slice][i + 25], INIT_LAST_X[3][i + 25]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_ctx_last_x_chroma[i], QP, INIT_LAST_Y[slice][i + 25], INIT_LAST_Y[3][i + 25]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_ctx_last_y_chroma[i], QP, INIT_LAST_Y[slice][i + 25], INIT_LAST_Y[3][i + 25]);
|
||||
kvz_ctx_init(&cabac->ctx.cu_ctx_last_x_chroma[i], QP, INIT_LAST_X[slice][i + 25], INIT_LAST_X[3][i + 25]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
|
|
2
src/cu.h
2
src/cu.h
|
@ -136,6 +136,8 @@ typedef struct
|
|||
*/
|
||||
uint8_t qp;
|
||||
|
||||
uint8_t bdpcmMode;
|
||||
|
||||
union {
|
||||
struct {
|
||||
int8_t mode;
|
||||
|
|
|
@ -796,12 +796,15 @@ static void encode_transform_coeff(encoder_state_t * const state,
|
|||
// when the flags from previous level are used.
|
||||
if (depth < MAX_PU_DEPTH && state->encoder_control->chroma_format != KVZ_CSP_400) {
|
||||
|
||||
if (tr_depth == 0 || parent_coeff_u) {
|
||||
if (tr_depth != TR_MAX_LOG2_SIZE - 1 || (!(depth > tr_depth) && false/*ISPMode*/)) {
|
||||
//if (tr_depth == 0 || parent_coeff_u) {
|
||||
assert(tr_depth < 5);
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_cb[tr_depth]);
|
||||
CABAC_BIN(cabac, cb_flag_u, "cbf_cb");
|
||||
}
|
||||
if (tr_depth == 0 || parent_coeff_v) {
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_cr[cb_flag_u]);
|
||||
if (tr_depth != TR_MAX_LOG2_SIZE - 1 || (!(depth > tr_depth) && false/*ISPMode*/)) {
|
||||
//if (tr_depth == 0 || parent_coeff_v) {
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_cr[cb_flag_u ? 1 : 0]);
|
||||
CABAC_BIN(cabac, cb_flag_v, "cbf_cr");
|
||||
}
|
||||
}
|
||||
|
@ -969,11 +972,43 @@ static void encode_intra_coding_unit(encoder_state_t * const state,
|
|||
int8_t mpm_preds[4] = {-1, -1, -1, -1};
|
||||
uint32_t flag[4];
|
||||
|
||||
/*
|
||||
if ((cur_cu->type == CU_INTRA && (LCU_WIDTH >> cur_cu->depth <= 32))) {
|
||||
cabac->cur_ctx = &(cabac->ctx.bdpcm_mode[0]);
|
||||
CABAC_BIN(cabac, cur_cu->bdpcmMode > 0 ? 1 : 0, "bdpcm_mode");
|
||||
if (cur_cu->bdpcmMode) {
|
||||
cabac->cur_ctx = &(cabac->ctx.bdpcm_mode[1]);
|
||||
CABAC_BIN(cabac, cur_cu->bdpcmMode > 1 ? 1 : 0, "bdpcm_mode > 1");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#if ENABLE_PCM == 1
|
||||
// Code must start after variable initialization
|
||||
kvz_cabac_encode_bin_trm(cabac, 0); // IPCMFlag == 0
|
||||
#endif
|
||||
|
||||
const int num_pred_units = kvz_part_mode_num_parts[cur_cu->part_size];
|
||||
|
||||
//ToDo: update multi_ref_lines variable when it's something else than constant 3
|
||||
int multi_ref_lines = 3;
|
||||
/*
|
||||
for (int i = 0; i < num_pred_units; i++) {
|
||||
if (multi_ref_lines > 1) {
|
||||
cabac->cur_ctx = &(cabac->ctx.multi_ref_line[0]);
|
||||
CABAC_BIN(cabac, cur_cu->intra.multi_ref_idx != 0, "multi_ref_line_0");
|
||||
if (multi_ref_lines > 2 && cur_cu->intra.multi_ref_idx != 0) {
|
||||
cabac->cur_ctx = &(cabac->ctx.multi_ref_line[1]);
|
||||
CABAC_BIN(cabac, cur_cu->intra.multi_ref_idx != 1, "multi_ref_line_1");
|
||||
if (multi_ref_lines > 3 && cur_cu->intra.multi_ref_idx != 1) {
|
||||
cabac->cur_ctx = &(cabac->ctx.multi_ref_line[2]);
|
||||
CABAC_BIN(cabac, cur_cu->intra.multi_ref_idx != 3, "multi_ref_line_2");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Intra Subpartition mode
|
||||
uint32_t width = (LCU_WIDTH >> depth);
|
||||
uint32_t height = (LCU_WIDTH >> depth);
|
||||
|
@ -1004,7 +1039,6 @@ static void encode_intra_coding_unit(encoder_state_t * const state,
|
|||
// it can be signaled with two EP's. Otherwise we can send
|
||||
// 5 EP bins with the full predmode
|
||||
// ToDo: fix comments for VVC
|
||||
const int num_pred_units = kvz_part_mode_num_parts[cur_cu->part_size];
|
||||
const int cu_width = LCU_WIDTH >> depth;
|
||||
|
||||
cabac->cur_ctx = &(cabac->ctx.intra_mode_model);
|
||||
|
|
|
@ -900,7 +900,7 @@ static void kvz_encoder_state_write_bitstream_slice_header_independent(
|
|||
}
|
||||
WRITE_U(stream, 0, 1, "dep_quant_enable_flag");
|
||||
//if !dep_quant_enable_flag
|
||||
WRITE_U(stream, 0, 1, "sign_data_hiding_enable_flag");
|
||||
WRITE_U(stream, encoder->cfg.signhide_enable, 1, "sign_data_hiding_enable_flag");
|
||||
|
||||
if (state->frame->slicetype != KVZ_SLICE_I) {
|
||||
|
||||
|
@ -1057,7 +1057,6 @@ static void encoder_state_write_slice_header(
|
|||
state->frame->first_nal = false;
|
||||
|
||||
kvz_encoder_state_write_bitstream_slice_header(stream, state, independent);
|
||||
kvz_bitstream_align(stream);
|
||||
kvz_bitstream_add_rbsp_trailing_bits(stream);
|
||||
}
|
||||
|
||||
|
|
|
@ -418,6 +418,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
cur_cu->part_size = SIZE_2Nx2N;
|
||||
cur_cu->qp = state->qp;
|
||||
cur_cu->intra.multi_ref_idx = 0;
|
||||
cur_cu->bdpcmMode = 0;
|
||||
|
||||
// If the CU is completely inside the frame at this depth, search for
|
||||
// prediction modes at this depth.
|
||||
|
|
Loading…
Reference in a new issue