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

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

Issue 1015483002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_firstpass.c ('k') | source/libvpx/vp9/encoder/vp9_pickmode.c » ('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 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 this_sad = vp9_vector_var(&ref[this_pos], src, bwl); 1776 this_sad = vp9_vector_var(&ref[this_pos], src, bwl);
1777 if (this_sad < best_sad) { 1777 if (this_sad < best_sad) {
1778 best_sad = this_sad; 1778 best_sad = this_sad;
1779 center = this_pos; 1779 center = this_pos;
1780 } 1780 }
1781 } 1781 }
1782 1782
1783 return (center - (bw >> 1)); 1783 return (center - (bw >> 1));
1784 } 1784 }
1785 1785
1786 static const MV search_pos[9] = { 1786 static const MV search_pos[4] = {
1787 {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, 1787 {-1, 0}, {0, -1}, {0, 1}, {1, 0},
1788 {1, -1}, {1, 0}, {1, 1},
1789 }; 1788 };
1790 1789
1791 unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x, 1790 unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
1792 BLOCK_SIZE bsize) { 1791 BLOCK_SIZE bsize) {
1793 MACROBLOCKD *xd = &x->e_mbd; 1792 MACROBLOCKD *xd = &x->e_mbd;
1794 DECLARE_ALIGNED(16, int16_t, hbuf[128]); 1793 DECLARE_ALIGNED(16, int16_t, hbuf[128]);
1795 DECLARE_ALIGNED(16, int16_t, vbuf[128]); 1794 DECLARE_ALIGNED(16, int16_t, vbuf[128]);
1796 DECLARE_ALIGNED(16, int16_t, src_hbuf[64]); 1795 DECLARE_ALIGNED(16, int16_t, src_hbuf[64]);
1797 DECLARE_ALIGNED(16, int16_t, src_vbuf[64]); 1796 DECLARE_ALIGNED(16, int16_t, src_vbuf[64]);
1798 int idx; 1797 int idx;
1799 const int bw = 4 << b_width_log2_lookup[bsize]; 1798 const int bw = 4 << b_width_log2_lookup[bsize];
1800 const int bh = 4 << b_height_log2_lookup[bsize]; 1799 const int bh = 4 << b_height_log2_lookup[bsize];
1801 const int search_width = bw << 1; 1800 const int search_width = bw << 1;
1802 const int search_height = bh << 1; 1801 const int search_height = bh << 1;
1803 const int src_stride = x->plane[0].src.stride; 1802 const int src_stride = x->plane[0].src.stride;
1804 const int ref_stride = xd->plane[0].pre[0].stride; 1803 const int ref_stride = xd->plane[0].pre[0].stride;
1805 uint8_t const *ref_buf, *src_buf; 1804 uint8_t const *ref_buf, *src_buf;
1806 MV *tmp_mv = &xd->mi[0].src_mi->mbmi.mv[0].as_mv; 1805 MV *tmp_mv = &xd->mi[0].src_mi->mbmi.mv[0].as_mv;
1807 int best_sad; 1806 unsigned int best_sad, tmp_sad, this_sad[4];
1808 MV this_mv; 1807 MV this_mv;
1809 1808
1809 #if CONFIG_VP9_HIGHBITDEPTH
1810 tmp_mv->row = 0;
1811 tmp_mv->col = 0;
1812 return cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, src_stride,
1813 xd->plane[0].pre[0].buf, ref_stride);
1814 #endif
1815
1810 // Set up prediction 1-D reference set 1816 // Set up prediction 1-D reference set
1811 ref_buf = xd->plane[0].pre[0].buf - (bw >> 1); 1817 ref_buf = xd->plane[0].pre[0].buf - (bw >> 1);
1812 for (idx = 0; idx < search_width; idx += 16) { 1818 for (idx = 0; idx < search_width; idx += 16) {
1813 vp9_int_pro_row(&hbuf[idx], ref_buf, ref_stride, bh); 1819 vp9_int_pro_row(&hbuf[idx], ref_buf, ref_stride, bh);
1814 ref_buf += 16; 1820 ref_buf += 16;
1815 } 1821 }
1816 1822
1817 ref_buf = xd->plane[0].pre[0].buf - (bh >> 1) * ref_stride; 1823 ref_buf = xd->plane[0].pre[0].buf - (bh >> 1) * ref_stride;
1818 for (idx = 0; idx < search_height; ++idx) { 1824 for (idx = 0; idx < search_height; ++idx) {
1819 vbuf[idx] = vp9_int_pro_col(ref_buf, bw); 1825 vbuf[idx] = vp9_int_pro_col(ref_buf, bw);
1820 ref_buf += ref_stride; 1826 ref_buf += ref_stride;
1821 } 1827 }
1822 1828
1823 // Set up src 1-D reference set 1829 // Set up src 1-D reference set
1824 for (idx = 0; idx < bw; idx += 16) { 1830 for (idx = 0; idx < bw; idx += 16) {
1825 src_buf = x->plane[0].src.buf + idx; 1831 src_buf = x->plane[0].src.buf + idx;
1826 vp9_int_pro_row(&src_hbuf[idx], src_buf, src_stride, bh); 1832 vp9_int_pro_row(&src_hbuf[idx], src_buf, src_stride, bh);
1827 } 1833 }
1828 1834
1829 src_buf = x->plane[0].src.buf; 1835 src_buf = x->plane[0].src.buf;
1830 for (idx = 0; idx < bh; ++idx) { 1836 for (idx = 0; idx < bh; ++idx) {
1831 src_vbuf[idx] = vp9_int_pro_col(src_buf, bw); 1837 src_vbuf[idx] = vp9_int_pro_col(src_buf, bw);
1832 src_buf += src_stride; 1838 src_buf += src_stride;
1833 } 1839 }
1834 1840
1835 // Find the best match per 1-D search 1841 // Find the best match per 1-D search
1836 tmp_mv->col = vector_match(hbuf, src_hbuf, b_width_log2_lookup[bsize]); 1842 tmp_mv->col = vector_match(hbuf, src_hbuf, b_width_log2_lookup[bsize]);
1837 tmp_mv->row = vector_match(vbuf, src_vbuf, b_height_log2_lookup[bsize]); 1843 tmp_mv->row = vector_match(vbuf, src_vbuf, b_height_log2_lookup[bsize]);
1838 1844
1839 best_sad = INT_MAX;
1840 this_mv = *tmp_mv; 1845 this_mv = *tmp_mv;
1841 for (idx = 0; idx < 9; ++idx) { 1846 src_buf = x->plane[0].src.buf;
1842 int this_sad; 1847 ref_buf = xd->plane[0].pre[0].buf + this_mv.row * ref_stride + this_mv.col;
1843 src_buf = x->plane[0].src.buf; 1848 best_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, ref_buf, ref_stride);
1844 ref_buf = xd->plane[0].pre[0].buf +
1845 (search_pos[idx].row + this_mv.row) * ref_stride +
1846 (search_pos[idx].col + this_mv.col);
1847 1849
1848 this_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, 1850 {
1849 ref_buf, ref_stride); 1851 const uint8_t * const pos[4] = {
1850 if (this_sad < best_sad) { 1852 ref_buf - ref_stride,
1851 best_sad = this_sad; 1853 ref_buf - 1,
1854 ref_buf + 1,
1855 ref_buf + ref_stride,
1856 };
1857
1858 cpi->fn_ptr[bsize].sdx4df(src_buf, src_stride, pos, ref_stride, this_sad);
1859 }
1860
1861 for (idx = 0; idx < 4; ++idx) {
1862 if (this_sad[idx] < best_sad) {
1863 best_sad = this_sad[idx];
1852 tmp_mv->row = search_pos[idx].row + this_mv.row; 1864 tmp_mv->row = search_pos[idx].row + this_mv.row;
1853 tmp_mv->col = search_pos[idx].col + this_mv.col; 1865 tmp_mv->col = search_pos[idx].col + this_mv.col;
1854 } 1866 }
1855 } 1867 }
1868
1869 if (this_sad[0] < this_sad[3])
1870 this_mv.row -= 1;
1871 else
1872 this_mv.row += 1;
1873
1874 if (this_sad[1] < this_sad[2])
1875 this_mv.col -= 1;
1876 else
1877 this_mv.col += 1;
1878
1879 ref_buf = xd->plane[0].pre[0].buf + this_mv.row * ref_stride + this_mv.col;
1880
1881 tmp_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride,
1882 ref_buf, ref_stride);
1883 if (best_sad > tmp_sad) {
1884 *tmp_mv = this_mv;
1885 best_sad = tmp_sad;
1886 }
1887
1856 tmp_mv->row *= 8; 1888 tmp_mv->row *= 8;
1857 tmp_mv->col *= 8; 1889 tmp_mv->col *= 8;
1858 1890
1859 return best_sad; 1891 return best_sad;
1860 } 1892 }
1861 1893
1862 /* do_refine: If last step (1-away) of n-step search doesn't pick the center 1894 /* do_refine: If last step (1-away) of n-step search doesn't pick the center
1863 point as the best match, we will do a final 1-away diamond 1895 point as the best match, we will do a final 1-away diamond
1864 refining search */ 1896 refining search */
1865 int vp9_full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x, 1897 int vp9_full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x,
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 break; 2317 break;
2286 default: 2318 default:
2287 assert(0 && "Invalid search method."); 2319 assert(0 && "Invalid search method.");
2288 } 2320 }
2289 2321
2290 if (method != NSTEP && rd && var < var_max) 2322 if (method != NSTEP && rd && var < var_max)
2291 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1); 2323 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1);
2292 2324
2293 return var; 2325 return var;
2294 } 2326 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_firstpass.c ('k') | source/libvpx/vp9/encoder/vp9_pickmode.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698