Remove CONFIG_REFINEMENT_SIMPLIFY and CONFIG_OPTFLOW_REFINEMENT
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h index e8a6792..22d5399 100644 --- a/aom/aom_encoder.h +++ b/aom/aom_encoder.h
@@ -209,7 +209,6 @@ AOM_SUPERRES_AUTO, } aom_superres_mode; -#if CONFIG_OPTFLOW_REFINEMENT /*!\brief Frame super-resolution mode. */ typedef enum { /**< MV refinement is disabled for all frames. */ @@ -223,7 +222,6 @@ * for each frame. */ AOM_OPFL_REFINE_AUTO, } aom_opfl_refine_type; -#endif // CONFIG_OPTFLOW_REFINEMENT /*!\brief Decoded Frame Hash Metadata OBU writing mode. * @@ -539,12 +537,10 @@ * */ unsigned int enable_angle_delta; -#if CONFIG_OPTFLOW_REFINEMENT /*!\brief enable optical flow refinement * */ aom_opfl_refine_type enable_opfl_refine; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT /*!\brief enable affine refinement *
diff --git a/aom_dsp/x86/convolve_avx2.h b/aom_dsp/x86/convolve_avx2.h index 0289591..fe48a98 100644 --- a/aom_dsp/x86/convolve_avx2.h +++ b/aom_dsp/x86/convolve_avx2.h
@@ -327,7 +327,6 @@ _mm256_store_si256((__m256i *)&im_block[i * im_stride], res); \ } -#if CONFIG_OPTFLOW_REFINEMENT // In optical flow MV refinement, unaligned store (_mm_storeu_si128) is used // in this function to avoid a subblock boundary error. #define DIST_WTD_CONVOLVE_VERTICAL_FILTER_8TAP \ @@ -431,109 +430,6 @@ s[5] = s[6]; \ s[6] = s[7]; \ } -#else -#define DIST_WTD_CONVOLVE_VERTICAL_FILTER_8TAP \ - __m256i s[8]; \ - __m256i s0 = _mm256_loadu_si256((__m256i *)(im_block + 0 * im_stride)); \ - __m256i s1 = _mm256_loadu_si256((__m256i *)(im_block + 1 * im_stride)); \ - __m256i s2 = _mm256_loadu_si256((__m256i *)(im_block + 2 * im_stride)); \ - __m256i s3 = _mm256_loadu_si256((__m256i *)(im_block + 3 * im_stride)); \ - __m256i s4 = _mm256_loadu_si256((__m256i *)(im_block + 4 * im_stride)); \ - __m256i s5 = _mm256_loadu_si256((__m256i *)(im_block + 5 * im_stride)); \ - \ - s[0] = _mm256_unpacklo_epi16(s0, s1); \ - s[1] = _mm256_unpacklo_epi16(s2, s3); \ - s[2] = _mm256_unpacklo_epi16(s4, s5); \ - \ - s[4] = _mm256_unpackhi_epi16(s0, s1); \ - s[5] = _mm256_unpackhi_epi16(s2, s3); \ - s[6] = _mm256_unpackhi_epi16(s4, s5); \ - \ - for (i = 0; i < h; i += 2) { \ - const int16_t *data = &im_block[i * im_stride]; \ - \ - const __m256i s6 = _mm256_loadu_si256((__m256i *)(data + 6 * im_stride)); \ - const __m256i s7 = _mm256_loadu_si256((__m256i *)(data + 7 * im_stride)); \ - \ - s[3] = _mm256_unpacklo_epi16(s6, s7); \ - s[7] = _mm256_unpackhi_epi16(s6, s7); \ - \ - const __m256i res_a = convolve(s, coeffs_y); \ - const __m256i res_a_round = _mm256_sra_epi32( \ - _mm256_add_epi32(res_a, round_const_v), round_shift_v); \ - \ - if (w - j > 4) { \ - const __m256i res_b = convolve(s + 4, coeffs_y); \ - const __m256i res_b_round = _mm256_sra_epi32( \ - _mm256_add_epi32(res_b, round_const_v), round_shift_v); \ - const __m256i res_16b = _mm256_packs_epi32(res_a_round, res_b_round); \ - const __m256i res_unsigned = _mm256_add_epi16(res_16b, offset_const); \ - \ - if (do_average) { \ - const __m256i data_ref_0 = load_line2_avx2( \ - &dst[i * dst_stride + j], &dst[i * dst_stride + j + dst_stride]); \ - const __m256i comp_avg_res = \ - comp_avg(&data_ref_0, &res_unsigned, &wt, use_wtd_comp_avg); \ - \ - const __m256i round_result = convolve_rounding( \ - &comp_avg_res, &offset_const, &rounding_const, rounding_shift); \ - \ - const __m256i res_8 = _mm256_packus_epi16(round_result, round_result); \ - const __m128i res_0 = _mm256_castsi256_si128(res_8); \ - const __m128i res_1 = _mm256_extracti128_si256(res_8, 1); \ - \ - _mm_storel_epi64((__m128i *)(&dst0[i * dst_stride0 + j]), res_0); \ - _mm_storel_epi64( \ - (__m128i *)((&dst0[i * dst_stride0 + j + dst_stride0])), res_1); \ - } else { \ - const __m128i res_0 = _mm256_castsi256_si128(res_unsigned); \ - _mm_store_si128((__m128i *)(&dst[i * dst_stride + j]), res_0); \ - \ - const __m128i res_1 = _mm256_extracti128_si256(res_unsigned, 1); \ - _mm_store_si128((__m128i *)(&dst[i * dst_stride + j + dst_stride]), \ - res_1); \ - } \ - } else { \ - const __m256i res_16b = _mm256_packs_epi32(res_a_round, res_a_round); \ - const __m256i res_unsigned = _mm256_add_epi16(res_16b, offset_const); \ - \ - if (do_average) { \ - const __m256i data_ref_0 = load_line2_avx2( \ - &dst[i * dst_stride + j], &dst[i * dst_stride + j + dst_stride]); \ - \ - const __m256i comp_avg_res = \ - comp_avg(&data_ref_0, &res_unsigned, &wt, use_wtd_comp_avg); \ - \ - const __m256i round_result = convolve_rounding( \ - &comp_avg_res, &offset_const, &rounding_const, rounding_shift); \ - \ - const __m256i res_8 = _mm256_packus_epi16(round_result, round_result); \ - const __m128i res_0 = _mm256_castsi256_si128(res_8); \ - const __m128i res_1 = _mm256_extracti128_si256(res_8, 1); \ - \ - *(uint32_t *)(&dst0[i * dst_stride0 + j]) = _mm_cvtsi128_si32(res_0); \ - *(uint32_t *)(&dst0[i * dst_stride0 + j + dst_stride0]) = \ - _mm_cvtsi128_si32(res_1); \ - \ - } else { \ - const __m128i res_0 = _mm256_castsi256_si128(res_unsigned); \ - _mm_store_si128((__m128i *)(&dst[i * dst_stride + j]), res_0); \ - \ - const __m128i res_1 = _mm256_extracti128_si256(res_unsigned, 1); \ - _mm_store_si128((__m128i *)(&dst[i * dst_stride + j + dst_stride]), \ - res_1); \ - } \ - } \ - \ - s[0] = s[1]; \ - s[1] = s[2]; \ - s[2] = s[3]; \ - \ - s[4] = s[5]; \ - s[5] = s[6]; \ - s[6] = s[7]; \ - } -#endif // CONFIG_OPTFLOW_REFINEMENT static INLINE void prepare_coeffs_lowbd( const InterpFilterParams *const filter_params, const int subpel_q4,
diff --git a/apps/aomenc.c b/apps/aomenc.c index c4f7dc9..9f426af 100644 --- a/apps/aomenc.c +++ b/apps/aomenc.c
@@ -470,9 +470,7 @@ &g_av1_codec_arg_defs.max_drl_refbvs, #endif // CONFIG_IBC_BV_IMPROVEMENT && CONFIG_IBC_MAX_DRL &g_av1_codec_arg_defs.enable_refmvbank, -#if CONFIG_OPTFLOW_REFINEMENT &g_av1_codec_arg_defs.enable_opfl_refine, -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT &g_av1_codec_arg_defs.enable_affine_refine, #endif // CONFIG_AFFINE_REFINEMENT @@ -730,9 +728,7 @@ config->enable_smooth_intra = 1; config->enable_filter_intra = 0; config->enable_angle_delta = 1; -#if CONFIG_OPTFLOW_REFINEMENT config->enable_opfl_refine = 1; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT config->enable_affine_refine = 1; #endif // CONFIG_AFFINE_REFINEMENT @@ -1641,10 +1637,8 @@ encoder_cfg->enable_interintra_wedge, encoder_cfg->enable_ref_frame_mvs); -#if CONFIG_OPTFLOW_REFINEMENT fprintf(stdout, " : OptflowRefinement (%d)\n", encoder_cfg->enable_opfl_refine); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT fprintf(stdout, " : AffineRefinement (%d)\n", encoder_cfg->enable_affine_refine);
diff --git a/av1/arg_defs.c b/av1/arg_defs.c index 7c1d73c..722ce00 100644 --- a/av1/arg_defs.c +++ b/av1/arg_defs.c
@@ -595,13 +595,11 @@ .enable_angle_delta = ARG_DEF(NULL, "enable-angle-delta", 1, "Enable intra angle delta (0: false, 1: true (default))"), -#if CONFIG_OPTFLOW_REFINEMENT .enable_opfl_refine = ARG_DEF(NULL, "enable-opfl-refine", 1, "Enable optical flow MV refinement (0: off , 1: switchable per " "block (default), 2: used in all blocks with simple compound " "average, 3: auto (swtichable per frame by the encoder))"), -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT .enable_affine_refine = ARG_DEF(NULL, "enable-affine-refine", 1,
diff --git a/av1/arg_defs.h b/av1/arg_defs.h index 92d086a..5ae03f9 100644 --- a/av1/arg_defs.h +++ b/av1/arg_defs.h
@@ -222,9 +222,7 @@ arg_def_t enable_intrabc_ext; #endif // CONFIG_IBC_SR_EXT arg_def_t enable_angle_delta; -#if CONFIG_OPTFLOW_REFINEMENT arg_def_t enable_opfl_refine; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT arg_def_t enable_affine_refine; #endif // CONFIG_AFFINE_REFINEMENT
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index e40ea61..dcccc77 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -208,10 +208,8 @@ int enable_intrabc_ext; // enable search range extension for intrabc #endif // CONFIG_IBC_SR_EXT int enable_angle_delta; -#if CONFIG_OPTFLOW_REFINEMENT aom_opfl_refine_type enable_opfl_refine; // optical flow refinement type // for sequence -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT int enable_affine_refine; // enable affine refinement #endif // CONFIG_AFFINE_REFINEMENT @@ -558,11 +556,9 @@ 1, // enable search range extension for intrabc #endif // CONFIG_IBC_SR_EXT 1, // enable angle delta -#if CONFIG_OPTFLOW_REFINEMENT - 1, -#endif // CONFIG_OPTFLOW_REFINEMENT + 1, // enable optical flow refinement #if CONFIG_AFFINE_REFINEMENT - 1, + 1, // enable affine refinement #endif // CONFIG_AFFINE_REFINEMENT #if CONFIG_DENOISE 0, // noise_level @@ -983,9 +979,7 @@ : 0; cfg->enable_warped_motion = extra_cfg->enable_warped_motion; cfg->enable_diff_wtd_comp = extra_cfg->enable_diff_wtd_comp; -#if CONFIG_OPTFLOW_REFINEMENT cfg->enable_opfl_refine = extra_cfg->enable_opfl_refine; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT cfg->enable_affine_refine = extra_cfg->enable_affine_refine; #endif // CONFIG_AFFINE_REFINEMENT @@ -1113,9 +1107,7 @@ : AOM_SUPERBLOCK_SIZE_DYNAMIC; extra_cfg->enable_warped_motion = cfg->enable_warped_motion; extra_cfg->enable_diff_wtd_comp = cfg->enable_diff_wtd_comp; -#if CONFIG_OPTFLOW_REFINEMENT extra_cfg->enable_opfl_refine = cfg->enable_opfl_refine; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT extra_cfg->enable_affine_refine = cfg->enable_affine_refine; #endif // CONFIG_AFFINE_REFINEMENT @@ -1497,11 +1489,9 @@ tool_cfg->max_drl_refbvs = extra_cfg->max_drl_refbvs; #endif // CONFIG_IBC_BV_IMPROVEMENT && CONFIG_IBC_MAX_DRL tool_cfg->enable_refmvbank = extra_cfg->enable_refmvbank; -#if CONFIG_OPTFLOW_REFINEMENT tool_cfg->enable_opfl_refine = extra_cfg->enable_order_hint ? extra_cfg->enable_opfl_refine : AOM_OPFL_REFINE_NONE; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT tool_cfg->enable_affine_refine = extra_cfg->enable_opfl_refine ? extra_cfg->enable_affine_refine : 0; @@ -4118,11 +4108,9 @@ } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_angle_delta, argv, err_string)) { extra_cfg.enable_angle_delta = arg_parse_int_helper(&arg, err_string); -#if CONFIG_OPTFLOW_REFINEMENT } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_opfl_refine, argv, err_string)) { extra_cfg.enable_opfl_refine = arg_parse_int_helper(&arg, err_string); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_affine_refine, argv, err_string)) { @@ -4516,10 +4504,7 @@ #if CONFIG_IBC_SR_EXT 1, #endif // CONFIG_IBC_SR_EXT - 1, 1, 1, 1, -#if CONFIG_OPTFLOW_REFINEMENT - 1, -#endif // CONFIG_OPTFLOW_REFINEMENT + 1, 1, 1, 1, 1, #if CONFIG_AFFINE_REFINEMENT 1, #endif // CONFIG_AFFINE_REFINEMENT
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h index d7a3de8..569ab3e 100644 --- a/av1/common/av1_common_int.h +++ b/av1/common/av1_common_int.h
@@ -360,7 +360,6 @@ #endif // CONFIG_FIX_CDEF_SYNTAX } CdefInfo; -#if CONFIG_OPTFLOW_REFINEMENT enum { /*! * MV refinement disabled for the current frame. @@ -375,7 +374,6 @@ */ REFINE_ALL = 2, } UENUM1BYTE(OPTFLOW_REFINE_TYPE); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_CCSO /** ccso info */ @@ -531,11 +529,9 @@ #if !CONFIG_EXTENDED_WARP_PREDICTION uint8_t enable_interintra_compound; // enables/disables interintra_compound #endif - uint8_t enable_masked_compound; // enables/disables masked compound -#if CONFIG_OPTFLOW_REFINEMENT + uint8_t enable_masked_compound; // enables/disables masked compound aom_opfl_refine_type enable_opfl_refine; // optical flow refinement type for // this frame -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT uint8_t enable_affine_refine; // To turn on/off DAMR #endif // CONFIG_AFFINE_REFINEMENT @@ -753,13 +749,11 @@ */ int max_bvp_drl_bits; #endif // CONFIG_IBC_BV_IMPROVEMENT && CONFIG_IBC_MAX_DRL -#if CONFIG_OPTFLOW_REFINEMENT /*! * Ternary symbol for optical flow refinement type. 0: do not refine, * 1: always refine, 2: switchable at block level. */ OPTFLOW_REFINE_TYPE opfl_refine_type; -#endif // CONFIG_OPTFLOW_REFINEMENT /*! * TIP mode. */ @@ -4049,7 +4043,6 @@ return diff; } -#if CONFIG_OPTFLOW_REFINEMENT // This parameter k=OPFL_DIST_RATIO_THR is used to prune MV refinement for the // case where d0 and d1 are very different. Assuming a = max(|d0|, |d1|) and // b = min(|d0|, |d1|), MV refinement will only be allowed only if a/b <= k. @@ -4148,7 +4141,6 @@ assert(0); return 0; } -#endif // CONFIG_OPTFLOW_REFINEMENT static INLINE int is_global_intrabc_allowed(const AV1_COMMON *const cm) { #if CONFIG_IBC_SR_EXT
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c index df38fea..45633b2 100644 --- a/av1/common/av1_loopfilter.c +++ b/av1/common/av1_loopfilter.c
@@ -71,10 +71,7 @@ 1, // WARPMV #endif // CONFIG_EXTENDED_WARP_PREDICTION 1, 1, 1, 0, 1, // INTER_COMPOUND_MODES (GLOBAL_GLOBALMV == 0) - 1, 1, -#if CONFIG_OPTFLOW_REFINEMENT - 1, 1, 1, 1, 1, 1, -#endif // CONFIG_OPTFLOW_REFINEMENT + 1, 1, 1, 1, 1, 1, 1, 1, }; // Function obtains q_threshold from the quantization index. @@ -440,7 +437,6 @@ } } -#if CONFIG_OPTFLOW_REFINEMENT // Check whether current block is OPFL mode static AOM_INLINE void check_opfl_edge(const AV1_COMMON *const cm, const int plane, @@ -461,7 +457,6 @@ *ts = opfl_ts; } } -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV // Check whether current block is RFMV mode @@ -492,14 +487,12 @@ TX_SIZE temp_ts = 0; check_tip_edge(mbmi, scale_horz, scale_vert, &temp_ts, &temp_edge); -#if CONFIG_OPTFLOW_REFINEMENT if (!temp_edge) check_opfl_edge(cm, plane, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN mbmi, &temp_ts, &temp_edge); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV if (!temp_edge) check_rfmv_edge(mbmi, scale_horz, scale_vert, &temp_ts, &temp_edge);
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl index 058827c..bc2e598 100644 --- a/av1/common/av1_rtcd_defs.pl +++ b/av1/common/av1_rtcd_defs.pl
@@ -111,16 +111,14 @@ specialize qw/av1_filter_intra_predictor sse4_1 neon/; # optical flow interpolation function -if (aom_config("CONFIG_OPTFLOW_REFINEMENT") eq "yes") { - add_proto qw/void av1_bicubic_grad_interpolation_highbd/, "const int16_t *pred_src,int16_t *x_grad,int16_t *y_grad,const int blk_width,const int blk_height"; - specialize qw/av1_bicubic_grad_interpolation_highbd sse4_1 avx2/; +add_proto qw/void av1_bicubic_grad_interpolation_highbd/, "const int16_t *pred_src,int16_t *x_grad,int16_t *y_grad,const int blk_width,const int blk_height"; +specialize qw/av1_bicubic_grad_interpolation_highbd sse4_1 avx2/; - add_proto qw/int av1_opfl_mv_refinement_nxn/, " const int16_t *pdiff, int pstride,const int16_t *gx, const int16_t *gy, int gstride, int bw, int bh, int n,int d0, int d1, int grad_prec_bits,int mv_prec_bits, int *vx0, int *vy0,int *vx1, int *vy1"; - specialize qw/av1_opfl_mv_refinement_nxn sse4_1 avx2/; +add_proto qw/int av1_opfl_mv_refinement_nxn/, " const int16_t *pdiff, int pstride,const int16_t *gx, const int16_t *gy, int gstride, int bw, int bh, int n,int d0, int d1, int grad_prec_bits,int mv_prec_bits, int *vx0, int *vy0,int *vx1, int *vy1"; +specialize qw/av1_opfl_mv_refinement_nxn sse4_1 avx2/; - add_proto qw/void av1_copy_pred_array_highbd/, "const uint16_t *src1, const uint16_t *src2, int16_t *dst1,int16_t *dst2, int bw, int bh, int d0, int d1, int centered"; - specialize qw/av1_copy_pred_array_highbd sse4_1/; -} +add_proto qw/void av1_copy_pred_array_highbd/, "const uint16_t *src1, const uint16_t *src2, int16_t *dst1,int16_t *dst2, int bw, int bh, int d0, int d1, int centered"; +specialize qw/av1_copy_pred_array_highbd sse4_1/; # High bitdepth functions
diff --git a/av1/common/blockd.h b/av1/common/blockd.h index c0d63c1..7d883c1 100644 --- a/av1/common/blockd.h +++ b/av1/common/blockd.h
@@ -124,14 +124,12 @@ NEWMV, // NEW_NEWMV NEWMV, // JOINT_NEWMV NEWMV, // JOINT_AMVDNEWMV -#if CONFIG_OPTFLOW_REFINEMENT - NEARMV, // NEAR_NEARMV_OPTFLOW - NEARMV, // NEAR_NEWMV_OPTFLOW - NEWMV, // NEW_NEARMV_OPTFLOW - NEWMV, // NEW_NEWMV_OPTFLOW - NEWMV, // JOINT_NEWMV_OPTFLOW - NEWMV, // JOINT_AMVDNEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT + NEARMV, // NEAR_NEARMV_OPTFLOW + NEARMV, // NEAR_NEWMV_OPTFLOW + NEWMV, // NEW_NEARMV_OPTFLOW + NEWMV, // NEW_NEWMV_OPTFLOW + NEWMV, // JOINT_NEWMV_OPTFLOW + NEWMV, // JOINT_AMVDNEWMV_OPTFLOW }; assert(NELEMENTS(lut) == MB_MODE_COUNT); assert(is_inter_compound_mode(mode) || is_inter_singleref_mode(mode)); @@ -167,14 +165,12 @@ NEWMV, // NEW_NEWMV NEARMV, // JOINT_NEWMV NEARMV, // JOINT_AMVDNEWMV -#if CONFIG_OPTFLOW_REFINEMENT - NEARMV, // NEAR_NEARMV_OPTFLOW - NEWMV, // NEAR_NEWMV_OPTFLOW - NEARMV, // NEW_NEARMV_OPTFLOW - NEWMV, // NEW_NEWMV_OPTFLOW - NEARMV, // JOINT_NEWMV_OPTFLOW - NEARMV, // JOINT_AMVDNEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT + NEARMV, // NEAR_NEARMV_OPTFLOW + NEWMV, // NEAR_NEWMV_OPTFLOW + NEARMV, // NEW_NEARMV_OPTFLOW + NEWMV, // NEW_NEWMV_OPTFLOW + NEARMV, // JOINT_NEWMV_OPTFLOW + NEARMV, // JOINT_AMVDNEWMV_OPTFLOW }; assert(NELEMENTS(lut) == MB_MODE_COUNT); assert(is_inter_compound_mode(mode)); @@ -183,45 +179,30 @@ // return whether current mode is joint MVD coding mode static INLINE int is_joint_mvd_coding_mode(PREDICTION_MODE mode) { - return mode == JOINT_NEWMV || mode == JOINT_AMVDNEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == JOINT_NEWMV_OPTFLOW || mode == JOINT_AMVDNEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - ; + return mode == JOINT_NEWMV || mode == JOINT_AMVDNEWMV || + mode == JOINT_NEWMV_OPTFLOW || mode == JOINT_AMVDNEWMV_OPTFLOW; } static INLINE int have_nearmv_in_inter_mode(PREDICTION_MODE mode) { return (mode == NEARMV || mode == NEAR_NEARMV || mode == NEAR_NEWMV || -#if CONFIG_OPTFLOW_REFINEMENT mode == NEAR_NEARMV_OPTFLOW || mode == NEAR_NEWMV_OPTFLOW || - mode == NEW_NEARMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT - mode == NEW_NEARMV); + mode == NEW_NEARMV_OPTFLOW || mode == NEW_NEARMV); } static INLINE int have_nearmv_newmv_in_inter_mode(PREDICTION_MODE mode) { - return mode == NEAR_NEWMV || -#if CONFIG_OPTFLOW_REFINEMENT - mode == NEAR_NEWMV_OPTFLOW || mode == NEW_NEARMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT - is_joint_mvd_coding_mode(mode) || mode == NEW_NEARMV; + return mode == NEAR_NEWMV || mode == NEAR_NEWMV_OPTFLOW || + mode == NEW_NEARMV_OPTFLOW || is_joint_mvd_coding_mode(mode) || + mode == NEW_NEARMV; } static INLINE int have_newmv_in_each_reference(PREDICTION_MODE mode) { - return mode == NEWMV || mode == AMVDNEWMV || -#if CONFIG_OPTFLOW_REFINEMENT - mode == NEW_NEWMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT + return mode == NEWMV || mode == AMVDNEWMV || mode == NEW_NEWMV_OPTFLOW || mode == NEW_NEWMV; } // return whether current mode is joint AMVD coding mode static INLINE int is_joint_amvd_coding_mode(PREDICTION_MODE mode) { - return mode == JOINT_AMVDNEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == JOINT_AMVDNEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - ; + return mode == JOINT_AMVDNEWMV || mode == JOINT_AMVDNEWMV_OPTFLOW; } // Scale the MVD for joint MVD coding mode based on the jmvd_scale_mode. @@ -259,11 +240,8 @@ static INLINE int have_newmv_in_inter_mode(PREDICTION_MODE mode) { return (mode == NEWMV || mode == NEW_NEWMV || mode == NEAR_NEWMV || mode == AMVDNEWMV || is_joint_mvd_coding_mode(mode) || -#if CONFIG_OPTFLOW_REFINEMENT mode == NEAR_NEWMV_OPTFLOW || mode == NEW_NEARMV_OPTFLOW || - mode == NEW_NEWMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT - mode == NEW_NEARMV); + mode == NEW_NEWMV_OPTFLOW || mode == NEW_NEARMV); } static INLINE int have_drl_index(PREDICTION_MODE mode) { return have_nearmv_in_inter_mode(mode) || have_newmv_in_inter_mode(mode); @@ -363,7 +341,6 @@ #endif // CONFIG_REFINEMV -#if CONFIG_OPTFLOW_REFINEMENT // Macros for optical flow experiment where offsets are added in nXn blocks // rather than adding a single offset to the entire prediction unit. #define OF_MIN_BSIZE_LOG2 2 @@ -374,9 +351,6 @@ #define N_OF_OFFSETS_1D (1 << (MAX_SB_SIZE_LOG2 - OF_BSIZE_LOG2)) // Maximum number of offsets to be computed #define N_OF_OFFSETS (N_OF_OFFSETS_1D * N_OF_OFFSETS_1D) -#else -#define N_OF_OFFSETS 1 -#endif // CONFIG_OPTFLOW_REFINEMENT /*! \brief Stores the coordinate/bsize for chroma plane. */ typedef struct CHROMA_REF_INFO {
diff --git a/av1/common/entropy.c b/av1/common/entropy.c index d6eb3a2..eabe90c 100644 --- a/av1/common/entropy.c +++ b/av1/common/entropy.c
@@ -205,12 +205,8 @@ #if CONFIG_SKIP_MODE_ENHANCEMENT || CONFIG_OPTIMIZE_CTX_TIP_WARP RESET_CDF_COUNTER(fc->skip_drl_cdf, 2); #endif // CONFIG_SKIP_MODE_ENHANCEMENT || CONFIG_OPTIMIZE_CTX_TIP_WARP -#if CONFIG_OPTFLOW_REFINEMENT RESET_CDF_COUNTER(fc->use_optflow_cdf, 2); RESET_CDF_COUNTER(fc->inter_compound_mode_cdf, INTER_COMPOUND_REF_TYPES); -#else - RESET_CDF_COUNTER(fc->inter_compound_mode_cdf, INTER_COMPOUND_MODES); -#endif // CONFIG_OPTFLOW_REFINEMENT RESET_CDF_COUNTER(fc->cwp_idx_cdf, 2); RESET_CDF_COUNTER(fc->jmvd_scale_mode_cdf, JOINT_NEWMV_SCALE_FACTOR_CNT);
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c index fa42842..576eda7 100644 --- a/av1/common/entropymode.c +++ b/av1/common/entropymode.c
@@ -5972,7 +5972,6 @@ #endif // CONFIG_SKIP_MODE_ENHANCEMENT || CONFIG_OPTIMIZE_CTX_TIP_WARP #if CONFIG_C076_INTER_MOD_CTX -#if CONFIG_OPTFLOW_REFINEMENT #if CONFIG_ENTROPY_PARA static const aom_cdf_prob default_use_optflow_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE(2)] = { @@ -5989,11 +5988,6 @@ static const aom_cdf_prob default_inter_compound_mode_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE( INTER_COMPOUND_REF_TYPES)] = { -#else -static const aom_cdf_prob - default_inter_compound_mode_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE( - INTER_COMPOUND_MODES)] = { -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_ENTROPY_PARA { AOM_CDF7(9967, 23734, 27123, 27502, 30774, 32039), 1 }, { AOM_CDF7(4681, 9362, 14043, 18725, 23406, 28087), 0 }, @@ -6011,23 +6005,15 @@ #endif // CONFIG_ENTROPY_PARA }; #else -#if CONFIG_OPTFLOW_REFINEMENT static const aom_cdf_prob default_use_optflow_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE(2)] = { { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, }; -#endif // CONFIG_OPTFLOW_REFINEMENT -#if CONFIG_OPTFLOW_REFINEMENT static const aom_cdf_prob default_inter_compound_mode_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE( INTER_COMPOUND_REF_TYPES)] = { -#else -static const aom_cdf_prob - default_inter_compound_mode_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE( - INTER_COMPOUND_MODES)] = { -#endif { AOM_CDF7(8510, 13103, 16330, 17536, 23536, 29536) }, { AOM_CDF7(12805, 16117, 19655, 20891, 24891, 29891) }, { AOM_CDF7(13700, 16333, 19425, 20305, 25305, 29305) }, @@ -8821,9 +8807,7 @@ av1_copy(fc->explicit_bawp_cdf, default_explicit_bawp_cdf); av1_copy(fc->explicit_bawp_scale_cdf, default_explicit_bawp_scale_cdf); #endif // CONFIG_EXPLICIT_BAWP -#if CONFIG_OPTFLOW_REFINEMENT av1_copy(fc->use_optflow_cdf, default_use_optflow_cdf); -#endif // CONFIG_OPTFLOW_REFINEMENT av1_copy(fc->cwp_idx_cdf, default_cwp_idx_cdf); av1_copy(fc->jmvd_scale_mode_cdf, default_jmvd_scale_mode_cdf);
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h index 5c8197b..bd6f013 100644 --- a/av1/common/entropymode.h +++ b/av1/common/entropymode.h
@@ -256,14 +256,9 @@ [CDF_SIZE(REFINEMV_NUM_MODES)]; #endif // CONFIG_REFINEMV -#if CONFIG_OPTFLOW_REFINEMENT aom_cdf_prob use_optflow_cdf[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE(2)]; aom_cdf_prob inter_compound_mode_cdf[INTER_COMPOUND_MODE_CONTEXTS] [CDF_SIZE(INTER_COMPOUND_REF_TYPES)]; -#else - aom_cdf_prob inter_compound_mode_cdf[INTER_COMPOUND_MODE_CONTEXTS] - [CDF_SIZE(INTER_COMPOUND_MODES)]; -#endif // CONFIG_OPTFLOW_REFINEMENT aom_cdf_prob cwp_idx_cdf[MAX_CWP_CONTEXTS][MAX_CWP_NUM - 1][CDF_SIZE(2)]; aom_cdf_prob jmvd_scale_mode_cdf[CDF_SIZE(JOINT_NEWMV_SCALE_FACTOR_CNT)]; @@ -759,8 +754,7 @@ void av1_setup_frame_contexts(struct AV1Common *cm); void av1_setup_past_independence(struct AV1Common *cm); -#if CONFIG_AFFINE_REFINEMENT || CONFIG_OPFL_MV_SEARCH || \ - CONFIG_REFINEMENT_SIMPLIFY +#if CONFIG_AFFINE_REFINEMENT || CONFIG_OPFL_MV_SEARCH static INLINE int get_msb_signed(int32_t n) { return n == 0 ? 0 : get_msb((unsigned int)abs(n)); } @@ -772,8 +766,7 @@ if (high32 != 0) return 32 + get_msb(high32); return low32 == 0 ? 0 : get_msb((unsigned int)low32); } -#endif // CONFIG_AFFINE_REFINEMENT || CONFIG_OPFL_MV_SEARCH || - // CONFIG_REFINEMENT_SIMPLIFY +#endif // CONFIG_AFFINE_REFINEMENT || CONFIG_OPFL_MV_SEARCH // Returns (int)ceil(log2(n)). // NOTE: This implementation only works for n <= 2^30. @@ -828,7 +821,6 @@ #endif // CONFIG_C076_INTER_MOD_CTX } -#if CONFIG_OPTFLOW_REFINEMENT static const int comp_idx_to_opfl_mode[INTER_COMPOUND_REF_TYPES] = { NEAR_NEARMV_OPTFLOW, NEAR_NEWMV_OPTFLOW, NEW_NEARMV_OPTFLOW, -1, NEW_NEWMV_OPTFLOW, JOINT_NEWMV_OPTFLOW, JOINT_AMVDNEWMV_OPTFLOW, @@ -852,7 +844,6 @@ default: assert(0); return 0; } } -#endif // CONFIG_OPTFLOW_REFINEMENT // Returns the context for palette color index at row 'r' and column 'c', // along with the 'color_order' of neighbors and the 'color_idx'.
diff --git a/av1/common/enums.h b/av1/common/enums.h index f5894f4..96120c6 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -863,14 +863,12 @@ NEW_NEWMV, JOINT_NEWMV, JOINT_AMVDNEWMV, -#if CONFIG_OPTFLOW_REFINEMENT NEAR_NEARMV_OPTFLOW, NEAR_NEWMV_OPTFLOW, NEW_NEARMV_OPTFLOW, NEW_NEWMV_OPTFLOW, JOINT_NEWMV_OPTFLOW, JOINT_AMVDNEWMV_OPTFLOW, -#endif // CONFIG_OPTFLOW_REFINEMENT MB_MODE_COUNT, INTRA_MODE_START = DC_PRED, INTRA_MODE_END = NEARMV, @@ -883,10 +881,8 @@ COMP_INTER_MODE_START = NEAR_NEARMV, COMP_INTER_MODE_END = MB_MODE_COUNT, COMP_INTER_MODE_NUM = COMP_INTER_MODE_END - COMP_INTER_MODE_START, -#if CONFIG_OPTFLOW_REFINEMENT COMP_OPTFLOW_MODE_START = NEAR_NEARMV_OPTFLOW, INTER_COMPOUND_REF_TYPES = COMP_OPTFLOW_MODE_START - COMP_INTER_MODE_START, -#endif // CONFIG_OPTFLOW_REFINEMENT INTER_MODE_START = NEARMV, INTER_MODE_END = MB_MODE_COUNT, INTRA_MODES = PAETH_PRED + 1, // PAETH_PRED has to be the last intra mode.
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h index 5fb4d8f..ff9ea97 100644 --- a/av1/common/mvref_common.h +++ b/av1/common/mvref_common.h
@@ -163,7 +163,6 @@ clamp_mv(mv, &mv_limits); } -#if CONFIG_OPTFLOW_REFINEMENT static INLINE int opfl_get_subblock_size(int bw, int bh, int plane #if CONFIG_OPTFLOW_ON_TIP , @@ -198,7 +197,6 @@ *opfl_sub_bh = AOMMAX((sub_bsize_y >> xd->plane[plane].subsampling_y), OF_MIN_BSIZE); } -#endif // CONFIG_OPTFLOW_REFINEMENT // Convert a global motion vector into a motion vector at the centre of the // given block.
diff --git a/av1/common/pef.c b/av1/common/pef.c index e76cdbc..4a346c3 100644 --- a/av1/common/pef.c +++ b/av1/common/pef.c
@@ -269,7 +269,6 @@ const int sub_bsize_y = PEF_MCU_SZ; // n is motion compensation unit size int sub_bw = sub_bsize_y; int sub_bh = sub_bsize_y; -#if CONFIG_OPTFLOW_REFINEMENT if (pef_mode == 0) { opfl_subblock_size_plane(xd, plane #if CONFIG_OPTFLOW_ON_TIP @@ -279,7 +278,6 @@ , &sub_bw, &sub_bh); } -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_EXT_WARP_FILTER if (pef_mode == 4) { sub_bw = PEF_MCU_SZ / 2; @@ -491,11 +489,8 @@ } void enhance_prediction(const AV1_COMMON *cm, MACROBLOCKD *xd, int plane, - uint16_t *dst, int dst_stride, int bw, int bh -#if CONFIG_OPTFLOW_REFINEMENT - , + uint16_t *dst, int dst_stride, int bw, int bh, int_mv *const mv_refined, int use_opfl -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV , int use_refinemv, REFINEMV_SUBMB_INFO *refinemv_subinfo @@ -521,7 +516,6 @@ return; } -#if CONFIG_OPTFLOW_REFINEMENT #if !CONFIG_AFFINE_REFINEMENT use_opfl &= (plane == 0); #endif // !CONFIG_AFFINE_REFINEMENT @@ -535,7 +529,6 @@ enhance_sub_prediction_blocks(cm, xd, &pef_input); return; } -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV if (use_refinemv) { PefFuncInput pef_input;
diff --git a/av1/common/pef.h b/av1/common/pef.h index a4404cc..721258b 100644 --- a/av1/common/pef.h +++ b/av1/common/pef.h
@@ -83,11 +83,8 @@ // enhance prediction blocks void enhance_prediction(const struct AV1Common *cm, MACROBLOCKD *xd, int plane, - uint16_t *dst, int dst_stride, int bw, int bh -#if CONFIG_OPTFLOW_REFINEMENT - , + uint16_t *dst, int dst_stride, int bw, int bh, int_mv *const mv_refined, int use_opfl -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV , int use_refinemv, REFINEMV_SUBMB_INFO *refinemv_subinfo
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c index 9a4d509..930c5e2 100644 --- a/av1/common/reconinter.c +++ b/av1/common/reconinter.c
@@ -81,10 +81,8 @@ InterpFilter interp_filter) { inter_pred_params->block_width = block_width; inter_pred_params->block_height = block_height; -#if CONFIG_OPTFLOW_REFINEMENT inter_pred_params->orig_block_width = block_width; inter_pred_params->orig_block_height = block_height; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV inter_pred_params->original_pu_width = block_width; @@ -1138,6 +1136,47 @@ } #endif // CONFIG_REFINEMV +#if CONFIG_AFFINE_REFINEMENT || CONFIG_E125_MHCCP_SIMPLIFY +int64_t stable_mult_shift(const int64_t a, const int64_t b, const int shift, + const int msb_a, const int msb_b, const int max_bd, + int *rem_shift) { + assert(shift >= 0); + + // Remaining bit shifts (may be used in the next stage of multiplcation) + int rem = AOMMAX(0, msb_a + msb_b - shift + 1 - max_bd); + if (rem_shift) *rem_shift += rem; + if (msb_a + msb_b + 1 <= max_bd) + return ROUND_POWER_OF_TWO_SIGNED_64(a * b, shift); + + // To determine s1/s2/s3 in ((a>>s1)*(b>>s2))>>s3, consider the equation + // (1+msb_a-s1)+(1+msb_b-s2)+1 <= max_bd+rem, + // where better numerical stability is obtained when + // msb_a-s1 ~= msb_b-s2. + // This leads to the following solution + int msb_diff = abs(msb_a - msb_b); + // Total required shifts (s1 + s2) + int s = msb_a + msb_b - max_bd - rem + 3; + int diff = AOMMIN(s, msb_diff); + int s1 = (s - diff) >> 1; + int s2 = s1; + if (msb_a >= msb_b) + s1 += diff; + else + s2 += diff; + + assert(s1 >= 0); + assert(s2 >= 0); + if (shift - s1 - s2 < 0) { + // bit depth not large enough to hold the result + return ((a > 0) ^ (b > 0)) ? -((1LL << (max_bd - 1)) - 1) + : ((1LL << (max_bd - 1)) - 1); + } + return ROUND_POWER_OF_TWO_SIGNED_64( + ROUND_POWER_OF_TWO_SIGNED_64(a, s1) * ROUND_POWER_OF_TWO_SIGNED_64(b, s2), + shift - s1 - s2); +} +#endif // CONFIG_AFFINE_REFINEMENT || CONFIG_E125_MHCCP_SIMPLIFY + #if CONFIG_AFFINE_REFINEMENT #if AFFINE_FAST_WARP_METHOD == 2 #define BICUBIC_PHASE_BITS 6 @@ -1315,7 +1354,6 @@ #endif // AFFINE_FAST_WARP_METHOD == 3 } -#if CONFIG_REFINEMENT_SIMPLIFY // Obtain the bit depth ranges for each row and column of a square matrix void get_mat4d_shifts(const int64_t *mat, int *shifts, const int max_mat_bits) { int bits[16] = { 0 }; @@ -1379,46 +1417,6 @@ // For better precision, set this number as minimal bits for intermediate // result of Gaussian elimination. #define GE_MULT_PREC_BITS 12 -#if CONFIG_REFINEMENT_SIMPLIFY || CONFIG_E125_MHCCP_SIMPLIFY -int64_t stable_mult_shift(const int64_t a, const int64_t b, const int shift, - const int msb_a, const int msb_b, const int max_bd, - int *rem_shift) { - assert(shift >= 0); - - // Remaining bit shifts (may be used in the next stage of multiplcation) - int rem = AOMMAX(0, msb_a + msb_b - shift + 1 - max_bd); - if (rem_shift) *rem_shift += rem; - if (msb_a + msb_b + 1 <= max_bd) - return ROUND_POWER_OF_TWO_SIGNED_64(a * b, shift); - - // To determine s1/s2/s3 in ((a>>s1)*(b>>s2))>>s3, consider the equation - // (1+msb_a-s1)+(1+msb_b-s2)+1 <= max_bd+rem, - // where better numerical stability is obtained when - // msb_a-s1 ~= msb_b-s2. - // This leads to the following solution - int msb_diff = abs(msb_a - msb_b); - // Total required shifts (s1 + s2) - int s = msb_a + msb_b - max_bd - rem + 3; - int diff = AOMMIN(s, msb_diff); - int s1 = (s - diff) >> 1; - int s2 = s1; - if (msb_a >= msb_b) - s1 += diff; - else - s2 += diff; - - assert(s1 >= 0); - assert(s2 >= 0); - if (shift - s1 - s2 < 0) { - // bit depth not large enough to hold the result - return ((a > 0) ^ (b > 0)) ? -((1LL << (max_bd - 1)) - 1) - : ((1LL << (max_bd - 1)) - 1); - } - return ROUND_POWER_OF_TWO_SIGNED_64( - ROUND_POWER_OF_TWO_SIGNED_64(a, s1) * ROUND_POWER_OF_TWO_SIGNED_64(b, s2), - shift - s1 - s2); -} -#endif // CONFIG_REFINEMENT_SIMPLIFY || CONFIG_E125_MHCCP_SIMPLIFY // Perform Gaussian elimination routine to solve a matrix inverse problem int gaussian_elimination(int64_t *mat, int64_t *sol, int *precbits, @@ -1556,93 +1554,15 @@ return 1; } -#else -// Compute intermediate results for 4D linear solver. -void getsub_4d(int64_t *sub, const int64_t *mat, const int64_t *vec) { - sub[0] = mat[0] * mat[5] - mat[1] * mat[4]; - sub[1] = mat[0] * mat[6] - mat[2] * mat[4]; - sub[2] = mat[0] * mat[7] - mat[3] * mat[4]; - sub[3] = mat[0] * vec[1] - vec[0] * mat[4]; - sub[4] = mat[1] * mat[6] - mat[2] * mat[5]; - sub[5] = mat[1] * mat[7] - mat[3] * mat[5]; - sub[6] = mat[1] * vec[1] - vec[0] * mat[5]; - sub[7] = mat[2] * mat[7] - mat[3] * mat[6]; - sub[8] = mat[2] * vec[1] - vec[0] * mat[6]; - sub[9] = mat[3] * vec[1] - vec[0] * mat[7]; -} - -// Solve a 4-dimensional matrix inverse using inverse determinant method: -// x = A^(-1) * b, where A: mat, b: vec, x: sol -int inverse_determinant_4d(int64_t *mat, int64_t *vec, int *precbits, - int64_t *sol) { - int64_t a[10], b[10]; // values of 20 2D subdeterminants - getsub_4d(&a[0], mat, vec); - getsub_4d(&b[0], mat + 8, vec + 2); - - // Flexibly adjust range to avoid overflow without losing precision. This - // moves the bit depth of a[] and b[] within 29 so that det and sol will - // not overflow - int64_t max_el = 0; - for (int i = 0; i < 10; i++) { - max_el = AOMMAX(max_el, llabs(a[i])); - max_el = AOMMAX(max_el, llabs(b[i])); - } - int max_bits = get_msb_signed_64(max_el); - int subdet_reduce_bits = AOMMAX(0, max_bits - 28); - for (int i = 0; i < 10; i++) { - a[i] = ROUND_POWER_OF_TWO_SIGNED_64(a[i], subdet_reduce_bits); - b[i] = ROUND_POWER_OF_TWO_SIGNED_64(b[i], subdet_reduce_bits); - } - - int64_t det = a[0] * b[7] + a[7] * b[0] + a[2] * b[4] + a[4] * b[2] - - a[5] * b[1] - a[1] * b[5]; - - sol[0] = a[5] * b[8] + a[8] * b[5] - a[6] * b[7] - a[7] * b[6] - a[4] * b[9] - - a[9] * b[4]; - sol[1] = a[1] * b[9] + a[9] * b[1] + a[3] * b[7] + a[7] * b[3] - a[2] * b[8] - - a[8] * b[2]; - sol[2] = a[2] * b[6] + a[6] * b[2] - a[0] * b[9] - a[9] * b[0] - a[3] * b[5] - - a[5] * b[3]; - sol[3] = a[0] * b[8] + a[8] * b[0] + a[3] * b[4] + a[4] * b[3] - a[6] * b[1] - - a[1] * b[6]; - - int max_det_msb = get_msb_signed_64(det); - for (int i = 0; i < 4; i++) - max_det_msb = AOMMAX(max_det_msb, get_msb_signed_64(sol[i]) + precbits[i]); - - int det_red_bits = AOMMAX(0, max_det_msb - 60); - det = ROUND_POWER_OF_TWO_SIGNED_64(det, det_red_bits); - if (det <= 0) return 0; - - for (int i = 0; i < 4; i++) { - int reduce_bits = det_red_bits - precbits[i]; - if (reduce_bits >= 0) - sol[i] = ROUND_POWER_OF_TWO_SIGNED_64(sol[i], reduce_bits); - else - sol[i] = clamp64(sol[i] * (1 << (-reduce_bits)), INT64_MIN, INT64_MAX); - } - - sol[0] = divide_and_round_signed(sol[0], det); - sol[1] = divide_and_round_signed(sol[1], det); - sol[2] = divide_and_round_signed(sol[2], det); - sol[3] = divide_and_round_signed(sol[3], det); - return 1; -} -#endif // CONFIG_REFINEMENT_SIMPLIFY // Solve a 4-dimensional matrix inverse int solver_4d(int64_t *mat, int64_t *vec, int *precbits, int64_t *sol) { -#if CONFIG_REFINEMENT_SIMPLIFY memcpy(sol, vec, 4 * sizeof(int64_t)); int ret = gaussian_elimination(mat, sol, precbits, 4); -#else - int ret = inverse_determinant_4d(mat, vec, precbits, sol); -#endif // CONFIG_REFINEMENT_SIMPLIFY return ret; } #endif // CONFIG_AFFINE_REFINEMENT -#if CONFIG_OPTFLOW_REFINEMENT // Restrict MV delta to 1 or 2 pixels. This restriction would reduce complexity // in hardware. #define OPFL_CLAMP_MV_DELTA 1 @@ -2094,12 +2014,8 @@ a[3] = gy[gidx]; for (int s = 0; s < 4; ++s) a[s] = clamp(a[s], -AFFINE_SAMP_CLAMP_VAL, AFFINE_SAMP_CLAMP_VAL); -#if CONFIG_REFINEMENT_SIMPLIFY const int d = clamp(pdiff[i * pstride + j], -AFFINE_SAMP_CLAMP_VAL, AFFINE_SAMP_CLAMP_VAL); -#else - const int d = pdiff[i * pstride + j]; -#endif // CONFIG_REFINEMENT_SIMPLIFY for (int s = 0; s < 4; ++s) { for (int t = 0; t <= s; ++t) { mat_a[s * 4 + t] += ROUND_POWER_OF_TWO_SIGNED_64( @@ -2109,7 +2025,6 @@ ROUND_POWER_OF_TWO_SIGNED_64((int64_t)a[s] * (int64_t)d, grad_bits); } } -#if CONFIG_REFINEMENT_SIMPLIFY // Do a range check and add a downshift if range is getting close to the bit // depth cap. This check is done for every 16 pixels so it can be easily // replicated in the SIMD version. @@ -2129,7 +2044,6 @@ grad_bits++; } } -#endif // CONFIG_REFINEMENT_SIMPLIFY } for (int s = 0; s < 4; ++s) { for (int t = s + 1; t < 4; ++t) mat_a[s * 4 + t] = mat_a[t * 4 + s]; @@ -2139,17 +2053,6 @@ mat_a[5] += rls_alpha; mat_a[10] += rls_alpha; mat_a[15] += rls_alpha; - -#if !CONFIG_REFINEMENT_SIMPLIFY - for (int s = 0; s < 4; ++s) { - for (int t = 0; t < 4; ++t) { - mat_a[s * 4 + t] = clamp64(mat_a[s * 4 + t], -AFFINE_AUTOCORR_CLAMP_VAL, - AFFINE_AUTOCORR_CLAMP_VAL); - } - vec_b[s] = clamp64(vec_b[s], -AFFINE_AUTOCORR_CLAMP_VAL, - AFFINE_AUTOCORR_CLAMP_VAL); - } -#endif // !CONFIG_REFINEMENT_SIMPLIFY } // Derivation of four parameters in the rotation-scale-translation affine model @@ -2225,25 +2128,18 @@ #if OPFL_DOWNSAMP_QUINCUNX if ((i + j) % 2 == 1) continue; #endif -#if CONFIG_REFINEMENT_SIMPLIFY const int u = clamp(gx[i * gstride + j], -OPFL_SAMP_CLAMP_VAL, OPFL_SAMP_CLAMP_VAL); const int v = clamp(gy[i * gstride + j], -OPFL_SAMP_CLAMP_VAL, OPFL_SAMP_CLAMP_VAL); const int w = clamp(pdiff[i * pstride + j], -OPFL_SAMP_CLAMP_VAL, OPFL_SAMP_CLAMP_VAL); -#else - const int u = gx[i * gstride + j]; - const int v = gy[i * gstride + j]; - const int w = pdiff[i * pstride + j]; -#endif // CONFIG_REFINEMENT_SIMPLIFY su2 += ROUND_POWER_OF_TWO_SIGNED_64(u * u, grad_bits); suv += ROUND_POWER_OF_TWO_SIGNED_64(u * v, grad_bits); sv2 += ROUND_POWER_OF_TWO_SIGNED_64(v * v, grad_bits); suw += ROUND_POWER_OF_TWO_SIGNED_64(u * w, grad_bits); svw += ROUND_POWER_OF_TWO_SIGNED_64(v * w, grad_bits); } -#if CONFIG_REFINEMENT_SIMPLIFY // For every 8 pixels, do a range check and add a downshift if range is // getting close to the max allowed bit depth if (bw >= 8 || i % 2 == 1) { @@ -2261,7 +2157,6 @@ grad_bits++; } } -#endif // CONFIG_REFINEMENT_SIMPLIFY } const int bits = mv_prec_bits + grad_prec_bits; #if OPFL_REGULARIZED_LS @@ -2270,19 +2165,8 @@ sv2 += rls_alpha; #endif -#if !CONFIG_REFINEMENT_SIMPLIFY - // Clamp su2, sv2, suv, suw, and svw to avoid overflow in det, det_x, and - // det_y - su2 = clamp64(su2, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - sv2 = clamp64(sv2, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - suv = clamp64(suv, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - suw = clamp64(suw, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - svw = clamp64(svw, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); -#endif // !CONFIG_REFINEMENT_SIMPLIFY - // Solve 2x2 matrix inverse: [ su2 suv ] [ vx0 ] [ -suw ] // [ suv sv2 ] * [ vy0 ] = [ -svw ] -#if CONFIG_REFINEMENT_SIMPLIFY int shifts[2] = { bits, bits }; int msb_su2 = 1 + get_msb_signed_64(su2); int msb_sv2 = 1 + get_msb_signed_64(sv2); @@ -2315,21 +2199,6 @@ divide_and_round_array(sol, det, 2, shifts); *vx0 = (int)-sol[0]; *vy0 = (int)-sol[1]; -#else - const int64_t det = su2 * sv2 - suv * suv; - if (det <= 0) { - *vx0 = 0; - *vy0 = 0; - *vx1 = 0; - *vy1 = 0; - return; - } - const int64_t det_x = (suv * svw - sv2 * suw) * (1 << bits); - const int64_t det_y = (suv * suw - su2 * svw) * (1 << bits); - - *vx0 = (int)divide_and_round_signed(det_x, det); - *vy0 = (int)divide_and_round_signed(det_y, det); -#endif // CONFIG_REFINEMENT_SIMPLIFY *vx1 = (*vx0) * d1; *vy1 = (*vy0) * d1; *vx0 = (*vx0) * d0; @@ -2725,7 +2594,6 @@ clamp(mv_refined[i * 2 + 1].as_mv.col + vx1[i], INT16_MIN, INT16_MAX); } } -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_D071_IMP_MSK_BLD int is_out_of_frame_block(const InterPredParams *inter_pred_params, @@ -2872,7 +2740,6 @@ #endif // CONFIG_D071_IMP_MSK_BLD } -#if CONFIG_OPTFLOW_REFINEMENT // Makes the interpredictor for the region by dividing it up into nxn blocks // and running the interpredictor code on each one. void make_inter_pred_of_nxn( @@ -3236,7 +3103,6 @@ #endif // CONFIG_OPTFLOW_ON_TIP &subpel_params); } -#endif // CONFIG_OPTFLOW_REFINEMENT void av1_build_one_inter_predictor( uint16_t *dst, int dst_stride, const MV *const src_mv, @@ -3245,10 +3111,7 @@ SubpelParams subpel_params; uint16_t *src; int src_stride; - calc_subpel_params_func(src_mv, inter_pred_params, xd, mi_x, mi_y, ref, -#if CONFIG_OPTFLOW_REFINEMENT - 0, /* use_optflow_refinement */ -#endif // CONFIG_OPTFLOW_REFINEMENT + calc_subpel_params_func(src_mv, inter_pred_params, xd, mi_x, mi_y, ref, 0, mc_buf, &src, &subpel_params, &src_stride); #if CONFIG_D071_IMP_MSK_BLD @@ -3475,10 +3338,7 @@ SubpelParams subpel_params; uint16_t *src; int src_stride; - calc_subpel_params_func(src_mv, inter_pred_params, xd, mi_x, mi_y, ref, -#if CONFIG_OPTFLOW_REFINEMENT - 0, /* use_optflow_refinement */ -#endif // CONFIG_OPTFLOW_REFINEMENT + calc_subpel_params_func(src_mv, inter_pred_params, xd, mi_x, mi_y, ref, 0, mc_buf, &src, &subpel_params, &src_stride); assert(inter_pred_params->comp_mode == UNIFORM_SINGLE); @@ -3585,11 +3445,8 @@ ref_h = height_p_unscaled - mi_y_p_unscaled; calc_subpel_params_func(&mbmi->mv[ref].as_mv, inter_pred_params, xd, mi_x, - mi_y, ref, -#if CONFIG_OPTFLOW_REFINEMENT - 0, /* use_optflow_refinement */ -#endif // CONFIG_OPTFLOW_REFINEMENT - mc_buf, &ref_buf, &subpel_params, &ref_stride); + mi_y, ref, 0, mc_buf, &ref_buf, &subpel_params, + &ref_stride); } uint16_t *ref_top = ref_buf - ref_stride * scaled_y_gen(BAWP_REF_LINES, sf); uint16_t *ref_left = ref_buf - scaled_x_gen(BAWP_REF_LINES, sf); @@ -3964,11 +3821,8 @@ const MACROBLOCKD *const xd, int mi_x, int mi_y, uint16_t **pre, SubpelParams *subpel_params, int *src_stride, PadBlock *block, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - MV32 *scaled_mv, int *subpel_x_mv, - int *subpel_y_mv) { + int use_optflow_refinement, MV32 *scaled_mv, + int *subpel_x_mv, int *subpel_y_mv) { const struct scale_factors *sf = inter_pred_params->scale_factors; struct buf_2d *pre_buf = &inter_pred_params->ref_frame_buf; @@ -3977,16 +3831,11 @@ const int bh = inter_pred_params->original_pu_height; #else -#if CONFIG_OPTFLOW_REFINEMENT // Use original block size to clamp MV and to extend block boundary const int bw = use_optflow_refinement ? inter_pred_params->orig_block_width : inter_pred_params->block_width; const int bh = use_optflow_refinement ? inter_pred_params->orig_block_height : inter_pred_params->block_height; -#else - const int bw = inter_pred_params->block_width; - const int bh = inter_pred_params->block_height; -#endif // CONFIG_OPTFLOW_REFINEMENT #endif // CONFIG_REFINEMV const int is_scaled = av1_is_scaled(sf); @@ -3995,7 +3844,6 @@ int ssy = inter_pred_params->subsampling_y; int orig_pos_y = inter_pred_params->pix_row << SUBPEL_BITS; int orig_pos_x = inter_pred_params->pix_col << SUBPEL_BITS; -#if CONFIG_OPTFLOW_REFINEMENT if (use_optflow_refinement) { orig_pos_y += ROUND_POWER_OF_TWO_SIGNED(src_mv->row * (1 << SUBPEL_BITS), MV_REFINE_PREC_BITS + ssy); @@ -4005,10 +3853,6 @@ orig_pos_y += src_mv->row * (1 << (1 - ssy)); orig_pos_x += src_mv->col * (1 << (1 - ssx)); } -#else - orig_pos_y += src_mv->row * (1 << (1 - ssy)); - orig_pos_x += src_mv->col * (1 << (1 - ssx)); -#endif // CONFIG_OPTFLOW_REFINEMENT int pos_y = sf->scale_value_y(orig_pos_y, sf); int pos_x = sf->scale_value_x(orig_pos_x, sf); pos_x += SCALE_EXTRA_OFF; @@ -4042,12 +3886,9 @@ 1; MV temp_mv; - temp_mv = clamp_mv_to_umv_border_sb(xd, src_mv, bw, bh, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - inter_pred_params->subsampling_x, - inter_pred_params->subsampling_y); + temp_mv = clamp_mv_to_umv_border_sb( + xd, src_mv, bw, bh, use_optflow_refinement, + inter_pred_params->subsampling_x, inter_pred_params->subsampling_y); *scaled_mv = av1_scale_mv(&temp_mv, mi_x, mi_y, sf); scaled_mv->row += SCALE_EXTRA_OFF; scaled_mv->col += SCALE_EXTRA_OFF; @@ -4060,10 +3901,7 @@ int pos_y = inter_pred_params->pix_row << SUBPEL_BITS; const MV mv_q4 = clamp_mv_to_umv_border_sb( - xd, src_mv, bw, bh, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT + xd, src_mv, bw, bh, use_optflow_refinement, inter_pred_params->subsampling_x, inter_pred_params->subsampling_y); subpel_params->xs = subpel_params->ys = SCALE_SUBPEL_SHIFTS; subpel_params->subpel_x = (mv_q4.col & SUBPEL_MASK) << SCALE_EXTRA_BITS; @@ -4102,11 +3940,8 @@ void common_calc_subpel_params_and_extend( const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *const xd, int mi_x, int mi_y, int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **mc_buf, uint16_t **pre, SubpelParams *subpel_params, - int *src_stride) { + int use_optflow_refinement, uint16_t **mc_buf, uint16_t **pre, + SubpelParams *subpel_params, int *src_stride) { (void)ref; (void)mc_buf; @@ -4114,12 +3949,9 @@ MV32 scaled_mv; int subpel_x_mv, subpel_y_mv; assert(inter_pred_params->use_ref_padding); - dec_calc_subpel_params(src_mv, inter_pred_params, xd, mi_x, mi_y, pre, - subpel_params, src_stride, &block, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - &scaled_mv, &subpel_x_mv, &subpel_y_mv); + dec_calc_subpel_params( + src_mv, inter_pred_params, xd, mi_x, mi_y, pre, subpel_params, src_stride, + &block, use_optflow_refinement, &scaled_mv, &subpel_x_mv, &subpel_y_mv); // printf(" Use ref padding \n"); const int paded_ref_buf_stride = @@ -4135,21 +3967,16 @@ static void get_ref_area_info(const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *const xd, int mi_x, int mi_y, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **pre, SubpelParams *subpel_params, - int *src_stride, ReferenceArea *ref_area) { + int use_optflow_refinement, uint16_t **pre, + SubpelParams *subpel_params, int *src_stride, + ReferenceArea *ref_area) { PadBlock block; MV32 scaled_mv; int subpel_x_mv, subpel_y_mv; - dec_calc_subpel_params(src_mv, inter_pred_params, xd, mi_x, mi_y, pre, - subpel_params, src_stride, &block, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - &scaled_mv, &subpel_x_mv, &subpel_y_mv); + dec_calc_subpel_params( + src_mv, inter_pred_params, xd, mi_x, mi_y, pre, subpel_params, src_stride, + &block, use_optflow_refinement, &scaled_mv, &subpel_x_mv, &subpel_y_mv); struct buf_2d *const pre_buf = &inter_pred_params->ref_frame_buf; int frame_height = pre_buf->height; @@ -4214,11 +4041,8 @@ assert(!inter_pred_params.use_ref_padding); const MV *src_mv = ref == 0 ? &mv[0] : &mv[1]; - get_ref_area_info(src_mv, &inter_pred_params, xd, mi_x, mi_y, -#if CONFIG_OPTFLOW_REFINEMENT - 0, /* use_optflow_refinement */ -#endif // CONFIG_OPTFLOW_REFINEMENT - &src, &subpel_params, &src_stride, &ref_area[ref]); + get_ref_area_info(src_mv, &inter_pred_params, xd, mi_x, mi_y, 0, &src, + &subpel_params, &src_stride, &ref_area[ref]); } } @@ -4237,11 +4061,7 @@ src_mv->col -= 8 * SUBBLK_REF_EXT_LINES; #endif // CONFIG_SUBBLK_REF_EXT calc_subpel_params_func(src_mv, &inter_pred_params[ref], xd, mi_x, mi_y, - ref, -#if CONFIG_OPTFLOW_REFINEMENT - 0, /* use_optflow_refinement */ -#endif // CONFIG_OPTFLOW_REFINEMENT - mc_buf, &src, &subpel_params, &src_stride); + ref, 0, mc_buf, &src, &subpel_params, &src_stride); assert(inter_pred_params[ref].comp_mode == UNIFORM_SINGLE || inter_pred_params[ref].comp_mode == UNIFORM_COMP); av1_make_inter_predictor(src, src_stride, dst_ref, bw, @@ -4637,7 +4457,6 @@ best_mv_ref[1] = chroma_refined_mv[1]; } -#if CONFIG_OPTFLOW_REFINEMENT if (tip_ref_frame) { mv_refined[0].as_mv.row = best_mv_ref[0].row * (1 << (1 - ss_y)); mv_refined[0].as_mv.col = best_mv_ref[0].col * (1 << (1 - ss_x)); @@ -4769,7 +4588,6 @@ #endif // CONFIG_AFFINE_REFINEMENT } } -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_D071_IMP_MSK_BLD BacpBlockData bacp_block_data[2 * N_OF_OFFSETS]; @@ -4837,11 +4655,10 @@ } #endif // CONFIG_D071_IMP_MSK_BLD -#if CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT if (use_optflow_refinement && (use_affine_opfl || plane == 0)) { #else - if (use_optflow_refinement && plane == 0) { + if (use_optflow_refinement && plane == 0) { #endif // CONFIG_AFFINE_REFINEMENT inter_pred_params.interp_filter_params[0] = av1_get_interp_filter_params_with_block_size(mi->interp_fltr, @@ -4866,7 +4683,6 @@ ); continue; } -#endif // CONFIG_OPTFLOW_REFINEMENT av1_build_one_inter_predictor(dst, dst_stride, &mv, &inter_pred_params, xd, mi_x, mi_y, ref, mc_buf, calc_subpel_params_func); @@ -4880,15 +4696,11 @@ use_affine_opfl); #endif // CONFIG_AFFINE_REFINEMENT if (use_optflow_refinement && plane == 0 && !tip_ref_frame) { - enhance_prediction(cm, xd, plane, dst, dst_stride, bw, bh -#if CONFIG_OPTFLOW_REFINEMENT - , - mv_refined_sb, + enhance_prediction(cm, xd, plane, dst, dst_stride, bw, bh, mv_refined_sb, use_optflow_refinement #if CONFIG_AFFINE_REFINEMENT && apply_pef_opfl #endif // CONFIG_AFFINE_REFINEMENT -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV , 0, NULL @@ -5055,7 +4867,6 @@ } } } - xd->tmp_conv_dst = tmp_conv_dst; return; } @@ -5083,7 +4894,6 @@ #if CONFIG_REFINEMV MV best_mv_ref[2] = { mi_mv[0], mi_mv[1] }; #endif // CONFIG_REFINEMV -#if CONFIG_OPTFLOW_REFINEMENT if (tip_ref_frame) { mv_refined[0].as_mv.row = best_mv_ref[0].row * (1 << (1 - ss_y)); mv_refined[0].as_mv.col = best_mv_ref[0].col * (1 << (1 - ss_x)); @@ -5127,14 +4937,14 @@ } #endif #else - WarpedMotionParams wms[2]; - wms[0] = default_warp_params; - wms[1] = default_warp_params; + WarpedMotionParams wms[2]; + wms[0] = default_warp_params; + wms[1] = default_warp_params; #if AFFINE_CHROMA_REFINE_METHOD > 0 - if (use_optflow_refinement && plane) { - wms[0] = mi->wm_params[0]; - wms[1] = mi->wm_params[1]; - } + if (use_optflow_refinement && plane) { + wms[0] = mi->wm_params[0]; + wms[1] = mi->wm_params[1]; + } #endif #endif // CONFIG_AFFINE_REFINEMENT_SB #endif // CONFIG_AFFINE_REFINEMENT @@ -5177,8 +4987,8 @@ const MV mv0 = best_mv_ref[0]; const MV mv1 = best_mv_ref[1]; #else - const MV mv0 = mi->mv[0].as_mv; - const MV mv1 = mi->mv[1].as_mv; + const MV mv0 = mi->mv[0].as_mv; + const MV mv1 = mi->mv[1].as_mv; #endif // CONFIG_REFINEMV // Refine MV using optical flow. The final output MV will be in 1/16 // precision. @@ -5220,9 +5030,9 @@ #if CONFIG_AFFINE_REFINEMENT_SB memcpy(xd->wm_params_sb, wms, 2 * NUM_AFFINE_PARAMS * sizeof(wms[0])); #elif CONFIG_AFFINE_REFINEMENT - // parameters derived are saved here and may be reused by chroma - mi->wm_params[0] = wms[0]; - mi->wm_params[1] = wms[1]; + // parameters derived are saved here and may be reused by chroma + mi->wm_params[0] = wms[0]; + mi->wm_params[1] = wms[1]; #endif // CONFIG_AFFINE_REFINEMENT_SB } } @@ -5234,7 +5044,6 @@ use_4x4, #endif // CONFIG_OPTFLOW_ON_TIP &opfl_sub_bw, &opfl_sub_bh); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_D071_IMP_MSK_BLD BacpBlockData bacp_block_data[2 * N_OF_OFFSETS]; @@ -5326,17 +5135,16 @@ } } -#if CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT if (use_optflow_refinement && #if AFFINE_CHROMA_REFINE_METHOD > 0 (mi->comp_refine_type >= COMP_AFFINE_REFINE_START || plane == 0) #else - mi->comp_refine_type >= COMP_AFFINE_REFINE_START && plane == 0 + mi->comp_refine_type >= COMP_AFFINE_REFINE_START && plane == 0 #endif ) { #else - if (use_optflow_refinement && plane == 0) { + if (use_optflow_refinement && plane == 0) { #endif // CONFIG_AFFINE_REFINEMENT inter_pred_params.interp_filter_params[0] = av1_get_interp_filter_params_with_block_size(mi->interp_fltr, @@ -5358,7 +5166,6 @@ ); continue; } -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_BAWP #if CONFIG_BAWP_CHROMA if (mi->bawp_flag[0] > 0 && (plane == 0 || mi->bawp_flag[1]) && @@ -5507,15 +5314,11 @@ damr_refine_subblock(plane, bw, bh, mi->comp_refine_type, opfl_sub_bw, opfl_sub_bh); #endif // CONFIG_AFFINE_REFINEMENT - enhance_prediction(cm, xd, plane, dst, dst_stride, bw, bh -#if CONFIG_OPTFLOW_REFINEMENT - , - xd->mv_refined, + enhance_prediction(cm, xd, plane, dst, dst_stride, bw, bh, xd->mv_refined, use_optflow_refinement #if CONFIG_AFFINE_REFINEMENT && apply_pef_opfl #endif // CONFIG_AFFINE_REFINEMENT -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV , apply_sub_block_refinemv, &xd->refinemv_subinfo[0]
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h index 05e336b..566eac3 100644 --- a/av1/common/reconinter.h +++ b/av1/common/reconinter.h
@@ -224,14 +224,12 @@ const InterpFilterParams *interp_filter_params[2]; int block_width; int block_height; -#if CONFIG_OPTFLOW_REFINEMENT // In optical flow refinement, block_width and block_height will pass the // subblock size into av1_make_inter_predictor, while orig_block_width and // orig_block_height keep the original block size that is needed by // calc_subpel_params_func int orig_block_width; int orig_block_height; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV // In refinemV, the prediction is generated maximum 16x16 sub-block basis @@ -270,7 +268,6 @@ #endif // CONFIG_D071_IMP_MSK_BLD } InterPredParams; -#if CONFIG_OPTFLOW_REFINEMENT // Apply bilinear and bicubic interpolation for subpel gradient to avoid // calls of build_one_inter_predictor function. Bicubic interpolation // brings better quality but the speed results are neutral. As such, bilinear @@ -313,7 +310,6 @@ { { 21, 42 }, { -3, -6 } }, // delta = 0.125 (SUBPEL_GRAD_DELTA_BITS = 3) }; #endif -#endif // CONFIG_OPTFLOW_REFINEMENT void av1_init_inter_params(InterPredParams *inter_pred_params, int block_width, int block_height, int pix_row, int pix_col, @@ -360,12 +356,10 @@ const MB_MODE_INFO *mbmi) { const int mode = mbmi->mode; - return (mode == NEAR_NEWMV || mode == NEW_NEARMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == NEAR_NEWMV_OPTFLOW || mode == NEW_NEARMV_OPTFLOW || - mode == JOINT_AMVDNEWMV_OPTFLOW -#endif - || mode == AMVDNEWMV || mode == JOINT_AMVDNEWMV) && + return (mode == NEAR_NEWMV || mode == NEW_NEARMV || + mode == NEAR_NEWMV_OPTFLOW || mode == NEW_NEARMV_OPTFLOW || + mode == JOINT_AMVDNEWMV_OPTFLOW || mode == AMVDNEWMV || + mode == JOINT_AMVDNEWMV) && cm->seq_params.enable_adaptive_mvd; } @@ -500,10 +494,7 @@ typedef void (*CalcSubpelParamsFunc)(const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *xd, int mi_x, int mi_y, - int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT + int ref, int use_optflow_refinement, uint16_t **mc_buf, uint16_t **pre, SubpelParams *subpel_params, int *src_stride); @@ -525,7 +516,6 @@ int mi_y, uint16_t **mc_buf, CalcSubpelParamsFunc calc_subpel_params_func); -#if CONFIG_OPTFLOW_REFINEMENT // Precision of refined MV returned, 0 being integer pel. For now, only 1/8 or // 1/16-pel can be used. #define MV_REFINE_PREC_BITS 4 // (1/16-pel) @@ -535,7 +525,6 @@ #define OPFL_REGULARIZED_LS 1 #define OPFL_RLS_PARAM 16 -#if CONFIG_REFINEMENT_SIMPLIFY // Number of bits allowed for all intermediate results of covariance matrix // filling #define MAX_OPFL_AUTOCORR_BITS 28 @@ -543,13 +532,6 @@ // unsigned bits. Every sum of 8 u2/v2 use at most 2h+3 unsigned bits, and // must not exceed max bd of su2/sv2 minus 2. Thus, 2h+3 <= H-2 #define OPFL_SAMP_CLAMP_VAL ((1 << ((MAX_OPFL_AUTOCORR_BITS - 6) >> 1)) - 1) -#else -// Number of bits allowed for covariance matrix elements (su2, sv2, suv, suw -// and svw) so that det, det_x, and det_y does not cause overflow issue in -// int64_t. Its value must be <= (64 - mv_prec_bits - grad_prec_bits) / 2. -#define MAX_OPFL_AUTOCORR_BITS 28 -#define OPFL_AUTOCORR_CLAMP_VAL (1 << MAX_OPFL_AUTOCORR_BITS) -#endif // CONFIG_REFINEMENT_SIMPLIFY void av1_opfl_build_inter_predictor( const AV1_COMMON *cm, MACROBLOCKD *xd, int plane, const MB_MODE_INFO *mi, @@ -598,7 +580,6 @@ #endif // CONFIG_OPTFLOW_ON_TIP ); -#if CONFIG_REFINEMENT_SIMPLIFY // We consider this tunable number K=MAX_LS_BITS-1 (sign bit excluded) // as the target maximum bit depth of all intermediate results for LS problem. #define MAX_LS_BITS 32 @@ -640,63 +621,17 @@ sol[i] = sign ? sol[i] : -sol[i]; } } -#else -// Integer division based on lookup table. -// num: numerator -// den: denominator -// out: output result (num / den) -static INLINE int32_t divide_and_round_signed(int64_t num, int64_t den) { - if (llabs(den) == 1) return (int32_t)(den < 0 ? -num : num); - const int optflow_prec_bits = 16; - int16_t shift; - const int sign_den = (den < 0 ? -1 : 1); - uint16_t inverse_den = resolve_divisor_64(llabs(den), &shift); - shift -= optflow_prec_bits; - if (shift < 0) { - inverse_den <<= (-shift); - shift = 0; - } - int32_t out; - // Make sure 1) the bits for right shift is < 63 and 2) the bit depth - // of num is < 48 to avoid overflow in num * inverse_den - if (optflow_prec_bits + shift >= 63 || - ROUND_POWER_OF_TWO_SIGNED_64(num, 63 - optflow_prec_bits) != 0) { - int64_t out_tmp = ROUND_POWER_OF_TWO_SIGNED_64(num, optflow_prec_bits); - out = (int32_t)ROUND_POWER_OF_TWO_SIGNED_64( - out_tmp * (int64_t)inverse_den * sign_den, shift); - } else { - out = (int32_t)ROUND_POWER_OF_TWO_SIGNED_64( - num * (int64_t)inverse_den * sign_den, optflow_prec_bits + shift); - } -#ifndef NDEBUG - // Verify that the result is consistent with built-in division. - // Quick overflow check - int32_t out_div = (llabs(num) + llabs(den) < 0) - ? (int32_t)DIVIDE_AND_ROUND_SIGNED( - ROUND_POWER_OF_TWO_SIGNED_64(num, 2), - ROUND_POWER_OF_TWO_SIGNED_64(den, 2)) - : (int32_t)DIVIDE_AND_ROUND_SIGNED(num, den); - // check if error is at most 1 at usable values of out_div - if (abs(out_div - out) > 1 && abs(out_div) <= 64) { - printf("Warning: num = %" PRId64 ", den = %" PRId64 - ", inverse_den = %d, shift = %d, v0 = %d, v = %d\n", - num, den, inverse_den, shift, out_div, out); - } -#endif // NDEBUG - return out; -} -#endif // CONFIG_REFINEMENT_SIMPLIFY -#endif // CONFIG_OPTFLOW_REFINEMENT -#if CONFIG_AFFINE_REFINEMENT -#if CONFIG_REFINEMENT_SIMPLIFY || CONFIG_E125_MHCCP_SIMPLIFY +#if CONFIG_AFFINE_REFINEMENT || CONFIG_E125_MHCCP_SIMPLIFY // This function is a stable version of ROUND_POWER_OF_TWO_SIGNED(a*b, shift), // where shifts are partially applied before multiplcation operations to avoid // overflow issues, i.e., (a>>s1)*(b>>s2)>>s3, where s1+s2+s3=shift int64_t stable_mult_shift(const int64_t a, const int64_t b, const int shift, const int msb_a, const int msb_b, const int max_bd, int *rem_shift); -#endif // CONFIG_REFINEMENT_SIMPLIFY || CONFIG_E125_MHCCP_SIMPLIFY +#endif // CONFIG_AFFINE_REFINEMENT || CONFIG_E125_MHCCP_SIMPLIFY + +#if CONFIG_AFFINE_REFINEMENT int solver_4d(int64_t *mat, int64_t *vec, int *precbits, int64_t *sol); void av1_avg_pooling_pdiff_gradients_c(int16_t *pdiff, const int pstride, int16_t *gx, int16_t *gy, @@ -733,7 +668,6 @@ #define AFFINE_AVG_MAX_SIZE_LOG2 4 #define AFFINE_AVG_MAX_SIZE (1 << AFFINE_AVG_MAX_SIZE_LOG2) -#if CONFIG_REFINEMENT_SIMPLIFY // We consider this tunable number H=MAX_AFFINE_AUTOCORR_BITS-1 (sign bit // excluded) as the maximum bit depth for autocorrelation matrix filling. // This value should not be set lower than 25, since gx*x+gy*y can reach 25 @@ -745,16 +679,6 @@ #define AFFINE_SAMP_CLAMP_VAL \ ((1L << ((MAX_AFFINE_AUTOCORR_BITS - 7) >> 1)) - 1) #define AFFINE_COORDS_OFFSET_BITS 2 -#else -// Number of bits allowed for covariance matrix elements so that determinants -// do not overflow int64_t. For dim=3, input bit depth must be -// <= (64 - mv_prec_bits - grad_prec_bits) / 3. For dim=4, input bit depth must -// be <= (64-1)/2 for the first stage (getsub_4d), and <= 64-3-precbits for -// the second stage (determinant and divide_and_round_signed). -#define AFFINE_SAMP_CLAMP_VAL ((1 << 15) - 1) -#define AFFINE_AUTOCORR_CLAMP_VAL ((1 << 30) - 1) -#define AFFINE_COORDS_OFFSET_BITS 3 -#endif // CONFIG_REFINEMENT_SIMPLIFY // Internal bit depths for affine parameter derivation #define AFFINE_GRAD_BITS_THR 32 @@ -895,11 +819,8 @@ const MACROBLOCKD *const xd, int mi_x, int mi_y, uint16_t **pre, SubpelParams *subpel_params, int *src_stride, PadBlock *block, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - MV32 *scaled_mv, int *subpel_x_mv, - int *subpel_y_mv); + int use_optflow_refinement, MV32 *scaled_mv, + int *subpel_x_mv, int *subpel_y_mv); // check if the refinemv mode is allwed for a given blocksize static INLINE int is_refinemv_allowed_bsize(BLOCK_SIZE bsize) { @@ -1122,11 +1043,8 @@ void common_calc_subpel_params_and_extend( const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *const xd, int mi_x, int mi_y, int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **mc_buf, uint16_t **pre, SubpelParams *subpel_params, - int *src_stride); + int use_optflow_refinement, uint16_t **mc_buf, uint16_t **pre, + SubpelParams *subpel_params, int *src_stride); #endif // CONFIG_REFINEMV #if CONFIG_REFINEMV || CONFIG_OPTFLOW_ON_TIP @@ -1141,7 +1059,6 @@ int bw, int bh); #endif // CONFIG_SUBBLK_REF_DS -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_OPFL_MV_SEARCH void calc_mv_process(int64_t su2, int64_t sv2, int64_t suv, int64_t suw, int64_t svw, const int d0, const int d1, const int bits, const int rls_alpha, int *vx0, int *vy0, int *vx1, @@ -1154,15 +1071,12 @@ void av1_compute_subpel_gradients_interp(int16_t *pred_dst, int bw, int bh, int *grad_prec_bits, int16_t *x_grad, int16_t *y_grad); -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_OPFL_MV_SEARCH // TODO(jkoleszar): yet another mv clamping function :-( static INLINE MV clamp_mv_to_umv_border_sb(const MACROBLOCKD *xd, const MV *src_mv, int bw, int bh, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - int ss_x, int ss_y) { + int use_optflow_refinement, int ss_x, + int ss_y) { // If the MV points so far into the UMV border that no visible pixels // are used for reconstruction, the subpel part of the MV can be // discarded and the MV limited to 16 pixels with equivalent results. @@ -1170,7 +1084,6 @@ const int spel_right = spel_left - SUBPEL_SHIFTS; const int spel_top = (AOM_INTERP_EXTEND + bh) << SUBPEL_BITS; const int spel_bottom = spel_top - SUBPEL_SHIFTS; -#if CONFIG_OPTFLOW_REFINEMENT MV clamped_mv; if (use_optflow_refinement) { // optflow refinement always returns MVs with 1/16 precision so it is not @@ -1183,10 +1096,6 @@ clamped_mv.row = (int16_t)(src_mv->row * (1 << (1 - ss_y))); clamped_mv.col = (int16_t)(src_mv->col * (1 << (1 - ss_x))); } -#else - MV clamped_mv = { (int16_t)(src_mv->row * (1 << (1 - ss_y))), - (int16_t)(src_mv->col * (1 << (1 - ss_x))) }; -#endif // CONFIG_OPTFLOW_REFINEMENT assert(ss_x <= 1); assert(ss_y <= 1); const SubpelMvLimits mv_limits = { @@ -1287,13 +1196,10 @@ } static INLINE void set_default_interp_filters( - MB_MODE_INFO *const mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - const AV1_COMMON *cm, + MB_MODE_INFO *const mbmi, const AV1_COMMON *cm, #if CONFIG_COMPOUND_4XN const MACROBLOCKD *xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT InterpFilter frame_interp_filter) { #if CONFIG_SKIP_MODE_ENHANCEMENT @@ -1302,7 +1208,6 @@ return; } #endif // CONFIG_SKIP_MODE_ENHANCEMENT -#if CONFIG_OPTFLOW_REFINEMENT mbmi->interp_fltr = (opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN xd, @@ -1314,9 +1219,6 @@ || is_tip_ref_frame(mbmi->ref_frame[0])) ? MULTITAP_SHARP : av1_unswitchable_filter(frame_interp_filter); -#else - mbmi->interp_fltr = av1_unswitchable_filter(frame_interp_filter); -#endif // CONFIG_OPTFLOW_REFINEMENT } static INLINE int av1_is_interp_needed(const AV1_COMMON *const cm, @@ -1329,7 +1231,6 @@ if (mbmi->mode == WARPMV) return 0; #endif // CONFIG_EXTENDED_WARP_PREDICTION -#if CONFIG_OPTFLOW_REFINEMENT // No interpolation filter search when optical flow MV refinement is used. if (opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN @@ -1337,7 +1238,6 @@ #endif // CONFIG_COMPOUND_4XN mbmi)) return 0; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV // No interpolation filter search when MV refinement is used.
diff --git a/av1/common/tip.h b/av1/common/tip.h index f2c7b2a..9217409 100644 --- a/av1/common/tip.h +++ b/av1/common/tip.h
@@ -76,7 +76,6 @@ *mv = get_mv_from_fullmv(&fullmv); } - #ifdef __cplusplus } // extern "C" #endif
diff --git a/av1/common/x86/affine_optflow_refine_avx2.c b/av1/common/x86/affine_optflow_refine_avx2.c index 0daadaa..3dda226 100644 --- a/av1/common/x86/affine_optflow_refine_avx2.c +++ b/av1/common/x86/affine_optflow_refine_avx2.c
@@ -232,28 +232,6 @@ *out_hi = _mm256_unpackhi_epi32(in, sign_bits); } -#if !CONFIG_REFINEMENT_SIMPLIFY -static INLINE __m256i highbd_clamp_epi64(__m256i in, int64_t max_value, - int64_t min_value) { - __m256i clamp_min = _mm256_set1_epi64x(min_value); - __m256i clamp_max = _mm256_set1_epi64x(max_value); - - // Compare to create masks - __m256i greater_than_min_mask = _mm256_cmpgt_epi64(in, clamp_min); - __m256i less_than_max_mask = _mm256_cmpgt_epi64(clamp_max, in); - - // vec = MAX(vec, min_value) - in = _mm256_or_si256(_mm256_and_si256(greater_than_min_mask, in), - _mm256_andnot_si256(greater_than_min_mask, clamp_min)); - - // vec = MIN(vec, max_value) - in = _mm256_or_si256(_mm256_and_si256(less_than_max_mask, in), - _mm256_andnot_si256(less_than_max_mask, clamp_max)); - - return in; -} -#endif // !CONFIG_REFINEMENT_SIMPLIFY - static INLINE __m256i round_power_of_two_epi32(__m256i in, int reduce_bits) { __m256i rounding_offset = _mm256_set1_epi32((1 << (reduce_bits)) >> 1); @@ -307,7 +285,6 @@ return sum; } -#if CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT static INLINE void calc_max_vector(__m256i *gx_vec, __m256i *gy_vec, __m256i *pdiff_vec, __m256i *max_vec) { @@ -397,9 +374,7 @@ __m256i a0_temp_hi = round_power_of_two_signed_epi32( _mm256_madd_epi16(gx_gy_hi, x_minus_y_hi), coords_bits); -#if CONFIG_REFINEMENT_SIMPLIFY assert(AFFINE_SAMP_CLAMP_VAL <= INT16_MAX); -#endif // CONFIG_REFINEMENT_SIMPLIFY // Clip the values of a[] to [-AFFINE_SAMP_CLAMP_VAL, AFFINE_SAMP_CLAMP_VAL-1] // (i.e., to 16-bit signed range). Here, using the instruction // _mm256_packs_epi32() to clip 32-bit signed values to 16-bit signed range. @@ -472,7 +447,6 @@ __m256i a23_hi = round_power_of_two_signed_epi32( _mm256_madd_epi16(gx_a2_hi, gy_a3_hi), grad_bits); -#if CONFIG_REFINEMENT_SIMPLIFY // a00 a_mat[0] = add_epi32_as_epi64(a00_lo, a00_hi); // a01 @@ -493,38 +467,14 @@ a_mat[8] = add_epi32_as_epi64(a23_lo, a23_hi); // a33 a_mat[9] = add_epi32_as_epi64(a33_lo, a33_hi); -#else - // a00 - a_mat[0] = _mm256_add_epi64(a_mat[0], add_epi32_as_epi64(a00_lo, a00_hi)); - // a01 - a_mat[1] = _mm256_add_epi64(a_mat[1], add_epi32_as_epi64(a01_lo, a01_hi)); - // a02 - a_mat[2] = _mm256_add_epi64(a_mat[2], add_epi32_as_epi64(a02_lo, a02_hi)); - // a03 - a_mat[3] = _mm256_add_epi64(a_mat[3], add_epi32_as_epi64(a03_lo, a03_hi)); - // a11 - a_mat[4] = _mm256_add_epi64(a_mat[4], add_epi32_as_epi64(a11_lo, a11_hi)); - // a12 - a_mat[5] = _mm256_add_epi64(a_mat[5], add_epi32_as_epi64(a12_lo, a12_hi)); - // a13 - a_mat[6] = _mm256_add_epi64(a_mat[6], add_epi32_as_epi64(a13_lo, a13_hi)); - // a22 - a_mat[7] = _mm256_add_epi64(a_mat[7], add_epi32_as_epi64(a22_lo, a22_hi)); - // a23 - a_mat[8] = _mm256_add_epi64(a_mat[8], add_epi32_as_epi64(a23_lo, a23_hi)); - // a33 - a_mat[9] = _mm256_add_epi64(a_mat[9], add_epi32_as_epi64(a33_lo, a33_hi)); -#endif // CONFIG_REFINEMENT_SIMPLIFY // Compute vec_b __m256i pdiff_vec_lo = _mm256_unpacklo_epi16(*pdiff_vec, zeros); __m256i pdiff_vec_hi = _mm256_unpackhi_epi16(*pdiff_vec, zeros); -#if CONFIG_REFINEMENT_SIMPLIFY pdiff_vec_lo = _mm256_min_epi16(_mm256_max_epi16(pdiff_vec_lo, clamp_min), clamp_max); pdiff_vec_hi = _mm256_min_epi16(_mm256_max_epi16(pdiff_vec_hi, clamp_min), clamp_max); -#endif // CONFIG_REFINEMENT_SIMPLIFY __m256i v0_lo = round_power_of_two_signed_epi32( _mm256_madd_epi16(a0_lo, pdiff_vec_lo), grad_bits); @@ -543,17 +493,10 @@ __m256i v3_hi = round_power_of_two_signed_epi32( _mm256_madd_epi16(gy_a3_hi, pdiff_vec_hi), grad_bits); -#if CONFIG_REFINEMENT_SIMPLIFY b_vec[0] = add_epi32_as_epi64(v0_lo, v0_hi); b_vec[1] = add_epi32_as_epi64(v1_lo, v1_hi); b_vec[2] = add_epi32_as_epi64(v2_lo, v2_hi); b_vec[3] = add_epi32_as_epi64(v3_lo, v3_hi); -#else - b_vec[0] = _mm256_add_epi64(b_vec[0], add_epi32_as_epi64(v0_lo, v0_hi)); - b_vec[1] = _mm256_add_epi64(b_vec[1], add_epi32_as_epi64(v1_lo, v1_hi)); - b_vec[2] = _mm256_add_epi64(b_vec[2], add_epi32_as_epi64(v2_lo, v2_hi)); - b_vec[3] = _mm256_add_epi64(b_vec[3], add_epi32_as_epi64(v3_lo, v3_hi)); -#endif // CONFIG_REFINEMENT_SIMPLIFY } static INLINE void calc_mat_a_and_vec_b(const int16_t *pdiff, int pstride, @@ -616,7 +559,7 @@ multiply_and_accumulate(&gx_vec, &gy_vec, &x_vec, &y_vec, &pdiff_vec, coords_bits, grad_bits, a_mat, b_vec); i_vec = _mm256_add_epi16(i_vec, _mm256_set1_epi16(2)); -#if CONFIG_REFINEMENT_SIMPLIFY + int index = 0; // Sum the individual values in upper triangular part of mat_a[] and in // vec_b[] @@ -638,7 +581,6 @@ } grad_bits++; } -#endif // CONFIG_REFINEMENT_SIMPLIFY } } else { __m256i j_vec = _mm256_load_si256((__m256i *)col_16_vector); @@ -656,7 +598,6 @@ multiply_and_accumulate(&gx_vec, &gy_vec, &x_vec, &y_vec, &pdiff_vec, coords_bits, grad_bits, a_mat, b_vec); -#if CONFIG_REFINEMENT_SIMPLIFY int index = 0; // Sum the individual values in upper triangular part of mat_a[] and in // vec_b[] @@ -678,21 +619,8 @@ } grad_bits++; } -#endif // CONFIG_REFINEMENT_SIMPLIFY } } -#if !CONFIG_REFINEMENT_SIMPLIFY - int index = 0; - // Sum the individual values in mat_a[] - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - if (j >= i) { - // Upper triangle - mat_a[i * 4 + j] = horiz_sum_epi64(a_mat[index++]); - } - } - } -#endif // !CONFIG_REFINEMENT_SIMPLIFY for (int s = 0; s < 4; ++s) { for (int t = s + 1; t < 4; ++t) mat_a[t * 4 + s] = mat_a[s * 4 + t]; // for (int t = 0; t < s; ++t) mat_a[s * 4 + t] = mat_a[t * 4 + s]; @@ -702,36 +630,6 @@ mat_a[5] += rls_alpha; mat_a[10] += rls_alpha; mat_a[15] += rls_alpha; - -#if !CONFIG_REFINEMENT_SIMPLIFY - // Sum the individual values in vec_b - for (int l = 0; l < 4; ++l) { - vec_b[l] = horiz_sum_epi64(b_vec[l]); - } - - __m256i ret[5]; - __m256i val = _mm256_loadu_si256((__m256i *)&mat_a[0]); - ret[0] = highbd_clamp_epi64(val, AFFINE_AUTOCORR_CLAMP_VAL, - -AFFINE_AUTOCORR_CLAMP_VAL); - val = _mm256_loadu_si256((__m256i *)&mat_a[4]); - ret[1] = highbd_clamp_epi64(val, AFFINE_AUTOCORR_CLAMP_VAL, - -AFFINE_AUTOCORR_CLAMP_VAL); - val = _mm256_loadu_si256((__m256i *)&mat_a[8]); - ret[2] = highbd_clamp_epi64(val, AFFINE_AUTOCORR_CLAMP_VAL, - -AFFINE_AUTOCORR_CLAMP_VAL); - val = _mm256_loadu_si256((__m256i *)&mat_a[12]); - ret[3] = highbd_clamp_epi64(val, AFFINE_AUTOCORR_CLAMP_VAL, - -AFFINE_AUTOCORR_CLAMP_VAL); - val = _mm256_loadu_si256((__m256i *)vec_b); - ret[4] = highbd_clamp_epi64(val, AFFINE_AUTOCORR_CLAMP_VAL, - -AFFINE_AUTOCORR_CLAMP_VAL); - - _mm256_storeu_si256((__m256i *)&mat_a[0], ret[0]); - _mm256_storeu_si256((__m256i *)&mat_a[4], ret[1]); - _mm256_storeu_si256((__m256i *)&mat_a[8], ret[2]); - _mm256_storeu_si256((__m256i *)&mat_a[12], ret[3]); - _mm256_storeu_si256((__m256i *)vec_b, ret[4]); -#endif // !CONFIG_REFINEMENT_SIMPLIFY } void av1_calc_affine_autocorrelation_matrix_avx2(const int16_t *pdiff, @@ -2488,7 +2386,6 @@ *t2 = _mm256_unpackhi_epi16(lo, hi); } -#if CONFIG_REFINEMENT_SIMPLIFY #define OPFL_OUTPUT_RANGE_CHECK(su2, sv2, suv, suw, svw) \ { \ su2 = ROUND_POWER_OF_TWO_SIGNED_64(su2, 1); \ @@ -2532,22 +2429,6 @@ *t1 = round_power_of_two_signed_avx2(*t1, rounding_offset, round_bits); *t2 = round_power_of_two_signed_avx2(*t2, rounding_offset, round_bits); } -#else -static AOM_FORCE_INLINE void xx256_storel_64(int64_t *store_lo, - int64_t *store_hi, const __m256i a, - const __m256i b) { - const __m256i lo_0 = _mm256_cvtepi32_epi64(_mm256_castsi256_si128(a)); - const __m256i hi_0 = _mm256_cvtepi32_epi64(_mm256_extracti128_si256(a, 1)); - const __m256i lo1 = _mm256_cvtepi32_epi64(_mm256_castsi256_si128(b)); - const __m256i hi1 = _mm256_cvtepi32_epi64(_mm256_extracti128_si256(b, 1)); - __m256i sum_lo = _mm256_add_epi64(lo_0, lo1); - __m256i sum_hi = _mm256_add_epi64(hi_0, hi1); - sum_lo = _mm256_add_epi64(sum_lo, _mm256_srli_si256(sum_lo, 8)); - sum_hi = _mm256_add_epi64(sum_hi, _mm256_srli_si256(sum_hi, 8)); - *store_lo = _mm256_extract_epi64(sum_lo, 0) + _mm256_extract_epi64(sum_lo, 2); - *store_hi = _mm256_extract_epi64(sum_hi, 0) + _mm256_extract_epi64(sum_hi, 2); -} -#endif // CONFIG_REFINEMENT_SIMPLIFY static void opfl_mv_refinement_16x8_avx2(const int16_t *pdiff, int pstride, const int16_t *gx, const int16_t *gy, @@ -2571,12 +2452,10 @@ int64_t suv_lo = 0; int64_t suw_lo = 0; int64_t svw_lo = 0; -#if CONFIG_REFINEMENT_SIMPLIFY int grad_bits_lo = 0; int grad_bits_hi = 0; const __m256i opfl_samp_min = _mm256_set1_epi16(-OPFL_SAMP_CLAMP_VAL); const __m256i opfl_samp_max = _mm256_set1_epi16(OPFL_SAMP_CLAMP_VAL); -#endif // CONFIG_REFINEMENT_SIMPLIFY #if OPFL_DOWNSAMP_QUINCUNX step_size = 2; const __m256i even_row = @@ -2602,7 +2481,6 @@ pred = _mm256_or_si256(_mm256_and_si256(pred, even_row), _mm256_and_si256(pred1, odd_row)); #endif -#if CONFIG_REFINEMENT_SIMPLIFY gradX = _mm256_max_epi16(_mm256_min_epi16(gradX, opfl_samp_max), opfl_samp_min); gradY = @@ -2669,30 +2547,6 @@ OPFL_OUTPUT_RANGE_CHECK(su2_hi, sv2_hi, suv_hi, suw_hi, svw_hi) grad_bits_hi++; } -#else - multiply(gradX, gradX, &u2_0, &u2_1); - multiply(gradY, gradY, &v2_0, &v2_1); - multiply(gradX, gradY, &uv_0, &uv_1); - multiply(gradX, pred, &uw_0, &uw_1); - multiply(gradY, pred, &vw_0, &vw_1); - - int64_t temp_lo, temp_hi; - xx256_storel_64(&temp_lo, &temp_hi, u2_0, u2_1); - su2_lo += temp_lo; - su2_hi += temp_hi; - xx256_storel_64(&temp_lo, &temp_hi, v2_0, v2_1); - sv2_lo += temp_lo; - sv2_hi += temp_hi; - xx256_storel_64(&temp_lo, &temp_hi, uv_0, uv_1); - suv_lo += temp_lo; - suv_hi += temp_hi; - xx256_storel_64(&temp_lo, &temp_hi, uw_0, uw_1); - suw_lo += temp_lo; - suw_hi += temp_hi; - xx256_storel_64(&temp_lo, &temp_hi, vw_0, vw_1); - svw_lo += temp_lo; - svw_hi += temp_hi; -#endif // CONFIG_REFINEMENT_SIMPLIFY gx += gstride * step_size; gy += gstride * step_size; @@ -2734,4 +2588,3 @@ } return n_blocks; } -#endif // CONFIG_OPTFLOW_REFINEMENT
diff --git a/av1/common/x86/optflow_refine_sse4.c b/av1/common/x86/optflow_refine_sse4.c index 31d9afd..48477f9 100644 --- a/av1/common/x86/optflow_refine_sse4.c +++ b/av1/common/x86/optflow_refine_sse4.c
@@ -19,8 +19,6 @@ #include "av1/common/reconinter.h" #include "aom_dsp/x86/synonyms.h" -#if CONFIG_OPTFLOW_REFINEMENT -#if CONFIG_REFINEMENT_SIMPLIFY static INLINE __m128i round_power_of_two_signed_epi64(__m128i in, int n) { __m128i sign_mask = _mm_srai_epi32(in, 31); sign_mask = _mm_or_si128(sign_mask, _mm_srli_epi64(sign_mask, 4)); @@ -36,7 +34,6 @@ rounded_vec = _mm_sub_epi64(rounded_vec, sign_mask); return rounded_vec; } -#endif // CONFIG_REFINEMENT_SIMPLIFY static INLINE __m128i pack_and_round_epi32(__m128i temp1, __m128i temp2, const __m128i v_bias_d, @@ -389,19 +386,8 @@ (void)rls_alpha; #endif -#if !CONFIG_REFINEMENT_SIMPLIFY - // Clamp su2, sv2, suv, suw, and svw to avoid overflow in det, det_x, and - // det_y - su2 = clamp64(su2, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - sv2 = clamp64(sv2, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - suv = clamp64(suv, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - suw = clamp64(suw, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); - svw = clamp64(svw, -OPFL_AUTOCORR_CLAMP_VAL, OPFL_AUTOCORR_CLAMP_VAL); -#endif // !CONFIG_REFINEMENT_SIMPLIFY - // Solve 2x2 matrix inverse: [ su2 suv ] [ vx0 ] [ -suw ] // [ suv sv2 ] * [ vy0 ] = [ -svw ] -#if CONFIG_REFINEMENT_SIMPLIFY int shifts[2] = { bits, bits }; int msb_su2 = 1 + get_msb_signed_64(su2); int msb_sv2 = 1 + get_msb_signed_64(sv2); @@ -434,37 +420,16 @@ divide_and_round_array(sol, det, 2, shifts); *vx0 = (int)-sol[0]; *vy0 = (int)-sol[1]; -#else - const int64_t det = su2 * sv2 - suv * suv; - if (det <= 0) { - *vx0 = 0; - *vy0 = 0; - *vx1 = 0; - *vy1 = 0; - return; - } - const int64_t det_x = (suv * svw - sv2 * suw) * (1 << bits); - const int64_t det_y = (suv * suw - su2 * svw) * (1 << bits); - - *vx0 = (int)divide_and_round_signed(det_x, det); - *vy0 = (int)divide_and_round_signed(det_y, det); -#endif // CONFIG_REFINEMENT_SIMPLIFY *vx1 = (*vx0) * d1; *vy1 = (*vy0) * d1; *vx0 = (*vx0) * d0; *vy0 = (*vy0) * d0; } -static AOM_FORCE_INLINE void multiply_and_accum(__m128i a_lo_0, __m128i b_lo_0, - __m128i a_hi_0, __m128i b_hi_0, - __m128i a_lo1, __m128i b_lo1, - __m128i a_hi1, __m128i b_hi1, -#if CONFIG_REFINEMENT_SIMPLIFY - const int grad_bits_lo, - const int grad_bits_hi, -#endif // CONFIG_REFINEMENT_SIMPLIFY - __m128i *t1, __m128i *t2) { -#if CONFIG_REFINEMENT_SIMPLIFY +static AOM_FORCE_INLINE void multiply_and_accum( + __m128i a_lo_0, __m128i b_lo_0, __m128i a_hi_0, __m128i b_hi_0, + __m128i a_lo1, __m128i b_lo1, __m128i a_hi1, __m128i b_hi1, + const int grad_bits_lo, const int grad_bits_hi, __m128i *t1, __m128i *t2) { const __m128i reg_lo_0 = round_power_of_two_signed_epi64( _mm_mul_epi32(a_lo_0, b_lo_0), grad_bits_lo); const __m128i reg_hi_0 = round_power_of_two_signed_epi64( @@ -473,12 +438,6 @@ _mm_mul_epi32(a_lo1, b_lo1), grad_bits_lo); const __m128i reg_hi1 = round_power_of_two_signed_epi64( _mm_mul_epi32(a_hi1, b_hi1), grad_bits_hi); -#else - const __m128i reg_lo_0 = _mm_mul_epi32(a_lo_0, b_lo_0); - const __m128i reg_hi_0 = _mm_mul_epi32(a_hi_0, b_hi_0); - const __m128i reg_lo1 = _mm_mul_epi32(a_lo1, b_lo1); - const __m128i reg_hi1 = _mm_mul_epi32(a_hi1, b_hi1); -#endif // CONFIG_REFINEMENT_SIMPLIFY *t1 = _mm_add_epi64(reg_lo_0, reg_lo1); *t2 = _mm_add_epi64(reg_hi_0, reg_hi1); } @@ -492,7 +451,6 @@ int bHeight = 4; const int bits = mv_prec_bits + grad_prec_bits; const int rls_alpha = OPFL_RLS_PARAM; -#if CONFIG_REFINEMENT_SIMPLIFY __m128i u2_lo, v2_lo, uv_lo, uw_lo, vw_lo; __m128i u2_hi, v2_hi, uv_hi, uw_hi, vw_hi; int64_t su2_hi = 0; @@ -509,18 +467,6 @@ int grad_bits_hi = 0; __m128i opfl_samp_min = _mm_set1_epi16(-OPFL_SAMP_CLAMP_VAL); __m128i opfl_samp_max = _mm_set1_epi16(OPFL_SAMP_CLAMP_VAL); -#else - __m128i u2_lo = _mm_setzero_si128(); - __m128i uv_lo = _mm_setzero_si128(); - __m128i v2_lo = _mm_setzero_si128(); - __m128i uw_lo = _mm_setzero_si128(); - __m128i vw_lo = _mm_setzero_si128(); - __m128i u2_hi = _mm_setzero_si128(); - __m128i uv_hi = _mm_setzero_si128(); - __m128i v2_hi = _mm_setzero_si128(); - __m128i uw_hi = _mm_setzero_si128(); - __m128i vw_hi = _mm_setzero_si128(); -#endif // CONFIG_REFINEMENT_SIMPLIFY #if OPFL_DOWNSAMP_QUINCUNX const __m128i even_row = _mm_set_epi16(0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF); @@ -546,11 +492,9 @@ // 16bit and there are cases where these buffers can be filled with extreme // values. Hence, the accumulation here needs to be done at 64-bit precision // to avoid overflow issues. -#if CONFIG_REFINEMENT_SIMPLIFY gradX = _mm_max_epi16(_mm_min_epi16(gradX, opfl_samp_max), opfl_samp_min); gradY = _mm_max_epi16(_mm_min_epi16(gradY, opfl_samp_max), opfl_samp_min); pred = _mm_max_epi16(_mm_min_epi16(pred, opfl_samp_max), opfl_samp_min); -#endif // CONFIG_REFINEMENT_SIMPLIFY const __m128i gradX_lo_0 = _mm_cvtepi16_epi32(gradX); const __m128i gradY_lo_0 = _mm_cvtepi16_epi32(gradY); const __m128i pred_lo_0 = _mm_cvtepi16_epi32(pred); @@ -565,7 +509,6 @@ const __m128i pred_lo1 = _mm_srli_si128(pred_lo_0, 4); const __m128i pred_hi1 = _mm_srli_si128(pred_hi_0, 4); -#if CONFIG_REFINEMENT_SIMPLIFY multiply_and_accum(gradX_lo_0, gradX_lo_0, gradX_hi_0, gradX_hi_0, gradX_lo1, gradX_lo1, gradX_hi1, gradX_hi1, grad_bits_lo, grad_bits_hi, &u2_lo, &u2_hi); @@ -581,33 +524,6 @@ multiply_and_accum(gradY_lo_0, pred_lo_0, gradY_hi_0, pred_hi_0, gradY_lo1, pred_lo1, gradY_hi1, pred_hi1, grad_bits_lo, grad_bits_hi, &vw_lo, &vw_hi); -#else - __m128i t1, t2; - multiply_and_accum(gradX_lo_0, gradX_lo_0, gradX_hi_0, gradX_hi_0, - gradX_lo1, gradX_lo1, gradX_hi1, gradX_hi1, &t1, &t2); - u2_lo = _mm_add_epi64(u2_lo, t1); - u2_hi = _mm_add_epi64(u2_hi, t2); - - multiply_and_accum(gradY_lo_0, gradY_lo_0, gradY_hi_0, gradY_hi_0, - gradY_lo1, gradY_lo1, gradY_hi1, gradY_hi1, &t1, &t2); - v2_lo = _mm_add_epi64(v2_lo, t1); - v2_hi = _mm_add_epi64(v2_hi, t2); - - multiply_and_accum(gradX_lo_0, gradY_lo_0, gradX_hi_0, gradY_hi_0, - gradX_lo1, gradY_lo1, gradX_hi1, gradY_hi1, &t1, &t2); - uv_lo = _mm_add_epi64(uv_lo, t1); - uv_hi = _mm_add_epi64(uv_hi, t2); - - multiply_and_accum(gradX_lo_0, pred_lo_0, gradX_hi_0, pred_hi_0, gradX_lo1, - pred_lo1, gradX_hi1, pred_hi1, &t1, &t2); - uw_lo = _mm_add_epi64(uw_lo, t1); - uw_hi = _mm_add_epi64(uw_hi, t2); - - multiply_and_accum(gradY_lo_0, pred_lo_0, gradY_hi_0, pred_hi_0, gradY_lo1, - pred_lo1, gradY_hi1, pred_hi1, &t1, &t2); - vw_lo = _mm_add_epi64(vw_lo, t1); - vw_hi = _mm_add_epi64(vw_hi, t2); -#endif // CONFIG_REFINEMENT_SIMPLIFY #if OPFL_DOWNSAMP_QUINCUNX gx += gstride << 1; @@ -620,7 +536,6 @@ pdiff += pstride; bHeight -= 1; #endif -#if CONFIG_REFINEMENT_SIMPLIFY int64_t temp; xx_storel_64(&temp, _mm_add_epi64(u2_lo, _mm_srli_si128(u2_lo, 8))); su2_lo += temp; @@ -666,45 +581,12 @@ grad_bits_hi++; } } -#endif // CONFIG_REFINEMENT_SIMPLIFY } while (bHeight != 0); -#if CONFIG_REFINEMENT_SIMPLIFY calc_mv_process(su2_lo, sv2_lo, suv_lo, suw_lo, svw_lo, d0, d1, bits, rls_alpha, vx0, vy0, vx1, vy1); calc_mv_process(su2_hi, sv2_hi, suv_hi, suw_hi, svw_hi, d0, d1, bits, rls_alpha, vx0 + 1, vy0 + 1, vx1 + 1, vy1 + 1); -#else - u2_lo = _mm_add_epi64(u2_lo, _mm_srli_si128(u2_lo, 8)); - u2_hi = _mm_add_epi64(u2_hi, _mm_srli_si128(u2_hi, 8)); - v2_lo = _mm_add_epi64(v2_lo, _mm_srli_si128(v2_lo, 8)); - v2_hi = _mm_add_epi64(v2_hi, _mm_srli_si128(v2_hi, 8)); - uv_lo = _mm_add_epi64(uv_lo, _mm_srli_si128(uv_lo, 8)); - uv_hi = _mm_add_epi64(uv_hi, _mm_srli_si128(uv_hi, 8)); - uw_lo = _mm_add_epi64(uw_lo, _mm_srli_si128(uw_lo, 8)); - uw_hi = _mm_add_epi64(uw_hi, _mm_srli_si128(uw_hi, 8)); - vw_lo = _mm_add_epi64(vw_lo, _mm_srli_si128(vw_lo, 8)); - vw_hi = _mm_add_epi64(vw_hi, _mm_srli_si128(vw_hi, 8)); - - int64_t su2, sv2, suv, suw, svw; - xx_storel_64(&su2, u2_lo); - xx_storel_64(&sv2, v2_lo); - xx_storel_64(&suv, uv_lo); - xx_storel_64(&suw, uw_lo); - xx_storel_64(&svw, vw_lo); - - calc_mv_process(su2, sv2, suv, suw, svw, d0, d1, bits, rls_alpha, vx0, vy0, - vx1, vy1); - - xx_storel_64(&su2, u2_hi); - xx_storel_64(&sv2, v2_hi); - xx_storel_64(&suv, uv_hi); - xx_storel_64(&suw, uw_hi); - xx_storel_64(&svw, vw_hi); - - calc_mv_process(su2, sv2, suv, suw, svw, d0, d1, bits, rls_alpha, vx0 + 1, - vy0 + 1, vx1 + 1, vy1 + 1); -#endif // CONFIG_REFINEMENT_SIMPLIFY } static void opfl_mv_refinement_8x8_sse4_1(const int16_t *pdiff, int pstride, @@ -716,7 +598,6 @@ int bHeight = 8; const int rls_alpha = 4 * OPFL_RLS_PARAM; const int bits = mv_prec_bits + grad_prec_bits; -#if CONFIG_REFINEMENT_SIMPLIFY __m128i u2, v2, uv, uw, vw; int64_t su2 = 0; int64_t sv2 = 0; @@ -726,13 +607,6 @@ int grad_bits = 0; __m128i opfl_samp_min = _mm_set1_epi16(-OPFL_SAMP_CLAMP_VAL); __m128i opfl_samp_max = _mm_set1_epi16(OPFL_SAMP_CLAMP_VAL); -#else - __m128i u2 = _mm_setzero_si128(); - __m128i uv = _mm_setzero_si128(); - __m128i v2 = _mm_setzero_si128(); - __m128i uw = _mm_setzero_si128(); - __m128i vw = _mm_setzero_si128(); -#endif // CONFIG_REFINEMENT_SIMPLIFY #if OPFL_DOWNSAMP_QUINCUNX const __m128i even_row = _mm_set_epi16(0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF, 0, 0xFFFF); @@ -758,11 +632,9 @@ // 16bit and there are cases where these buffers can be filled with extreme // values. Hence, the accumulation here needs to be done at 64bit to avoid // overflow issues. -#if CONFIG_REFINEMENT_SIMPLIFY gradX = _mm_max_epi16(_mm_min_epi16(gradX, opfl_samp_max), opfl_samp_min); gradY = _mm_max_epi16(_mm_min_epi16(gradY, opfl_samp_max), opfl_samp_min); pred = _mm_max_epi16(_mm_min_epi16(pred, opfl_samp_max), opfl_samp_min); -#endif // CONFIG_REFINEMENT_SIMPLIFY const __m128i gradX_lo_0 = _mm_cvtepi16_epi32(gradX); const __m128i gradY_lo_0 = _mm_cvtepi16_epi32(gradY); const __m128i pred_lo_0 = _mm_cvtepi16_epi32(pred); @@ -778,7 +650,6 @@ const __m128i pred_hi1 = _mm_srli_si128(pred_hi_0, 4); __m128i t1, t2; -#if CONFIG_REFINEMENT_SIMPLIFY multiply_and_accum(gradX_lo_0, gradX_lo_0, gradX_hi_0, gradX_hi_0, gradX_lo1, gradX_lo1, gradX_hi1, gradX_hi1, grad_bits, grad_bits, &t1, &t2); @@ -803,32 +674,6 @@ pred_lo1, gradY_hi1, pred_hi1, grad_bits, grad_bits, &t1, &t2); vw = _mm_add_epi64(t1, t2); -#else - multiply_and_accum(gradX_lo_0, gradX_lo_0, gradX_hi_0, gradX_hi_0, - gradX_lo1, gradX_lo1, gradX_hi1, gradX_hi1, &t1, &t2); - t2 = _mm_add_epi64(t1, t2); - u2 = _mm_add_epi64(u2, t2); - - multiply_and_accum(gradY_lo_0, gradY_lo_0, gradY_hi_0, gradY_hi_0, - gradY_lo1, gradY_lo1, gradY_hi1, gradY_hi1, &t1, &t2); - t2 = _mm_add_epi64(t1, t2); - v2 = _mm_add_epi64(v2, t2); - - multiply_and_accum(gradX_lo_0, gradY_lo_0, gradX_hi_0, gradY_hi_0, - gradX_lo1, gradY_lo1, gradX_hi1, gradY_hi1, &t1, &t2); - t2 = _mm_add_epi64(t1, t2); - uv = _mm_add_epi64(uv, t2); - - multiply_and_accum(gradX_lo_0, pred_lo_0, gradX_hi_0, pred_hi_0, gradX_lo1, - pred_lo1, gradX_hi1, pred_hi1, &t1, &t2); - t2 = _mm_add_epi64(t1, t2); - uw = _mm_add_epi64(uw, t2); - - multiply_and_accum(gradY_lo_0, pred_lo_0, gradY_hi_0, pred_hi_0, gradY_lo1, - pred_lo1, gradY_hi1, pred_hi1, &t1, &t2); - t2 = _mm_add_epi64(t1, t2); - vw = _mm_add_epi64(vw, t2); -#endif // CONFIG_REFINEMENT_SIMPLIFY #if OPFL_DOWNSAMP_QUINCUNX gx += gstride << 1; gy += gstride << 1; @@ -840,7 +685,6 @@ pdiff += pstride; bHeight -= 1; #endif -#if CONFIG_REFINEMENT_SIMPLIFY int64_t temp; xx_storel_64(&temp, _mm_add_epi64(u2, _mm_srli_si128(u2, 8))); su2 += temp; @@ -864,23 +708,8 @@ svw = ROUND_POWER_OF_TWO_SIGNED_64(svw, 1); grad_bits++; } -#endif // CONFIG_REFINEMENT_SIMPLIFY } while (bHeight != 0); -#if !CONFIG_REFINEMENT_SIMPLIFY - int64_t su2, sv2, suv, suw, svw; - u2 = _mm_add_epi64(u2, _mm_srli_si128(u2, 8)); - v2 = _mm_add_epi64(v2, _mm_srli_si128(v2, 8)); - uv = _mm_add_epi64(uv, _mm_srli_si128(uv, 8)); - uw = _mm_add_epi64(uw, _mm_srli_si128(uw, 8)); - vw = _mm_add_epi64(vw, _mm_srli_si128(vw, 8)); - xx_storel_64(&su2, u2); - xx_storel_64(&sv2, v2); - xx_storel_64(&suv, uv); - xx_storel_64(&suw, uw); - xx_storel_64(&svw, vw); -#endif // !CONFIG_REFINEMENT_SIMPLIFY - calc_mv_process(su2, sv2, suv, suw, svw, d0, d1, bits, rls_alpha, vx0, vy0, vx1, vy1); } @@ -981,4 +810,3 @@ compute_pred_using_interp_grad_highbd_sse4_1(src1, src2, dst1, dst2, bw, bh, d0, d1, centered); } -#endif // CONFIG_OPTFLOW_REFINEMENT
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 52afaef..b4fbb16 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -739,33 +739,27 @@ } } #if !CONFIG_REFINEMV -static void dec_calc_subpel_params( - const MV *const src_mv, InterPredParams *const inter_pred_params, - const MACROBLOCKD *const xd, int mi_x, int mi_y, uint16_t **pre, - SubpelParams *subpel_params, int *src_stride, PadBlock *block, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - MV32 *scaled_mv, int *subpel_x_mv, int *subpel_y_mv) { +static void dec_calc_subpel_params(const MV *const src_mv, + InterPredParams *const inter_pred_params, + const MACROBLOCKD *const xd, int mi_x, + int mi_y, uint16_t **pre, + SubpelParams *subpel_params, int *src_stride, + PadBlock *block, int use_optflow_refinement, + MV32 *scaled_mv, int *subpel_x_mv, + int *subpel_y_mv) { const struct scale_factors *sf = inter_pred_params->scale_factors; struct buf_2d *pre_buf = &inter_pred_params->ref_frame_buf; -#if CONFIG_OPTFLOW_REFINEMENT // Use original block size to clamp MV and to extend block boundary const int bw = use_optflow_refinement ? inter_pred_params->orig_block_width : inter_pred_params->block_width; const int bh = use_optflow_refinement ? inter_pred_params->orig_block_height : inter_pred_params->block_height; -#else - const int bw = inter_pred_params->block_width; - const int bh = inter_pred_params->block_height; -#endif // CONFIG_OPTFLOW_REFINEMENT const int is_scaled = av1_is_scaled(sf); if (is_scaled) { int ssx = inter_pred_params->subsampling_x; int ssy = inter_pred_params->subsampling_y; int orig_pos_y = inter_pred_params->pix_row << SUBPEL_BITS; int orig_pos_x = inter_pred_params->pix_col << SUBPEL_BITS; -#if CONFIG_OPTFLOW_REFINEMENT if (use_optflow_refinement) { orig_pos_y += ROUND_POWER_OF_TWO_SIGNED(src_mv->row * (1 << SUBPEL_BITS), MV_REFINE_PREC_BITS + ssy); @@ -775,10 +769,6 @@ orig_pos_y += src_mv->row * (1 << (1 - ssy)); orig_pos_x += src_mv->col * (1 << (1 - ssx)); } -#else - orig_pos_y += src_mv->row * (1 << (1 - ssy)); - orig_pos_x += src_mv->col * (1 << (1 - ssx)); -#endif // CONFIG_OPTFLOW_REFINEMENT int pos_y = sf->scale_value_y(orig_pos_y, sf); int pos_x = sf->scale_value_x(orig_pos_x, sf); pos_x += SCALE_EXTRA_OFF; @@ -812,12 +802,9 @@ 1; MV temp_mv; - temp_mv = clamp_mv_to_umv_border_sb(xd, src_mv, bw, bh, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - inter_pred_params->subsampling_x, - inter_pred_params->subsampling_y); + temp_mv = clamp_mv_to_umv_border_sb( + xd, src_mv, bw, bh, use_optflow_refinement, + inter_pred_params->subsampling_x, inter_pred_params->subsampling_y); *scaled_mv = av1_scale_mv(&temp_mv, mi_x, mi_y, sf); scaled_mv->row += SCALE_EXTRA_OFF; scaled_mv->col += SCALE_EXTRA_OFF; @@ -830,10 +817,7 @@ int pos_y = inter_pred_params->pix_row << SUBPEL_BITS; const MV mv_q4 = clamp_mv_to_umv_border_sb( - xd, src_mv, bw, bh, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT + xd, src_mv, bw, bh, use_optflow_refinement, inter_pred_params->subsampling_x, inter_pred_params->subsampling_y); subpel_params->xs = subpel_params->ys = SCALE_SUBPEL_SHIFTS; subpel_params->subpel_x = (mv_q4.col & SUBPEL_MASK) << SCALE_EXTRA_BITS; @@ -872,19 +856,12 @@ static void dec_calc_subpel_params_and_extend( const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *const xd, int mi_x, int mi_y, int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **mc_buf, uint16_t **pre, SubpelParams *subpel_params, - int *src_stride) { - + int use_optflow_refinement, uint16_t **mc_buf, uint16_t **pre, + SubpelParams *subpel_params, int *src_stride) { #if CONFIG_REFINEMV if (inter_pred_params->use_ref_padding) { common_calc_subpel_params_and_extend( - src_mv, inter_pred_params, xd, mi_x, mi_y, ref, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT + src_mv, inter_pred_params, xd, mi_x, mi_y, ref, use_optflow_refinement, mc_buf, pre, subpel_params, src_stride); return; } @@ -893,12 +870,9 @@ PadBlock block; MV32 scaled_mv; int subpel_x_mv, subpel_y_mv; - dec_calc_subpel_params(src_mv, inter_pred_params, xd, mi_x, mi_y, pre, - subpel_params, src_stride, &block, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - &scaled_mv, &subpel_x_mv, &subpel_y_mv); + dec_calc_subpel_params( + src_mv, inter_pred_params, xd, mi_x, mi_y, pre, subpel_params, src_stride, + &block, use_optflow_refinement, &scaled_mv, &subpel_x_mv, &subpel_y_mv); extend_mc_border(inter_pred_params->scale_factors, &inter_pred_params->ref_frame_buf, scaled_mv, block, subpel_x_mv, subpel_y_mv, @@ -6418,9 +6392,7 @@ seq_params->force_screen_content_tools = 2; // SELECT_SCREEN_CONTENT_TOOLS seq_params->force_integer_mv = 2; // SELECT_INTEGER_MV seq_params->order_hint_info.order_hint_bits_minus_1 = -1; -#if CONFIG_OPTFLOW_REFINEMENT seq_params->enable_opfl_refine = AOM_OPFL_REFINE_NONE; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT seq_params->enable_affine_refine = 0; #endif // CONFIG_AFFINE_REFINEMENT @@ -6558,7 +6530,6 @@ #if CONFIG_IDIF seq_params->enable_idif = aom_rb_read_bit(rb); #endif // CONFIG_IDIF -#if CONFIG_OPTFLOW_REFINEMENT seq_params->enable_opfl_refine = seq_params->order_hint_info.enable_order_hint ? aom_rb_read_literal(rb, 2) : AOM_OPFL_REFINE_NONE; @@ -6566,7 +6537,6 @@ seq_params->enable_affine_refine = seq_params->enable_opfl_refine ? aom_rb_read_bit(rb) : 0; #endif // CONFIG_AFFINE_REFINEMENT -#endif // CONFIG_OPTFLOW_REFINEMENT seq_params->enable_ibp = aom_rb_read_bit(rb); seq_params->enable_adaptive_mvd = aom_rb_read_bit(rb); @@ -7748,7 +7718,6 @@ #else features->switchable_motion_mode = aom_rb_read_bit(rb); #endif // CONFIG_EXTENDED_WARP_PREDICTION -#if CONFIG_OPTFLOW_REFINEMENT if (cm->seq_params.enable_opfl_refine == AOM_OPFL_REFINE_AUTO) { features->opfl_refine_type = aom_rb_read_literal(rb, 2); if (features->opfl_refine_type == AOM_OPFL_REFINE_AUTO) @@ -7757,7 +7726,6 @@ } else { features->opfl_refine_type = cm->seq_params.enable_opfl_refine; } -#endif // CONFIG_OPTFLOW_REFINEMENT } }
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c index 2ae0597..69589e6 100644 --- a/av1/decoder/decodemv.c +++ b/av1/decoder/decodemv.c
@@ -764,10 +764,8 @@ } static PREDICTION_MODE read_inter_compound_mode(MACROBLOCKD *xd, aom_reader *r, -#if CONFIG_OPTFLOW_REFINEMENT const AV1_COMMON *cm, MB_MODE_INFO *const mbmi, -#endif // CONFIG_OPTFLOW_REFINEMNET int16_t ctx) { #if CONFIG_AFFINE_REFINEMENT mbmi->comp_refine_type = cm->features.opfl_refine_type == REFINE_ALL @@ -776,7 +774,6 @@ : COMP_REFINE_SUBBLK2P) : COMP_REFINE_NONE; #endif // CONFIG_AFFINE_REFINEMENT -#if CONFIG_OPTFLOW_REFINEMENT int use_optical_flow = 0; const int mode = aom_read_symbol( r, xd->tile_ctx->inter_compound_mode_cdf[ctx], INTER_COMPOUND_REF_TYPES, @@ -811,11 +808,6 @@ return comp_idx_to_opfl_mode[mode]; } } -#else - const int mode = aom_read_symbol( - r, xd->tile_ctx->inter_compound_mode_cdf[ctx], INTER_COMPOUND_MODES, - ACCT_INFO("inter_compound_mode_cdf")); -#endif // CONFIG_OPTFLOW_REFINEMENT assert(is_inter_compound_mode(NEAR_NEARMV + mode)); return NEAR_NEARMV + mode; } @@ -2808,13 +2800,10 @@ FRAME_CONTEXT *ec_ctx = xd->tile_ctx; if (!av1_is_interp_needed(cm, xd)) { - set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(mbmi, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT interp_filter); return; } @@ -3157,10 +3146,7 @@ break; } case NEW_NEWMV: -#if CONFIG_OPTFLOW_REFINEMENT - case NEW_NEWMV_OPTFLOW: -#endif // CONFIG_OPTFLOW_REFINEMENT - { + case NEW_NEWMV_OPTFLOW: { assert(is_compound); #if CONFIG_DERIVED_MVD_SIGN num_signaled_mvd = 2; @@ -3188,20 +3174,14 @@ break; } case NEAR_NEARMV: -#if CONFIG_OPTFLOW_REFINEMENT - case NEAR_NEARMV_OPTFLOW: -#endif // CONFIG_OPTFLOW_REFINEMENT - { + case NEAR_NEARMV_OPTFLOW: { assert(is_compound); mv[0].as_int = ref_mv[0].as_int; mv[1].as_int = ref_mv[1].as_int; break; } case NEAR_NEWMV: -#if CONFIG_OPTFLOW_REFINEMENT - case NEAR_NEWMV_OPTFLOW: -#endif // CONFIG_OPTFLOW_REFINEMENT - { + case NEAR_NEWMV_OPTFLOW: { nmv_context *const nmvc = &ec_ctx->nmvc; mv[0].as_int = ref_mv[0].as_int; #if CONFIG_DERIVED_MVD_SIGN @@ -3229,10 +3209,7 @@ break; } case NEW_NEARMV: -#if CONFIG_OPTFLOW_REFINEMENT - case NEW_NEARMV_OPTFLOW: -#endif // CONFIG_OPTFLOW_REFINEMENT - { + case NEW_NEARMV_OPTFLOW: { nmv_context *const nmvc = &ec_ctx->nmvc; assert(is_compound); mv[1].as_int = ref_mv[1].as_int; @@ -3273,10 +3250,8 @@ .as_int; break; } -#if CONFIG_OPTFLOW_REFINEMENT case JOINT_NEWMV_OPTFLOW: case JOINT_AMVDNEWMV_OPTFLOW: -#endif // CONFIG_OPTFLOW_REFINEMENT case JOINT_AMVDNEWMV: case JOINT_NEWMV: { nmv_context *const nmvc = &ec_ctx->nmvc; @@ -3676,7 +3651,7 @@ assert(is_compound); #endif // !CONFIG_D072_SKIP_MODE_IMPROVE -#if CONFIG_SKIP_MODE_ENHANCEMENT && CONFIG_OPTFLOW_REFINEMENT +#if CONFIG_SKIP_MODE_ENHANCEMENT #if CONFIG_SKIP_MODE_NO_REFINEMENTS mbmi->mode = NEAR_NEARMV; #else @@ -3686,7 +3661,7 @@ #endif // CONFIG_SKIP_MODE_NO_REFINEMENTS #else mbmi->mode = NEAR_NEARMV; -#endif // CONFIG_SKIP_MODE_ENHANCEMENT && CONFIG_OPTFLOW_REFINEMENT +#endif // CONFIG_SKIP_MODE_ENHANCEMENT #if CONFIG_SKIP_MODE_ENHANCEMENT read_drl_idx(cm->features.max_drl_bits, @@ -3725,7 +3700,7 @@ #endif #endif // CONFIG_SKIP_MODE_ENHANCEMENT -#if CONFIG_SKIP_MODE_ENHANCEMENT && CONFIG_OPTFLOW_REFINEMENT +#if CONFIG_SKIP_MODE_ENHANCEMENT #if CONFIG_D072_SKIP_MODE_IMPROVE is_compound = has_second_ref(mbmi); if (!is_compound) { @@ -3751,7 +3726,7 @@ #endif // CONFIG_D072_SKIP_MODE_IMPROVE #else mbmi->mode = NEAR_NEARMV; -#endif // CONFIG_SKIP_MODE_ENHANCEMENT && CONFIG_OPTFLOW_REFINEMENT +#endif // CONFIG_SKIP_MODE_ENHANCEMENT #if CONFIG_AFFINE_REFINEMENT mbmi->comp_refine_type = mbmi->mode == NEAR_NEARMV_OPTFLOW ? COMP_REFINE_TYPE_FOR_SKIP @@ -3765,11 +3740,7 @@ const int16_t mode_ctx = av1_mode_context_analyzer(inter_mode_ctx, mbmi->ref_frame); if (is_compound) -#if CONFIG_OPTFLOW_REFINEMENT mbmi->mode = read_inter_compound_mode(xd, r, cm, mbmi, mode_ctx); -#else - mbmi->mode = read_inter_compound_mode(xd, r, mode_ctx); -#endif // CONFIG_OPTFLOW_REFINEMENT else mbmi->mode = read_inter_mode(ec_ctx, r, mode_ctx #if CONFIG_EXTENDED_WARP_PREDICTION @@ -3997,7 +3968,7 @@ #endif // CONFIG_D072_SKIP_MODE_IMPROVE if (mbmi->skip_mode) { -#if CONFIG_SKIP_MODE_ENHANCEMENT && CONFIG_OPTFLOW_REFINEMENT +#if CONFIG_SKIP_MODE_ENHANCEMENT #if CONFIG_D072_SKIP_MODE_IMPROVE #if CONFIG_SKIP_MODE_NO_REFINEMENTS assert(mbmi->mode == (!is_compound ? NEARMV : NEAR_NEARMV)); @@ -4027,7 +3998,7 @@ #endif // CONFIG_D072_SKIP_MODE_IMPROVE #else assert(mbmi->mode == NEAR_NEARMV); -#endif // CONFIG_SKIP_MODE_ENHANCEMENT && CONFIG_OPTFLOW_REFINEMENT +#endif // CONFIG_SKIP_MODE_ENHANCEMENT #if !CONFIG_SKIP_MODE_ENHANCEMENT assert(mbmi->ref_mv_idx == 0); @@ -4143,10 +4114,7 @@ mbmi->comp_group_idx = 0; mbmi->interinter_comp.type = COMPOUND_AVERAGE; - if (has_second_ref(mbmi) && -#if CONFIG_OPTFLOW_REFINEMENT - mbmi->mode < NEAR_NEARMV_OPTFLOW && -#endif // CONFIG_OPTFLOW_REFINEMENT + if (has_second_ref(mbmi) && mbmi->mode < NEAR_NEARMV_OPTFLOW && #if CONFIG_REFINEMV (!mbmi->refinemv_flag || !switchable_refinemv_flag(cm, mbmi)) && #endif // CONFIG_REFINEMV
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 9257380..28bf43e 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -285,13 +285,10 @@ static AOM_INLINE void write_inter_compound_mode(MACROBLOCKD *xd, aom_writer *w, PREDICTION_MODE mode, -#if CONFIG_OPTFLOW_REFINEMENT const AV1_COMMON *cm, const MB_MODE_INFO *const mbmi, -#endif // CONFIG_OPTFLOW_REFINEMENT const int16_t mode_ctx) { assert(is_inter_compound_mode(mode)); -#if CONFIG_OPTFLOW_REFINEMENT int comp_mode_idx = opfl_get_comp_idx(mode); aom_write_symbol(w, comp_mode_idx, xd->tile_ctx->inter_compound_mode_cdf[mode_ctx], @@ -323,11 +320,6 @@ aom_write_symbol(w, use_optical_flow, xd->tile_ctx->use_optflow_cdf[mode_ctx], 2); } -#else - aom_write_symbol(w, INTER_COMPOUND_OFFSET(mode), - xd->tile_ctx->inter_compound_mode_cdf[mode_ctx], - INTER_COMPOUND_MODES); -#endif // CONFIG_OPTFLOW_REFINEMENT } #if CONFIG_NEW_TX_PARTITION @@ -1322,7 +1314,6 @@ if (!av1_is_interp_needed(cm, xd)) { #if CONFIG_DEBUG -#if CONFIG_OPTFLOW_REFINEMENT // Sharp filter is always used whenever optical flow refinement is applied. int mb_interp_filter = (opfl_allowed_for_cur_block(cm, @@ -1337,16 +1328,12 @@ || is_tip_ref_frame(mbmi->ref_frame[0])) ? MULTITAP_SHARP : cm->features.interp_filter; -#else - int mb_interp_filter = cm->features.interp_filter; -#endif // CONFIG_OPTFLOW_REFINEMENT assert(mbmi->interp_fltr == av1_unswitchable_filter(mb_interp_filter)); (void)mb_interp_filter; #endif // CONFIG_DEBUG return; } if (cm->features.interp_filter == SWITCHABLE) { -#if CONFIG_OPTFLOW_REFINEMENT if (opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN xd, @@ -1359,7 +1346,6 @@ assert(mbmi->interp_fltr == MULTITAP_SHARP); return; } -#endif // CONFIG_OPTFLOW_REFINEMENT const int ctx = av1_get_pred_context_switchable_interp(xd, 0); const InterpFilter filter = mbmi->interp_fltr; aom_write_symbol(w, filter, ec_ctx->switchable_interp_cdf[ctx], @@ -2590,11 +2576,7 @@ // If segment skip is not enabled code the mode. if (!segfeature_active(seg, segment_id, SEG_LVL_SKIP)) { if (is_inter_compound_mode(mode)) - write_inter_compound_mode(xd, w, mode, -#if CONFIG_OPTFLOW_REFINEMENT - cm, mbmi, -#endif // CONFIG_OPTFLOW_REFINEMENT - mode_ctx); + write_inter_compound_mode(xd, w, mode, cm, mbmi, mode_ctx); else if (is_inter_singleref_mode(mode)) write_inter_mode(w, mode, ec_ctx, mode_ctx #if CONFIG_EXTENDED_WARP_PREDICTION @@ -2769,11 +2751,7 @@ nmvc, pb_mv_precision); #endif // CONFIG_VQ_MVD_CODING } - } else if (mode == NEAR_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == NEAR_NEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - || + } else if (mode == NEAR_NEWMV || mode == NEAR_NEWMV_OPTFLOW || (is_joint_mvd_coding_mode(mode) && jmvd_base_ref_list == 1)) { nmv_context *nmvc = &ec_ctx->nmvc; int_mv ref_mv = get_ref_mv(x, 1); @@ -2800,11 +2778,7 @@ nmvc, pb_mv_precision); #endif // CONFIG_VQ_MVD_CODING - } else if (mode == NEW_NEARMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == NEW_NEARMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - || + } else if (mode == NEW_NEARMV || mode == NEW_NEARMV_OPTFLOW || (is_joint_mvd_coding_mode(mode) && jmvd_base_ref_list == 0)) { nmv_context *nmvc = &ec_ctx->nmvc; int_mv ref_mv = get_ref_mv(x, 0); @@ -2945,10 +2919,7 @@ // group Group A (0): dist_wtd_comp, compound_average Group B (1): // interintra, compound_diffwtd, wedge - if (has_second_ref(mbmi) -#if CONFIG_OPTFLOW_REFINEMENT - && mbmi->mode < NEAR_NEARMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT + if (has_second_ref(mbmi) && mbmi->mode < NEAR_NEARMV_OPTFLOW #if CONFIG_REFINEMV && (!mbmi->refinemv_flag || !switchable_refinemv_flag(cm, mbmi)) #endif // CONFIG_REFINEMV @@ -5664,7 +5635,6 @@ #if CONFIG_IDIF aom_wb_write_bit(wb, seq_params->enable_idif); #endif // CONFIG_IDIF -#if CONFIG_OPTFLOW_REFINEMENT if (seq_params->order_hint_info.enable_order_hint) { aom_wb_write_literal(wb, seq_params->enable_opfl_refine, 2); #if CONFIG_AFFINE_REFINEMENT @@ -5672,7 +5642,6 @@ aom_wb_write_bit(wb, seq_params->enable_affine_refine); #endif // CONFIG_AFFINE_REFINEMENT } -#endif // CONFIG_OPTFLOW_REFINEMENT aom_wb_write_bit(wb, seq_params->enable_ibp); aom_wb_write_bit(wb, seq_params->enable_adaptive_mvd); @@ -6311,11 +6280,9 @@ #else aom_wb_write_bit(wb, features->switchable_motion_mode); #endif // CONFIG_EXTENDED_WARP_PREDICTION -#if CONFIG_OPTFLOW_REFINEMENT if (cm->seq_params.enable_opfl_refine == AOM_OPFL_REFINE_AUTO) { aom_wb_write_literal(wb, features->opfl_refine_type, 2); } -#endif // CONFIG_OPTFLOW_REFINEMENT } } }
diff --git a/av1/encoder/block.h b/av1/encoder/block.h index 8028de8..0a2c143 100644 --- a/av1/encoder/block.h +++ b/av1/encoder/block.h
@@ -1085,17 +1085,11 @@ int intra_inter_cost[INTRA_INTER_CONTEXTS][2]; #endif // CONFIG_CONTEXT_DERIVATION && !CONFIG_SKIP_TXFM_OPT -#if CONFIG_OPTFLOW_REFINEMENT /*! use_optflow_cost */ int use_optflow_cost[INTER_COMPOUND_MODE_CONTEXTS][2]; /*! inter_compound_mode_cost */ int inter_compound_mode_cost[INTER_COMPOUND_MODE_CONTEXTS] [INTER_COMPOUND_REF_TYPES]; -#else - /*! inter_compound_mode_cost */ - int inter_compound_mode_cost[INTER_COMPOUND_MODE_CONTEXTS] - [INTER_COMPOUND_MODES]; -#endif // CONFIG_OPTFLOW_REFINEMENT //! cwp_idx_cost for compound weighted prediction int cwp_idx_cost[MAX_CWP_CONTEXTS][MAX_CWP_NUM - 1][2];
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c index 3c07648..cb98f0c 100644 --- a/av1/encoder/compound_type.c +++ b/av1/encoder/compound_type.c
@@ -1003,7 +1003,6 @@ COMPOUND_TYPE *valid_comp_types) { int valid_type_count = 0; int comp_type, valid_check; -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_REFINEMV MACROBLOCKD *xd = &x->e_mbd; MB_MODE_INFO *mbmi = xd->mi[0]; const PREDICTION_MODE this_mode = mbmi->mode; @@ -1019,7 +1018,6 @@ valid_comp_types[0] = COMPOUND_AVERAGE; return 1; } -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_REFINEMV int8_t enable_masked_type[MASKED_COMPOUND_TYPES] = { 0, 0 }; const int try_average_comp = (mode_search_mask & (1 << COMPOUND_AVERAGE)); @@ -1495,11 +1493,9 @@ // The following context indices are independent of compound type const int comp_group_idx_ctx = get_comp_group_idx_context(cm, xd); -#if CONFIG_OPTFLOW_REFINEMENT if (this_mode >= NEAR_NEARMV_OPTFLOW) av1_zero_array(masked_type_cost, COMPOUND_TYPES); else -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV if (mbmi->refinemv_flag && switchable_refinemv_flag(cm, mbmi)) av1_zero_array(masked_type_cost, COMPOUND_TYPES); @@ -1516,10 +1512,7 @@ // If the match is found, calculate the rd cost using the // stored stats and update the mbmi appropriately. - if (match_found && -#if CONFIG_OPTFLOW_REFINEMENT - this_mode < NEAR_NEARMV_OPTFLOW && -#endif // CONFIG_OPTFLOW_REFINEMENT + if (match_found && this_mode < NEAR_NEARMV_OPTFLOW && #if CONFIG_REFINEMV (!mbmi->refinemv_flag || !switchable_refinemv_flag(cm, mbmi)) && #endif // CONFIG_REFINEMV
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 4aff20d..0eb3e32 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -1811,7 +1811,6 @@ rdc->compound_ref_used_flag = 0; rdc->skip_mode_used_flag = 0; -#if CONFIG_OPTFLOW_REFINEMENT if (cm->seq_params.enable_opfl_refine == AOM_OPFL_REFINE_AUTO) { // Auto mode: encoder decides which refine type to use for each frame. // For now, set all frame to REFINE_SWITCHABLE. The search or heuristic @@ -1821,7 +1820,6 @@ // 0: REFINE_NONE, 1: REFINE_SWTICHABLE, 2: REFINE_ALL features->opfl_refine_type = cm->seq_params.enable_opfl_refine; } -#endif // CONFIG_OPTFLOW_REFINEMENT encode_frame_internal(cpi);
diff --git a/av1/encoder/encodeframe.h b/av1/encoder/encodeframe.h index 7990195..598190d 100644 --- a/av1/encoder/encodeframe.h +++ b/av1/encoder/encodeframe.h
@@ -49,11 +49,9 @@ void av1_enc_calc_subpel_params(const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *xd, int mi_x, int mi_y, int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **mc_buf, uint16_t **pre, - SubpelParams *subpel_params, int *src_stride); + int use_optflow_refinement, uint16_t **mc_buf, + uint16_t **pre, SubpelParams *subpel_params, + int *src_stride); #ifdef __cplusplus } // extern "C" #endif
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c index 43e6cc3..b95df0a 100644 --- a/av1/encoder/encodeframe_utils.c +++ b/av1/encoder/encodeframe_utils.c
@@ -1520,13 +1520,8 @@ #if CONFIG_SKIP_MODE_ENHANCEMENT || CONFIG_OPTIMIZE_CTX_TIP_WARP AVERAGE_CDF(ctx_left->skip_drl_cdf, ctx_tr->skip_drl_cdf, 2); #endif // CONFIG_SKIP_MODE_ENHANCEMENT || CONFIG_OPTIMIZE_CTX_TIP_WARP -#if CONFIG_OPTFLOW_REFINEMENT AVERAGE_CDF(ctx_left->inter_compound_mode_cdf, ctx_tr->inter_compound_mode_cdf, INTER_COMPOUND_REF_TYPES); -#else - AVERAGE_CDF(ctx_left->inter_compound_mode_cdf, - ctx_tr->inter_compound_mode_cdf, INTER_COMPOUND_MODES); -#endif // CONFIG_OPTFLOW_REFINEMENT AVERAGE_CDF(ctx_left->cwp_idx_cdf, ctx_tr->cwp_idx_cdf, 2); AVERAGE_CDF(ctx_left->jmvd_scale_mode_cdf, ctx_tr->jmvd_scale_mode_cdf, JOINT_NEWMV_SCALE_FACTOR_CNT);
diff --git a/av1/encoder/encodemv.h b/av1/encoder/encodemv.h index e0d7b48..68aaca9 100644 --- a/av1/encoder/encodemv.h +++ b/av1/encoder/encodemv.h
@@ -141,32 +141,21 @@ MB_MODE_INFO *mbmi = xd->mi[0]; const PREDICTION_MODE this_mode = mbmi->mode; -#if CONFIG_OPTFLOW_REFINEMENT if (this_mode == NEW_NEWMV || this_mode == NEW_NEWMV_OPTFLOW) { -#else - if (this_mode == NEW_NEWMV) { -#endif // CONFIG_OPTFLOW_REFINEMENT const int_mv ref_mv_0 = av1_get_ref_mv(x, 0); const int_mv ref_mv_1 = av1_get_ref_mv(x, 1); if (mbmi->mv[0].as_int == ref_mv_0.as_int || mbmi->mv[1].as_int == ref_mv_1.as_int) { return 0; } -#if CONFIG_OPTFLOW_REFINEMENT } else if (this_mode == NEAR_NEWMV || this_mode == NEAR_NEWMV_OPTFLOW) { -#else - } else if (this_mode == NEAR_NEWMV) { -#endif // CONFIG_OPTFLOW_REFINEMENT const int_mv ref_mv_1 = av1_get_ref_mv(x, 1); if (mbmi->mv[1].as_int == ref_mv_1.as_int) { return 0; } - } else if (this_mode == NEW_NEARMV -#if CONFIG_OPTFLOW_REFINEMENT - || this_mode == NEW_NEARMV_OPTFLOW -#endif - || is_joint_mvd_coding_mode(this_mode)) { + } else if (this_mode == NEW_NEARMV || this_mode == NEW_NEARMV_OPTFLOW || + is_joint_mvd_coding_mode(this_mode)) { const int_mv ref_mv_0 = av1_get_ref_mv(x, 0); if (mbmi->mv[0].as_int == ref_mv_0.as_int) { return 0; @@ -193,11 +182,7 @@ const PREDICTION_MODE mode = mbmi->mode; if (is_pb_mv_precision_active(cm, mbmi, mbmi->sb_type[PLANE_TYPE_Y])) { - if (mode == NEWMV || mode == NEW_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == NEW_NEWMV_OPTFLOW -#endif - ) { + if (mode == NEWMV || mode == NEW_NEWMV || mode == NEW_NEWMV_OPTFLOW) { for (int i = 0; i < is_comp_pred + 1; ++i) { #if CONFIG_C071_SUBBLK_WARPMV MV diff = { mbmi->mv[i].as_mv.row, mbmi->mv[i].as_mv.col }; @@ -227,11 +212,7 @@ } } else { const int jmvd_base_ref_list = get_joint_mvd_base_ref_list(cm, mbmi); - const int i = (mode == JOINT_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mode == JOINT_NEWMV_OPTFLOW -#endif - ) + const int i = (mode == JOINT_NEWMV || mode == JOINT_NEWMV_OPTFLOW) ? jmvd_base_ref_list : (compound_ref1_mode(mode) == NEWMV); #if CONFIG_C071_SUBBLK_WARPMV
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index caee9eb..f18b681 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -420,9 +420,7 @@ #if CONFIG_LF_SUB_PU seq->enable_lf_sub_pu = tool_cfg->enable_lf_sub_pu; #endif // CONFIG_LF_SUB_PU -#if CONFIG_OPTFLOW_REFINEMENT seq->enable_opfl_refine = tool_cfg->enable_opfl_refine; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT seq->enable_affine_refine = tool_cfg->enable_affine_refine; #endif // CONFIG_AFFINE_REFINEMENT @@ -904,9 +902,7 @@ cm->features.switchable_motion_mode = 1; #endif // !CONFIG_EXTENDED_WARP_PREDICTION -#if CONFIG_OPTFLOW_REFINEMENT cm->features.opfl_refine_type = REFINE_SWITCHABLE; -#endif // CONFIG_OPTFLOW_REFINEMENT if (frm_dim_cfg->render_width > 0 && frm_dim_cfg->render_height > 0) { cm->render_width = frm_dim_cfg->render_width;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index ac9a943..bd6ce1c 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -925,10 +925,8 @@ #endif // CONFIG_IBC_BV_IMPROVEMENT && CONFIG_IBC_MAX_DRL // Indicates if ref MV Bank should be enabled. bool enable_refmvbank; -#if CONFIG_OPTFLOW_REFINEMENT // Indicates if optical flow refinement should be enabled aom_opfl_refine_type enable_opfl_refine; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT // Indicates if affine motion refinement should be enabled aom_opfl_refine_type enable_affine_refine; @@ -1529,20 +1527,9 @@ unsigned int cwp_idx_cnts[MAX_CWP_CONTEXTS][MAX_CWP_NUM - 1] [2]; // placeholder - -#if CONFIG_OPTFLOW_REFINEMENT - unsigned int use_optflow_cnts[INTER_COMPOUND_MODE_CONTEXTS] - [2]; // placeholder -#endif // CONFIG_OPTFLOW_REFINEMENT - -#if CONFIG_OPTFLOW_REFINEMENT unsigned int use_optflow[INTER_COMPOUND_MODE_CONTEXTS][2]; unsigned int inter_compound_mode[INTER_COMPOUND_MODE_CONTEXTS] [INTER_COMPOUND_REF_TYPES]; -#else - unsigned int inter_compound_mode[INTER_COMPOUND_MODE_CONTEXTS] - [INTER_COMPOUND_MODES]; -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_WEDGE_MOD_EXT #if CONFIG_D149_CTX_MODELING_OPT unsigned int wedge_angle_dir_cnt[2]; @@ -1739,11 +1726,7 @@ // TODO(angiebird): This is an estimated size. We still need to figure what is // the maximum number of modes. -#if CONFIG_OPTFLOW_REFINEMENT #define MAX_INTER_MODES 1536 * 6 -#else -#define MAX_INTER_MODES 1024 * 6 -#endif // CONFIG_OPTFLOW_REFINEMENT // TODO(any): rename this struct to something else. There is already another // struct called inter_mode_info, which makes this terribly confusing.
diff --git a/av1/encoder/encoder_utils.h b/av1/encoder/encoder_utils.h index 8d5f584..246ae21 100644 --- a/av1/encoder/encoder_utils.h +++ b/av1/encoder/encoder_utils.h
@@ -1139,9 +1139,7 @@ #if !CONFIG_EXTENDED_WARP_PREDICTION cm->features.switchable_motion_mode = 1; #endif // !CONFIG_EXTENDED_WARP_PREDICTION -#if CONFIG_OPTFLOW_REFINEMENT cm->features.opfl_refine_type = REFINE_SWITCHABLE; -#endif // CONFIG_OPTFLOW_REFINEMENT } static AOM_INLINE void release_scaled_references(AV1_COMP *cpi) {
diff --git a/av1/encoder/interp_search.c b/av1/encoder/interp_search.c index e861269..8f09250 100644 --- a/av1/encoder/interp_search.c +++ b/av1/encoder/interp_search.c
@@ -104,13 +104,10 @@ cpi->sf.interp_sf.use_interp_filter); if (!need_search || match_found_idx == -1) - set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - &cpi->common, + set_default_interp_filters(mbmi, &cpi->common, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT assign_filter); return match_found_idx; } @@ -126,11 +123,9 @@ static INLINE int get_switchable_rate(MACROBLOCK *const x, const InterpFilter interp_fltr, const int ctx[2]) { -#if CONFIG_OPTFLOW_REFINEMENT // When optical flow refinement is used, interp filter type is always set // to MULTITAP_SHARP, and thus is not switchable. assert(x->e_mbd.mi[0]->mode < NEAR_NEARMV_OPTFLOW); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV assert(!x->e_mbd.mi[0]->refinemv_flag); #endif // CONFIG_REFINEMV @@ -200,7 +195,6 @@ this_rd_stats = *rd_stats_luma; const InterpFilter last_best = mbmi->interp_fltr; mbmi->interp_fltr = filter_idx; -#if CONFIG_OPTFLOW_REFINEMENT const int tmp_rs = (opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN @@ -213,9 +207,6 @@ || is_tip_ref_frame(mbmi->ref_frame[0])) ? 0 : get_switchable_rate(x, mbmi->interp_fltr, switchable_ctx); -#else - const int tmp_rs = get_switchable_rate(x, mbmi->interp_fltr, switchable_ctx); -#endif // CONFIG_OPTFLOW_REFINEMENT int64_t min_rd = RDCOST(x->rdmult, tmp_rs, 0); if (min_rd > *rd) { @@ -353,12 +344,8 @@ struct macroblockd_plane *const pd = &xd->plane[plane_idx]; const int bw = pd->width; const int bh = pd->height; - const MV mv_q4 = - clamp_mv_to_umv_border_sb(xd, &mv, bw, bh, -#if CONFIG_OPTFLOW_REFINEMENT - 0, -#endif // CONFIG_OPTFLOW_REFINEMENT - pd->subsampling_x, pd->subsampling_y); + const MV mv_q4 = clamp_mv_to_umv_border_sb( + xd, &mv, bw, bh, 0, pd->subsampling_x, pd->subsampling_y); const int sub_x = (mv_q4.col & SUBPEL_MASK) << SCALE_EXTRA_BITS; const int sub_y = (mv_q4.row & SUBPEL_MASK) << SCALE_EXTRA_BITS; skip_hor_plane |= ((sub_x == 0) << plane_idx); @@ -462,7 +449,6 @@ int switchable_ctx[2]; switchable_ctx[0] = av1_get_pred_context_switchable_interp(xd, 0); switchable_ctx[1] = av1_get_pred_context_switchable_interp(xd, 1); -#if CONFIG_OPTFLOW_REFINEMENT *switchable_rate = (opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN @@ -475,9 +461,6 @@ || is_tip_ref_frame(mbmi->ref_frame[0])) ? 0 : get_switchable_rate(x, mbmi->interp_fltr, switchable_ctx); -#else - *switchable_rate = get_switchable_rate(x, mbmi->interp_fltr, switchable_ctx); -#endif // CONFIG_OPTFLOW_REFINEMENT // Do MC evaluation for default filter_type. // Luma MC @@ -507,7 +490,6 @@ return 0; } if (!need_search) { -#if CONFIG_OPTFLOW_REFINEMENT #if CONFIG_REFINEMV assert(mbmi->interp_fltr == ((opfl_allowed_for_cur_block(cm, @@ -528,33 +510,24 @@ ? MULTITAP_SHARP : EIGHTTAP_REGULAR)); #endif // CONFIG_REFINEMV -#else - assert(mbmi->interp_fltr == EIGHTTAP_REGULAR); -#endif // CONFIG_OPTFLOW_REFINEMENT return 0; } if (args->modelled_rd != NULL) { #if CONFIG_REFINEMV - int use_default_filter = mbmi->refinemv_flag -#if CONFIG_OPTFLOW_REFINEMENT - || opfl_allowed_for_cur_block(cm, + int use_default_filter = mbmi->refinemv_flag || + opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN - xd, + xd, #endif // CONFIG_COMPOUND_4XN - mbmi) -#endif - || is_tip_ref_frame(mbmi->ref_frame[0]); + mbmi) || + is_tip_ref_frame(mbmi->ref_frame[0]); if (has_second_ref(mbmi) && !use_default_filter) { #else -#if CONFIG_OPTFLOW_REFINEMENT if (has_second_ref(mbmi) && !opfl_allowed_for_cur_block(cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN mbmi)) { -#else - if (has_second_ref(mbmi)) { -#endif // CONFIG_OPTFLOW_REFINEMENT #endif // CONFIG_REFINEMV #if !CONFIG_SEP_COMP_DRL const int ref_mv_idx = mbmi->ref_mv_idx;
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c index 78772dc..d64f423 100644 --- a/av1/encoder/mcomp.c +++ b/av1/encoder/mcomp.c
@@ -4904,13 +4904,10 @@ const int mi_row = xd->mi_row; const int mi_col = xd->mi_col; - set_default_interp_filters(xd->mi[0], -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(xd->mi[0], cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, bsize, AOM_PLANE_Y, AOM_PLANE_Y); @@ -5207,12 +5204,9 @@ } } } - } else if (mbmi->mode == NEAR_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mbmi->mode == NEAR_NEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - || (is_joint_mvd_coding_mode(mbmi->mode) && - jmvd_base_ref_list == 1)) { + } else if (mbmi->mode == NEAR_NEWMV || mbmi->mode == NEAR_NEWMV_OPTFLOW || + (is_joint_mvd_coding_mode(mbmi->mode) && + jmvd_base_ref_list == 1)) { const int_mv ref_mv = av1_get_ref_mv(x, 1); get_mvd_from_ref_mv(mbmi->mv[1].as_mv, ref_mv.as_mv, is_adaptive_mvd, pb_mv_precision, &mv_diffs[1]); @@ -5228,12 +5222,9 @@ num_nonzero_mvd_comp++; } } - } else if (mbmi->mode == NEW_NEARMV -#if CONFIG_OPTFLOW_REFINEMENT - || mbmi->mode == NEW_NEARMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - || (is_joint_mvd_coding_mode(mbmi->mode) && - jmvd_base_ref_list == 0)) { + } else if (mbmi->mode == NEW_NEARMV || mbmi->mode == NEW_NEARMV_OPTFLOW || + (is_joint_mvd_coding_mode(mbmi->mode) && + jmvd_base_ref_list == 0)) { const int_mv ref_mv = av1_get_ref_mv(x, 0); get_mvd_from_ref_mv(mbmi->mv[0].as_mv, ref_mv.as_mv, is_adaptive_mvd, pb_mv_precision, &mv_diffs[0]);
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c index 8df4645..48cf35f 100644 --- a/av1/encoder/motion_search_facade.c +++ b/av1/encoder/motion_search_facade.c
@@ -1088,11 +1088,7 @@ #if CONFIG_VQ_MVD_CODING if (bestsme == INT_MAX) best_mv.as_int = INVALID_MV; #endif // CONFIG_VQ_MVD_CODING - } else if (mbmi->mode == JOINT_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mbmi->mode == JOINT_NEWMV_OPTFLOW -#endif - ) { + } else if (mbmi->mode == JOINT_NEWMV || mbmi->mode == JOINT_NEWMV_OPTFLOW) { int dis; /* TODO: use dis in distortion calculation later. */ unsigned int sse; SUBPEL_MOTION_SEARCH_PARAMS ms_params; @@ -1114,13 +1110,8 @@ &best_other_mv.as_mv, second_pred, &inter_pred_params, NULL); } - } else -#if CONFIG_OPTFLOW_REFINEMENT - if (mbmi->mode == JOINT_AMVDNEWMV || - mbmi->mode == JOINT_AMVDNEWMV_OPTFLOW) { -#else - if (mbmi->mode == JOINT_AMVDNEWMV) { -#endif + } else if (mbmi->mode == JOINT_AMVDNEWMV || + mbmi->mode == JOINT_AMVDNEWMV_OPTFLOW) { int dis; /* TODO: use dis in distortion calculation later. */ unsigned int sse; SUBPEL_MOTION_SEARCH_PARAMS ms_params; @@ -1362,11 +1353,7 @@ mbmi->interinter_comp.seg_mask = xd->seg_mask; const INTERINTER_COMPOUND_DATA *compound_data = &mbmi->interinter_comp; -#if CONFIG_OPTFLOW_REFINEMENT if (this_mode == NEW_NEWMV || this_mode == NEW_NEWMV_OPTFLOW) { -#else - if (this_mode == NEW_NEWMV) { -#endif // CONFIG_OPTFLOW_REFINEMENT do_masked_motion_search_indexed(cpi, x, cur_mv, compound_data, bsize, tmp_mv, &tmp_rate_mv, 2); mbmi->mv[0].as_int = tmp_mv[0].as_int;
diff --git a/av1/encoder/mv_prec.c b/av1/encoder/mv_prec.c index f8603f4..61db6e6 100644 --- a/av1/encoder/mv_prec.c +++ b/av1/encoder/mv_prec.c
@@ -637,10 +637,7 @@ MvSubpelPrecision pb_mv_precision = mbmi->pb_mv_precision; const int most_probable_pb_mv_precision = mbmi->most_probable_pb_mv_precision; - if (mode == NEWMV || mode == AMVDNEWMV || -#if CONFIG_OPTFLOW_REFINEMENT - mode == NEW_NEWMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT + if (mode == NEWMV || mode == AMVDNEWMV || mode == NEW_NEWMV_OPTFLOW || mode == NEW_NEWMV) { // All mvs are new for (int ref_idx = 0; ref_idx < 1 + is_compound; ++ref_idx) { @@ -663,15 +660,9 @@ } else if (have_nearmv_newmv_in_inter_mode(mode)) { // has exactly one new_mv mv_stats->default_mvs += 1; -#if CONFIG_OPTFLOW_REFINEMENT int ref_idx = is_joint_mvd_coding_mode(mbmi->mode) ? get_joint_mvd_base_ref_list(cm, mbmi) : (mode == NEAR_NEWMV || mode == NEAR_NEWMV_OPTFLOW); -#else - int ref_idx = is_joint_mvd_coding_mode(mbmi->mode) - ? get_joint_mvd_base_ref_list(cm, mbmi) - : (mode == NEAR_NEWMV); -#endif // CONFIG_OPTFLOW_REFINEMENT const MV ref_mv = get_ref_mv_for_mv_stats(mbmi, mbmi_ext_frame, ref_idx).as_mv;
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c index 4e701ae..6accad3 100644 --- a/av1/encoder/partition_search.c +++ b/av1/encoder/partition_search.c
@@ -1932,10 +1932,7 @@ mbmi->comp_group_idx == 0 && mbmi->interinter_comp.type == COMPOUND_AVERAGE)); #endif // CONFIG_REFINEMV - if (has_second_ref(mbmi) -#if CONFIG_OPTFLOW_REFINEMENT - && mbmi->mode < NEAR_NEARMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT + if (has_second_ref(mbmi) && mbmi->mode < NEAR_NEARMV_OPTFLOW #if CONFIG_REFINEMV && (!mbmi->refinemv_flag || !is_refinemv_signaled) #endif // CONFIG_REFINEMV @@ -2028,7 +2025,6 @@ const int16_t mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context, mbmi->ref_frame); if (has_second_ref(mbmi)) { -#if CONFIG_OPTFLOW_REFINEMENT if (cm->features.opfl_refine_type == REFINE_SWITCHABLE && opfl_allowed_for_cur_refs(cm, #if CONFIG_COMPOUND_4XN @@ -2061,13 +2057,6 @@ #endif update_cdf(fc->inter_compound_mode_cdf[mode_ctx], comp_mode_idx, INTER_COMPOUND_REF_TYPES); -#else -#if CONFIG_ENTROPY_STATS - ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET(mode)]; -#endif - update_cdf(fc->inter_compound_mode_cdf[mode_ctx], - INTER_COMPOUND_OFFSET(mode), INTER_COMPOUND_MODES); -#endif // CONFIG_OPTFLOW_REFINEMENT if (is_joint_mvd_coding_mode(mbmi->mode)) { const int is_joint_amvd_mode = is_joint_amvd_coding_mode(mbmi->mode); aom_cdf_prob *jmvd_scale_mode_cdf = is_joint_amvd_mode @@ -2204,11 +2193,8 @@ #endif // CONFIG_VQ_MVD_CODING } } else if (have_nearmv_newmv_in_inter_mode(mbmi->mode)) { - const int ref = -#if CONFIG_OPTFLOW_REFINEMENT - mbmi->mode == NEAR_NEWMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT - jmvd_base_ref_list || mbmi->mode == NEAR_NEWMV; + const int ref = mbmi->mode == NEAR_NEWMV_OPTFLOW || + jmvd_base_ref_list || mbmi->mode == NEAR_NEWMV; const int_mv ref_mv = av1_get_ref_mv(x, ref); #if CONFIG_DERIVED_MVD_SIGN num_signaled_mvd = 1;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c index cf481bb..15cbd58 100644 --- a/av1/encoder/rd.c +++ b/av1/encoder/rd.c
@@ -662,11 +662,9 @@ } #endif // CONFIG_SKIP_MODE_ENHANCEMENT || CONFIG_OPTIMIZE_CTX_TIP_WARP -#if CONFIG_OPTFLOW_REFINEMENT for (i = 0; i < INTER_COMPOUND_MODE_CONTEXTS; ++i) av1_cost_tokens_from_cdf(mode_costs->use_optflow_cost[i], fc->use_optflow_cdf[i], NULL); -#endif // CONFIG_OPTFLOW_REFINEMENT for (j = 0; j < NUM_MV_PREC_MPP_CONTEXT; ++j) { av1_cost_tokens_from_cdf(mode_costs->pb_block_mv_mpp_flag_costs[j], @@ -2106,9 +2104,7 @@ InterpFilter interp_filter) { if (interp_filter == SWITCHABLE) { const MB_MODE_INFO *const mbmi = xd->mi[0]; -#if CONFIG_OPTFLOW_REFINEMENT assert(mbmi->mode < NEAR_NEARMV_OPTFLOW); -#endif // CONFIG_OPTFLOW_REFINEMENT const int ctx = av1_get_pred_context_switchable_interp(xd, 0); const int inter_filter_cost = x->mode_costs.switchable_interp_costs[ctx][mbmi->interp_fltr];
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 31268fa..9df3129 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -475,15 +475,12 @@ } static int cost_mv_ref(const ModeCosts *const mode_costs, PREDICTION_MODE mode, -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION const AV1_COMMON *cm, const MB_MODE_INFO *const mbmi, -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION #if CONFIG_EXTENDED_WARP_PREDICTION const MACROBLOCKD *xd, #endif // CONFIG_EXTENDED_WARP_PREDICTION int16_t mode_context) { if (is_inter_compound_mode(mode)) { -#if CONFIG_OPTFLOW_REFINEMENT int use_optical_flow_cost = 0; const int comp_mode_idx = opfl_get_comp_idx(mode); if (cm->features.opfl_refine_type == REFINE_SWITCHABLE && @@ -515,10 +512,6 @@ } return use_optical_flow_cost + mode_costs->inter_compound_mode_cost[mode_context][comp_mode_idx]; -#else - return mode_costs - ->inter_compound_mode_cost[mode_context][INTER_COMPOUND_OFFSET(mode)]; -#endif // CONFIG_OPTFLOW_REFINEMENT } assert(is_inter_mode(mode)); @@ -916,7 +909,6 @@ } const int16_t mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context, ref_frames); -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION const MB_MODE_INFO *const mbmi = x->e_mbd.mi[0]; const int compare_cost = cost_mv_ref(&x->mode_costs, compare_mode, cm, mbmi, #if CONFIG_EXTENDED_WARP_PREDICTION @@ -928,10 +920,6 @@ &x->e_mbd, #endif // CONFIG_EXTENDED_WARP_PREDICTION mode_ctx); -#else - const int compare_cost = cost_mv_ref(&x->mode_costs, compare_mode, mode_ctx); - const int this_cost = cost_mv_ref(&x->mode_costs, this_mode, mode_ctx); -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION // Only skip if the mode cost is larger than compare mode cost if (this_cost > compare_cost) { @@ -1031,7 +1019,6 @@ const int valid_mv0 = valid_mv0_found; const int valid_mv1 = valid_mv1_found; -#if CONFIG_OPTFLOW_REFINEMENT if (this_mode == NEW_NEWMV || this_mode == NEW_NEWMV_OPTFLOW) { #if CONFIG_SKIP_ME_FOR_OPFL_MODES if (this_mode == NEW_NEWMV_OPTFLOW && @@ -1070,9 +1057,6 @@ } } else { #endif // CONFIG_SKIP_ME_FOR_OPFL_MODES -#else - if (this_mode == NEW_NEWMV) { -#endif // CONFIG_OPTFLOW_REFINEMENT if (valid_mv0) { cur_mv[0].as_int = #if CONFIG_SEP_COMP_DRL @@ -1128,14 +1112,14 @@ #if CONFIG_SEP_COMP_DRL [av1_ref_mv_idx_type(mbmi, mbmi->ref_mv_idx)] #else - [mbmi->ref_mv_idx] + [mbmi->ref_mv_idx] #endif [pb_mv_precision] = 1; args->comp_newmv[av1_ref_frame_type(mbmi->ref_frame)] #if CONFIG_SEP_COMP_DRL [av1_ref_mv_idx_type(mbmi, mbmi->ref_mv_idx)] #else - [mbmi->ref_mv_idx] + [mbmi->ref_mv_idx] #endif [pb_mv_precision][0] .as_int = cur_mv[0].as_int; @@ -1143,18 +1127,14 @@ #if CONFIG_SEP_COMP_DRL [av1_ref_mv_idx_type(mbmi, mbmi->ref_mv_idx)] #else - [mbmi->ref_mv_idx] + [mbmi->ref_mv_idx] #endif [pb_mv_precision][1] .as_int = cur_mv[1].as_int; } } #endif // CONFIG_SKIP_ME_FOR_OPFL_MODES -#if CONFIG_OPTFLOW_REFINEMENT } else if (this_mode == NEAR_NEWMV || this_mode == NEAR_NEWMV_OPTFLOW) { -#else - } else if (this_mode == NEAR_NEWMV) { -#endif // CONFIG_OPTFLOW_REFINEMENT if (valid_mv1) { cur_mv[1].as_int = #if CONFIG_SEP_COMP_DRL @@ -1241,11 +1221,7 @@ if (cur_mv->as_int == INVALID_MV) return INT64_MAX; #endif // CONFIG_VQ_MVD_CODING } else { -#if CONFIG_OPTFLOW_REFINEMENT assert(this_mode == NEW_NEARMV || this_mode == NEW_NEARMV_OPTFLOW); -#else - assert(this_mode == NEW_NEARMV); -#endif // CONFIG_OPTFLOW_REFINEMENT if (valid_mv0) { cur_mv[0].as_int = #if CONFIG_SEP_COMP_DRL @@ -3901,10 +3877,7 @@ mbmi->mv[i].as_int = cur_mv[i].as_int; } - const int ref_mv_cost = cost_mv_ref(mode_costs, mbmi->mode, -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION - cm, mbmi, -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION + const int ref_mv_cost = cost_mv_ref(mode_costs, mbmi->mode, cm, mbmi, #if CONFIG_EXTENDED_WARP_PREDICTION xd, #endif // CONFIG_EXTENDED_WARP_PREDICTION @@ -3929,13 +3902,10 @@ mbmi->interinter_comp.type = COMPOUND_AVERAGE; mbmi->comp_group_idx = 0; } - set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(mbmi, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); const int mi_row = xd->mi_row; @@ -5209,10 +5179,7 @@ av1_mode_context_analyzer(mbmi_ext->mode_context, mbmi->ref_frame); const ModeCosts *mode_costs = &x->mode_costs; - const int ref_mv_cost = cost_mv_ref(mode_costs, this_mode, -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION - cm, mbmi, -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXTENDED_WARP_PREDICTION + const int ref_mv_cost = cost_mv_ref(mode_costs, this_mode, cm, mbmi, #if CONFIG_EXTENDED_WARP_PREDICTION xd, #endif // CONFIG_EXTENDED_WARP_PREDICTION @@ -5994,9 +5961,7 @@ #if CONFIG_EXTENDED_WARP_PREDICTION mbmi->mode == WARPMV || #endif // CONFIG_EXTENDED_WARP_PREDICTION -#if CONFIG_OPTFLOW_REFINEMENT mbmi->mode == NEAR_NEARMV_OPTFLOW || -#endif // CONFIG_OPTFLOW_REFINEMENT mbmi->mode == NEAR_NEARMV) && #if CONFIG_SEP_COMP_DRL mbmi->ref_mv_idx[0] == 0 && @@ -6135,11 +6100,7 @@ #endif // CONFIG_EXTENDED_WARP_PREDICTION // Compute modelled RD if enabled if (args->modelled_rd != NULL) { -#if CONFIG_OPTFLOW_REFINEMENT if (is_comp_pred && this_mode < NEAR_NEARMV_OPTFLOW) { -#else - if (is_comp_pred) { -#endif // CONFIG_OPTFLOW_REFINEMENT const int mode0 = compound_ref0_mode(this_mode); const int mode1 = compound_ref1_mode(this_mode); const int64_t mrd = @@ -7354,7 +7315,7 @@ const MV_REFERENCE_FRAME ref_frame = skip_mode_info->ref_frame_idx_0; const MV_REFERENCE_FRAME second_ref_frame = skip_mode_info->ref_frame_idx_1; -#if CONFIG_OPTFLOW_REFINEMENT && !CONFIG_SKIP_MODE_NO_REFINEMENTS +#if !CONFIG_SKIP_MODE_NO_REFINEMENTS const PREDICTION_MODE this_mode = cm->features.opfl_refine_type == REFINE_SWITCHABLE && opfl_allowed_for_cur_refs(cm, @@ -7367,7 +7328,7 @@ : NEAR_NEARMV; #else const PREDICTION_MODE this_mode = NEAR_NEARMV; -#endif // CONFIG_OPTFLOW_REFINEMENT && !CONFIG_SKIP_MODE_NO_REFINEMENTS +#endif // !CONFIG_SKIP_MODE_NO_REFINEMENTS if ((!cpi->oxcf.ref_frm_cfg.enable_onesided_comp || cpi->sf.inter_sf.disable_onesided_comp) && @@ -7433,7 +7394,7 @@ } #endif // CONFIG_SKIP_MODE_ENHANCEMENT -#if CONFIG_OPTFLOW_REFINEMENT && !CONFIG_SKIP_MODE_NO_REFINEMENTS +#if !CONFIG_SKIP_MODE_NO_REFINEMENTS assert(this_mode == (cm->features.opfl_refine_type == REFINE_SWITCHABLE && opfl_allowed_for_cur_refs(cm, #if CONFIG_COMPOUND_4XN @@ -7445,7 +7406,7 @@ : NEAR_NEARMV)); #else assert(this_mode == NEAR_NEARMV); -#endif // CONFIG_OPTFLOW_REFINEMENT && !CONFIG_SKIP_MODE_NO_REFINEMENTS +#endif // !CONFIG_SKIP_MODE_NO_REFINEMENTS #if !CONFIG_SKIP_MODE_ENHANCEMENT if (!build_cur_mv(mbmi->mv, this_mode, cm, x, 0)) { @@ -7489,13 +7450,10 @@ mbmi->warpmv_with_mvd_flag = 0; #endif // CONFIG_EXTENDED_WARP_PREDICTION - set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(mbmi, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); #if CONFIG_SKIP_MODE_ENHANCEMENT @@ -7709,7 +7667,7 @@ search_state->best_mbmode.fsc_mode[xd->tree_type == CHROMA_PART] = 0; -#if CONFIG_OPTFLOW_REFINEMENT && !CONFIG_SKIP_MODE_NO_REFINEMENTS +#if !CONFIG_SKIP_MODE_NO_REFINEMENTS search_state->best_mbmode.mode = #if CONFIG_D072_SKIP_MODE_IMPROVE !is_compound ? NEARMV : @@ -7729,7 +7687,7 @@ !is_compound ? NEARMV : #endif // CONFIG_D072_SKIP_MODE_IMPROVE NEAR_NEARMV; -#endif // CONFIG_OPTFLOW_REFINEMENT && !CONFIG_SKIP_MODE_NO_REFINEMENTS +#endif // !CONFIG_SKIP_MODE_NO_REFINEMENTS #if CONFIG_AFFINE_REFINEMENT search_state->best_mbmode.comp_refine_type = search_state->best_mbmode.mode == NEAR_NEARMV_OPTFLOW @@ -7805,13 +7763,10 @@ (INTERINTRA_MODE)(II_DC_PRED - 1); search_state->best_mbmode.filter_intra_mode_info.use_filter_intra = 0; - set_default_interp_filters(&search_state->best_mbmode, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(&search_state->best_mbmode, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); #if CONFIG_REFINEMV search_state->best_mbmode.refinemv_flag = mbmi->refinemv_flag; @@ -7916,13 +7871,10 @@ #endif // CONFIG_SEP_COMP_DRL mbmi->skip_mode = mbmi->skip_txfm[xd->tree_type == CHROMA_PART] = 1; - set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(mbmi, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); set_mv_precision(mbmi, mbmi->max_mv_precision); @@ -8011,13 +7963,10 @@ (INTERINTRA_MODE)(II_DC_PRED - 1); search_state->best_mbmode.filter_intra_mode_info.use_filter_intra = 0; - set_default_interp_filters(&search_state->best_mbmode, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(&search_state->best_mbmode, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); // Update rd_cost @@ -8804,23 +8753,12 @@ // If the mode is single, we know the modes can't match. But we might // still want to search it if compound mode depends on the current mode. int skip_motion_mode_only = 0; - if (cached_mode == NEW_NEARMV -#if CONFIG_OPTFLOW_REFINEMENT - || cached_mode == NEW_NEARMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - ) { + if (cached_mode == NEW_NEARMV || cached_mode == NEW_NEARMV_OPTFLOW) { skip_motion_mode_only = (ref_frame[0] == cached_frame[0]); - } else if (cached_mode == NEAR_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || cached_mode == NEAR_NEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - ) { + } else if (cached_mode == NEAR_NEWMV || + cached_mode == NEAR_NEWMV_OPTFLOW) { skip_motion_mode_only = (ref_frame[0] == cached_frame[1]); - } else if (cached_mode == NEW_NEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || cached_mode == NEW_NEWMV_OPTFLOW -#endif // CONFIG_OPTFLOW_REFINEMENT - ) { + } else if (cached_mode == NEW_NEWMV || cached_mode == NEW_NEWMV_OPTFLOW) { skip_motion_mode_only = (ref_frame[0] == cached_frame[0] || ref_frame[0] == cached_frame[1]); } else if (is_joint_mvd_coding_mode(cached_mode)) { @@ -8995,13 +8933,10 @@ mbmi->is_wide_angle[1] = 0; #endif // CONFIG_NEW_TX_PARTITION #endif // CONFIG_WAIP - set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT - cm, + set_default_interp_filters(mbmi, cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT cm->features.interp_filter); #if CONFIG_IBC_SR_EXT mbmi->use_intrabc[xd->tree_type == CHROMA_PART] = 0; @@ -9628,10 +9563,8 @@ // Skip this compound mode based on the RD results from the single // prediction modes if (sf->inter_sf.prune_comp_search_by_single_result > 0 && -#if CONFIG_OPTFLOW_REFINEMENT - this_mode < NEAR_NEARMV_OPTFLOW && -#endif // CONFIG_OPTFLOW_REFINEMENT - comp_pred && !has_second_drl(xd->mi[0])) { + this_mode < NEAR_NEARMV_OPTFLOW && comp_pred && + !has_second_drl(xd->mi[0])) { if (compound_skip_by_single_states(cpi, args->search_state, this_mode, ref_frame, second_ref_frame, x)) return 1; @@ -10291,7 +10224,6 @@ if (is_pb_mv_precision_active(cm, mbmi, bsize)) set_most_probable_mv_precision(cm, mbmi, bsize); -#if CONFIG_OPTFLOW_REFINEMENT // Initialize compound average type for optical flow refinement mbmi->interinter_comp.type = COMPOUND_AVERAGE; @@ -10311,8 +10243,6 @@ continue; #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT - #if CONFIG_AFFINE_REFINEMENT // Search compound refine type const int allowed_comp_refine_mask = @@ -10332,11 +10262,8 @@ ref_frames, &sf_args)) continue; - if ((this_mode == AMVDNEWMV || mbmi->mode == JOINT_AMVDNEWMV -#if CONFIG_OPTFLOW_REFINEMENT - || mbmi->mode == JOINT_AMVDNEWMV_OPTFLOW -#endif - ) && + if ((this_mode == AMVDNEWMV || mbmi->mode == JOINT_AMVDNEWMV || + mbmi->mode == JOINT_AMVDNEWMV_OPTFLOW) && cm->seq_params.enable_adaptive_mvd == 0) continue; @@ -11098,12 +11025,10 @@ const InterpFilter interp_filter = features->interp_filter; set_default_interp_filters(mbmi, -#if CONFIG_OPTFLOW_REFINEMENT cm, #if CONFIG_COMPOUND_4XN xd, #endif // CONFIG_COMPOUND_4XN -#endif // CONFIG_OPTFLOW_REFINEMENT interp_filter); if (interp_filter != SWITCHABLE) {
diff --git a/av1/encoder/reconinter_enc.c b/av1/encoder/reconinter_enc.c index 82cf2d2..73636b1 100644 --- a/av1/encoder/reconinter_enc.c +++ b/av1/encoder/reconinter_enc.c
@@ -32,18 +32,13 @@ void av1_enc_calc_subpel_params(const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *xd, int mi_x, int mi_y, int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **mc_buf, uint16_t **pre, - SubpelParams *subpel_params, int *src_stride) { + int use_optflow_refinement, uint16_t **mc_buf, + uint16_t **pre, SubpelParams *subpel_params, + int *src_stride) { #if CONFIG_REFINEMV if (inter_pred_params->use_ref_padding) { common_calc_subpel_params_and_extend( - src_mv, inter_pred_params, xd, mi_x, mi_y, ref, -#if CONFIG_OPTFLOW_REFINEMENT - use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT + src_mv, inter_pred_params, xd, mi_x, mi_y, ref, use_optflow_refinement, mc_buf, pre, subpel_params, src_stride); return; } @@ -59,15 +54,12 @@ const struct scale_factors *sf = inter_pred_params->scale_factors; struct buf_2d *pre_buf = &inter_pred_params->ref_frame_buf; -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXT_RECUR_PARTITIONS const int is_scaled = av1_is_scaled(sf); if (is_scaled || !xd) { -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXT_RECUR_PARTITIONS int ssx = inter_pred_params->subsampling_x; int ssy = inter_pred_params->subsampling_y; int orig_pos_y = inter_pred_params->pix_row << SUBPEL_BITS; int orig_pos_x = inter_pred_params->pix_col << SUBPEL_BITS; -#if CONFIG_OPTFLOW_REFINEMENT if (use_optflow_refinement) { orig_pos_y += ROUND_POWER_OF_TWO_SIGNED(src_mv->row * (1 << SUBPEL_BITS), MV_REFINE_PREC_BITS + ssy); @@ -77,10 +69,6 @@ orig_pos_y += src_mv->row * (1 << (1 - ssy)); orig_pos_x += src_mv->col * (1 << (1 - ssx)); } -#else - orig_pos_y += src_mv->row * (1 << (1 - ssy)); - orig_pos_x += src_mv->col * (1 << (1 - ssx)); -#endif // CONFIG_OPTFLOW_REFINEMENT int pos_y = sf->scale_value_y(orig_pos_y, sf); int pos_x = sf->scale_value_x(orig_pos_x, sf); pos_x += SCALE_EXTRA_OFF; @@ -118,28 +106,18 @@ *pre = pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride + (pos_x >> SCALE_SUBPEL_BITS); -#if CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXT_RECUR_PARTITIONS } else { int pos_x = inter_pred_params->pix_col << SUBPEL_BITS; int pos_y = inter_pred_params->pix_row << SUBPEL_BITS; #if CONFIG_REFINEMV -#if CONFIG_OPTFLOW_REFINEMENT const int bw = inter_pred_params->original_pu_width; const int bh = inter_pred_params->original_pu_height; const MV mv_q4 = clamp_mv_to_umv_border_sb( xd, src_mv, bw, bh, use_optflow_refinement, inter_pred_params->subsampling_x, inter_pred_params->subsampling_y); -#else - const int bw = inter_pred_params->original_pu_width; - const int bh = inter_pred_params->original_pu_height; - const MV mv_q4 = clamp_mv_to_umv_border_sb( - xd, src_mv, bw, bh, inter_pred_params->subsampling_x, - inter_pred_params->subsampling_y); -#endif // CONFIG_OPTFLOW_REFINEMENT #else -#if CONFIG_OPTFLOW_REFINEMENT const int bw = use_optflow_refinement ? inter_pred_params->orig_block_width : inter_pred_params->block_width; const int bh = use_optflow_refinement ? inter_pred_params->orig_block_height @@ -147,13 +125,6 @@ const MV mv_q4 = clamp_mv_to_umv_border_sb( xd, src_mv, bw, bh, use_optflow_refinement, inter_pred_params->subsampling_x, inter_pred_params->subsampling_y); -#else - const int bw = inter_pred_params->block_width; - const int bh = inter_pred_params->block_height; - const MV mv_q4 = clamp_mv_to_umv_border_sb( - xd, src_mv, bw, bh, inter_pred_params->subsampling_x, - inter_pred_params->subsampling_y); -#endif // CONFIG_OPTFLOW_REFINEMENT #endif // CONFIG_REFINEMV subpel_params->xs = subpel_params->ys = SCALE_SUBPEL_SHIFTS; @@ -176,7 +147,6 @@ *pre = pre_buf->buf0 + (pos_y >> SUBPEL_BITS) * pre_buf->stride + (pos_x >> SUBPEL_BITS); } -#endif // CONFIG_OPTFLOW_REFINEMENT || CONFIG_EXT_RECUR_PARTITIONS *src_stride = pre_buf->stride; }
diff --git a/av1/encoder/reconinter_enc.h b/av1/encoder/reconinter_enc.h index badc9e9..2798593 100644 --- a/av1/encoder/reconinter_enc.h +++ b/av1/encoder/reconinter_enc.h
@@ -29,11 +29,9 @@ void enc_calc_subpel_params(const MV *const src_mv, InterPredParams *const inter_pred_params, MACROBLOCKD *xd, int mi_x, int mi_y, int ref, -#if CONFIG_OPTFLOW_REFINEMENT - int use_optflow_refinement, -#endif // CONFIG_OPTFLOW_REFINEMENT - uint16_t **mc_buf, uint16_t **pre, - SubpelParams *subpel_params, int *src_stride); + int use_optflow_refinement, uint16_t **mc_buf, + uint16_t **pre, SubpelParams *subpel_params, + int *src_stride); #endif // CONFIG_OPFL_MV_SEARCH // Build single or compound reference inter predictors for all planes. // Can build inter-intra predictors, masked predictors etc as well.
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake index a402b39..9d84e36 100644 --- a/build/cmake/aom_config_defaults.cmake +++ b/build/cmake/aom_config_defaults.cmake
@@ -184,10 +184,6 @@ CONFIG_CCSO 1 "AV2 experiment flag to enable cross component sample offset.") set_aom_config_var(CONFIG_CCSO_EDGE_CLF 1 "Enable adaptive edge classifier for CCSO.") -set_aom_config_var(CONFIG_OPTFLOW_REFINEMENT 1 - "AV2 experiment flag for optical flow MV refinement") -set_aom_config_var(CONFIG_REFINEMENT_SIMPLIFY 1 - "Simplification of optical flow and affine refinements") set_aom_config_var( CONFIG_IBP_DC 1 "AV2 experiment flag to enable intra bi-prediction for DC mode.")
diff --git a/build/cmake/aom_experiment_deps.cmake b/build/cmake/aom_experiment_deps.cmake index 893d492..282d363 100644 --- a/build/cmake/aom_experiment_deps.cmake +++ b/build/cmake/aom_experiment_deps.cmake
@@ -46,13 +46,6 @@ change_config_and_warn(CONFIG_CCSO_EXT 0 !CONFIG_CCSO) endif() - # CONFIG_OPTFLOW_ON_TIP is dependent on CONFIG_OPTFLOW_REFINEMENT. If - # CONFIG_OPTFLOW_REFINEMENT is off, CONFIG_OPTFLOW_ON_TIP needs to be turned - # off. - if(NOT CONFIG_OPTFLOW_REFINEMENT AND CONFIG_OPTFLOW_ON_TIP) - change_config_and_warn(CONFIG_OPTFLOW_ON_TIP 0 !CONFIG_OPTFLOW_REFINEMENT) - endif() - # CONFIG_EXPLICIT_BAWP is dependent on CONFIG_BAWP. If CONFIG_BAWP is off, # CONFIG_EXPLICIT_BAWP needs to be turned off. if(NOT CONFIG_BAWP AND CONFIG_EXPLICIT_BAWP) @@ -131,17 +124,6 @@ !CONFIG_SKIP_MODE_ENHANCEMENT) endif() - # CONFIG_REFINED_MVS_IN_TMVP depends on CONFIG_OPTFLOW_REFINEMENT - if(NOT CONFIG_OPTFLOW_REFINEMENT AND CONFIG_REFINED_MVS_IN_TMVP) - change_config_and_warn(CONFIG_REFINED_MVS_IN_TMVP 0 - !CONFIG_OPTFLOW_REFINEMENT) - endif() - - # CONFIG_AFFINE_REFINEMENT depends on CONFIG_OPTFLOW_REFINEMENT - if(NOT CONFIG_OPTFLOW_REFINEMENT AND CONFIG_AFFINE_REFINEMENT) - change_config_and_warn(CONFIG_AFFINE_REFINEMENT 0 - !CONFIG_OPTFLOW_REFINEMENT) - endif() # CONFIG_AFFINE_REFINEMENT_SB depends on CONFIG_AFFINE_REFINEMENT if(NOT CONFIG_AFFINE_REFINEMENT AND CONFIG_AFFINE_REFINEMENT_SB) change_config_and_warn(CONFIG_AFFINE_REFINEMENT_SB 0
diff --git a/common/args.c b/common/args.c index bf591c2..e911792 100644 --- a/common/args.c +++ b/common/args.c
@@ -158,9 +158,7 @@ GET_PARAMS(enable_smooth_intra); GET_PARAMS(enable_filter_intra); GET_PARAMS(enable_angle_delta); -#if CONFIG_OPTFLOW_REFINEMENT GET_PARAMS(enable_opfl_refine); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT GET_PARAMS(enable_affine_refine); #endif // CONFIG_AFFINE_REFINEMENT
diff --git a/common/av1_config.c b/common/av1_config.c index 95a10a3..d2fe7e7 100644 --- a/common/av1_config.c +++ b/common/av1_config.c
@@ -431,9 +431,7 @@ AV1C_READ_BIT_OR_RETURN_ERROR(enable_order_hint); if (enable_order_hint) { AV1C_READ_BIT_OR_RETURN_ERROR(enable_ref_frame_mvs); -#if CONFIG_OPTFLOW_REFINEMENT AV1C_READ_BIT_OR_RETURN_ERROR(enable_opfl_refine); -#endif // CONFIG_OPTFLOW_REFINEMENT #if CONFIG_AFFINE_REFINEMENT AV1C_READ_BIT_OR_RETURN_ERROR(enable_affine_refine); #endif // CONFIG_AFFINE_REFINEMENT
diff --git a/test/opt_flow_test.cc b/test/opt_flow_test.cc index 1376ef3..90354d7 100644 --- a/test/opt_flow_test.cc +++ b/test/opt_flow_test.cc
@@ -22,7 +22,6 @@ #include "av1/common/reconinter.h" #include "av1/common/mvref_common.h" -#if CONFIG_OPTFLOW_REFINEMENT namespace { class BlockSize { @@ -1206,5 +1205,3 @@ #endif // HAVE_AVX2 #endif // CONFIG_AFFINE_REFINEMENT } // namespace - -#endif // CONFIG_OPTFLOW_REFINEMENT
diff --git a/tools/aom_entropy_optimizer.c b/tools/aom_entropy_optimizer.c index 92b938a..0743795 100644 --- a/tools/aom_entropy_optimizer.c +++ b/tools/aom_entropy_optimizer.c
@@ -1143,7 +1143,6 @@ "[MAX_CWP_CONTEXTS][MAX_CWP_NUM - 1][CDF_SIZE(2)]", 0, &total_count, 0, mem_wanted, "Inter"); -#if CONFIG_OPTFLOW_REFINEMENT /* Optical flow MV refinement */ cts_each_dim[0] = INTER_COMPOUND_MODE_CONTEXTS; cts_each_dim[1] = 2; @@ -1151,12 +1150,10 @@ "static const aom_cdf_prob default_use_optflow_cdf" "[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE(2)]", 0, &total_count, 0, mem_wanted, "Inter"); -#endif // CONFIG_OPTFLOW_REFINEMENT /* ext_inter experiment */ /* New compound mode */ cts_each_dim[0] = INTER_COMPOUND_MODE_CONTEXTS; -#if CONFIG_OPTFLOW_REFINEMENT cts_each_dim[1] = INTER_COMPOUND_REF_TYPES; optimize_cdf_table(&fc.inter_compound_mode[0][0], probsfile, 2, cts_each_dim, "static const aom_cdf_prob " @@ -1164,14 +1161,6 @@ "[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE(" "INTER_COMPOUND_REF_TYPES)]", 0, &total_count, 0, mem_wanted, "Inter"); -#else - cts_each_dim[1] = INTER_COMPOUND_MODES; - optimize_cdf_table(&fc.inter_compound_mode[0][0], probsfile, 2, cts_each_dim, - "static const aom_cdf_prob\n" - "default_inter_compound_mode_cdf" - "[INTER_COMPOUND_MODE_CONTEXTS][CDF_SIZE(" - "INTER_COMPOUND_MODES)]"); -#endif // CONFIG_OPTFLOW_REFINEMENT /* Interintra */ cts_each_dim[0] = BLOCK_SIZE_GROUPS;