From 643238a3e02a1936fe9ddbfe2f1f7e046f25c8a0 Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Tue, 15 Nov 2011 16:16:30 -0800 Subject: [PATCH] changed find_near_mvs search to include a mb from last frame This is an experiment to include a mv contribution from last frame to nearest and near mv definition. Initial test showed some small though consistent gain. latest patch slightly better result ~.13%-~.18%. TODO: the entropy used to encode the mode choice, i.e. the mv counts based conditional distribution of modes should be re-collected to reflect this change, it is expected that there is some further gain from that. Change-Id: Ief1e284a36d8aa56b49ae5b360c91419ec494fa4 --- vp8/common/alloccommon.c | 2 +- vp8/common/blockd.h | 3 + vp8/common/findnearmv.c | 136 +++++++++++++++++++++++++++++++++++++- vp8/common/findnearmv.h | 3 + vp8/decoder/decodemv.c | 28 ++++++-- vp8/decoder/onyxd_if.c | 53 +++++++++++++++ vp8/encoder/bitstream.c | 25 ++++++- vp8/encoder/encodeframe.c | 26 +++++++- vp8/encoder/ethreading.c | 22 +++++- vp8/encoder/onyx_if.c | 23 ++++++- vp8/encoder/pickinter.c | 23 +++++-- vp8/encoder/rdopt.c | 22 ++++-- 12 files changed, 342 insertions(+), 24 deletions(-) diff --git a/vp8/common/alloccommon.c b/vp8/common/alloccommon.c index a7d8a2ac1..2535a78fa 100644 --- a/vp8/common/alloccommon.c +++ b/vp8/common/alloccommon.c @@ -116,7 +116,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->mi = oci->mip + oci->mode_info_stride + 1; /* allocate memory for last frame MODE_INFO array */ -#if CONFIG_ERROR_CONCEALMENT +#if CONFIG_ERROR_CONCEALMENT || CONFIG_NEWNEAR oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO)); if (!oci->prev_mip) diff --git a/vp8/common/blockd.h b/vp8/common/blockd.h index 222cff574..cef66f02e 100644 --- a/vp8/common/blockd.h +++ b/vp8/common/blockd.h @@ -235,6 +235,9 @@ typedef struct MacroBlockD YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */ YV12_BUFFER_CONFIG dst; +#if CONFIG_NEWNEAR + MODE_INFO *prev_mode_info_context; +#endif MODE_INFO *mode_info_context; int mode_info_stride; diff --git a/vp8/common/findnearmv.c b/vp8/common/findnearmv.c index 189b545fa..ab44f7393 100644 --- a/vp8/common/findnearmv.c +++ b/vp8/common/findnearmv.c @@ -21,10 +21,12 @@ const unsigned char vp8_mbsplit_offset[4][16] = { /* Predict motion vectors using those from already-decoded nearby blocks. Note that we only consider one 4x4 subblock from each candidate 16x16 macroblock. */ +#if CONFIG_NEWNEAR void vp8_find_near_mvs ( MACROBLOCKD *xd, const MODE_INFO *here, + const MODE_INFO *lf_here, int_mv *nearest, int_mv *nearby, int_mv *best_mv, @@ -36,6 +38,7 @@ void vp8_find_near_mvs const MODE_INFO *above = here - xd->mode_info_stride; const MODE_INFO *left = here - 1; const MODE_INFO *aboveleft = above - 1; + const MODE_INFO *third = NULL; int_mv near_mvs[4]; int_mv *mv = near_mvs; int *cntx = cnt; @@ -55,7 +58,138 @@ void vp8_find_near_mvs refframe, mv, ref_frame_sign_bias); ++cntx; } + *cntx += 2; + } + + /* Process left */ + if (left->mbmi.ref_frame != INTRA_FRAME) + { + if (left->mbmi.mv.as_int) + { + int_mv this_mv; + this_mv.as_int = left->mbmi.mv.as_int; + mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame], + refframe, &this_mv, ref_frame_sign_bias); + + if (this_mv.as_int != mv->as_int) + { + (++mv)->as_int = this_mv.as_int; + ++cntx; + } + *cntx += 2; + } + else + cnt[CNT_INTRA] += 2; + } + /* Process above left or the one frome last frame */ + if ( aboveleft->mbmi.ref_frame != INTRA_FRAME|| + (lf_here->mbmi.ref_frame==LAST_FRAME && refframe == LAST_FRAME)) + { + if (aboveleft->mbmi.mv.as_int) + { + third = aboveleft; + } + else if(lf_here->mbmi.mv.as_int) + { + third = lf_here; + } + if(third) + { + int_mv this_mv; + this_mv.as_int = third->mbmi.mv.as_int; + mv_bias(ref_frame_sign_bias[third->mbmi.ref_frame], + refframe, &this_mv, ref_frame_sign_bias); + + if (this_mv.as_int != mv->as_int) + { + (++mv)->as_int = this_mv.as_int; + ++cntx; + } + *cntx += 1; + } + else + cnt[CNT_INTRA] += 1; + } + + /* If we have three distinct MV's ... */ + if (cnt[CNT_SPLITMV]) + { + /* See if the third MV can be merged with NEAREST */ + if (mv->as_int == near_mvs[CNT_NEAREST].as_int) + cnt[CNT_NEAREST] += 1; + } + + cnt[CNT_SPLITMV] = ((above->mbmi.mode == SPLITMV) + + (left->mbmi.mode == SPLITMV)) * 2 + + ( +#if CONFIG_NEWNEAR + lf_here->mbmi.mode == SPLITMV || +#endif + aboveleft->mbmi.mode == SPLITMV); + + /* Swap near and nearest if necessary */ + if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) + { + int tmp; + tmp = cnt[CNT_NEAREST]; + cnt[CNT_NEAREST] = cnt[CNT_NEAR]; + cnt[CNT_NEAR] = tmp; + tmp = near_mvs[CNT_NEAREST].as_int; + near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int; + near_mvs[CNT_NEAR].as_int = tmp; + } + + /* Use near_mvs[0] to store the "best" MV */ + if (cnt[CNT_NEAREST] >= cnt[CNT_INTRA]) + near_mvs[CNT_INTRA] = near_mvs[CNT_NEAREST]; + + /* Set up return values */ + best_mv->as_int = near_mvs[0].as_int; + nearest->as_int = near_mvs[CNT_NEAREST].as_int; + nearby->as_int = near_mvs[CNT_NEAR].as_int; + + //TODO: move clamp outside findnearmv + vp8_clamp_mv2(nearest, xd); + vp8_clamp_mv2(nearby, xd); + vp8_clamp_mv2(best_mv, xd); +} + + +#else +void vp8_find_near_mvs +( + MACROBLOCKD *xd, + const MODE_INFO *here, + int_mv *nearest, + int_mv *nearby, + int_mv *best_mv, + int cnt[4], + int refframe, + int *ref_frame_sign_bias +) +{ + const MODE_INFO *above = here - xd->mode_info_stride; + const MODE_INFO *left = here - 1; + const MODE_INFO *aboveleft = above - 1; + int_mv near_mvs[4]; + int_mv *mv = near_mvs; + int *cntx = cnt; + enum {CNT_INTRA, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV}; + /* Zero accumulators */ + mv[0].as_int = mv[1].as_int = mv[2].as_int = 0; + cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0; + + /* Process above */ + if (above->mbmi.ref_frame != INTRA_FRAME) + { + if (above->mbmi.mv.as_int) + { + (++mv)->as_int = above->mbmi.mv.as_int; + mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame], + refframe, mv, ref_frame_sign_bias); + ++cntx; + } *cntx += 2; } @@ -81,7 +215,6 @@ void vp8_find_near_mvs else cnt[CNT_INTRA] += 2; } - /* Process above left */ if (aboveleft->mbmi.ref_frame != INTRA_FRAME) { @@ -143,6 +276,7 @@ void vp8_find_near_mvs vp8_clamp_mv2(nearby, xd); vp8_clamp_mv2(best_mv, xd); } +#endif vp8_prob *vp8_mv_ref_probs( vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4] diff --git a/vp8/common/findnearmv.h b/vp8/common/findnearmv.h index ffc02ed6c..4a5b0f3a4 100644 --- a/vp8/common/findnearmv.h +++ b/vp8/common/findnearmv.h @@ -75,6 +75,9 @@ void vp8_find_near_mvs ( MACROBLOCKD *xd, const MODE_INFO *here, +#if CONFIG_NEWNEAR + const MODE_INFO *lfhere, +#endif int_mv *nearest, int_mv *nearby, int_mv *best, int near_mv_ref_cts[4], int refframe, diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c index c6403ba10..683f40a5b 100644 --- a/vp8/decoder/decodemv.c +++ b/vp8/decoder/decodemv.c @@ -425,6 +425,9 @@ static void mb_mode_mv_init(VP8D_COMP *pbi) static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, +#if CONFIG_NEWNEAR + MODE_INFO *prev_mi, +#endif int mb_row, int mb_col) { vp8_reader *const bc = & pbi->bc; @@ -529,7 +532,11 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, int_mv nearest, nearby, best_mv; vp8_prob mv_ref_p [VP8_MVREFS-1]; - vp8_find_near_mvs(xd, mi, &nearest, &nearby, &best_mv, rct, + vp8_find_near_mvs(xd, mi, +#if CONFIG_NEWNEAR + prev_mi, +#endif + &nearest, &nearby, &best_mv, rct, mbmi->ref_frame, pbi->common.ref_frame_sign_bias); vp8_mv_ref_probs(mv_ref_p, rct); @@ -725,6 +732,11 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, void vp8_decode_mode_mvs(VP8D_COMP *pbi) { MODE_INFO *mi = pbi->common.mi; + +#if CONFIG_NEWNEAR + MODE_INFO *prev_mi = pbi->common.prev_mi; +#endif + int mb_row = -1; //#if CONFIG_SEGFEATURES @@ -771,7 +783,11 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) if(pbi->common.frame_type == KEY_FRAME) vp8_kfread_modes(pbi, mi, mb_row, mb_col); else - read_mb_modes_mv(pbi, mi, &mi->mbmi, mb_row, mb_col); + read_mb_modes_mv(pbi, mi, &mi->mbmi, +#if CONFIG_NEWNEAR + prev_mi, +#endif + mb_row, mb_col); //printf("%3d", mi->mbmi.mode); @@ -807,11 +823,15 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) fprintf(statsfile, "%2d%2d%2d ", mi->mbmi.segment_id, mi->mbmi.ref_frame, mi->mbmi.mode ); #endif - - +#if CONFIG_NEWNEAR + prev_mi++; +#endif mi++; /* next macroblock */ } // printf("\n"); +#if CONFIG_NEWNEAR + prev_mi++; +#endif mi++; /* skip left predictor each row */ } diff --git a/vp8/decoder/onyxd_if.c b/vp8/decoder/onyxd_if.c index 4f77a6b83..39df72d07 100644 --- a/vp8/decoder/onyxd_if.c +++ b/vp8/decoder/onyxd_if.c @@ -81,6 +81,41 @@ void vp8_recon_write_yuv_frame(char *name, YV12_BUFFER_CONFIG *s) } #endif +#if WRITE_RECON_BUFFER +void write_dx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) +{ + + // write the frame + FILE *yframe; + int i; + char filename[255]; + + sprintf(filename, "dx\\y%04d.raw", this_frame); + yframe = fopen(filename, "wb"); + + for (i = 0; i < frame->y_height; i++) + fwrite(frame->y_buffer + i * frame->y_stride, frame->y_width, 1, yframe); + + fclose(yframe); + sprintf(filename, "dx\\u%04d.raw", this_frame); + yframe = fopen(filename, "wb"); + + for (i = 0; i < frame->uv_height; i++) + fwrite(frame->u_buffer + i * frame->uv_stride, frame->uv_width, 1, yframe); + + fclose(yframe); + sprintf(filename, "dx\\v%04d.raw", this_frame); + yframe = fopen(filename, "wb"); + + for (i = 0; i < frame->uv_height; i++) + fwrite(frame->v_buffer + i * frame->uv_stride, frame->uv_width, 1, yframe); + + fclose(yframe); +} +#endif + + + void vp8dx_initialize() { static int init_done = 0; @@ -540,6 +575,11 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign return -1; } +#if WRITE_RECON_BUFFER + if(cm->show_frame) + write_dx_frame_to_file(cm->frame_to_show, cm->current_video_frame); +#endif + if(cm->filter_level) { /* Apply the loop filter if appropriate. */ @@ -576,6 +616,19 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign } #endif +#if CONFIG_NEWNEAR + if(cm->show_frame) + { + vpx_memcpy(cm->prev_mip, cm->mip, + (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + } + else + { + vpx_memset(cm->prev_mip, 0, + (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + } +#endif + /*vp8_print_modes_and_motion_vectors( cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/ if (cm->show_frame) diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index f239d8107..07077208a 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -948,14 +948,17 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) const int rf_intra = rfct[INTRA_FRAME]; const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]; - MODE_INFO *m = pc->mi, *ms; + MODE_INFO *m = pc->mi; +#if CONFIG_NEWNEAR + MODE_INFO *prev_m = pc->prev_mi; +#endif + const int mis = pc->mode_info_stride; int mb_row = -1; int prob_last_coded; int prob_gf_coded; int prob_skip_false = 0; - ms = pc->mi - 1; cpi->mb.partition_info = cpi->mb.pi; @@ -1033,6 +1036,9 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) // Make sure the MacroBlockD mode info pointer is set correctly xd->mode_info_context = m; +#if CONFIG_NEWNEAR + xd->prev_mode_info_context = prev_m; +#endif #ifdef ENTROPY_STATS active_section = 9; @@ -1110,7 +1116,11 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) int_mv n1, n2; int ct[4]; - vp8_find_near_mvs(xd, m, &n1, &n2, &best_mv, ct, rf, cpi->common.ref_frame_sign_bias); + vp8_find_near_mvs(xd, m, +#if CONFIG_NEWNEAR + prev_m, +#endif + &n1, &n2, &best_mv, ct, rf, cpi->common.ref_frame_sign_bias); vp8_mv_ref_probs(mv_ref_p, ct); #ifdef ENTROPY_STATS @@ -1193,10 +1203,19 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) } ++m; +#if CONFIG_NEWNEAR + ++prev_m; + assert((prev_m-cpi->common.prev_mip)==(m-cpi->common.mip)); + assert((prev_m-cpi->common.prev_mi)==(m-cpi->common.mi)); +#endif + cpi->mb.partition_info++; } ++m; /* skip L prediction border */ +#if CONFIG_NEWNEAR + ++prev_m; +#endif cpi->mb.partition_info++; } } diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index da6d7a451..22d53302a 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -767,6 +767,12 @@ void encode_mb_row(VP8_COMP *cpi, // skip to next mb xd->mode_info_context++; + +#if CONFIG_NEWNEAR + xd->prev_mode_info_context++; + assert((xd->prev_mode_info_context - cpi->common.prev_mip) + ==(xd->mode_info_context - cpi->common.mip)); +#endif x->partition_info++; xd->above_context++; @@ -786,6 +792,9 @@ void encode_mb_row(VP8_COMP *cpi, xd->dst.v_buffer + 8); // this is to account for the border +#if CONFIG_NEWNEAR + xd->prev_mode_info_context++; +#endif xd->mode_info_context++; x->partition_info++; @@ -829,6 +838,10 @@ void init_encode_frame_mb_context(VP8_COMP *cpi) xd->mode_info_context = cm->mi; xd->mode_info_stride = cm->mode_info_stride; +#if CONFIG_NEWNEAR + xd->prev_mode_info_context = cm->prev_mi; +#endif + xd->frame_type = cm->frame_type; @@ -970,6 +983,11 @@ void vp8_encode_frame(VP8_COMP *cpi) xd->mode_info_context = cm->mi; +#if CONFIG_NEWNEAR + xd->prev_mode_info_context = cm->prev_mi; +#endif + + vp8_zero(cpi->MVcount); vp8_zero(cpi->coef_counts); @@ -1022,7 +1040,13 @@ void vp8_encode_frame(VP8_COMP *cpi) x->src.u_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols; x->src.v_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols; - xd->mode_info_context += xd->mode_info_stride * cpi->encoding_thread_count; + xd->mode_info_context += xd->mode_info_stride + * cpi->encoding_thread_count; +#if CONFIG_NEWNEAR + xd->prev_mode_info_context += xd->mode_info_stride + * cpi->encoding_thread_count; +#endif + x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count; x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count; diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index bd0b1c718..64d7707f7 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -248,6 +248,9 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data) recon_uvoffset += 8; // skip to next mb +#if CONFIG_NEWNEAR + xd->prev_mode_info_context++; +#endif xd->mode_info_context++; x->partition_info++; xd->above_context++; @@ -263,6 +266,10 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data) xd->dst.v_buffer + 8); // this is to account for the border +#if CONFIG_NEWNEAR + xd->prev_mode_info_context++; +#endif + xd->mode_info_context++; x->partition_info++; @@ -270,7 +277,13 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data) x->src.u_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols; x->src.v_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols; - xd->mode_info_context += xd->mode_info_stride * cpi->encoding_thread_count; + xd->mode_info_context += xd->mode_info_stride + * cpi->encoding_thread_count; +#if CONFIG_NEWNEAR + xd->prev_mode_info_context += xd->mode_info_stride + * cpi->encoding_thread_count; +#endif + x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count; x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count; @@ -437,7 +450,12 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi, mb->partition_info = x->pi + x->e_mbd.mode_info_stride * (i + 1); - mbd->mode_info_context = cm->mi + x->e_mbd.mode_info_stride * (i + 1); + mbd->mode_info_context = cm->mi + + x->e_mbd.mode_info_stride * (i + 1); +#if CONFIG_NEWNEAR + mbd->prev_mode_info_context = cm->prev_mi + + x->e_mbd.mode_info_stride * (i + 1); +#endif mbd->mode_info_stride = cm->mode_info_stride; mbd->frame_type = cm->frame_type; diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 2dcddc0d1..d44b69c9d 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -2439,7 +2439,7 @@ void vp8_remove_compressor(VP8_PTR *ptr) { extern int count_mb_seg[4]; char modes_stats_file[250]; - FILE *f; + FILE *f; double dr = (double)cpi->oxcf.frame_rate * (double)cpi->bytes * (double)8 / (double)cpi->count / (double)1000 ; sprintf(modes_stats_file, "modes_q%03d.stt",cpi->common.base_qindex); f = fopen(modes_stats_file, "w"); @@ -3292,7 +3292,7 @@ static void Pass1Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest, } #endif -#if 0 +#if WRITE_RECON_BUFFER void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) { @@ -4437,6 +4437,11 @@ static void encode_frame_to_data_rate cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; +#if WRITE_RECON_BUFFER + if(cm->show_frame) + write_cx_frame_to_file(cm->frame_to_show, cm->current_video_frame); +#endif + #if CONFIG_MULTITHREAD if (cpi->b_multi_threaded) { @@ -4812,6 +4817,20 @@ static void encode_frame_to_data_rate vp8_write_yuv_rec_frame(cm); #endif +#if CONFIG_NEWNEAR + if(cm->show_frame) + { + vpx_memcpy(cm->prev_mip, cm->mip, + (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + } + else + { + vpx_memset(cm->prev_mip, 0, + (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + } +#endif + + } diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 73595738b..d7a205868 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -460,7 +460,11 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, { YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx]; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &nearest_mv[LAST_FRAME], &near_mv[LAST_FRAME], + vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, +#if CONFIG_NEWNEAR + x->e_mbd.prev_mode_info_context, +#endif + &nearest_mv[LAST_FRAME], &near_mv[LAST_FRAME], &frame_best_ref_mv[LAST_FRAME], MDCounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias); y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset; @@ -474,8 +478,13 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, { YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx]; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &nearest_mv[GOLDEN_FRAME], &near_mv[GOLDEN_FRAME], - &frame_best_ref_mv[GOLDEN_FRAME], MDCounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias); + vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, +#if CONFIG_NEWNEAR + x->e_mbd.prev_mode_info_context, +#endif + + &nearest_mv[GOLDEN_FRAME], &near_mv[GOLDEN_FRAME], + &frame_best_ref_mv[GOLDEN_FRAME], MDCounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias); y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset; u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset; @@ -488,8 +497,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, { YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx]; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &nearest_mv[ALTREF_FRAME], &near_mv[ALTREF_FRAME], - &frame_best_ref_mv[ALTREF_FRAME], MDCounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias); + vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, +#if CONFIG_NEWNEAR + x->e_mbd.prev_mode_info_context, +#endif + &nearest_mv[ALTREF_FRAME], &near_mv[ALTREF_FRAME], + &frame_best_ref_mv[ALTREF_FRAME], MDCounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias); y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset; u_buffer[ALTREF_FRAME] = alt_yv12->u_buffer + recon_uvoffset; diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index d4458b9bf..76eec8a80 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -2003,8 +2003,12 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int { YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx]; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &frame_nearest_mv[LAST_FRAME], &frame_near_mv[LAST_FRAME], - &frame_best_ref_mv[LAST_FRAME], frame_mdcounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias); + vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, +#if CONFIG_NEWNEAR + x->e_mbd.prev_mode_info_context, +#endif + &frame_nearest_mv[LAST_FRAME], &frame_near_mv[LAST_FRAME], + &frame_best_ref_mv[LAST_FRAME], frame_mdcounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias); y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset; u_buffer[LAST_FRAME] = lst_yv12->u_buffer + recon_uvoffset; @@ -2015,8 +2019,12 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int { YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx]; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &frame_nearest_mv[GOLDEN_FRAME], &frame_near_mv[GOLDEN_FRAME], - &frame_best_ref_mv[GOLDEN_FRAME], frame_mdcounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias); + vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, +#if CONFIG_NEWNEAR + x->e_mbd.prev_mode_info_context, +#endif + &frame_nearest_mv[GOLDEN_FRAME], &frame_near_mv[GOLDEN_FRAME], + &frame_best_ref_mv[GOLDEN_FRAME], frame_mdcounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias); y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset; u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset; @@ -2027,7 +2035,11 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int { YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx]; - vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &frame_nearest_mv[ALTREF_FRAME], &frame_near_mv[ALTREF_FRAME], + vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, +#if CONFIG_NEWNEAR + x->e_mbd.prev_mode_info_context, +#endif + &frame_nearest_mv[ALTREF_FRAME], &frame_near_mv[ALTREF_FRAME], &frame_best_ref_mv[ALTREF_FRAME], frame_mdcounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias); y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset; -- 2.40.0