diff options
author | trav90 <travawine@palemoon.org> | 2018-10-19 21:52:15 -0500 |
---|---|---|
committer | trav90 <travawine@palemoon.org> | 2018-10-19 21:52:20 -0500 |
commit | bbcc64772580c8a979288791afa02d30bc476d2e (patch) | |
tree | 437ce94c3fdd7497508e5b55de06c6d011678597 /third_party/aom/av1/encoder/global_motion.c | |
parent | 14805f6ddbfb173c327768fff9f81f40ce5e81b0 (diff) | |
download | UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar.gz UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar.lz UXP-bbcc64772580c8a979288791afa02d30bc476d2e.tar.xz UXP-bbcc64772580c8a979288791afa02d30bc476d2e.zip |
Update aom to v1.0.0
Update aom to commit id d14c5bb4f336ef1842046089849dee4a301fbbf0.
Diffstat (limited to 'third_party/aom/av1/encoder/global_motion.c')
-rw-r--r-- | third_party/aom/av1/encoder/global_motion.c | 109 |
1 files changed, 44 insertions, 65 deletions
diff --git a/third_party/aom/av1/encoder/global_motion.c b/third_party/aom/av1/encoder/global_motion.c index 4d44e9a6f..f07d1bc00 100644 --- a/third_party/aom/av1/encoder/global_motion.c +++ b/third_party/aom/av1/encoder/global_motion.c @@ -32,12 +32,14 @@ // Border over which to compute the global motion #define ERRORADV_BORDER 0 -#define ERRORADV_MAX_THRESH 0.995 -#define ERRORADV_COST_PRODUCT_THRESH 26000 +static const double erroradv_tr[] = { 0.75, 0.70, 0.65 }; +static const double erroradv_prod_tr[] = { 22000, 20000, 18000 }; -int is_enough_erroradvantage(double best_erroradvantage, int params_cost) { - return best_erroradvantage < ERRORADV_MAX_THRESH && - best_erroradvantage * params_cost < ERRORADV_COST_PRODUCT_THRESH; +int is_enough_erroradvantage(double best_erroradvantage, int params_cost, + int erroradv_type) { + assert(erroradv_type < GM_ERRORADV_TR_TYPES); + return best_erroradvantage < erroradv_tr[erroradv_type] && + best_erroradvantage * params_cost < erroradv_prod_tr[erroradv_type]; } static void convert_to_params(const double *params, int32_t *model) { @@ -76,6 +78,7 @@ static void convert_to_params(const double *params, int32_t *model) { void convert_model_to_params(const double *params, WarpedMotionParams *model) { convert_to_params(params, model->wmmat); model->wmtype = get_gmtype(model); + model->invalid = 0; } // Adds some offset to a global motion parameter and handles @@ -110,32 +113,31 @@ static int32_t add_param_offset(int param_index, int32_t param_value, static void force_wmtype(WarpedMotionParams *wm, TransformationType wmtype) { switch (wmtype) { - case IDENTITY: wm->wmmat[0] = 0; wm->wmmat[1] = 0; + case IDENTITY: + wm->wmmat[0] = 0; + wm->wmmat[1] = 0; + AOM_FALLTHROUGH_INTENDED; case TRANSLATION: wm->wmmat[2] = 1 << WARPEDMODEL_PREC_BITS; wm->wmmat[3] = 0; - case ROTZOOM: wm->wmmat[4] = -wm->wmmat[3]; wm->wmmat[5] = wm->wmmat[2]; + AOM_FALLTHROUGH_INTENDED; + case ROTZOOM: + wm->wmmat[4] = -wm->wmmat[3]; + wm->wmmat[5] = wm->wmmat[2]; + AOM_FALLTHROUGH_INTENDED; case AFFINE: wm->wmmat[6] = wm->wmmat[7] = 0; break; - case HORTRAPEZOID: wm->wmmat[6] = wm->wmmat[4] = 0; break; - case VERTRAPEZOID: wm->wmmat[7] = wm->wmmat[3] = 0; break; - case HOMOGRAPHY: break; default: assert(0); } wm->wmtype = wmtype; } int64_t refine_integerized_param(WarpedMotionParams *wm, - TransformationType wmtype, -#if CONFIG_HIGHBITDEPTH - int use_hbd, int bd, -#endif // CONFIG_HIGHBITDEPTH + TransformationType wmtype, int use_hbd, int bd, uint8_t *ref, int r_width, int r_height, int r_stride, uint8_t *dst, int d_width, int d_height, int d_stride, int n_refinements, int64_t best_frame_error) { - static const int max_trans_model_params[TRANS_TYPES] = { - 0, 2, 4, 6, 8, 8, 8 - }; + static const int max_trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6 }; const int border = ERRORADV_BORDER; int i = 0, p; int n_params = max_trans_model_params[wmtype]; @@ -147,35 +149,26 @@ int64_t refine_integerized_param(WarpedMotionParams *wm, int32_t best_param; force_wmtype(wm, wmtype); - best_error = av1_warp_error( - wm, -#if CONFIG_HIGHBITDEPTH - use_hbd, bd, -#endif // CONFIG_HIGHBITDEPTH - ref, r_width, r_height, r_stride, dst + border * d_stride + border, - border, border, d_width - 2 * border, d_height - 2 * border, d_stride, 0, - 0, SCALE_SUBPEL_SHIFTS, SCALE_SUBPEL_SHIFTS, best_frame_error); + best_error = av1_warp_error(wm, use_hbd, bd, ref, r_width, r_height, r_stride, + dst + border * d_stride + border, border, border, + d_width - 2 * border, d_height - 2 * border, + d_stride, 0, 0, best_frame_error); best_error = AOMMIN(best_error, best_frame_error); step = 1 << (n_refinements - 1); for (i = 0; i < n_refinements; i++, step >>= 1) { for (p = 0; p < n_params; ++p) { int step_dir = 0; // Skip searches for parameters that are forced to be 0 - if (wmtype == HORTRAPEZOID && (p == 4 || p == 6)) continue; - if (wmtype == VERTRAPEZOID && (p == 3 || p == 7)) continue; param = param_mat + p; curr_param = *param; best_param = curr_param; // look to the left *param = add_param_offset(p, curr_param, -step); - step_error = av1_warp_error( - wm, -#if CONFIG_HIGHBITDEPTH - use_hbd, bd, -#endif // CONFIG_HIGHBITDEPTH - ref, r_width, r_height, r_stride, dst + border * d_stride + border, - border, border, d_width - 2 * border, d_height - 2 * border, d_stride, - 0, 0, SCALE_SUBPEL_SHIFTS, SCALE_SUBPEL_SHIFTS, best_error); + step_error = + av1_warp_error(wm, use_hbd, bd, ref, r_width, r_height, r_stride, + dst + border * d_stride + border, border, border, + d_width - 2 * border, d_height - 2 * border, d_stride, + 0, 0, best_error); if (step_error < best_error) { best_error = step_error; best_param = *param; @@ -184,14 +177,11 @@ int64_t refine_integerized_param(WarpedMotionParams *wm, // look to the right *param = add_param_offset(p, curr_param, step); - step_error = av1_warp_error( - wm, -#if CONFIG_HIGHBITDEPTH - use_hbd, bd, -#endif // CONFIG_HIGHBITDEPTH - ref, r_width, r_height, r_stride, dst + border * d_stride + border, - border, border, d_width - 2 * border, d_height - 2 * border, d_stride, - 0, 0, SCALE_SUBPEL_SHIFTS, SCALE_SUBPEL_SHIFTS, best_error); + step_error = + av1_warp_error(wm, use_hbd, bd, ref, r_width, r_height, r_stride, + dst + border * d_stride + border, border, border, + d_width - 2 * border, d_height - 2 * border, d_stride, + 0, 0, best_error); if (step_error < best_error) { best_error = step_error; best_param = *param; @@ -203,15 +193,11 @@ int64_t refine_integerized_param(WarpedMotionParams *wm, // for the biggest step size while (step_dir) { *param = add_param_offset(p, best_param, step * step_dir); - step_error = av1_warp_error( - wm, -#if CONFIG_HIGHBITDEPTH - use_hbd, bd, -#endif // CONFIG_HIGHBITDEPTH - ref, r_width, r_height, r_stride, dst + border * d_stride + border, - border, border, d_width - 2 * border, d_height - 2 * border, - d_stride, 0, 0, SCALE_SUBPEL_SHIFTS, SCALE_SUBPEL_SHIFTS, - best_error); + step_error = + av1_warp_error(wm, use_hbd, bd, ref, r_width, r_height, r_stride, + dst + border * d_stride + border, border, border, + d_width - 2 * border, d_height - 2 * border, + d_stride, 0, 0, best_error); if (step_error < best_error) { best_error = step_error; best_param = *param; @@ -229,9 +215,6 @@ int64_t refine_integerized_param(WarpedMotionParams *wm, static INLINE RansacFunc get_ransac_type(TransformationType type) { switch (type) { - case HOMOGRAPHY: return ransac_homography; - case HORTRAPEZOID: return ransac_hortrapezoid; - case VERTRAPEZOID: return ransac_vertrapezoid; case AFFINE: return ransac_affine; case ROTZOOM: return ransac_rotzoom; case TRANSLATION: return ransac_translation; @@ -239,7 +222,6 @@ static INLINE RansacFunc get_ransac_type(TransformationType type) { } } -#if CONFIG_HIGHBITDEPTH static unsigned char *downconvert_frame(YV12_BUFFER_CONFIG *frm, int bit_depth) { int i, j; @@ -257,14 +239,13 @@ static unsigned char *downconvert_frame(YV12_BUFFER_CONFIG *frm, } return buf_8bit; } -#endif -int compute_global_motion_feature_based( - TransformationType type, YV12_BUFFER_CONFIG *frm, YV12_BUFFER_CONFIG *ref, -#if CONFIG_HIGHBITDEPTH - int bit_depth, -#endif - int *num_inliers_by_motion, double *params_by_motion, int num_motions) { +int compute_global_motion_feature_based(TransformationType type, + YV12_BUFFER_CONFIG *frm, + YV12_BUFFER_CONFIG *ref, int bit_depth, + int *num_inliers_by_motion, + double *params_by_motion, + int num_motions) { int i; int num_frm_corners, num_ref_corners; int num_correspondences; @@ -274,7 +255,6 @@ int compute_global_motion_feature_based( unsigned char *ref_buffer = ref->y_buffer; RansacFunc ransac = get_ransac_type(type); -#if CONFIG_HIGHBITDEPTH if (frm->flags & YV12_FLAG_HIGHBITDEPTH) { // The frame buffer is 16-bit, so we need to convert to 8 bits for the // following code. We cache the result until the frame is released. @@ -283,7 +263,6 @@ int compute_global_motion_feature_based( if (ref->flags & YV12_FLAG_HIGHBITDEPTH) { ref_buffer = downconvert_frame(ref, bit_depth); } -#endif // compute interest points in images using FAST features num_frm_corners = fast_corner_detect(frm_buffer, frm->y_width, frm->y_height, |