From dce5c2b293b4c6dae8e3c19f7d0a862296651480 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Fri, 10 Dec 2021 16:07:34 +0200 Subject: [PATCH 1/3] [threading] Add dependency to one more CTU to the right * in VVC the conditions for limiting motion vectors might not have been correct * x + 1 and y + 1 CTU dependency did not mean that x + 2 would be available, as in HEVC --- src/encoderstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoderstate.c b/src/encoderstate.c index f43c12f9..b0691ac7 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -937,7 +937,7 @@ static void encoder_state_encode_leaf(encoder_state_t * const state) for (int i = 0; dep_lcu->below && i < ctrl->max_inter_ref_lcu.down; i++) { dep_lcu = dep_lcu->below; } - for (int i = 0; dep_lcu->right && i < ctrl->max_inter_ref_lcu.right; i++) { + for (int i = 0; dep_lcu->right && i < ctrl->max_inter_ref_lcu.right + 1; i++) { dep_lcu = dep_lcu->right; } kvz_threadqueue_job_dep_add(job[0], ref_state->tile->wf_recon_jobs[dep_lcu->id]); From 2cdeff75cbee820cadbbf9024fe29dd5bf2862c5 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Mon, 13 Dec 2021 16:01:52 +0200 Subject: [PATCH 2/3] [debug] Add debug.c/.h to visual studio project and some debugging options --- src/debug.c | 3 ++- src/debug.h | 3 ++- src/encode_coding_tree.c | 3 +++ src/global.h | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/debug.c b/src/debug.c index 50b90e03..1a35fb25 100644 --- a/src/debug.c +++ b/src/debug.c @@ -146,7 +146,8 @@ void kvz_dbg_yuview_init(const encoder_control_t* const encoder, char* filename, fprintf(yuview_output, "%%;scaleToBlockSize;1\r\n"); fprintf(yuview_output, "%%;type;18;TR-Skip;range\r\n"); fprintf(yuview_output, "%%;defaultRange;0;2;heat\r\n"); - + fprintf(yuview_output, "%%;type;19;MRL;range\r\n"); + fprintf(yuview_output, "%%;defaultRange;0;2;autumn\r\n"); } static int yuview_check_allocated_memory(int poc, int type) { diff --git a/src/debug.h b/src/debug.h index 7c9197a8..d471cc0f 100644 --- a/src/debug.h +++ b/src/debug.h @@ -54,7 +54,8 @@ enum { DBG_YUVIEW_NUM_SIG_COEFF_U = 16, DBG_YUVIEW_NUM_SIG_COEFF_V = 17, DBG_YUVIEW_TR_SKIP = 18, - DBG_YUVIEW_NUM_ITEMS = 19, + DBG_YUVIEW_MRL = 19, + DBG_YUVIEW_NUM_ITEMS = 20, }; diff --git a/src/encode_coding_tree.c b/src/encode_coding_tree.c index 3e37ae5e..97d6115f 100644 --- a/src/encode_coding_tree.c +++ b/src/encode_coding_tree.c @@ -858,6 +858,9 @@ static void encode_intra_coding_unit(encoder_state_t * const state, bool enable_mrl = state->encoder_control->cfg.mrl; int multi_ref_idx = enable_mrl ? cur_cu->intra.multi_ref_idx : 0; +#ifdef KVZ_DEBUG_PRINT_YUVIEW_CSV + if(multi_ref_idx) DBG_YUVIEW_VALUE(state->frame->poc, DBG_YUVIEW_MRL, x, y, width, width, multi_ref_idx); +#endif if (cur_cu->type == CU_INTRA && (y % LCU_WIDTH) != 0 && !cur_cu->bdpcmMode && enable_mrl) { if (MAX_REF_LINE_IDX > 1) { diff --git a/src/global.h b/src/global.h index 4e42b8ce..7d8507b8 100644 --- a/src/global.h +++ b/src/global.h @@ -131,7 +131,7 @@ typedef int16_t mv_t; //#define KVZ_DEBUG 1 //#define KVZ_DEBUG_PRINT_YUVIEW_CSV 1 - +//#define KVZ_DEBUG_PRINT_MV_INFO 1 /* CONFIG VARIABLES */ //spec: references to variables defined in Rec. ITU-T H.265 (04/2013) From 2545081be5550bddde1b009a02b65a5fee57141c Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Mon, 13 Dec 2021 16:00:13 +0200 Subject: [PATCH 3/3] [threading] Added more margin to fracmv_within_tile() because of nondeterministic behaviour --- src/search_inter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/search_inter.c b/src/search_inter.c index 41f64d07..7c8bc0bb 100644 --- a/src/search_inter.c +++ b/src/search_inter.c @@ -116,15 +116,15 @@ static INLINE bool fracmv_within_tile(const inter_search_info_t *info, int x, in // Check that the block does not reference pixels that are not final. // Margin as luma pixels. - int margin = 0; + int margin = 2; // Added two-pixel margin since some nondeterministic behaviour happens otherwise if (is_frac_luma) { // Fractional motion estimation needs up to 4 pixels outside the // block. - margin = 4; + margin += 4; } else if (is_frac_chroma) { // Odd chroma interpolation needs up to 2 luma pixels outside the // block. - margin = 2; + margin += 2; } if (ctrl->cfg.sao_type) {