ref: 0a922ffaf6cd2b9eeb059fa6ca1742833a056eee
parent: 219ea62d00e68de9267c266913d3205a1530b58a
parent: a047b31e2fb37609ca3652b547e921f16d8fb110
author: Angie Chiang <angiebird@google.com>
date: Thu Jan 24 20:47:43 EST 2019
Merge changes I0fb46784,I6c89fae4 * changes: Add set_block_src_pred_buf() [cleanup] Move get_feature_score to a proper place
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5838,31 +5838,6 @@
}
}
-#if CONFIG_NON_GREEDY_MV
-double get_feature_score(uint8_t *buf, ptrdiff_t stride, int rows, int cols) {
- double IxIx = 0;
- double IxIy = 0;
- double IyIy = 0;
- double score;
- int r, c;
- vpx_clear_system_state();
- for (r = 0; r + 1 < rows; ++r) {
- for (c = 0; c + 1 < cols; ++c) {
- int diff_x = buf[r * stride + c] - buf[r * stride + c + 1];
- int diff_y = buf[r * stride + c] - buf[(r + 1) * stride + c];
- IxIx += diff_x * diff_x;
- IxIy += diff_x * diff_y;
- IyIy += diff_y * diff_y;
- }
- }
- IxIx /= (rows - 1) * (cols - 1);
- IxIy /= (rows - 1) * (cols - 1);
- IyIy /= (rows - 1) * (cols - 1);
- score = (IxIx * IyIy - IxIy * IxIy + 0.0001) / (IxIx + IyIy + 0.0001);
- return score;
-}
-#endif
-
static void set_mv_limits(const VP9_COMMON *cm, MACROBLOCK *x, int mi_row,
int mi_col) {
x->mv_limits.row_min = -((mi_row * MI_SIZE) + (17 - 2 * VP9_INTERP_EXTEND));
@@ -6035,6 +6010,47 @@
}
#if CONFIG_NON_GREEDY_MV
+void set_block_src_pred_buf(MACROBLOCK *x, GF_PICTURE *gf_picture,
+ int frame_idx, int rf_idx, int mi_row, int mi_col) {
+ MACROBLOCKD *xd = &x->e_mbd;
+ const int mb_y_offset =
+ mi_row * MI_SIZE * xd->cur_buf->y_stride + mi_col * MI_SIZE;
+ YV12_BUFFER_CONFIG *ref_frame = NULL;
+ int ref_frame_idx = gf_picture[frame_idx].ref_frame[rf_idx];
+ if (ref_frame_idx != -1) {
+ ref_frame = gf_picture[ref_frame_idx].frame;
+ }
+ x->plane[0].src.buf = xd->cur_buf->y_buffer + mb_y_offset;
+ x->plane[0].src.stride = xd->cur_buf->y_stride;
+ xd->plane[0].pre[0].buf = ref_frame->y_buffer + mb_y_offset;
+ xd->plane[0].pre[0].stride = ref_frame->y_stride;
+ assert(xd->cur_buf->y_stride == ref_frame->y_stride);
+}
+
+static double get_feature_score(uint8_t *buf, ptrdiff_t stride, int rows,
+ int cols) {
+ double IxIx = 0;
+ double IxIy = 0;
+ double IyIy = 0;
+ double score;
+ int r, c;
+ vpx_clear_system_state();
+ for (r = 0; r + 1 < rows; ++r) {
+ for (c = 0; c + 1 < cols; ++c) {
+ int diff_x = buf[r * stride + c] - buf[r * stride + c + 1];
+ int diff_y = buf[r * stride + c] - buf[(r + 1) * stride + c];
+ IxIx += diff_x * diff_x;
+ IxIy += diff_x * diff_y;
+ IyIy += diff_y * diff_y;
+ }
+ }
+ IxIx /= (rows - 1) * (cols - 1);
+ IxIy /= (rows - 1) * (cols - 1);
+ IyIy /= (rows - 1) * (cols - 1);
+ score = (IxIx * IyIy - IxIy * IxIy + 0.0001) / (IxIx + IyIy + 0.0001);
+ return score;
+}
+
static int compare_feature_score(const void *a, const void *b) {
const FEATURE_SCORE_LOC *aa = *(FEATURE_SCORE_LOC *const *)a;
const FEATURE_SCORE_LOC *bb = *(FEATURE_SCORE_LOC *const *)b;