summaryrefslogtreecommitdiff
path: root/vp8/encoder/rdopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder/rdopt.c')
-rw-r--r--vp8/encoder/rdopt.c78
1 files changed, 68 insertions, 10 deletions
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index d9b49bfb6..d07c2383e 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -41,6 +41,10 @@
#include "vp8/common/seg_common.h"
#include "vp8/common/pred_common.h"
+#if CONFIG_NEW_MVREF
+#include "vp8/common/mvref_common.h"
+#endif
+
#if CONFIG_RUNTIME_CPU_DETECT
#define IF_RTCD(x) (x)
#else
@@ -2892,9 +2896,10 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type,
unsigned char *y_buffer[4], unsigned char *u_buffer[4],
unsigned char *v_buffer[4]) {
YV12_BUFFER_CONFIG *yv12 = &cpi->common.yv12_fb[idx];
+ MACROBLOCKD *xd = &x->e_mbd;
- vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
- x->e_mbd.prev_mode_info_context,
+ vp8_find_near_mvs(xd, xd->mode_info_context,
+ xd->prev_mode_info_context,
&frame_nearest_mv[frame_type], &frame_near_mv[frame_type],
&frame_best_ref_mv[frame_type], frame_mdcounts[frame_type],
frame_type, cpi->common.ref_frame_sign_bias);
@@ -2902,8 +2907,27 @@ void setup_buffer_inter(VP8_COMP *cpi, MACROBLOCK *x, int idx, int frame_type,
y_buffer[frame_type] = yv12->y_buffer + recon_yoffset;
u_buffer[frame_type] = yv12->u_buffer + recon_uvoffset;
v_buffer[frame_type] = yv12->v_buffer + recon_uvoffset;
+
#if CONFIG_NEWBESTREFMV
- vp8_find_best_ref_mvs(&x->e_mbd, y_buffer[frame_type],
+#if CONFIG_NEW_MVREF
+ // Update stats on relative distance of chosen vector to the
+ // possible best reference vectors.
+ {
+ MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
+
+ find_mv_refs(xd, xd->mode_info_context,
+ xd->prev_mode_info_context,
+ frame_type,
+ mbmi->ref_mvs[frame_type],
+ cpi->common.ref_frame_sign_bias );
+
+ // Copy over the mv candidates
+ vpx_memcpy(xd->ref_mv, mbmi->ref_mvs[frame_type],
+ (MAX_MV_REFS * sizeof(int_mv)) );
+ }
+#endif
+
+ vp8_find_best_ref_mvs(xd, y_buffer[frame_type],
yv12->y_stride,
&frame_best_ref_mv[frame_type],
&frame_nearest_mv[frame_type],
@@ -2943,7 +2967,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
int uv_intra_rate_8x8 = 0, uv_intra_distortion_8x8 = 0, uv_intra_rate_tokenonly_8x8 = 0;
int uv_intra_skippable_8x8 = 0;
int rate_y, UNINITIALIZED_IS_SAFE(rate_uv);
- int distortion_uv;
+ int distortion_uv = INT_MAX;
int64_t best_yrd = INT64_MAX;
#if CONFIG_PRED_FILTER
int best_filter_state;
@@ -3407,6 +3431,43 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
d->bmi.as_mv.first.as_int = tmp_mv.as_int;
frame_mv[NEWMV][refs[0]].as_int = d->bmi.as_mv.first.as_int;
+#if CONFIG_NEW_MVREF
+ // Update stats on relative distance of chosen vector to the
+ // possible best reference vectors.
+ {
+ unsigned int distance;
+ MV_REFERENCE_FRAME ref = mbmi->ref_frame;
+ int_mv selected_best_ref;
+ unsigned int best_index = 0;
+
+ find_mv_refs(xd, xd->mode_info_context,
+ xd->prev_mode_info_context,
+ ref,
+ mbmi->ref_mvs[ref],
+ cpi->common.ref_frame_sign_bias );
+
+ distance = mv_distance(&tmp_mv, &best_ref_mv);
+ cpi->mv_ref_sum_distance[ref][CUR_BEST] += distance;
+
+ distance =
+ mv_distance(&tmp_mv,
+ &mbmi->ref_mvs[ref][0]);
+ cpi->mv_ref_sum_distance[ref][NEW_BEST] += distance;
+
+ best_index = pick_best_mv_ref(tmp_mv, mbmi->ref_mvs[ref],
+ &selected_best_ref);
+
+ distance = mv_distance(&tmp_mv, &selected_best_ref);
+ mbmi->mv_ref_index[ref] = best_index;
+ cpi->mv_ref_sum_distance[ref][BEST_SELECTED] += distance;
+ cpi->best_ref_index_counts[best_index]++;
+
+ // Temp
+ //mbmi->mv_ref_index[ref] = 0;
+ //mbmi->ref_mvs[ref][0].as_int = best_ref_mv.as_int;
+ }
+#endif
+
// Add the new motion vector cost to our rolling cost variable
rate2 += vp8_mv_bit_cost(&tmp_mv, &best_ref_mv,
XMVCOST, 96,
@@ -3856,7 +3917,6 @@ void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x,
int mode16x16;
int mode8x8[2][4];
int dist;
- int rateuv8, rateuv_tokenonly8, distuv8;
mbmi->ref_frame = INTRA_FRAME;
rd_pick_intra_mbuv_mode(cpi, x, &rateuv, &rateuv_tokenonly, &distuv);
@@ -3961,7 +4021,6 @@ int64_t vp8_rd_pick_inter_mode_sb(VP8_COMP *cpi, MACROBLOCK *x,
BLOCKD *d = &xd->block[0];
MB_PREDICTION_MODE this_mode;
MV_REFERENCE_FRAME ref_frame;
- int mis = xd->mode_info_stride;
unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;
int comp_pred;
int_mv best_ref_mv, second_best_ref_mv;
@@ -4313,11 +4372,11 @@ int64_t vp8_rd_pick_inter_mode_sb(VP8_COMP *cpi, MACROBLOCK *x,
if ((sse - var < q2dc *q2dc >> 4) ||
(sse / 2 > var && sse - var < 64)) {
// Check u and v to make sure skip is ok
- int sse2, sse3;
- int var2 = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
+ unsigned int sse2, sse3;
+ var += VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
(x->src.u_buffer, x->src.uv_stride,
xd->dst.u_buffer, xd->dst.uv_stride, &sse2);
- int var3 = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
+ var += VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
(x->src.v_buffer, x->src.uv_stride,
xd->dst.v_buffer, xd->dst.uv_stride, &sse3);
sse2 += sse3;
@@ -4658,7 +4717,6 @@ void vp8cx_pick_mode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
int recon_yoffset,
int recon_uvoffset,
int *totalrate, int *totaldist) {
- VP8_COMMON *cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
int rate, distortion;