| 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 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 break; | 1707 break; |
| 1708 }; | 1708 }; |
| 1709 #endif | 1709 #endif |
| 1710 } else if (best_address == in_what) { | 1710 } else if (best_address == in_what) { |
| 1711 (*num00)++; | 1711 (*num00)++; |
| 1712 } | 1712 } |
| 1713 } | 1713 } |
| 1714 return bestsad; | 1714 return bestsad; |
| 1715 } | 1715 } |
| 1716 | 1716 |
| 1717 static int vector_match(int16_t *ref, int16_t *src, int bwl) { |
| 1718 int best_sad = INT_MAX; |
| 1719 int this_sad; |
| 1720 int d; |
| 1721 int center, offset = 0; |
| 1722 int bw = 4 << bwl; // redundant variable, to be changed in the experiments. |
| 1723 for (d = 0; d <= bw; d += 16) { |
| 1724 this_sad = vp9_vector_var(&ref[d], src, bwl); |
| 1725 if (this_sad < best_sad) { |
| 1726 best_sad = this_sad; |
| 1727 offset = d; |
| 1728 } |
| 1729 } |
| 1730 center = offset; |
| 1731 |
| 1732 for (d = -8; d <= 8; d += 16) { |
| 1733 int this_pos = offset + d; |
| 1734 // check limit |
| 1735 if (this_pos < 0 || this_pos > bw) |
| 1736 continue; |
| 1737 this_sad = vp9_vector_var(&ref[this_pos], src, bwl); |
| 1738 if (this_sad < best_sad) { |
| 1739 best_sad = this_sad; |
| 1740 center = this_pos; |
| 1741 } |
| 1742 } |
| 1743 offset = center; |
| 1744 |
| 1745 for (d = -4; d <= 4; d += 8) { |
| 1746 int this_pos = offset + d; |
| 1747 // check limit |
| 1748 if (this_pos < 0 || this_pos > bw) |
| 1749 continue; |
| 1750 this_sad = vp9_vector_var(&ref[this_pos], src, bwl); |
| 1751 if (this_sad < best_sad) { |
| 1752 best_sad = this_sad; |
| 1753 center = this_pos; |
| 1754 } |
| 1755 } |
| 1756 offset = center; |
| 1757 |
| 1758 for (d = -2; d <= 2; d += 4) { |
| 1759 int this_pos = offset + d; |
| 1760 // check limit |
| 1761 if (this_pos < 0 || this_pos > bw) |
| 1762 continue; |
| 1763 this_sad = vp9_vector_var(&ref[this_pos], src, bwl); |
| 1764 if (this_sad < best_sad) { |
| 1765 best_sad = this_sad; |
| 1766 center = this_pos; |
| 1767 } |
| 1768 } |
| 1769 offset = center; |
| 1770 |
| 1771 for (d = -1; d <= 1; d += 2) { |
| 1772 int this_pos = offset + d; |
| 1773 // check limit |
| 1774 if (this_pos < 0 || this_pos > bw) |
| 1775 continue; |
| 1776 this_sad = vp9_vector_var(&ref[this_pos], src, bwl); |
| 1777 if (this_sad < best_sad) { |
| 1778 best_sad = this_sad; |
| 1779 center = this_pos; |
| 1780 } |
| 1781 } |
| 1782 |
| 1783 return (center - (bw >> 1)); |
| 1784 } |
| 1785 |
| 1786 static const MV search_pos[9] = { |
| 1787 {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, {0, 1}, |
| 1788 {1, -1}, {1, 0}, {1, 1}, |
| 1789 }; |
| 1790 |
| 1791 unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x, |
| 1792 BLOCK_SIZE bsize) { |
| 1793 MACROBLOCKD *xd = &x->e_mbd; |
| 1794 DECLARE_ALIGNED(16, int16_t, hbuf[128]); |
| 1795 DECLARE_ALIGNED(16, int16_t, vbuf[128]); |
| 1796 DECLARE_ALIGNED(16, int16_t, src_hbuf[64]); |
| 1797 DECLARE_ALIGNED(16, int16_t, src_vbuf[64]); |
| 1798 int idx; |
| 1799 const int bw = 4 << b_width_log2_lookup[bsize]; |
| 1800 const int bh = 4 << b_height_log2_lookup[bsize]; |
| 1801 const int search_width = bw << 1; |
| 1802 const int search_height = bh << 1; |
| 1803 const int src_stride = x->plane[0].src.stride; |
| 1804 const int ref_stride = xd->plane[0].pre[0].stride; |
| 1805 uint8_t const *ref_buf, *src_buf; |
| 1806 MV *tmp_mv = &xd->mi[0].src_mi->mbmi.mv[0].as_mv; |
| 1807 int best_sad; |
| 1808 MV this_mv; |
| 1809 |
| 1810 // Set up prediction 1-D reference set |
| 1811 ref_buf = xd->plane[0].pre[0].buf - (bw >> 1); |
| 1812 for (idx = 0; idx < search_width; idx += 16) { |
| 1813 vp9_int_pro_row(&hbuf[idx], ref_buf, ref_stride, bh); |
| 1814 ref_buf += 16; |
| 1815 } |
| 1816 |
| 1817 ref_buf = xd->plane[0].pre[0].buf - (bh >> 1) * ref_stride; |
| 1818 for (idx = 0; idx < search_height; ++idx) { |
| 1819 vbuf[idx] = vp9_int_pro_col(ref_buf, bw); |
| 1820 ref_buf += ref_stride; |
| 1821 } |
| 1822 |
| 1823 // Set up src 1-D reference set |
| 1824 for (idx = 0; idx < bw; idx += 16) { |
| 1825 src_buf = x->plane[0].src.buf + idx; |
| 1826 vp9_int_pro_row(&src_hbuf[idx], src_buf, src_stride, bh); |
| 1827 } |
| 1828 |
| 1829 src_buf = x->plane[0].src.buf; |
| 1830 for (idx = 0; idx < bh; ++idx) { |
| 1831 src_vbuf[idx] = vp9_int_pro_col(src_buf, bw); |
| 1832 src_buf += src_stride; |
| 1833 } |
| 1834 |
| 1835 // Find the best match per 1-D search |
| 1836 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]); |
| 1838 |
| 1839 best_sad = INT_MAX; |
| 1840 this_mv = *tmp_mv; |
| 1841 for (idx = 0; idx < 9; ++idx) { |
| 1842 int this_sad; |
| 1843 src_buf = x->plane[0].src.buf; |
| 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 |
| 1848 this_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, |
| 1849 ref_buf, ref_stride); |
| 1850 if (this_sad < best_sad) { |
| 1851 best_sad = this_sad; |
| 1852 tmp_mv->row = search_pos[idx].row + this_mv.row; |
| 1853 tmp_mv->col = search_pos[idx].col + this_mv.col; |
| 1854 } |
| 1855 } |
| 1856 tmp_mv->row *= 8; |
| 1857 tmp_mv->col *= 8; |
| 1858 x->pred_mv[LAST_FRAME] = *tmp_mv; |
| 1859 |
| 1860 return best_sad; |
| 1861 } |
| 1862 |
| 1717 /* do_refine: If last step (1-away) of n-step search doesn't pick the center | 1863 /* do_refine: If last step (1-away) of n-step search doesn't pick the center |
| 1718 point as the best match, we will do a final 1-away diamond | 1864 point as the best match, we will do a final 1-away diamond |
| 1719 refining search */ | 1865 refining search */ |
| 1720 int vp9_full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x, | 1866 int vp9_full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x, |
| 1721 MV *mvp_full, int step_param, | 1867 MV *mvp_full, int step_param, |
| 1722 int sadpb, int further_steps, int do_refine, | 1868 int sadpb, int further_steps, int do_refine, |
| 1723 int *cost_list, | 1869 int *cost_list, |
| 1724 const vp9_variance_fn_ptr_t *fn_ptr, | 1870 const vp9_variance_fn_ptr_t *fn_ptr, |
| 1725 const MV *ref_mv, MV *dst_mv) { | 1871 const MV *ref_mv, MV *dst_mv) { |
| 1726 MV temp_mv; | 1872 MV temp_mv; |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 break; | 2286 break; |
| 2141 default: | 2287 default: |
| 2142 assert(0 && "Invalid search method."); | 2288 assert(0 && "Invalid search method."); |
| 2143 } | 2289 } |
| 2144 | 2290 |
| 2145 if (method != NSTEP && rd && var < var_max) | 2291 if (method != NSTEP && rd && var < var_max) |
| 2146 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1); | 2292 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1); |
| 2147 | 2293 |
| 2148 return var; | 2294 return var; |
| 2149 } | 2295 } |
| OLD | NEW |