ref: 91e2bcdc0cee2b219d490d1824599b0e474014c8
parent: a3ff9370aeac48f9cafe8b6a21bc1af28618ce5e
author: Hui Su <[email protected]>
date: Thu Aug 2 11:53:24 EDT 2018
Refactor vp9_full_pixel_search() Code cleanup; add some comment. Also remove a reduncant call to vp9_get_mvpred_var() at the end when method is MESH. Change-Id: I4b58e7e1c42161642708f8b0342ab3c0ce39ed7d
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -2186,7 +2186,7 @@
const SEARCH_METHODS method = (SEARCH_METHODS)search_method;
vp9_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
int var = 0;
- int run_mesh_search = (method == MESH);
+ int run_exhaustive_search = 0;
if (cost_list) {
cost_list[0] = INT_MAX;
@@ -2217,39 +2217,39 @@
var = bigdia_search(x, mvp_full, step_param, error_per_bit, 1, cost_list,
fn_ptr, 1, ref_mv, tmp_mv);
break;
- default:
- assert(method == NSTEP || method == MESH);
+ case NSTEP:
+ case MESH:
var = full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
MAX_MVSEARCH_STEPS - 1 - step_param, 1,
cost_list, fn_ptr, ref_mv, tmp_mv);
+ break;
+ default: assert(0 && "Unknown search method");
+ }
- // Should we allow a follow on exhaustive search, in regular rd search
- // mode.
- if (run_mesh_search == 0) {
- if ((sf->exhaustive_searches_thresh < INT_MAX) &&
- !cpi->rc.is_src_frame_alt_ref) {
- int64_t exhuastive_thr = sf->exhaustive_searches_thresh;
- exhuastive_thr >>=
- 8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]);
- if (var > exhuastive_thr) run_mesh_search = 1;
- }
- }
+ if (method == NSTEP) {
+ if (sf->exhaustive_searches_thresh < INT_MAX &&
+ !cpi->rc.is_src_frame_alt_ref) {
+ const int64_t exhuastive_thr =
+ sf->exhaustive_searches_thresh >>
+ (8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]));
+ if (var > exhuastive_thr) run_exhaustive_search = 1;
+ }
+ } else if (method == MESH) {
+ run_exhaustive_search = 1;
+ }
- if (run_mesh_search) {
- int var_ex;
- MV tmp_mv_ex;
- var_ex = full_pixel_exhaustive(cpi, x, tmp_mv, error_per_bit, cost_list,
- fn_ptr, ref_mv, &tmp_mv_ex);
-
- if (var_ex < var) {
- var = var_ex;
- *tmp_mv = tmp_mv_ex;
- }
- }
- break;
+ if (run_exhaustive_search) {
+ int var_ex;
+ MV tmp_mv_ex;
+ var_ex = full_pixel_exhaustive(cpi, x, tmp_mv, error_per_bit, cost_list,
+ fn_ptr, ref_mv, &tmp_mv_ex);
+ if (var_ex < var) {
+ var = var_ex;
+ *tmp_mv = tmp_mv_ex;
+ }
}
- if (method != NSTEP && rd && var < var_max)
+ if (method != NSTEP && method != MESH && rd && var < var_max)
var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1);
return var;
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -107,6 +107,9 @@
struct VP9_COMP;
+// "mvp_full" is the MV search starting point;
+// "ref_mv" is the context reference MV;
+// "tmp_mv" is the searched best MV.
int vp9_full_pixel_search(struct VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
MV *mvp_full, int step_param, int search_method,
int error_per_bit, int *cost_list, const MV *ref_mv,