[dual-tree][tests] Fix some issues and enable cabac state test to test for dual tree

This commit is contained in:
Joose Sainio 2022-06-21 15:44:00 +03:00
parent 345c50ecee
commit b0d616b03c
4 changed files with 19 additions and 14 deletions

View file

@ -1747,7 +1747,7 @@ void uvg_encode_coding_tree(
exit(1); exit(1);
} }
if (state->encoder_control->cabac_debug_file) { if (state->encoder_control->cabac_debug_file) {
fprintf(state->encoder_control->cabac_debug_file, "E %4d %4d %d", x, y, depth); fprintf(state->encoder_control->cabac_debug_file, "E %4d %4d %d %d", x << (tree_type == UVG_CHROMA_T), y << (tree_type == UVG_CHROMA_T), depth, tree_type);
fwrite(&cabac->ctx, 1, sizeof(cabac->ctx), state->encoder_control->cabac_debug_file); fwrite(&cabac->ctx, 1, sizeof(cabac->ctx), state->encoder_control->cabac_debug_file);
} }

View file

@ -589,7 +589,7 @@ static double cu_rd_cost_tr_split_accurate(
unsigned chroma_ssd = 0; unsigned chroma_ssd = 0;
if(has_chroma) { if(has_chroma) {
const vector2d_t lcu_px = { (x_px & ~7 ) / 2, (y_px & ~7) / 2 }; const vector2d_t lcu_px = { (x_px >> (tree_type != UVG_CHROMA_T)) & ~3, (y_px >> (tree_type != UVG_CHROMA_T)) &~3 };
const int chroma_width = MAX(4, LCU_WIDTH >> (depth + 1)); const int chroma_width = MAX(4, LCU_WIDTH >> (depth + 1));
int8_t scan_order = uvg_get_scan_order(pred_cu->type, pred_cu->intra.mode_chroma, depth); int8_t scan_order = uvg_get_scan_order(pred_cu->type, pred_cu->intra.mode_chroma, depth);
const unsigned index = xy_to_zorder(LCU_WIDTH_C, lcu_px.x, lcu_px.y); const unsigned index = xy_to_zorder(LCU_WIDTH_C, lcu_px.x, lcu_px.y);
@ -943,7 +943,7 @@ static double search_cu(
intra_search.pred_cu.joint_cb_cr = 0; intra_search.pred_cu.joint_cb_cr = 0;
// TODO: This heavily relies to square CUs // TODO: This heavily relies to square CUs
if ((depth != 4 || (x % 8 && y % 8)) && state->encoder_control->chroma_format != UVG_CSP_400) { if ((depth != 4 || (x % 8 && y % 8)) && state->encoder_control->chroma_format != UVG_CSP_400 && tree_type != UVG_LUMA_T) {
// There is almost no benefit to doing the chroma mode search for // There is almost no benefit to doing the chroma mode search for
// rd2. Possibly because the luma mode search already takes chroma // rd2. Possibly because the luma mode search already takes chroma
// into account, so there is less of a chanse of luma mode being // into account, so there is less of a chanse of luma mode being
@ -973,7 +973,12 @@ static double search_cu(
&intra_search.pred_cu, &intra_search.pred_cu,
lcu, lcu,
tree_type); tree_type);
intra_cost += uvg_cu_rd_cost_chroma(state, x_local, y_local, depth, &intra_search.pred_cu, lcu); if(tree_type != UVG_CHROMA_T) {
intra_cost += uvg_cu_rd_cost_chroma(state, x_local, y_local, depth, &intra_search.pred_cu, lcu);
}
else {
intra_cost = intra_search.cost;
}
intra_search.pred_cu.intra.mode = intra_mode; intra_search.pred_cu.intra.mode = intra_mode;
intra_search.pred_cu.violates_lfnst_constrained_chroma = false; intra_search.pred_cu.violates_lfnst_constrained_chroma = false;
intra_search.pred_cu.lfnst_last_scan_pos = false; intra_search.pred_cu.lfnst_last_scan_pos = false;
@ -1124,7 +1129,7 @@ static double search_cu(
depth < pu_depth_inter.max); depth < pu_depth_inter.max);
if(state->encoder_control->cabac_debug_file) { if(state->encoder_control->cabac_debug_file) {
fprintf(state->encoder_control->cabac_debug_file, "S %4d %4d %d", x, y, depth); fprintf(state->encoder_control->cabac_debug_file, "S %4d %4d %d %d", x, y, depth, tree_type);
fwrite(&state->search_cabac.ctx, 1, sizeof(state->search_cabac.ctx), state->encoder_control->cabac_debug_file); fwrite(&state->search_cabac.ctx, 1, sizeof(state->search_cabac.ctx), state->encoder_control->cabac_debug_file);
} }

View file

@ -1628,7 +1628,7 @@ int8_t uvg_search_cu_intra_chroma(
chroma_data[i].pred_cu.intra.mode_chroma = num_modes == 1 ? intra_mode : modes[i]; chroma_data[i].pred_cu.intra.mode_chroma = num_modes == 1 ? intra_mode : modes[i];
chroma_data[i].pred_cu.intra.mode = -1; chroma_data[i].pred_cu.intra.mode = -1;
chroma_data[i].cost = 0; chroma_data[i].cost = 0;
if(depth != 4) { if(depth != 4 && tree_type == UVG_BOTH_T) {
memcpy(chroma_data[i].lfnst_costs, search_data->lfnst_costs, sizeof(double) * 3); memcpy(chroma_data[i].lfnst_costs, search_data->lfnst_costs, sizeof(double) * 3);
} }
} }

View file

@ -30,9 +30,9 @@ def main(state_file: Path, ctx_names: list, ctx_count: int = 332, ctx_size: int
with open(state_file, "rb") as file: with open(state_file, "rb") as file:
try: try:
while True: while True:
type_, x, y, depth = file.read(13).decode().split() type_, x, y, depth, tree_type = file.read(15).decode().split()
# Reset stored data at the beginning of the frame # Reset stored data at the beginning of the frame
if x == '0' and y == '0' and type_ == "S": if x == '0' and y == '0' and type_ == "S" and tree_type != "2":
if not was_zero_last: if not was_zero_last:
frame_num += 1 frame_num += 1
ctx_store = dict() ctx_store = dict()
@ -44,14 +44,14 @@ def main(state_file: Path, ctx_names: list, ctx_count: int = 332, ctx_size: int
ctx = file.read(ctx_count * ctx_size) ctx = file.read(ctx_count * ctx_size)
if type_ == "S": if type_ == "S":
# These shouldn't happen but just to make sure everything is working as intended # These shouldn't happen but just to make sure everything is working as intended
if ctx_store.get((x, y, depth)): if ctx_store.get((x, y, depth, tree_type)):
raise RuntimeError raise RuntimeError
ctx_store[(x, y, depth)] = ctx ctx_store[(x, y, depth, tree_type)] = ctx
else: else:
if (x, y, depth) in e_store: if (x, y, depth, tree_type) in e_store:
raise RuntimeError raise RuntimeError
e_store.add((x, y, depth)) e_store.add((x, y, depth, tree_type))
if (s_ctx := ctx_store[(x, y, depth)]) != ctx: if (s_ctx := ctx_store[(x, y, depth, tree_type)]) != ctx:
actual_problem = False actual_problem = False
for i in range(ctx_count): for i in range(ctx_count):
@ -61,7 +61,7 @@ def main(state_file: Path, ctx_names: list, ctx_count: int = 332, ctx_size: int
if ctx_names[i] in ignore_list: if ctx_names[i] in ignore_list:
continue continue
actual_problem = True actual_problem = True
print(f"MISSMATCH in {ctx_names[i]} {frame_num=} {x=} {y=} {depth=}") print(f"MISSMATCH in {ctx_names[i]} {frame_num=} {x=} {y=} {depth=} {tree_type=}")
print( print(
f"GOT : {int.from_bytes(temp_s[0:2], 'little')}:" f"GOT : {int.from_bytes(temp_s[0:2], 'little')}:"
f"{int.from_bytes(temp_s[2:4], 'little')} " f"{int.from_bytes(temp_s[2:4], 'little')} "