History

Fix use of scaling in joint motion search

To enable us to the scale-invariant motion estimation code during mode selection, each of the reference buffers is scaled to match the size of the frame being encoded. This fix ensures that a unit scaling factor is used in this case rather than the one calculated assuming that the reference frame is not scaled. (cherry picked from commit 8d8d7bfde5d311bb7d4ff4e921a9dbaa8f389af5)

Adrian Grange committed 11 years ago

Commit 5ef2d1d1 parent bb5a39c1 file · +16 −6Browse files

Unified · Split

vp9/encoder/vp9_rdopt.c+16−6
@@ -1540,6 +1540,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 1539 unmodified lines
15401540 int mi_row, int mi_col,
15411541 int_mv single_newmv[MAX_REF_FRAMES],
15421542 int *rate_mv) {
1543+ const VP9_COMMON *const cm = &cpi->common;
15431544 const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];
15441545 const int ph = 4 * num_4x4_blocks_high_lookup[bsize];
15451546 MACROBLOCKD *xd = &x->e_mbd;
@@ -1556,6 +1557,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 10 unmodified lines
15561557 uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t));
15571558 #endif // CONFIG_VP9_HIGHBITDEPTH
15581559 const InterpKernel *kernel = vp9_get_interp_kernel(mbmi->interp_filter);
1560+ struct scale_factors sf;
15591561
15601562 // Do joint motion search in compound mode to get more accurate mv.
15611563 struct buf_2d backup_yv12[2][MAX_MB_PLANE];
@@ -1591,6 +1593,17 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 29 unmodified lines
15911593 frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int;
15921594 }
15931595
1596+ // Since we have scaled the reference frames to match the size of the current
1597+ // frame we must use a unit scaling factor during mode selection.
1598+#if CONFIG_VP9_HIGHBITDEPTH
1599+ vp9_setup_scale_factors_for_frame(&sf, cm->width, cm->height,
1600+ cm->width, cm->height,
1601+ cm->use_highbitdepth);
1602+#else
1603+ vp9_setup_scale_factors_for_frame(&sf, cm->width, cm->height,
1604+ cm->width, cm->height);
1605+#endif // CONFIG_VP9_HIGHBITDEPTH
1606+
15941607 // Allow joint search multiple times iteratively for each reference frame
15951608 // and break out of the search loop if it couldn't find a better mv.
15961609 for (ite = 0; ite < 4; ite++) {
@@ -1619,8 +1632,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 22 unmodified lines
16191632 ref_yv12[!id].stride,
16201633 second_pred, pw,
16211634 &frame_mv[refs[!id]].as_mv,
1622− &xd->block_refs[!id]->sf,
1623− pw, ph, 0,
1635+ &sf, pw, ph, 0,
16241636 kernel, MV_PRECISION_Q3,
16251637 mi_col * MI_SIZE, mi_row * MI_SIZE,
16261638 xd->bd);
@@ -1629,8 +1641,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 2 unmodified lines
16291641 ref_yv12[!id].stride,
16301642 second_pred, pw,
16311643 &frame_mv[refs[!id]].as_mv,
1632− &xd->block_refs[!id]->sf,
1633− pw, ph, 0,
1644+ &sf, pw, ph, 0,
16341645 kernel, MV_PRECISION_Q3,
16351646 mi_col * MI_SIZE, mi_row * MI_SIZE);
16361647 }
@@ -1639,8 +1650,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 2 unmodified lines
16391650 ref_yv12[!id].stride,
16401651 second_pred, pw,
16411652 &frame_mv[refs[!id]].as_mv,
1642− &xd->block_refs[!id]->sf,
1643− pw, ph, 0,
1653+ &sf, pw, ph, 0,
16441654 kernel, MV_PRECISION_Q3,
16451655 mi_col * MI_SIZE, mi_row * MI_SIZE);
16461656 #endif // CONFIG_VP9_HIGHBITDEPTH

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t