Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_rdopt.c

Issue 23440041: Libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_onyx_int.h ('k') | source/libvpx/vp9/vp9_common.mk » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 if (i > 0) { 1764 if (i > 0) {
1765 bsi->mvp.as_int = mi->bmi[i - 1].as_mv[0].as_int; 1765 bsi->mvp.as_int = mi->bmi[i - 1].as_mv[0].as_int;
1766 if (i == 2) 1766 if (i == 2)
1767 bsi->mvp.as_int = mi->bmi[i - 2].as_mv[0].as_int; 1767 bsi->mvp.as_int = mi->bmi[i - 2].as_mv[0].as_int;
1768 } 1768 }
1769 } 1769 }
1770 if (i == 0) 1770 if (i == 0)
1771 max_mv = x->max_mv_context[mbmi->ref_frame[0]]; 1771 max_mv = x->max_mv_context[mbmi->ref_frame[0]];
1772 else 1772 else
1773 max_mv = MAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3; 1773 max_mv = MAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3;
1774
1774 if (cpi->sf.auto_mv_step_size && cpi->common.show_frame) { 1775 if (cpi->sf.auto_mv_step_size && cpi->common.show_frame) {
1775 // Take wtd average of the step_params based on the last frame's 1776 // Take wtd average of the step_params based on the last frame's
1776 // max mv magnitude and the best ref mvs of the current block for 1777 // max mv magnitude and the best ref mvs of the current block for
1777 // the given reference. 1778 // the given reference.
1778 step_param = (vp9_init_search_range(cpi, max_mv) + 1779 step_param = (vp9_init_search_range(cpi, max_mv) +
1779 cpi->mv_step_param) >> 1; 1780 cpi->mv_step_param) >> 1;
1780 } else { 1781 } else {
1781 step_param = cpi->mv_step_param; 1782 step_param = cpi->mv_step_param;
1782 } 1783 }
1783 1784
1784 further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
1785
1786 mvp_full.as_mv.row = bsi->mvp.as_mv.row >> 3; 1785 mvp_full.as_mv.row = bsi->mvp.as_mv.row >> 3;
1787 mvp_full.as_mv.col = bsi->mvp.as_mv.col >> 3; 1786 mvp_full.as_mv.col = bsi->mvp.as_mv.col >> 3;
1788 1787
1788 if (cpi->sf.adaptive_motion_search && cpi->common.show_frame) {
1789 mvp_full.as_mv.row = x->pred_mv[mbmi->ref_frame[0]].as_mv.row >> 3;
1790 mvp_full.as_mv.col = x->pred_mv[mbmi->ref_frame[0]].as_mv.col >> 3;
1791 step_param = MAX(step_param, 8);
1792 }
1793
1794 further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
1789 // adjust src pointer for this block 1795 // adjust src pointer for this block
1790 mi_buf_shift(x, i); 1796 mi_buf_shift(x, i);
1791 if (cpi->sf.search_method == HEX) { 1797 if (cpi->sf.search_method == HEX) {
1792 bestsme = vp9_hex_search(x, &mvp_full, 1798 bestsme = vp9_hex_search(x, &mvp_full,
1793 step_param, 1799 step_param,
1794 sadpb, 1, v_fn_ptr, 1, 1800 sadpb, 1, v_fn_ptr, 1,
1795 bsi->ref_mv, &mode_mv[NEWMV]); 1801 bsi->ref_mv, &mode_mv[NEWMV]);
1796 } else if (cpi->sf.search_method == SQUARE) { 1802 } else if (cpi->sf.search_method == SQUARE) {
1797 bestsme = vp9_square_search(x, &mvp_full, 1803 bestsme = vp9_square_search(x, &mvp_full,
1798 step_param, 1804 step_param,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 1838
1833 if (bestsme < INT_MAX) { 1839 if (bestsme < INT_MAX) {
1834 int distortion; 1840 int distortion;
1835 unsigned int sse; 1841 unsigned int sse;
1836 cpi->find_fractional_mv_step(x, &mode_mv[NEWMV], 1842 cpi->find_fractional_mv_step(x, &mode_mv[NEWMV],
1837 bsi->ref_mv, x->errorperbit, v_fn_ptr, 1843 bsi->ref_mv, x->errorperbit, v_fn_ptr,
1838 0, cpi->sf.subpel_iters_per_step, 1844 0, cpi->sf.subpel_iters_per_step,
1839 x->nmvjointcost, x->mvcost, 1845 x->nmvjointcost, x->mvcost,
1840 &distortion, &sse); 1846 &distortion, &sse);
1841 1847
1842 // safe motion search result for use in compound prediction 1848 // save motion search result for use in compound prediction
1843 seg_mvs[i][mbmi->ref_frame[0]].as_int = mode_mv[NEWMV].as_int; 1849 seg_mvs[i][mbmi->ref_frame[0]].as_int = mode_mv[NEWMV].as_int;
1844 } 1850 }
1845 1851
1852 if (cpi->sf.adaptive_motion_search)
1853 x->pred_mv[mbmi->ref_frame[0]].as_int = mode_mv[NEWMV].as_int;
1854
1846 // restore src pointers 1855 // restore src pointers
1847 mi_buf_restore(x, orig_src, orig_pre); 1856 mi_buf_restore(x, orig_src, orig_pre);
1848 } 1857 }
1849 1858
1850 if (mbmi->ref_frame[1] > 0 && this_mode == NEWMV && 1859 if (mbmi->ref_frame[1] > 0 && this_mode == NEWMV &&
1851 mbmi->interp_filter == EIGHTTAP) { 1860 mbmi->interp_filter == EIGHTTAP) {
1852 if (seg_mvs[i][mbmi->ref_frame[1]].as_int == INVALID_MV || 1861 if (seg_mvs[i][mbmi->ref_frame[1]].as_int == INVALID_MV ||
1853 seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV) 1862 seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV)
1854 continue; 1863 continue;
1855 1864
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 int i; 2087 int i;
2079 int zero_seen = 0; 2088 int zero_seen = 0;
2080 int best_index = 0; 2089 int best_index = 0;
2081 int best_sad = INT_MAX; 2090 int best_sad = INT_MAX;
2082 int this_sad = INT_MAX; 2091 int this_sad = INT_MAX;
2083 unsigned int max_mv = 0; 2092 unsigned int max_mv = 0;
2084 2093
2085 uint8_t *src_y_ptr = x->plane[0].src.buf; 2094 uint8_t *src_y_ptr = x->plane[0].src.buf;
2086 uint8_t *ref_y_ptr; 2095 uint8_t *ref_y_ptr;
2087 int row_offset, col_offset; 2096 int row_offset, col_offset;
2097 int num_mv_refs = MAX_MV_REF_CANDIDATES +
2098 (cpi->sf.adaptive_motion_search &&
2099 cpi->common.show_frame && block_size < BLOCK_64X64);
2088 2100
2089 // Get the sad for each candidate reference mv 2101 // Get the sad for each candidate reference mv
2090 for (i = 0; i < MAX_MV_REF_CANDIDATES; i++) { 2102 for (i = 0; i < num_mv_refs; i++) {
2091 this_mv.as_int = mbmi->ref_mvs[ref_frame][i].as_int; 2103 this_mv.as_int = (i < MAX_MV_REF_CANDIDATES) ?
2104 mbmi->ref_mvs[ref_frame][i].as_int : x->pred_mv[ref_frame].as_int;
2092 2105
2093 max_mv = MAX(max_mv, 2106 max_mv = MAX(max_mv,
2094 MAX(abs(this_mv.as_mv.row), abs(this_mv.as_mv.col)) >> 3); 2107 MAX(abs(this_mv.as_mv.row), abs(this_mv.as_mv.col)) >> 3);
2095 // The list is at an end if we see 0 for a second time. 2108 // The list is at an end if we see 0 for a second time.
2096 if (!this_mv.as_int && zero_seen) 2109 if (!this_mv.as_int && zero_seen)
2097 break; 2110 break;
2098 zero_seen = zero_seen || !this_mv.as_int; 2111 zero_seen = zero_seen || !this_mv.as_int;
2099 2112
2100 row_offset = this_mv.as_mv.row >> 3; 2113 row_offset = this_mv.as_mv.row >> 3;
2101 col_offset = this_mv.as_mv.col >> 3; 2114 col_offset = this_mv.as_mv.col >> 3;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 // Adjust search parameters based on small partitions' result. 2355 // Adjust search parameters based on small partitions' result.
2343 if (x->fast_ms) { 2356 if (x->fast_ms) {
2344 // && abs(mvp_full.as_mv.row - x->pred_mv.as_mv.row) < 24 && 2357 // && abs(mvp_full.as_mv.row - x->pred_mv.as_mv.row) < 24 &&
2345 // abs(mvp_full.as_mv.col - x->pred_mv.as_mv.col) < 24) { 2358 // abs(mvp_full.as_mv.col - x->pred_mv.as_mv.col) < 24) {
2346 // adjust search range 2359 // adjust search range
2347 step_param = 6; 2360 step_param = 6;
2348 if (x->fast_ms > 1) 2361 if (x->fast_ms > 1)
2349 step_param = 8; 2362 step_param = 8;
2350 2363
2351 // Get prediction MV. 2364 // Get prediction MV.
2352 mvp_full.as_int = x->pred_mv.as_int; 2365 mvp_full.as_int = x->pred_mv[ref].as_int;
2353 2366
2354 // Adjust MV sign if needed. 2367 // Adjust MV sign if needed.
2355 if (cm->ref_frame_sign_bias[ref]) { 2368 if (cm->ref_frame_sign_bias[ref]) {
2356 mvp_full.as_mv.col *= -1; 2369 mvp_full.as_mv.col *= -1;
2357 mvp_full.as_mv.row *= -1; 2370 mvp_full.as_mv.row *= -1;
2358 } 2371 }
2359 } else { 2372 } else {
2360 // Work out the size of the first step in the mv step search. 2373 // Work out the size of the first step in the mv step search.
2361 // 0 here is maximum length first step. 1 is MAX >> 1 etc. 2374 // 0 here is maximum length first step. 1 is MAX >> 1 etc.
2362 if (cpi->sf.auto_mv_step_size && cpi->common.show_frame) { 2375 if (cpi->sf.auto_mv_step_size && cpi->common.show_frame) {
2363 // Take wtd average of the step_params based on the last frame's 2376 // Take wtd average of the step_params based on the last frame's
2364 // max mv magnitude and that based on the best ref mvs of the current 2377 // max mv magnitude and that based on the best ref mvs of the current
2365 // block for the given reference. 2378 // block for the given reference.
2366 step_param = (vp9_init_search_range(cpi, x->max_mv_context[ref]) + 2379 step_param = (vp9_init_search_range(cpi, x->max_mv_context[ref]) +
2367 cpi->mv_step_param) >> 1; 2380 cpi->mv_step_param) >> 1;
2368 } else { 2381 } else {
2369 step_param = cpi->mv_step_param; 2382 step_param = cpi->mv_step_param;
2370 } 2383 }
2371 // mvp_full.as_int = ref_mv[0].as_int;
2372 mvp_full.as_int =
2373 mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_int;
2374 } 2384 }
2375 2385
2386 if (cpi->sf.adaptive_motion_search && bsize < BLOCK_64X64 &&
2387 cpi->common.show_frame) {
2388 int boffset = 2 * (b_width_log2(BLOCK_64X64) - MIN(b_height_log2(bsize),
2389 b_width_log2(bsize)));
2390 step_param = MAX(step_param, boffset);
2391 }
2392
2393 mvp_full.as_int = x->mv_best_ref_index[ref] < MAX_MV_REF_CANDIDATES ?
2394 mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_int :
2395 x->pred_mv[ref].as_int;
2396
2376 mvp_full.as_mv.col >>= 3; 2397 mvp_full.as_mv.col >>= 3;
2377 mvp_full.as_mv.row >>= 3; 2398 mvp_full.as_mv.row >>= 3;
2378 2399
2379 // Further step/diamond searches as necessary 2400 // Further step/diamond searches as necessary
2380 further_steps = (cpi->sf.max_step_search_steps - 1) - step_param; 2401 further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
2381 2402
2382 if (cpi->sf.search_method == HEX) { 2403 if (cpi->sf.search_method == HEX) {
2383 bestsme = vp9_hex_search(x, &mvp_full, 2404 bestsme = vp9_hex_search(x, &mvp_full,
2384 step_param, 2405 step_param,
2385 sadpb, 1, 2406 sadpb, 1,
(...skipping 29 matching lines...) Expand all
2415 cpi->find_fractional_mv_step(x, tmp_mv, &ref_mv, 2436 cpi->find_fractional_mv_step(x, tmp_mv, &ref_mv,
2416 x->errorperbit, 2437 x->errorperbit,
2417 &cpi->fn_ptr[block_size], 2438 &cpi->fn_ptr[block_size],
2418 0, cpi->sf.subpel_iters_per_step, 2439 0, cpi->sf.subpel_iters_per_step,
2419 x->nmvjointcost, x->mvcost, 2440 x->nmvjointcost, x->mvcost,
2420 &dis, &sse); 2441 &dis, &sse);
2421 } 2442 }
2422 *rate_mv = vp9_mv_bit_cost(tmp_mv, &ref_mv, 2443 *rate_mv = vp9_mv_bit_cost(tmp_mv, &ref_mv,
2423 x->nmvjointcost, x->mvcost, 2444 x->nmvjointcost, x->mvcost,
2424 96); 2445 96);
2446
2447 if (cpi->sf.adaptive_motion_search && cpi->common.show_frame)
2448 x->pred_mv[ref].as_int = tmp_mv->as_int;
2449
2425 if (scaled_ref_frame) { 2450 if (scaled_ref_frame) {
2426 int i; 2451 int i;
2427 for (i = 0; i < MAX_MB_PLANE; i++) 2452 for (i = 0; i < MAX_MB_PLANE; i++)
2428 xd->plane[i].pre[0] = backup_yv12[i]; 2453 xd->plane[i].pre[0] = backup_yv12[i];
2429 } 2454 }
2430 } 2455 }
2431 2456
2432 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, 2457 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
2433 BLOCK_SIZE bsize, 2458 BLOCK_SIZE bsize,
2434 int_mv *frame_mv, 2459 int_mv *frame_mv,
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 scale_factor); 4040 scale_factor);
4016 store_coding_context(x, ctx, best_mode_index, 4041 store_coding_context(x, ctx, best_mode_index,
4017 &best_partition, 4042 &best_partition,
4018 &mbmi->ref_mvs[mbmi->ref_frame[0]][0], 4043 &mbmi->ref_mvs[mbmi->ref_frame[0]][0],
4019 &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 : 4044 &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 :
4020 mbmi->ref_frame[1]][0], 4045 mbmi->ref_frame[1]][0],
4021 best_pred_diff, best_tx_diff, best_filter_diff); 4046 best_pred_diff, best_tx_diff, best_filter_diff);
4022 4047
4023 return best_rd; 4048 return best_rd;
4024 } 4049 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_onyx_int.h ('k') | source/libvpx/vp9/vp9_common.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698