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