mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
[isp] Redo call hierarchy to include x, y coordinates.
This commit is contained in:
parent
10f9b2be26
commit
2e8f008de4
|
@ -465,10 +465,8 @@ void uvg_encode_last_significant_xy(cabac_data_t * const cabac,
|
|||
|
||||
static void encode_chroma_tu(
|
||||
encoder_state_t* const state,
|
||||
int x,
|
||||
int y,
|
||||
cu_loc_t *cu_loc,
|
||||
int depth,
|
||||
const uint8_t width_c,
|
||||
cu_info_t* cur_pu,
|
||||
int8_t* scan_idx,
|
||||
lcu_coeff_t* coeff,
|
||||
|
@ -476,9 +474,10 @@ static void encode_chroma_tu(
|
|||
enum
|
||||
uvg_tree_type tree_type)
|
||||
{
|
||||
int height_c = width_c; // TODO: height for non-square blocks
|
||||
int x_local = ((x >> (tree_type != UVG_CHROMA_T)) & ~3) % LCU_WIDTH_C;
|
||||
int y_local = ((y >> (tree_type != UVG_CHROMA_T)) & ~3) % LCU_WIDTH_C;
|
||||
int width_c = cu_loc->chroma_width;
|
||||
//int height_c = cu_loc->chroma_height;
|
||||
int x_local = ((cu_loc->x >> (tree_type != UVG_CHROMA_T)) & ~3) % LCU_WIDTH_C;
|
||||
int y_local = ((cu_loc->y >> (tree_type != UVG_CHROMA_T)) & ~3) % LCU_WIDTH_C;
|
||||
cabac_data_t* const cabac = &state->cabac;
|
||||
*scan_idx = uvg_get_scan_order(cur_pu->type, cur_pu->intra.mode_chroma, depth);
|
||||
if(!joint_chroma){
|
||||
|
@ -486,13 +485,14 @@ static void encode_chroma_tu(
|
|||
const coeff_t *coeff_v = &coeff->v[xy_to_zorder(LCU_WIDTH_C, x_local, y_local)];
|
||||
|
||||
if (cbf_is_set(cur_pu->cbf, depth, COLOR_U)) {
|
||||
// ISP_TODO: do these checks need height?
|
||||
if(state->encoder_control->cfg.trskip_enable && width_c <= (1 << state->encoder_control->cfg.trskip_max_size)){
|
||||
cabac->cur_ctx = &cabac->ctx.transform_skip_model_chroma;
|
||||
// HEVC only supports transform_skip for Luma
|
||||
// TODO: transform skip for chroma blocks
|
||||
CABAC_BIN(cabac, (cur_pu->tr_skip >> COLOR_U) & 1, "transform_skip_flag");
|
||||
}
|
||||
uvg_encode_coeff_nxn(state, &state->cabac, coeff_u, width_c, height_c, COLOR_U, *scan_idx, cur_pu, NULL);
|
||||
uvg_encode_coeff_nxn(state, &state->cabac, coeff_u, cu_loc, COLOR_U, *scan_idx, cur_pu, NULL);
|
||||
}
|
||||
|
||||
if (cbf_is_set(cur_pu->cbf, depth, COLOR_V)) {
|
||||
|
@ -500,7 +500,7 @@ static void encode_chroma_tu(
|
|||
cabac->cur_ctx = &cabac->ctx.transform_skip_model_chroma;
|
||||
CABAC_BIN(cabac, (cur_pu->tr_skip >> COLOR_V) & 1, "transform_skip_flag");
|
||||
}
|
||||
uvg_encode_coeff_nxn(state, &state->cabac, coeff_v, width_c, height_c, COLOR_V, *scan_idx, cur_pu, NULL);
|
||||
uvg_encode_coeff_nxn(state, &state->cabac, coeff_v, cu_loc, COLOR_V, *scan_idx, cur_pu, NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -509,7 +509,7 @@ static void encode_chroma_tu(
|
|||
cabac->cur_ctx = &cabac->ctx.transform_skip_model_chroma;
|
||||
CABAC_BIN(cabac, 0, "transform_skip_flag");
|
||||
}
|
||||
uvg_encode_coeff_nxn(state, &state->cabac, coeff_uv, width_c, height_c, COLOR_V, *scan_idx, cur_pu, NULL);
|
||||
uvg_encode_coeff_nxn(state, &state->cabac, coeff_uv, cu_loc, COLOR_V, *scan_idx, cur_pu, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -561,8 +561,7 @@ static void encode_transform_unit(
|
|||
uvg_encode_coeff_nxn(state,
|
||||
cabac,
|
||||
coeff_y,
|
||||
width,
|
||||
height,
|
||||
cu_loc,
|
||||
0,
|
||||
scan_idx,
|
||||
(cu_info_t * )cur_pu,
|
||||
|
@ -589,7 +588,7 @@ static void encode_transform_unit(
|
|||
cbf_is_set(cur_pu->cbf, depth, COLOR_V);
|
||||
if ((chroma_cbf_set || joint_chroma) && last_split) {
|
||||
//Need to drop const to get lfnst constraints
|
||||
encode_chroma_tu(state, x, y, depth, width_c, (cu_info_t*)cur_pu, &scan_idx, coeff, joint_chroma, tree_type);
|
||||
encode_chroma_tu(state, cu_loc, depth, (cu_info_t*)cur_pu, &scan_idx, coeff, joint_chroma, tree_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1630,12 +1629,12 @@ void uvg_encode_coding_tree(
|
|||
int split_limit = split_type == ISP_MODE_NO_ISP ? 1 : uvg_get_isp_split_num(cu_width, cu_height, split_type);
|
||||
|
||||
for (int i = 0; i < split_limit; ++i) {
|
||||
cu_loc_t loc;
|
||||
uvg_get_isp_split_loc(&loc, x, y, cu_width, cu_height, i, split_type);
|
||||
cu_loc_t split_loc;
|
||||
uvg_get_isp_split_loc(&split_loc, x, y, cu_width, cu_height, i, split_type);
|
||||
|
||||
// Check if last split to write chroma
|
||||
bool last_split = (i + 1) == split_limit;
|
||||
encode_transform_coeff(state, &loc, depth, 0, 0, 0, 0, coeff, tree_type, last_split);
|
||||
encode_transform_coeff(state, &split_loc, depth, 0, 0, 0, 0, coeff, tree_type, last_split);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1520,6 +1520,7 @@ int uvg_get_isp_split_num(const int width, const int height, const int split_typ
|
|||
void uvg_get_isp_split_loc(cu_loc_t *loc, const int x, const int y, const int block_w, const int block_h, const int split_idx, const int split_type)
|
||||
{
|
||||
assert((split_idx >= 0 && split_idx <= 3) && "ISP split index must be in [0, 3].");
|
||||
assert((split_type == ISP_MODE_NO_ISP && split_idx > 0) && "Trying to ISP split when split type = NO_ISP.");
|
||||
int part_dim = block_w;
|
||||
if (split_type != ISP_MODE_NO_ISP) {
|
||||
part_dim = uvg_get_isp_split_dim(block_w, block_h, split_type);
|
||||
|
@ -1698,12 +1699,12 @@ void uvg_intra_recon_cu(
|
|||
int split_limit = uvg_get_isp_split_num(width, height, split_type);
|
||||
|
||||
for (int i = 0; i < split_limit; ++i) {
|
||||
cu_loc_t loc;
|
||||
uvg_get_isp_split_loc(&loc, x, y, width, height, i, split_type);
|
||||
cu_loc_t split_loc;
|
||||
uvg_get_isp_split_loc(&split_loc, x, y, width, height, i, split_type);
|
||||
|
||||
intra_recon_tb_leaf(state, &loc, lcu, COLOR_Y, search_data, tree_type);
|
||||
intra_recon_tb_leaf(state, &split_loc, lcu, COLOR_Y, search_data, tree_type);
|
||||
uvg_quantize_lcu_residual(state, true, false, false,
|
||||
&loc, depth, cur_cu, lcu,
|
||||
&split_loc, depth, cur_cu, lcu,
|
||||
false, tree_type);
|
||||
search_data->best_isp_cbfs |= cbf_is_set(cur_cu->cbf, depth, COLOR_Y) << (i++);
|
||||
}
|
||||
|
|
19
src/rdo.c
19
src/rdo.c
|
@ -297,15 +297,17 @@ out:
|
|||
static INLINE double get_coeff_cabac_cost(
|
||||
const encoder_state_t * const state,
|
||||
const coeff_t *coeff,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
cu_loc_t *cu_loc,
|
||||
color_t color,
|
||||
int8_t scan_mode,
|
||||
int8_t tr_skip,
|
||||
cu_info_t* cur_tu)
|
||||
{
|
||||
const int width = cu_loc->width;
|
||||
const int height = cu_loc->height;
|
||||
// Make sure there are coeffs present
|
||||
bool found = false;
|
||||
// ISP_TODO: this needs to be two separate x, y loops?
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
if (coeff[i] != 0) {
|
||||
found = 1;
|
||||
|
@ -331,8 +333,7 @@ static INLINE double get_coeff_cabac_cost(
|
|||
uvg_encode_coeff_nxn((encoder_state_t*) state,
|
||||
&cabac_copy,
|
||||
coeff,
|
||||
width,
|
||||
height,
|
||||
cu_loc,
|
||||
color,
|
||||
scan_mode,
|
||||
cur_tu,
|
||||
|
@ -394,8 +395,7 @@ double uvg_get_coeff_cost(
|
|||
const encoder_state_t * const state,
|
||||
const coeff_t *coeff,
|
||||
cu_info_t* cur_tu,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
cu_loc_t *cu_loc,
|
||||
color_t color,
|
||||
int8_t scan_mode,
|
||||
int8_t tr_skip)
|
||||
|
@ -403,6 +403,9 @@ double uvg_get_coeff_cost(
|
|||
uint8_t save_cccs = state->encoder_control->cfg.fastrd_sampling_on;
|
||||
uint8_t check_accuracy = state->encoder_control->cfg.fastrd_accuracy_check_on;
|
||||
|
||||
const int width = color == COLOR_Y ? cu_loc->width : cu_loc->chroma_width;
|
||||
const int height = color == COLOR_Y ? cu_loc->height : cu_loc->chroma_height;
|
||||
|
||||
if (state->qp < state->encoder_control->cfg.fast_residual_cost_limit &&
|
||||
state->qp < MAX_FAST_COEFF_COST_QP && !tr_skip) {
|
||||
// TODO: do we need to assert(0) out of the fast-estimation branch if we
|
||||
|
@ -415,13 +418,13 @@ double uvg_get_coeff_cost(
|
|||
uint64_t weights = uvg_fast_coeff_get_weights(state);
|
||||
uint32_t fast_cost = uvg_fast_coeff_cost(coeff, width, height, weights);
|
||||
if (check_accuracy) {
|
||||
double ccc = get_coeff_cabac_cost(state, coeff, width, height, color, scan_mode, tr_skip, cur_tu);
|
||||
double ccc = get_coeff_cabac_cost(state, coeff, cu_loc, color, scan_mode, tr_skip, cur_tu);
|
||||
save_accuracy(state->qp, ccc, fast_cost);
|
||||
}
|
||||
return fast_cost;
|
||||
}
|
||||
} else {
|
||||
double ccc = get_coeff_cabac_cost(state, coeff, width, height, color, scan_mode, tr_skip, cur_tu);
|
||||
double ccc = get_coeff_cabac_cost(state, coeff, cu_loc, color, scan_mode, tr_skip, cur_tu);
|
||||
if (save_cccs) {
|
||||
save_ccc(state->qp, coeff, width * width, ccc);
|
||||
}
|
||||
|
|
|
@ -73,8 +73,7 @@ double uvg_get_coeff_cost(
|
|||
const encoder_state_t * const state,
|
||||
const coeff_t *coeff,
|
||||
cu_info_t* cur_tu,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
cu_loc_t *cu_loc,
|
||||
color_t color,
|
||||
int8_t scan_mode,
|
||||
int8_t tr_skip);
|
||||
|
|
51
src/search.c
51
src/search.c
|
@ -316,6 +316,9 @@ double uvg_cu_rd_cost_luma(const encoder_state_t *const state,
|
|||
const int skip_residual_coding = pred_cu->skipped || (pred_cu->type != CU_INTRA && pred_cu->cbf == 0);
|
||||
cabac_data_t* cabac = (cabac_data_t *)&state->search_cabac;
|
||||
|
||||
cu_loc_t loc;
|
||||
uvg_cu_loc_ctor(&loc, x_px, y_px, width, height);
|
||||
|
||||
// cur_cu is used for TU parameters.
|
||||
cu_info_t *const tr_cu = LCU_GET_CU_AT_PX(lcu, x_px, y_px);
|
||||
|
||||
|
@ -383,24 +386,22 @@ double uvg_cu_rd_cost_luma(const encoder_state_t *const state,
|
|||
if (pred_cu->type == CU_INTER || pred_cu->intra.isp_mode == ISP_MODE_NO_ISP) {
|
||||
const coeff_t* coeffs = &lcu->coeff.y[xy_to_zorder(LCU_WIDTH, x_px, y_px)];
|
||||
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, NULL, width, height, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, NULL, &loc, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
}
|
||||
else {
|
||||
int split_type = pred_cu->intra.isp_mode;
|
||||
int split_limit = uvg_get_isp_split_num(width, height, split_type);
|
||||
|
||||
for (int i = 0; i < split_limit; ++i) {
|
||||
cu_loc_t loc;
|
||||
uvg_get_isp_split_loc(&loc, x_px, y_px, width, height, i, split_type);
|
||||
const int part_x = loc.x;
|
||||
const int part_y = loc.y;
|
||||
const int part_w = loc.width;
|
||||
const int part_h = loc.height;
|
||||
cu_loc_t split_loc;
|
||||
uvg_get_isp_split_loc(&split_loc, x_px, y_px, width, height, i, split_type);
|
||||
const int part_x = split_loc.x;
|
||||
const int part_y = split_loc.y;
|
||||
|
||||
// TODO: maybe just pass the cu_loc_t to these functions
|
||||
const coeff_t* coeffs = &lcu->coeff.y[xy_to_zorder(LCU_WIDTH, part_x, part_y)];
|
||||
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, NULL, part_w, part_h, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, NULL, &split_loc, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -421,6 +422,9 @@ double uvg_cu_rd_cost_chroma(const encoder_state_t *const state,
|
|||
cu_info_t *const tr_cu = LCU_GET_CU_AT_PX(lcu, x_px, y_px);
|
||||
const int skip_residual_coding = pred_cu->skipped || (pred_cu->type != CU_INTRA && pred_cu->cbf == 0);
|
||||
|
||||
cu_loc_t loc;
|
||||
uvg_cu_loc_ctor(&loc, x_px, y_px, width, height);
|
||||
|
||||
double tr_tree_bits = 0;
|
||||
double coeff_bits = 0;
|
||||
|
||||
|
@ -491,11 +495,11 @@ double uvg_cu_rd_cost_chroma(const encoder_state_t *const state,
|
|||
const int index = xy_to_zorder(LCU_WIDTH_C, lcu_px.x, lcu_px.y);
|
||||
|
||||
if((pred_cu->joint_cb_cr & 3) == 0){
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.u[index], NULL, width, height, 2, scan_order, 0);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.v[index], NULL, width, height, 2, scan_order, 0);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.u[index], NULL, &loc, 2, scan_order, 0);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.v[index], NULL, &loc, 2, scan_order, 0);
|
||||
}
|
||||
else {
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.joint_uv[index], NULL, width, height, 2, scan_order, 0);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.joint_uv[index], NULL, &loc, 2, scan_order, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -518,6 +522,9 @@ static double cu_rd_cost_tr_split_accurate(
|
|||
const int width = LCU_WIDTH >> depth;
|
||||
const int height = width; // TODO: height for non-square blocks
|
||||
|
||||
cu_loc_t loc;
|
||||
uvg_cu_loc_ctor(&loc, x_px, y_px, width, height);
|
||||
|
||||
const int skip_residual_coding = pred_cu->skipped || (pred_cu->type != CU_INTRA && pred_cu->cbf == 0);
|
||||
// cur_cu is used for TU parameters.
|
||||
cu_info_t* const tr_cu = LCU_GET_CU_AT_PX(lcu, x_px, y_px);
|
||||
|
@ -622,24 +629,22 @@ static double cu_rd_cost_tr_split_accurate(
|
|||
if (pred_cu->type == CU_INTER || pred_cu->intra.isp_mode == ISP_MODE_NO_ISP) {
|
||||
const coeff_t* coeffs = &lcu->coeff.y[xy_to_zorder(LCU_WIDTH, x_px, y_px)];
|
||||
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, tr_cu, width, height, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, tr_cu, &loc, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
}
|
||||
else {
|
||||
int split_type = pred_cu->intra.isp_mode;
|
||||
int split_limit = uvg_get_isp_split_num(width, height, split_type);
|
||||
|
||||
for (int i = 0; i < split_limit; ++i) {
|
||||
cu_loc_t loc;
|
||||
uvg_get_isp_split_loc(&loc, x_px, y_px, width, height, i, split_type);
|
||||
const int part_x = loc.x;
|
||||
const int part_y = loc.y;
|
||||
const int part_w = loc.width;
|
||||
const int part_h = loc.height;
|
||||
cu_loc_t split_loc;
|
||||
uvg_get_isp_split_loc(&split_loc, x_px, y_px, width, height, i, split_type);
|
||||
const int part_x = split_loc.x;
|
||||
const int part_y = split_loc.y;
|
||||
|
||||
// TODO: maybe just pass the cu_loc_t to these functions
|
||||
const coeff_t* coeffs = &lcu->coeff.y[xy_to_zorder(LCU_WIDTH, part_x, part_y)];
|
||||
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, tr_cu, part_w, part_h, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
coeff_bits += uvg_get_coeff_cost(state, coeffs, tr_cu, &split_loc, 0, luma_scan_mode, pred_cu->tr_idx == MTS_SKIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -691,8 +696,8 @@ static double cu_rd_cost_tr_split_accurate(
|
|||
if(chroma_can_use_tr_skip && cb_flag_v) {
|
||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_model_chroma, tr_cu->tr_skip & 4, tr_tree_bits, "transform_skip_flag");
|
||||
}
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.u[index], tr_cu, chroma_width, chroma_height, COLOR_U, scan_order, tr_cu->tr_skip & 2);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.v[index], tr_cu, chroma_width, chroma_height, COLOR_V, scan_order, tr_cu->tr_skip & 4);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.u[index], tr_cu, &loc, COLOR_U, scan_order, tr_cu->tr_skip & 2);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.v[index], tr_cu, &loc, COLOR_V, scan_order, tr_cu->tr_skip & 4);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -709,11 +714,11 @@ static double cu_rd_cost_tr_split_accurate(
|
|||
if (chroma_can_use_tr_skip) {
|
||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_model_chroma, tr_cu->tr_skip & 2, tr_tree_bits, "transform_skip_flag");
|
||||
}
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.joint_uv[index], tr_cu, chroma_width, chroma_height, COLOR_U, scan_order, 0);
|
||||
coeff_bits += uvg_get_coeff_cost(state, &lcu->coeff.joint_uv[index], tr_cu, &loc, COLOR_U, scan_order, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (uvg_is_lfnst_allowed(state, tr_cu, width, width, x_px, y_px, tree_type, depth == 4 || tree_type == UVG_CHROMA_T ? COLOR_UV : COLOR_Y, lcu)) {
|
||||
if (uvg_is_lfnst_allowed(state, tr_cu, width, height, x_px, y_px, tree_type, depth == 4 || tree_type == UVG_CHROMA_T ? COLOR_UV : COLOR_Y, lcu)) {
|
||||
const int lfnst_idx = (depth != 4 && tree_type != UVG_CHROMA_T) ? tr_cu->lfnst_idx : tr_cu->cr_lfnst_idx;
|
||||
CABAC_FBITS_UPDATE(
|
||||
cabac,
|
||||
|
|
|
@ -2243,8 +2243,7 @@ void uvg_cu_cost_inter_rd2(encoder_state_t * const state,
|
|||
depth,
|
||||
lcu,
|
||||
&cabac_copy,
|
||||
width,
|
||||
width,
|
||||
&loc,
|
||||
index,
|
||||
0,
|
||||
cur_cu,
|
||||
|
|
|
@ -1495,11 +1495,16 @@ int8_t uvg_search_intra_chroma_rdo(
|
|||
{
|
||||
const bool reconstruct_chroma = (depth != 4) || (x_px & 4 && y_px & 4);
|
||||
|
||||
int log2_width = MAX(LOG2_LCU_WIDTH - depth - 1, 2);
|
||||
int8_t width = 1 << log2_width;
|
||||
int8_t height = 1 << log2_width;
|
||||
const cu_loc_t loc = { x_px & ~7, y_px & ~7, width, height, width, height };
|
||||
const int luma_width = LCU_WIDTH >> depth;
|
||||
const int luma_height = LCU_WIDTH >> depth; // TODO: height
|
||||
|
||||
int log2_width = MAX(LOG2_LCU_WIDTH - depth - 1, 2);
|
||||
|
||||
cu_loc_t loc;
|
||||
uvg_cu_loc_ctor(&loc, x_px & ~7, y_px & ~7, luma_width, luma_height);
|
||||
|
||||
const int chroma_width = loc.chroma_width;
|
||||
const int chroma_height = loc.chroma_height;
|
||||
uvg_intra_references refs[2];
|
||||
const vector2d_t luma_px = { x_px & ~7, y_px & ~7 };
|
||||
const vector2d_t pic_px = {
|
||||
|
@ -1576,26 +1581,25 @@ int8_t uvg_search_intra_chroma_rdo(
|
|||
&lcu->ref.u[offset],
|
||||
u_pred,
|
||||
u_resi,
|
||||
width,
|
||||
height,
|
||||
chroma_width,
|
||||
chroma_height,
|
||||
LCU_WIDTH_C,
|
||||
width);
|
||||
chroma_width);
|
||||
uvg_generate_residual(
|
||||
&lcu->ref.v[offset],
|
||||
v_pred,
|
||||
v_resi,
|
||||
width,
|
||||
height,
|
||||
chroma_width,
|
||||
chroma_height,
|
||||
LCU_WIDTH_C,
|
||||
width);
|
||||
chroma_width);
|
||||
uvg_chorma_ts_out_t chorma_ts_out;
|
||||
uvg_chroma_transform_search(
|
||||
state,
|
||||
depth,
|
||||
lcu,
|
||||
&temp_cabac,
|
||||
width,
|
||||
height,
|
||||
&loc,
|
||||
offset,
|
||||
mode,
|
||||
pred_cu,
|
||||
|
|
|
@ -38,14 +38,14 @@
|
|||
* Functions for writing the coding quadtree and related syntax.
|
||||
*/
|
||||
|
||||
#include "cu.h"
|
||||
#include "encoderstate.h"
|
||||
#include "global.h"
|
||||
|
||||
void uvg_encode_coeff_nxn_avx2(encoder_state_t * const state,
|
||||
cabac_data_t * const cabac,
|
||||
const coeff_t *coeff,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
cu_loc_t *loc,
|
||||
uint8_t type,
|
||||
int8_t scan_mode,
|
||||
int8_t tr_skip,
|
||||
|
|
|
@ -54,13 +54,16 @@
|
|||
void uvg_encode_coeff_nxn_generic(encoder_state_t * const state,
|
||||
cabac_data_t * const cabac,
|
||||
const coeff_t *coeff,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
cu_loc_t *cu_loc,
|
||||
uint8_t color,
|
||||
int8_t scan_mode,
|
||||
cu_info_t* cur_cu,
|
||||
double* bits_out) {
|
||||
|
||||
double* bits_out)
|
||||
{
|
||||
const int x = cu_loc->x;
|
||||
const int y = cu_loc->y;
|
||||
const int width = color == COLOR_Y ? cu_loc->width : cu_loc->chroma_width;
|
||||
const int height = color == COLOR_Y ? cu_loc->height : cu_loc->chroma_height;
|
||||
//const encoder_control_t * const encoder = state->encoder_control;
|
||||
//int c1 = 1;
|
||||
uint8_t last_coeff_x = 0;
|
||||
|
@ -91,10 +94,12 @@ void uvg_encode_coeff_nxn_generic(encoder_state_t * const state,
|
|||
unsigned scan_cg_last = (unsigned)-1;
|
||||
unsigned scan_pos_last = (unsigned)-1;
|
||||
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
if (coeff[scan[i]]) {
|
||||
scan_pos_last = i;
|
||||
sig_coeffgroup_flag[scan_cg[i >> log2_cg_size]] = 1;
|
||||
for (int j = 0; j < height; j++) {
|
||||
for (int i = 0; i < width; i++) {
|
||||
if (coeff[scan[i + j * width]]) {
|
||||
scan_pos_last = i + j * width;
|
||||
sig_coeffgroup_flag[scan_cg[(i + j * width) >> log2_cg_size]] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
scan_cg_last = scan_pos_last >> log2_cg_size;
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
void uvg_encode_coeff_nxn_generic(encoder_state_t * const state,
|
||||
cabac_data_t * const cabac,
|
||||
const coeff_t *coeff,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
cu_loc_t *loc,
|
||||
uint8_t color,
|
||||
int8_t scan_mode,
|
||||
cu_info_t* cur_cu,
|
||||
|
|
|
@ -49,8 +49,7 @@
|
|||
typedef unsigned (encode_coeff_nxn_func)(encoder_state_t * const state,
|
||||
cabac_data_t * const cabac,
|
||||
const coeff_t *coeff,
|
||||
uint8_t width,
|
||||
uint8_t heigth,
|
||||
cu_loc_t *loc,
|
||||
uint8_t color,
|
||||
int8_t scan_mode,
|
||||
cu_info_t* cur_cu,
|
||||
|
|
|
@ -483,8 +483,7 @@ void uvg_chroma_transform_search(
|
|||
int depth,
|
||||
lcu_t* const lcu,
|
||||
cabac_data_t* temp_cabac,
|
||||
int8_t width,
|
||||
int8_t height,
|
||||
cu_loc_t *cu_loc,
|
||||
const int offset,
|
||||
const uint8_t mode,
|
||||
cu_info_t* pred_cu,
|
||||
|
@ -499,6 +498,9 @@ void uvg_chroma_transform_search(
|
|||
ALIGNED(64) uint8_t u_recon[LCU_WIDTH_C * LCU_WIDTH_C * 5];
|
||||
ALIGNED(64) coeff_t v_coeff[LCU_WIDTH_C * LCU_WIDTH_C * 2];
|
||||
ALIGNED(64) uint8_t v_recon[LCU_WIDTH_C * LCU_WIDTH_C * 5];
|
||||
const int width = cu_loc->chroma_width;
|
||||
const int height = cu_loc->chroma_height;
|
||||
|
||||
uvg_transform2d(
|
||||
state->encoder_control, u_resi, u_coeff, width, height, COLOR_U, pred_cu
|
||||
);
|
||||
|
@ -689,8 +691,7 @@ void uvg_chroma_transform_search(
|
|||
state,
|
||||
u_quant_coeff,
|
||||
pred_cu,
|
||||
width,
|
||||
height,
|
||||
cu_loc,
|
||||
COLOR_U,
|
||||
scan_order,
|
||||
transforms[i] == CHROMA_TS);
|
||||
|
@ -706,8 +707,7 @@ void uvg_chroma_transform_search(
|
|||
state,
|
||||
v_quant_coeff,
|
||||
pred_cu,
|
||||
width,
|
||||
height,
|
||||
cu_loc,
|
||||
COLOR_V,
|
||||
scan_order,
|
||||
transforms[i] == CHROMA_TS);
|
||||
|
@ -1161,6 +1161,8 @@ static void quantize_tr_residual(
|
|||
// Pointers to current location in arrays with quantized coefficients.
|
||||
coeff_t *coeff = NULL;
|
||||
|
||||
// ISP_TODO: use temp coeff array size MAX_TR_WIDTH^2 instead of coeff pointers
|
||||
// ISP_TODO: inside temp coeff array, entries are in the old order. PÖTKÖ
|
||||
switch (color) {
|
||||
case COLOR_Y:
|
||||
pred = &lcu->rec.y[offset];
|
||||
|
@ -1272,9 +1274,9 @@ static void quantize_tr_residual(
|
|||
|
||||
cbf_clear(&cur_pu->cbf, depth, color);
|
||||
if (has_coeffs) {
|
||||
// ISP_TODO: copy coeffs into CU order instead of pötkö
|
||||
cbf_set(&cur_pu->cbf, depth, color);
|
||||
}
|
||||
|
||||
} // ISP_TODO: if no coeffs, mem set width * height amount of coeffs to zero
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,8 +103,7 @@ void uvg_chroma_transform_search(
|
|||
int depth,
|
||||
lcu_t* const lcu,
|
||||
cabac_data_t* temp_cabac,
|
||||
int8_t width,
|
||||
int8_t height,
|
||||
cu_loc_t *cu_loc,
|
||||
const int offset,
|
||||
const uint8_t mode,
|
||||
cu_info_t* pred_cu,
|
||||
|
|
Loading…
Reference in a new issue