From 20d0a9b65e48b24b3adb43abffca4ff9f857f8a5 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Fri, 17 Jun 2022 09:15:01 +0300 Subject: [PATCH] [ibc] Add `--ibc` parameter and config values for Intra Block Copy --- src/cfg.c | 11 +++++++++++ src/cli.c | 1 + src/cu.h | 1 + src/encoder_state-bitstream.c | 6 +++++- src/global.h | 6 ++++++ src/uvg266.h | 3 +++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/cfg.c b/src/cfg.c index 6f3cbfef..c7c0ef9e 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -221,6 +221,9 @@ int uvg_config_init(uvg_config *cfg) cfg->cabac_debug_file_name = NULL; cfg->dual_tree = 0; + + cfg->ibc = 0; + return 1; } @@ -1475,6 +1478,14 @@ int uvg_config_parse(uvg_config *cfg, const char *name, const char *value) else if OPT("dual-tree") { cfg->dual_tree = atobool(value); } + else if OPT ("ibc") { + int ibc_value = atoi(value); + if (ibc_value < 0 || ibc_value > 2) { + fprintf(stderr, "ibc supports only range from 0 to 2\n"); + return 0; + } + cfg->ibc = (uint8_t)ibc_value; + } else { return 0; } diff --git a/src/cli.c b/src/cli.c index 53f2df9b..3afaed62 100644 --- a/src/cli.c +++ b/src/cli.c @@ -191,6 +191,7 @@ static const struct option long_options[] = { { "dual-tree", no_argument, NULL, 0 }, { "no-dual-tree", no_argument, NULL, 0 }, { "cabac-debug-file", required_argument, NULL, 0 }, + { "ibc", required_argument, NULL, 0 }, {0, 0, 0, 0} }; diff --git a/src/cu.h b/src/cu.h index 74ff25a6..e3555d08 100644 --- a/src/cu.h +++ b/src/cu.h @@ -52,6 +52,7 @@ typedef enum { CU_INTRA = 1, CU_INTER = 2, CU_PCM = 3, + CU_IBC = 4, } cu_type_t; typedef enum { diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index 3ef5c64e..b19ab758 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -694,7 +694,11 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, WRITE_UE(stream, 0, "sps_internal_bit_depth_minus_input_bit_depth"); } - WRITE_U(stream, 0, 1, "sps_ibc_enabled_flag"); + WRITE_U(stream, encoder->cfg.ibc > 0 ? 1 : 0, 1, "sps_ibc_enabled_flag"); + + if (encoder->cfg.ibc) { + WRITE_UE(stream,6 - IBC_MRG_MAX_NUM_CANDS, "sps_six_minus_max_num_ibc_merge_cand"); + } #if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET // if(!no_ladf_constraint_flag) diff --git a/src/global.h b/src/global.h index 448ea1f1..1c2da76f 100644 --- a/src/global.h +++ b/src/global.h @@ -254,6 +254,12 @@ typedef int32_t mv_t; #define AMVP_MAX_NUM_CANDS 2 #define AMVP_MAX_NUM_CANDS_MEM 3 #define MRG_MAX_NUM_CANDS 6 +/** + * \brief Max number of merge candidates in Intra Block Copy + * + */ +#define IBC_MRG_MAX_NUM_CANDS 6 + #define MAX_NUM_HMVP_CANDS 5 diff --git a/src/uvg266.h b/src/uvg266.h index 1801c8ac..0c449913 100644 --- a/src/uvg266.h +++ b/src/uvg266.h @@ -541,6 +541,9 @@ typedef struct uvg_config char* cabac_debug_file_name; uint8_t dual_tree; + + uint8_t ibc; /* \brief Intra Block Copy parameter */ + } uvg_config; /**