CWG-E182: Simplification of IBP DC mode CWG-E182: simplify the prediction process of the IBP DC mode. STATS_CHANGED
diff --git a/aom/internal/aom_codec_internal.h b/aom/internal/aom_codec_internal.h index 1660585..d6e3ce9 100644 --- a/aom/internal/aom_codec_internal.h +++ b/aom/internal/aom_codec_internal.h
@@ -348,8 +348,8 @@ const char *err_detail; aom_codec_flags_t init_flags; #if CONFIG_IBP_WEIGHT - uint8_t ibp_directional_weights[IBP_WEIGHT_SIZE][IBP_WEIGHT_SIZE] - [DIR_MODES_0_90]; + IbpWeightsType ibp_directional_weights[IBP_WEIGHT_SIZE][IBP_WEIGHT_SIZE] + [DIR_MODES_0_90]; #else uint8_t *ibp_directional_weights[TX_SIZES_ALL][DIR_MODES_0_90]; #endif // CONFIG_IBP_WEIGHT
diff --git a/aom_dsp/intrapred.c b/aom_dsp/intrapred.c index 1dfb7b6..86d4106 100644 --- a/aom_dsp/intrapred.c +++ b/aom_dsp/intrapred.c
@@ -576,7 +576,7 @@ for (r = 0; r < len; r++) { for (c = 0; c < bw; c++) { int val = ROUND_POWER_OF_TWO( - above[c] * (256 - weights[r]) + dst[c] * weights[r], + above[c] * (IBP_WEIGHT_REF - weights[r]) + dst[c] * weights[r], IBP_WEIGHT_SHIFT); dst[c] = val; } @@ -594,24 +594,33 @@ uint16_t *orig_dst = dst; int len_h = bh >> 2; int len_w = bw >> 2; + int row_start = 0; + int col_start = 0; +#if CONFIG_FIX_IBP_DC + if (bw >= bh) + row_start = len_h; + else + col_start = len_w; +#endif // CONFIG_FIX_IBP_DC uint8_t weights_index = size_to_weights_index[bh >> 3]; const uint8_t *weights = ibp_weights[weights_index]; for (r = 0; r < len_h; r++) { - for (c = 0; c < bw; c++) { + for (c = col_start; c < bw; c++) { int val = ROUND_POWER_OF_TWO( - above[c] * (256 - weights[r]) + dst[c] * weights[r], + above[c] * (IBP_WEIGHT_REF - weights[r]) + dst[c] * weights[r], IBP_WEIGHT_SHIFT); dst[c] = val; } dst += stride; } - dst = orig_dst; + dst = orig_dst + row_start * stride; weights_index = size_to_weights_index[bw >> 3]; weights = ibp_weights[weights_index]; - for (r = 0; r < bh; r++) { + for (r = row_start; r < bh; r++) { for (c = 0; c < len_w; c++) { int val = ROUND_POWER_OF_TWO( - left[r] * (256 - weights[c]) + dst[c] * weights[c], IBP_WEIGHT_SHIFT); + left[r] * (IBP_WEIGHT_REF - weights[c]) + dst[c] * weights[c], + IBP_WEIGHT_SHIFT); dst[c] = val; } dst += stride; @@ -630,7 +639,8 @@ for (r = 0; r < bh; r++) { for (c = 0; c < len; c++) { int val = ROUND_POWER_OF_TWO( - left[r] * (256 - weights[c]) + dst[c] * weights[c], IBP_WEIGHT_SHIFT); + left[r] * (IBP_WEIGHT_REF - weights[c]) + dst[c] * weights[c], + IBP_WEIGHT_SHIFT); dst[c] = val; } dst += stride; @@ -649,7 +659,7 @@ for (r = 0; r < len; r++) { for (c = 0; c < bw; c++) { int val = ROUND_POWER_OF_TWO( - above[c] * (256 - weights[r]) + dst[c] * weights[r], + above[c] * (IBP_WEIGHT_REF - weights[r]) + dst[c] * weights[r], IBP_WEIGHT_SHIFT); dst[c] = val; } @@ -666,22 +676,31 @@ const uint8_t *weights = ibp_weights[weights_index]; int len_w = bw >> 2; int len_h = bh >> 2; + int row_start = 0; + int col_start = 0; +#if CONFIG_FIX_IBP_DC + if (bw >= bh) + row_start = len_h; + else + col_start = len_w; +#endif // CONFIG_FIX_IBP_DC for (r = 0; r < len_h; r++) { - for (c = 0; c < bw; c++) { + for (c = col_start; c < bw; c++) { int val = ROUND_POWER_OF_TWO( - above[c] * (256 - weights[r]) + dst[c] * weights[r], + above[c] * (IBP_WEIGHT_REF - weights[r]) + dst[c] * weights[r], IBP_WEIGHT_SHIFT); dst[c] = val; } dst += stride; } - dst = orig_dst; + dst = orig_dst + row_start * stride; weights_index = size_to_weights_index[bw >> 3]; weights = ibp_weights[weights_index]; - for (r = 0; r < bh; r++) { + for (r = row_start; r < bh; r++) { for (c = 0; c < len_w; c++) { int val = ROUND_POWER_OF_TWO( - left[r] * (256 - weights[c]) + dst[c] * weights[c], IBP_WEIGHT_SHIFT); + left[r] * (IBP_WEIGHT_REF - weights[c]) + dst[c] * weights[c], + IBP_WEIGHT_SHIFT); dst[c] = val; } dst += stride;
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h index 2b17325..27b310f 100644 --- a/av1/common/av1_common_int.h +++ b/av1/common/av1_common_int.h
@@ -1782,8 +1782,8 @@ * Weights for IBP of directional modes. */ #if CONFIG_IBP_WEIGHT - uint8_t ibp_directional_weights[IBP_WEIGHT_SIZE][IBP_WEIGHT_SIZE] - [DIR_MODES_0_90]; + IbpWeightsType ibp_directional_weights[IBP_WEIGHT_SIZE][IBP_WEIGHT_SIZE] + [DIR_MODES_0_90]; #else uint8_t *ibp_directional_weights[TX_SIZES_ALL][DIR_MODES_0_90]; #endif // CONFIG_IBP_WEIGHT @@ -3842,7 +3842,8 @@ // Generate the weights per pixel position for IBP #if CONFIG_IBP_WEIGHT static void av1_dr_prediction_z1_info( - uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int dy, int mode_idx) { + IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int dy, + int mode_idx) { int32_t r, c, y; for (r = 0; r < IBP_WEIGHT_SIZE; ++r) { y = dy; @@ -3948,7 +3949,8 @@ // Generate weights for IBP of one directional mode static INLINE void init_ibp_info_per_mode( #if CONFIG_IBP_WEIGHT - uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode, int delta + IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode, + int delta #else uint8_t *weights[TX_SIZES_ALL][DIR_MODES_0_90], int block_idx, int mode, int delta, int txw, int txh, int txw_log2, int txh_log2 @@ -3975,7 +3977,7 @@ // Generate weights for IBP of directional modes static INLINE void init_ibp_info( #if CONFIG_IBP_WEIGHT - uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90]) { + IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90]) { for (int r = 0; r < IBP_WEIGHT_SIZE; ++r) { for (int c = 0; c < IBP_WEIGHT_SIZE; ++c) { for (int m = 0; m < DIR_MODES_0_90; ++m) {
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl index 883e20a..9e0b50e 100644 --- a/av1/common/av1_rtcd_defs.pl +++ b/av1/common/av1_rtcd_defs.pl
@@ -301,9 +301,9 @@ if (aom_config("CONFIG_IBP_WEIGHT") eq "yes") { add_proto qw / void av1_highbd_ibp_dr_prediction_z1 /, - "const uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode_idx, uint16_t *dst, ptrdiff_t stride, uint16_t* second_pred, ptrdiff_t second_stride, int bw, int bh"; + "const IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode_idx, uint16_t *dst, ptrdiff_t stride, uint16_t* second_pred, ptrdiff_t second_stride, int bw, int bh"; add_proto qw / void av1_highbd_ibp_dr_prediction_z3 /, - "const uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode_idx, uint16_t *dst, ptrdiff_t stride, uint16_t* second_pred, ptrdiff_t second_stride, int bw, int bh"; + "const IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode_idx, uint16_t *dst, ptrdiff_t stride, uint16_t* second_pred, ptrdiff_t second_stride, int bw, int bh"; } else { add_proto qw / void av1_highbd_ibp_dr_prediction_z1 /,
diff --git a/av1/common/enums.h b/av1/common/enums.h index 0935a00..e9d8c07 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -1283,7 +1283,15 @@ #define DIR_MODES_0_90 17 #define IBP_WEIGHT_SHIFT 8 +#if CONFIG_FIX_IBP_DC +#define IBP_WEIGHT_MAX 256 +#define IBP_WEIGHT_REF IBP_WEIGHT_MAX +typedef uint16_t IbpWeightsType; +#else #define IBP_WEIGHT_MAX 255 +typedef uint8_t IbpWeightsType; +#define IBP_WEIGHT_REF 256 +#endif // CONFIG_FIX_IBP_DC /*!\enum Warp projection type * \brief This enumeration defines various warp projection type supported
diff --git a/av1/common/reconintra.c b/av1/common/reconintra.c index b28fd8e..9a427ce 100644 --- a/av1/common/reconintra.c +++ b/av1/common/reconintra.c
@@ -1417,8 +1417,8 @@ #if CONFIG_IBP_WEIGHT void av1_highbd_ibp_dr_prediction_z1_c( - const uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode_idx, - uint16_t *dst, ptrdiff_t stride, uint16_t *second_pred, + const IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], + int mode_idx, uint16_t *dst, ptrdiff_t stride, uint16_t *second_pred, ptrdiff_t second_stride, int bw, int bh) { const int col_shift = bw >> (IBP_WEIGHT_SIZE_LOG2 + 1); const int row_shift = bh >> (IBP_WEIGHT_SIZE_LOG2 + 1); @@ -1438,8 +1438,8 @@ } void av1_highbd_ibp_dr_prediction_z3_c( - const uint8_t weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], int mode_idx, - uint16_t *dst, ptrdiff_t stride, uint16_t *second_pred, + const IbpWeightsType weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90], + int mode_idx, uint16_t *dst, ptrdiff_t stride, uint16_t *second_pred, ptrdiff_t second_stride, int bw, int bh) { const int col_shift = bw >> (IBP_WEIGHT_SIZE_LOG2 + 1); const int row_shift = bh >> (IBP_WEIGHT_SIZE_LOG2 + 1); @@ -1506,7 +1506,7 @@ int n_bottomleft_px, int plane, int is_sb_boundary, const int seq_intra_pred_filter_flag, const int seq_ibp_flag, #if CONFIG_IBP_WEIGHT - const uint8_t ibp_weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90] + const IbpWeightsType ibp_weights[][IBP_WEIGHT_SIZE][DIR_MODES_0_90] #else uint8_t *const ibp_weights[TX_SIZES_ALL][DIR_MODES_0_90] #endif // CONFIG_IBP_WEIGHT
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake index c102b91..1bb359d 100644 --- a/build/cmake/aom_config_defaults.cmake +++ b/build/cmake/aom_config_defaults.cmake
@@ -416,6 +416,7 @@ set_aom_config_var(CONFIG_COEFF_HR_ADAPTIVE 1 "AV2 enable adaptive coding of HR coefficients.") set_aom_config_var(CONFIG_IBP_WEIGHT 1 "Reduce IBP weights memory.") +set_aom_config_var(CONFIG_FIX_IBP_DC 1 "Simplify prediction of IBP DC mode.") set_aom_config_var(CONFIG_WEDGE_TMVP 1 "Improvements to tmvp MV storing for wedge mode.") set_aom_config_var(