OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 } | 1254 } |
1255 *mode_uv = x->e_mbd.mi[0].src_mi->mbmi.uv_mode; | 1255 *mode_uv = x->e_mbd.mi[0].src_mi->mbmi.uv_mode; |
1256 } | 1256 } |
1257 | 1257 |
1258 static int cost_mv_ref(const VP9_COMP *cpi, PREDICTION_MODE mode, | 1258 static int cost_mv_ref(const VP9_COMP *cpi, PREDICTION_MODE mode, |
1259 int mode_context) { | 1259 int mode_context) { |
1260 assert(is_inter_mode(mode)); | 1260 assert(is_inter_mode(mode)); |
1261 return cpi->inter_mode_cost[mode_context][INTER_OFFSET(mode)]; | 1261 return cpi->inter_mode_cost[mode_context][INTER_OFFSET(mode)]; |
1262 } | 1262 } |
1263 | 1263 |
1264 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, | |
1265 BLOCK_SIZE bsize, | |
1266 int_mv *frame_mv, | |
1267 int mi_row, int mi_col, | |
1268 int_mv single_newmv[MAX_REF_FRAMES], | |
1269 int *rate_mv); | |
1270 | |
1271 static int set_and_cost_bmi_mvs(VP9_COMP *cpi, MACROBLOCKD *xd, int i, | 1264 static int set_and_cost_bmi_mvs(VP9_COMP *cpi, MACROBLOCKD *xd, int i, |
1272 PREDICTION_MODE mode, int_mv this_mv[2], | 1265 PREDICTION_MODE mode, int_mv this_mv[2], |
1273 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES], | 1266 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES], |
1274 int_mv seg_mvs[MAX_REF_FRAMES], | 1267 int_mv seg_mvs[MAX_REF_FRAMES], |
1275 int_mv *best_ref_mv[2], const int *mvjcost, | 1268 int_mv *best_ref_mv[2], const int *mvjcost, |
1276 int *mvcost[2]) { | 1269 int *mvcost[2]) { |
1277 MODE_INFO *const mic = xd->mi[0].src_mi; | 1270 MODE_INFO *const mic = xd->mi[0].src_mi; |
1278 const MB_MODE_INFO *const mbmi = &mic->mbmi; | 1271 const MB_MODE_INFO *const mbmi = &mic->mbmi; |
1279 int thismvcost = 0; | 1272 int thismvcost = 0; |
1280 int idx, idy; | 1273 int idx, idy; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 frame_mv[NEARESTMV][ref_frames[1]].as_int == 0) || | 1527 frame_mv[NEARESTMV][ref_frames[1]].as_int == 0) || |
1535 (c3 >= c1 && frame_mv[NEARMV][ref_frames[0]].as_int == 0 && | 1528 (c3 >= c1 && frame_mv[NEARMV][ref_frames[0]].as_int == 0 && |
1536 frame_mv[NEARMV][ref_frames[1]].as_int == 0)) | 1529 frame_mv[NEARMV][ref_frames[1]].as_int == 0)) |
1537 return 0; | 1530 return 0; |
1538 } | 1531 } |
1539 } | 1532 } |
1540 } | 1533 } |
1541 return 1; | 1534 return 1; |
1542 } | 1535 } |
1543 | 1536 |
| 1537 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, |
| 1538 BLOCK_SIZE bsize, |
| 1539 int_mv *frame_mv, |
| 1540 int mi_row, int mi_col, |
| 1541 int_mv single_newmv[MAX_REF_FRAMES], |
| 1542 int *rate_mv) { |
| 1543 const int pw = 4 * num_4x4_blocks_wide_lookup[bsize]; |
| 1544 const int ph = 4 * num_4x4_blocks_high_lookup[bsize]; |
| 1545 MACROBLOCKD *xd = &x->e_mbd; |
| 1546 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; |
| 1547 const int refs[2] = {mbmi->ref_frame[0], |
| 1548 mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]}; |
| 1549 int_mv ref_mv[2]; |
| 1550 int ite, ref; |
| 1551 // Prediction buffer from second frame. |
| 1552 #if CONFIG_VP9_HIGHBITDEPTH |
| 1553 uint8_t *second_pred; |
| 1554 uint8_t *second_pred_alloc; |
| 1555 #else |
| 1556 uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t)); |
| 1557 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 1558 const InterpKernel *kernel = vp9_get_interp_kernel(mbmi->interp_filter); |
| 1559 |
| 1560 // Do joint motion search in compound mode to get more accurate mv. |
| 1561 struct buf_2d backup_yv12[2][MAX_MB_PLANE]; |
| 1562 int last_besterr[2] = {INT_MAX, INT_MAX}; |
| 1563 const YV12_BUFFER_CONFIG *const scaled_ref_frame[2] = { |
| 1564 vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]), |
| 1565 vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[1]) |
| 1566 }; |
| 1567 #if CONFIG_VP9_HIGHBITDEPTH |
| 1568 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 1569 second_pred_alloc = vpx_memalign(16, pw * ph * sizeof(uint16_t)); |
| 1570 second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc); |
| 1571 } else { |
| 1572 second_pred_alloc = vpx_memalign(16, pw * ph * sizeof(uint8_t)); |
| 1573 second_pred = second_pred_alloc; |
| 1574 } |
| 1575 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 1576 |
| 1577 for (ref = 0; ref < 2; ++ref) { |
| 1578 ref_mv[ref] = mbmi->ref_mvs[refs[ref]][0]; |
| 1579 |
| 1580 if (scaled_ref_frame[ref]) { |
| 1581 int i; |
| 1582 // Swap out the reference frame for a version that's been scaled to |
| 1583 // match the resolution of the current frame, allowing the existing |
| 1584 // motion search code to be used without additional modifications. |
| 1585 for (i = 0; i < MAX_MB_PLANE; i++) |
| 1586 backup_yv12[ref][i] = xd->plane[i].pre[ref]; |
| 1587 vp9_setup_pre_planes(xd, ref, scaled_ref_frame[ref], mi_row, mi_col, |
| 1588 NULL); |
| 1589 } |
| 1590 |
| 1591 frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int; |
| 1592 } |
| 1593 |
| 1594 // 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. |
| 1596 for (ite = 0; ite < 4; ite++) { |
| 1597 struct buf_2d ref_yv12[2]; |
| 1598 int bestsme = INT_MAX; |
| 1599 int sadpb = x->sadperbit16; |
| 1600 MV tmp_mv; |
| 1601 int search_range = 3; |
| 1602 |
| 1603 int tmp_col_min = x->mv_col_min; |
| 1604 int tmp_col_max = x->mv_col_max; |
| 1605 int tmp_row_min = x->mv_row_min; |
| 1606 int tmp_row_max = x->mv_row_max; |
| 1607 int id = ite % 2; // Even iterations search in the first reference frame, |
| 1608 // odd iterations search in the second. The predictor |
| 1609 // found for the 'other' reference frame is factored in. |
| 1610 |
| 1611 // Initialized here because of compiler problem in Visual Studio. |
| 1612 ref_yv12[0] = xd->plane[0].pre[0]; |
| 1613 ref_yv12[1] = xd->plane[0].pre[1]; |
| 1614 |
| 1615 // Get the prediction block from the 'other' reference frame. |
| 1616 #if CONFIG_VP9_HIGHBITDEPTH |
| 1617 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 1618 vp9_highbd_build_inter_predictor(ref_yv12[!id].buf, |
| 1619 ref_yv12[!id].stride, |
| 1620 second_pred, pw, |
| 1621 &frame_mv[refs[!id]].as_mv, |
| 1622 &xd->block_refs[!id]->sf, |
| 1623 pw, ph, 0, |
| 1624 kernel, MV_PRECISION_Q3, |
| 1625 mi_col * MI_SIZE, mi_row * MI_SIZE, |
| 1626 xd->bd); |
| 1627 } else { |
| 1628 vp9_build_inter_predictor(ref_yv12[!id].buf, |
| 1629 ref_yv12[!id].stride, |
| 1630 second_pred, pw, |
| 1631 &frame_mv[refs[!id]].as_mv, |
| 1632 &xd->block_refs[!id]->sf, |
| 1633 pw, ph, 0, |
| 1634 kernel, MV_PRECISION_Q3, |
| 1635 mi_col * MI_SIZE, mi_row * MI_SIZE); |
| 1636 } |
| 1637 #else |
| 1638 vp9_build_inter_predictor(ref_yv12[!id].buf, |
| 1639 ref_yv12[!id].stride, |
| 1640 second_pred, pw, |
| 1641 &frame_mv[refs[!id]].as_mv, |
| 1642 &xd->block_refs[!id]->sf, |
| 1643 pw, ph, 0, |
| 1644 kernel, MV_PRECISION_Q3, |
| 1645 mi_col * MI_SIZE, mi_row * MI_SIZE); |
| 1646 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 1647 |
| 1648 // Do compound motion search on the current reference frame. |
| 1649 if (id) |
| 1650 xd->plane[0].pre[0] = ref_yv12[id]; |
| 1651 vp9_set_mv_search_range(x, &ref_mv[id].as_mv); |
| 1652 |
| 1653 // Use the mv result from the single mode as mv predictor. |
| 1654 tmp_mv = frame_mv[refs[id]].as_mv; |
| 1655 |
| 1656 tmp_mv.col >>= 3; |
| 1657 tmp_mv.row >>= 3; |
| 1658 |
| 1659 // Small-range full-pixel motion search. |
| 1660 bestsme = vp9_refining_search_8p_c(x, &tmp_mv, sadpb, |
| 1661 search_range, |
| 1662 &cpi->fn_ptr[bsize], |
| 1663 &ref_mv[id].as_mv, second_pred); |
| 1664 if (bestsme < INT_MAX) |
| 1665 bestsme = vp9_get_mvpred_av_var(x, &tmp_mv, &ref_mv[id].as_mv, |
| 1666 second_pred, &cpi->fn_ptr[bsize], 1); |
| 1667 |
| 1668 x->mv_col_min = tmp_col_min; |
| 1669 x->mv_col_max = tmp_col_max; |
| 1670 x->mv_row_min = tmp_row_min; |
| 1671 x->mv_row_max = tmp_row_max; |
| 1672 |
| 1673 if (bestsme < INT_MAX) { |
| 1674 int dis; /* TODO: use dis in distortion calculation later. */ |
| 1675 unsigned int sse; |
| 1676 bestsme = cpi->find_fractional_mv_step( |
| 1677 x, &tmp_mv, |
| 1678 &ref_mv[id].as_mv, |
| 1679 cpi->common.allow_high_precision_mv, |
| 1680 x->errorperbit, |
| 1681 &cpi->fn_ptr[bsize], |
| 1682 0, cpi->sf.mv.subpel_iters_per_step, |
| 1683 NULL, |
| 1684 x->nmvjointcost, x->mvcost, |
| 1685 &dis, &sse, second_pred, |
| 1686 pw, ph); |
| 1687 } |
| 1688 |
| 1689 // Restore the pointer to the first (possibly scaled) prediction buffer. |
| 1690 if (id) |
| 1691 xd->plane[0].pre[0] = ref_yv12[0]; |
| 1692 |
| 1693 if (bestsme < last_besterr[id]) { |
| 1694 frame_mv[refs[id]].as_mv = tmp_mv; |
| 1695 last_besterr[id] = bestsme; |
| 1696 } else { |
| 1697 break; |
| 1698 } |
| 1699 } |
| 1700 |
| 1701 *rate_mv = 0; |
| 1702 |
| 1703 for (ref = 0; ref < 2; ++ref) { |
| 1704 if (scaled_ref_frame[ref]) { |
| 1705 // Restore the prediction frame pointers to their unscaled versions. |
| 1706 int i; |
| 1707 for (i = 0; i < MAX_MB_PLANE; i++) |
| 1708 xd->plane[i].pre[ref] = backup_yv12[ref][i]; |
| 1709 } |
| 1710 |
| 1711 *rate_mv += vp9_mv_bit_cost(&frame_mv[refs[ref]].as_mv, |
| 1712 &mbmi->ref_mvs[refs[ref]][0].as_mv, |
| 1713 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); |
| 1714 } |
| 1715 |
| 1716 #if CONFIG_VP9_HIGHBITDEPTH |
| 1717 vpx_free(second_pred_alloc); |
| 1718 #else |
| 1719 vpx_free(second_pred); |
| 1720 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 1721 } |
| 1722 |
1544 static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x, | 1723 static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x, |
1545 const TileInfo * const tile, | 1724 const TileInfo * const tile, |
1546 int_mv *best_ref_mv, | 1725 int_mv *best_ref_mv, |
1547 int_mv *second_best_ref_mv, | 1726 int_mv *second_best_ref_mv, |
1548 int64_t best_rd, int *returntotrate, | 1727 int64_t best_rd, int *returntotrate, |
1549 int *returnyrate, | 1728 int *returnyrate, |
1550 int64_t *returndistortion, | 1729 int64_t *returndistortion, |
1551 int *skippable, int64_t *psse, | 1730 int *skippable, int64_t *psse, |
1552 int mvthresh, | 1731 int mvthresh, |
1553 int_mv seg_mvs[4][MAX_REF_FRAMES], | 1732 int_mv seg_mvs[4][MAX_REF_FRAMES], |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 if (cpi->sf.adaptive_motion_search) | 2344 if (cpi->sf.adaptive_motion_search) |
2166 x->pred_mv[ref] = tmp_mv->as_mv; | 2345 x->pred_mv[ref] = tmp_mv->as_mv; |
2167 | 2346 |
2168 if (scaled_ref_frame) { | 2347 if (scaled_ref_frame) { |
2169 int i; | 2348 int i; |
2170 for (i = 0; i < MAX_MB_PLANE; i++) | 2349 for (i = 0; i < MAX_MB_PLANE; i++) |
2171 xd->plane[i].pre[0] = backup_yv12[i]; | 2350 xd->plane[i].pre[0] = backup_yv12[i]; |
2172 } | 2351 } |
2173 } | 2352 } |
2174 | 2353 |
2175 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, | |
2176 BLOCK_SIZE bsize, | |
2177 int_mv *frame_mv, | |
2178 int mi_row, int mi_col, | |
2179 int_mv single_newmv[MAX_REF_FRAMES], | |
2180 int *rate_mv) { | |
2181 const int pw = 4 * num_4x4_blocks_wide_lookup[bsize]; | |
2182 const int ph = 4 * num_4x4_blocks_high_lookup[bsize]; | |
2183 MACROBLOCKD *xd = &x->e_mbd; | |
2184 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; | |
2185 const int refs[2] = { mbmi->ref_frame[0], | |
2186 mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1] }; | |
2187 int_mv ref_mv[2]; | |
2188 int ite, ref; | |
2189 // Prediction buffer from second frame. | |
2190 #if CONFIG_VP9_HIGHBITDEPTH | |
2191 uint8_t *second_pred; | |
2192 uint8_t *second_pred_alloc; | |
2193 #else | |
2194 uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t)); | |
2195 #endif // CONFIG_VP9_HIGHBITDEPTH | |
2196 const InterpKernel *kernel = vp9_get_interp_kernel(mbmi->interp_filter); | |
2197 | 2354 |
2198 // Do joint motion search in compound mode to get more accurate mv. | |
2199 struct buf_2d backup_yv12[2][MAX_MB_PLANE]; | |
2200 struct buf_2d scaled_first_yv12 = xd->plane[0].pre[0]; | |
2201 int last_besterr[2] = {INT_MAX, INT_MAX}; | |
2202 const YV12_BUFFER_CONFIG *const scaled_ref_frame[2] = { | |
2203 vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]), | |
2204 vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[1]) | |
2205 }; | |
2206 #if CONFIG_VP9_HIGHBITDEPTH | |
2207 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { | |
2208 second_pred_alloc = vpx_memalign(16, pw * ph * sizeof(uint16_t)); | |
2209 second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc); | |
2210 } else { | |
2211 second_pred_alloc = vpx_memalign(16, pw * ph * sizeof(uint8_t)); | |
2212 second_pred = second_pred_alloc; | |
2213 } | |
2214 #endif // CONFIG_VP9_HIGHBITDEPTH | |
2215 | |
2216 for (ref = 0; ref < 2; ++ref) { | |
2217 ref_mv[ref] = mbmi->ref_mvs[refs[ref]][0]; | |
2218 | |
2219 if (scaled_ref_frame[ref]) { | |
2220 int i; | |
2221 // Swap out the reference frame for a version that's been scaled to | |
2222 // match the resolution of the current frame, allowing the existing | |
2223 // motion search code to be used without additional modifications. | |
2224 for (i = 0; i < MAX_MB_PLANE; i++) | |
2225 backup_yv12[ref][i] = xd->plane[i].pre[ref]; | |
2226 vp9_setup_pre_planes(xd, ref, scaled_ref_frame[ref], mi_row, mi_col, | |
2227 NULL); | |
2228 } | |
2229 | |
2230 frame_mv[refs[ref]].as_int = single_newmv[refs[ref]].as_int; | |
2231 } | |
2232 | |
2233 // Allow joint search multiple times iteratively for each ref frame | |
2234 // and break out the search loop if it couldn't find better mv. | |
2235 for (ite = 0; ite < 4; ite++) { | |
2236 struct buf_2d ref_yv12[2]; | |
2237 int bestsme = INT_MAX; | |
2238 int sadpb = x->sadperbit16; | |
2239 MV tmp_mv; | |
2240 int search_range = 3; | |
2241 | |
2242 int tmp_col_min = x->mv_col_min; | |
2243 int tmp_col_max = x->mv_col_max; | |
2244 int tmp_row_min = x->mv_row_min; | |
2245 int tmp_row_max = x->mv_row_max; | |
2246 int id = ite % 2; | |
2247 | |
2248 // Initialized here because of compiler problem in Visual Studio. | |
2249 ref_yv12[0] = xd->plane[0].pre[0]; | |
2250 ref_yv12[1] = xd->plane[0].pre[1]; | |
2251 | |
2252 // Get pred block from second frame. | |
2253 #if CONFIG_VP9_HIGHBITDEPTH | |
2254 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { | |
2255 vp9_highbd_build_inter_predictor(ref_yv12[!id].buf, | |
2256 ref_yv12[!id].stride, | |
2257 second_pred, pw, | |
2258 &frame_mv[refs[!id]].as_mv, | |
2259 &xd->block_refs[!id]->sf, | |
2260 pw, ph, 0, | |
2261 kernel, MV_PRECISION_Q3, | |
2262 mi_col * MI_SIZE, mi_row * MI_SIZE, | |
2263 xd->bd); | |
2264 } else { | |
2265 vp9_build_inter_predictor(ref_yv12[!id].buf, | |
2266 ref_yv12[!id].stride, | |
2267 second_pred, pw, | |
2268 &frame_mv[refs[!id]].as_mv, | |
2269 &xd->block_refs[!id]->sf, | |
2270 pw, ph, 0, | |
2271 kernel, MV_PRECISION_Q3, | |
2272 mi_col * MI_SIZE, mi_row * MI_SIZE); | |
2273 } | |
2274 #else | |
2275 vp9_build_inter_predictor(ref_yv12[!id].buf, | |
2276 ref_yv12[!id].stride, | |
2277 second_pred, pw, | |
2278 &frame_mv[refs[!id]].as_mv, | |
2279 &xd->block_refs[!id]->sf, | |
2280 pw, ph, 0, | |
2281 kernel, MV_PRECISION_Q3, | |
2282 mi_col * MI_SIZE, mi_row * MI_SIZE); | |
2283 #endif // CONFIG_VP9_HIGHBITDEPTH | |
2284 | |
2285 // Compound motion search on first ref frame. | |
2286 if (id) | |
2287 xd->plane[0].pre[0] = ref_yv12[id]; | |
2288 vp9_set_mv_search_range(x, &ref_mv[id].as_mv); | |
2289 | |
2290 // Use mv result from single mode as mvp. | |
2291 tmp_mv = frame_mv[refs[id]].as_mv; | |
2292 | |
2293 tmp_mv.col >>= 3; | |
2294 tmp_mv.row >>= 3; | |
2295 | |
2296 // Small-range full-pixel motion search | |
2297 bestsme = vp9_refining_search_8p_c(x, &tmp_mv, sadpb, | |
2298 search_range, | |
2299 &cpi->fn_ptr[bsize], | |
2300 &ref_mv[id].as_mv, second_pred); | |
2301 if (bestsme < INT_MAX) | |
2302 bestsme = vp9_get_mvpred_av_var(x, &tmp_mv, &ref_mv[id].as_mv, | |
2303 second_pred, &cpi->fn_ptr[bsize], 1); | |
2304 | |
2305 x->mv_col_min = tmp_col_min; | |
2306 x->mv_col_max = tmp_col_max; | |
2307 x->mv_row_min = tmp_row_min; | |
2308 x->mv_row_max = tmp_row_max; | |
2309 | |
2310 if (bestsme < INT_MAX) { | |
2311 int dis; /* TODO: use dis in distortion calculation later. */ | |
2312 unsigned int sse; | |
2313 bestsme = cpi->find_fractional_mv_step( | |
2314 x, &tmp_mv, | |
2315 &ref_mv[id].as_mv, | |
2316 cpi->common.allow_high_precision_mv, | |
2317 x->errorperbit, | |
2318 &cpi->fn_ptr[bsize], | |
2319 0, cpi->sf.mv.subpel_iters_per_step, | |
2320 NULL, | |
2321 x->nmvjointcost, x->mvcost, | |
2322 &dis, &sse, second_pred, | |
2323 pw, ph); | |
2324 } | |
2325 | |
2326 if (id) | |
2327 xd->plane[0].pre[0] = scaled_first_yv12; | |
2328 | |
2329 if (bestsme < last_besterr[id]) { | |
2330 frame_mv[refs[id]].as_mv = tmp_mv; | |
2331 last_besterr[id] = bestsme; | |
2332 } else { | |
2333 break; | |
2334 } | |
2335 } | |
2336 | |
2337 *rate_mv = 0; | |
2338 | |
2339 for (ref = 0; ref < 2; ++ref) { | |
2340 if (scaled_ref_frame[ref]) { | |
2341 // restore the predictor | |
2342 int i; | |
2343 for (i = 0; i < MAX_MB_PLANE; i++) | |
2344 xd->plane[i].pre[ref] = backup_yv12[ref][i]; | |
2345 } | |
2346 | |
2347 *rate_mv += vp9_mv_bit_cost(&frame_mv[refs[ref]].as_mv, | |
2348 &mbmi->ref_mvs[refs[ref]][0].as_mv, | |
2349 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); | |
2350 } | |
2351 | |
2352 #if CONFIG_VP9_HIGHBITDEPTH | |
2353 vpx_free(second_pred_alloc); | |
2354 #else | |
2355 vpx_free(second_pred); | |
2356 #endif // CONFIG_VP9_HIGHBITDEPTH | |
2357 } | |
2358 | 2355 |
2359 static INLINE void restore_dst_buf(MACROBLOCKD *xd, | 2356 static INLINE void restore_dst_buf(MACROBLOCKD *xd, |
2360 uint8_t *orig_dst[MAX_MB_PLANE], | 2357 uint8_t *orig_dst[MAX_MB_PLANE], |
2361 int orig_dst_stride[MAX_MB_PLANE]) { | 2358 int orig_dst_stride[MAX_MB_PLANE]) { |
2362 int i; | 2359 int i; |
2363 for (i = 0; i < MAX_MB_PLANE; i++) { | 2360 for (i = 0; i < MAX_MB_PLANE; i++) { |
2364 xd->plane[i].dst.buf = orig_dst[i]; | 2361 xd->plane[i].dst.buf = orig_dst[i]; |
2365 xd->plane[i].dst.stride = orig_dst_stride[i]; | 2362 xd->plane[i].dst.stride = orig_dst_stride[i]; |
2366 } | 2363 } |
2367 } | 2364 } |
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4234 } | 4231 } |
4235 if (cm->interp_filter == SWITCHABLE) | 4232 if (cm->interp_filter == SWITCHABLE) |
4236 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); | 4233 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); |
4237 } else { | 4234 } else { |
4238 vp9_zero(best_filter_diff); | 4235 vp9_zero(best_filter_diff); |
4239 } | 4236 } |
4240 | 4237 |
4241 store_coding_context(x, ctx, best_ref_index, | 4238 store_coding_context(x, ctx, best_ref_index, |
4242 best_pred_diff, best_tx_diff, best_filter_diff, 0); | 4239 best_pred_diff, best_tx_diff, best_filter_diff, 0); |
4243 } | 4240 } |
OLD | NEW |