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
1540 int mi_row, int mi_col,1540 int mi_row, int mi_col,
1541 int_mv single_newmv[MAX_REF_FRAMES],1541 int_mv single_newmv[MAX_REF_FRAMES],
1542 int *rate_mv) {1542 int *rate_mv) {
1543 const VP9_COMMON *const cm = &cpi->common;
1543 const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];1544 const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];
1544 const int ph = 4 * num_4x4_blocks_high_lookup[bsize];1545 const int ph = 4 * num_4x4_blocks_high_lookup[bsize];
1545 MACROBLOCKD *xd = &x->e_mbd;1546 MACROBLOCKD *xd = &x->e_mbd;
@@ -1556,6 +1557,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 10 unmodified lines
1556 uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t));1557 uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t));
1557#endif // CONFIG_VP9_HIGHBITDEPTH1558#endif // CONFIG_VP9_HIGHBITDEPTH
1558 const InterpKernel *kernel = vp9_get_interp_kernel(mbmi->interp_filter);1559 const InterpKernel *kernel = vp9_get_interp_kernel(mbmi->interp_filter);
1560 struct scale_factors sf;
1559 1561
1560 // Do joint motion search in compound mode to get more accurate mv.1562 // Do joint motion search in compound mode to get more accurate mv.
1561 struct buf_2d backup_yv12[2][MAX_MB_PLANE];1563 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
1591 frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int;1593 frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int;
1592 }1594 }
1593 1595
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
1594 // Allow joint search multiple times iteratively for each reference frame1607 // Allow joint search multiple times iteratively for each reference frame
1595 // and break out of the search loop if it couldn't find a better mv.1608 // and break out of the search loop if it couldn't find a better mv.
1596 for (ite = 0; ite < 4; ite++) {1609 for (ite = 0; ite < 4; ite++) {
@@ -1619,8 +1632,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 22 unmodified lines
1619 ref_yv12[!id].stride,1632 ref_yv12[!id].stride,
1620 second_pred, pw,1633 second_pred, pw,
1621 &frame_mv[refs[!id]].as_mv,1634 &frame_mv[refs[!id]].as_mv,
1622 &xd->block_refs[!id]->sf,1635 &sf, pw, ph, 0,
1623 pw, ph, 0,
1624 kernel, MV_PRECISION_Q3,1636 kernel, MV_PRECISION_Q3,
1625 mi_col * MI_SIZE, mi_row * MI_SIZE,1637 mi_col * MI_SIZE, mi_row * MI_SIZE,
1626 xd->bd);1638 xd->bd);
@@ -1629,8 +1641,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 2 unmodified lines
1629 ref_yv12[!id].stride,1641 ref_yv12[!id].stride,
1630 second_pred, pw,1642 second_pred, pw,
1631 &frame_mv[refs[!id]].as_mv,1643 &frame_mv[refs[!id]].as_mv,
1632 &xd->block_refs[!id]->sf,1644 &sf, pw, ph, 0,
1633 pw, ph, 0,
1634 kernel, MV_PRECISION_Q3,1645 kernel, MV_PRECISION_Q3,
1635 mi_col * MI_SIZE, mi_row * MI_SIZE);1646 mi_col * MI_SIZE, mi_row * MI_SIZE);
1636 }1647 }
@@ -1639,8 +1650,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, · 2 unmodified lines
1639 ref_yv12[!id].stride,1650 ref_yv12[!id].stride,
1640 second_pred, pw,1651 second_pred, pw,
1641 &frame_mv[refs[!id]].as_mv,1652 &frame_mv[refs[!id]].as_mv,
1642 &xd->block_refs[!id]->sf,1653 &sf, pw, ph, 0,
1643 pw, ph, 0,
1644 kernel, MV_PRECISION_Q3,1654 kernel, MV_PRECISION_Q3,
1645 mi_col * MI_SIZE, mi_row * MI_SIZE);1655 mi_col * MI_SIZE, mi_row * MI_SIZE);
1646#endif // CONFIG_VP9_HIGHBITDEPTH1656#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