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

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

Issue 17451020: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 6 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_quantize.c ('k') | no next file » | 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 int64_t txfm_cache[NB_TXFM_MODES]) { 607 int64_t txfm_cache[NB_TXFM_MODES]) {
608 VP9_COMMON *const cm = &cpi->common; 608 VP9_COMMON *const cm = &cpi->common;
609 int r[TX_SIZE_MAX_SB][2], d[TX_SIZE_MAX_SB], s[TX_SIZE_MAX_SB]; 609 int r[TX_SIZE_MAX_SB][2], d[TX_SIZE_MAX_SB], s[TX_SIZE_MAX_SB];
610 MACROBLOCKD *xd = &x->e_mbd; 610 MACROBLOCKD *xd = &x->e_mbd;
611 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; 611 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
612 612
613 assert(bs == mbmi->sb_type); 613 assert(bs == mbmi->sb_type);
614 if (mbmi->ref_frame[0] > INTRA_FRAME) 614 if (mbmi->ref_frame[0] > INTRA_FRAME)
615 vp9_subtract_sby(x, bs); 615 vp9_subtract_sby(x, bs);
616 616
617 if (cpi->speed > 4) { 617 if (cpi->sf.use_largest_txform) {
618 if (bs >= BLOCK_SIZE_SB32X32) { 618 if (bs >= BLOCK_SIZE_SB32X32) {
619 mbmi->txfm_size = TX_32X32; 619 mbmi->txfm_size = TX_32X32;
620 } else if (bs >= BLOCK_SIZE_MB16X16) { 620 } else if (bs >= BLOCK_SIZE_MB16X16) {
621 mbmi->txfm_size = TX_16X16; 621 mbmi->txfm_size = TX_16X16;
622 } else if (bs >= BLOCK_SIZE_SB8X8) { 622 } else if (bs >= BLOCK_SIZE_SB8X8) {
623 mbmi->txfm_size = TX_8X8; 623 mbmi->txfm_size = TX_8X8;
624 } else { 624 } else {
625 mbmi->txfm_size = TX_4X4; 625 mbmi->txfm_size = TX_4X4;
626 } 626 }
627 vpx_memset(txfm_cache, 0, NB_TXFM_MODES * sizeof(int64_t)); 627 vpx_memset(txfm_cache, 0, NB_TXFM_MODES * sizeof(int64_t));
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 985
986 int vp9_cost_mv_ref(VP9_COMP *cpi, 986 int vp9_cost_mv_ref(VP9_COMP *cpi,
987 MB_PREDICTION_MODE m, 987 MB_PREDICTION_MODE m,
988 const int mode_context) { 988 const int mode_context) {
989 MACROBLOCKD *xd = &cpi->mb.e_mbd; 989 MACROBLOCKD *xd = &cpi->mb.e_mbd;
990 int segment_id = xd->mode_info_context->mbmi.segment_id; 990 int segment_id = xd->mode_info_context->mbmi.segment_id;
991 991
992 // Dont account for mode here if segment skip is enabled. 992 // Dont account for mode here if segment skip is enabled.
993 if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) { 993 if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) {
994 VP9_COMMON *pc = &cpi->common; 994 VP9_COMMON *pc = &cpi->common;
995
996 vp9_prob p[VP9_INTER_MODES - 1];
997 assert(NEARESTMV <= m && m <= NEWMV); 995 assert(NEARESTMV <= m && m <= NEWMV);
998 vp9_mv_ref_probs(pc, p, mode_context); 996 return cost_token(vp9_sb_mv_ref_tree,
999 return cost_token(vp9_sb_mv_ref_tree, p, 997 pc->fc.inter_mode_probs[mode_context],
1000 vp9_sb_mv_ref_encoding_array - NEARESTMV + m); 998 vp9_sb_mv_ref_encoding_array - NEARESTMV + m);
1001 } else 999 } else
1002 return 0; 1000 return 0;
1003 } 1001 }
1004 1002
1005 void vp9_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv) { 1003 void vp9_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv) {
1006 x->e_mbd.mode_info_context->mbmi.mode = mb; 1004 x->e_mbd.mode_info_context->mbmi.mode = mb;
1007 x->e_mbd.mode_info_context->mbmi.mv[0].as_int = mv->as_int; 1005 x->e_mbd.mode_info_context->mbmi.mv[0].as_int = mv->as_int;
1008 } 1006 }
1009 1007
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 } 1793 }
1796 1794
1797 static YV12_BUFFER_CONFIG *get_scaled_ref_frame(VP9_COMP *cpi, int ref_frame) { 1795 static YV12_BUFFER_CONFIG *get_scaled_ref_frame(VP9_COMP *cpi, int ref_frame) {
1798 YV12_BUFFER_CONFIG *scaled_ref_frame = NULL; 1796 YV12_BUFFER_CONFIG *scaled_ref_frame = NULL;
1799 int fb = get_ref_frame_idx(cpi, ref_frame); 1797 int fb = get_ref_frame_idx(cpi, ref_frame);
1800 if (cpi->scaled_ref_idx[fb] != cpi->common.ref_frame_map[fb]) 1798 if (cpi->scaled_ref_idx[fb] != cpi->common.ref_frame_map[fb])
1801 scaled_ref_frame = &cpi->common.yv12_fb[cpi->scaled_ref_idx[fb]]; 1799 scaled_ref_frame = &cpi->common.yv12_fb[cpi->scaled_ref_idx[fb]];
1802 return scaled_ref_frame; 1800 return scaled_ref_frame;
1803 } 1801 }
1804 1802
1803 static double linear_interpolate(double x, int ntab, double step,
1804 const double *tab) {
1805 double y = x / step;
1806 int d = (int) y;
1807 double a = y - d;
1808 if (d >= ntab - 1)
1809 return tab[ntab - 1];
1810 else
1811 return tab[d] * (1 - a) + tab[d + 1] * a;
1812 }
1813
1814 static double model_rate_norm(double x) {
1815 // Normalized rate
1816 // This function models the rate for a Laplacian source
1817 // source with given variance when quantized with a uniform quantizer
1818 // with given stepsize. The closed form expressions are in:
1819 // Hang and Chen, "Source Model for transform video coder and its
1820 // application - Part I: Fundamental Theory", IEEE Trans. Circ.
1821 // Sys. for Video Tech., April 1997.
1822 static const double rate_tab_step = 0.125;
1823 static const double rate_tab[] = {
1824 256.0000, 4.944453, 3.949276, 3.371593,
1825 2.965771, 2.654550, 2.403348, 2.193612,
1826 2.014208, 1.857921, 1.719813, 1.596364,
1827 1.484979, 1.383702, 1.291025, 1.205767,
1828 1.126990, 1.053937, 0.985991, 0.922644,
1829 0.863472, 0.808114, 0.756265, 0.707661,
1830 0.662070, 0.619287, 0.579129, 0.541431,
1831 0.506043, 0.472828, 0.441656, 0.412411,
1832 0.384980, 0.359260, 0.335152, 0.312563,
1833 0.291407, 0.271600, 0.253064, 0.235723,
1834 0.219508, 0.204351, 0.190189, 0.176961,
1835 0.164611, 0.153083, 0.142329, 0.132298,
1836 0.122945, 0.114228, 0.106106, 0.098541,
1837 0.091496, 0.084937, 0.078833, 0.073154,
1838 0.067872, 0.062959, 0.058392, 0.054147,
1839 0.050202, 0.046537, 0.043133, 0.039971,
1840 0.037036, 0.034312, 0.031783, 0.029436,
1841 0.027259, 0.025240, 0.023367, 0.021631,
1842 0.020021, 0.018528, 0.017145, 0.015863,
1843 0.014676, 0.013575, 0.012556, 0.011612,
1844 0.010738, 0.009929, 0.009180, 0.008487,
1845 0.007845, 0.007251, 0.006701, 0.006193,
1846 0.005722, 0.005287, 0.004884, 0.004512,
1847 0.004168, 0.003850, 0.003556, 0.003284,
1848 0.003032, 0.002800, 0.002585, 0.002386,
1849 0.002203, 0.002034, 0.001877, 0.001732,
1850 0.001599, 0.001476, 0.001362, 0.001256,
1851 0.001159, 0.001069, 0.000987, 0.000910,
1852 0.000840, 0.000774, 0.000714, 0.000659,
1853 0.000608, 0.000560, 0.000517, 0.000476,
1854 0.000439, 0.000405, 0.000373, 0.000344,
1855 0.000317, 0.000292, 0.000270, 0.000248,
1856 0.000229, 0.000211, 0.000195, 0.000179,
1857 0.000165, 0.000152, 0.000140, 0.000129,
1858 0.000119, 0.000110, 0.000101, 0.000093,
1859 0.000086, 0.000079, 0.000073, 0.000067,
1860 0.000062, 0.000057, 0.000052, 0.000048,
1861 0.000044, 0.000041, 0.000038, 0.000035,
1862 0.000032, 0.000029, 0.000027, 0.000025,
1863 0.000023, 0.000021, 0.000019, 0.000018,
1864 0.000016, 0.000015, 0.000014, 0.000013,
1865 0.000012, 0.000011, 0.000010, 0.000009,
1866 0.000008, 0.000008, 0.000007, 0.000007,
1867 0.000006, 0.000006, 0.000005, 0.000005,
1868 0.000004, 0.000004, 0.000004, 0.000003,
1869 0.000003, 0.000003, 0.000003, 0.000002,
1870 0.000002, 0.000002, 0.000002, 0.000002,
1871 0.000002, 0.000001, 0.000001, 0.000001,
1872 0.000001, 0.000001, 0.000001, 0.000001,
1873 0.000001, 0.000001, 0.000001, 0.000001,
1874 0.000001, 0.000001, 0.000000, 0.000000,
1875 };
1876 const int rate_tab_num = sizeof(rate_tab)/sizeof(rate_tab[0]);
1877 assert(x >= 0.0);
1878 return linear_interpolate(x, rate_tab_num, rate_tab_step, rate_tab);
1879 }
1880
1881 static double model_dist_norm(double x) {
1882 // Normalized distortion
1883 // This function models the normalized distortion for a Laplacian source
1884 // source with given variance when quantized with a uniform quantizer
1885 // with given stepsize. The closed form expression is:
1886 // Dn(x) = 1 - 1/sqrt(2) * x / sinh(x/sqrt(2))
1887 // where x = qpstep / sqrt(variance)
1888 // Note the actual distortion is Dn * variance.
1889 static const double dist_tab_step = 0.25;
1890 static const double dist_tab[] = {
1891 0.000000, 0.005189, 0.020533, 0.045381,
1892 0.078716, 0.119246, 0.165508, 0.215979,
1893 0.269166, 0.323686, 0.378318, 0.432034,
1894 0.484006, 0.533607, 0.580389, 0.624063,
1895 0.664475, 0.701581, 0.735418, 0.766092,
1896 0.793751, 0.818575, 0.840761, 0.860515,
1897 0.878045, 0.893554, 0.907238, 0.919281,
1898 0.929857, 0.939124, 0.947229, 0.954306,
1899 0.960475, 0.965845, 0.970512, 0.974563,
1900 0.978076, 0.981118, 0.983750, 0.986024,
1901 0.987989, 0.989683, 0.991144, 0.992402,
1902 0.993485, 0.994417, 0.995218, 0.995905,
1903 0.996496, 0.997002, 0.997437, 0.997809,
1904 0.998128, 0.998401, 0.998635, 0.998835,
1905 0.999006, 0.999152, 0.999277, 0.999384,
1906 0.999475, 0.999553, 0.999619, 0.999676,
1907 0.999724, 0.999765, 0.999800, 0.999830,
1908 0.999855, 0.999877, 0.999895, 0.999911,
1909 0.999924, 0.999936, 0.999945, 0.999954,
1910 0.999961, 0.999967, 0.999972, 0.999976,
1911 0.999980, 0.999983, 0.999985, 0.999988,
1912 0.999989, 0.999991, 0.999992, 0.999994,
1913 0.999995, 0.999995, 0.999996, 0.999997,
1914 0.999997, 0.999998, 0.999998, 0.999998,
1915 0.999999, 0.999999, 0.999999, 0.999999,
1916 0.999999, 0.999999, 0.999999, 1.000000,
1917 };
1918 const int dist_tab_num = sizeof(dist_tab)/sizeof(dist_tab[0]);
1919 assert(x >= 0.0);
1920 return linear_interpolate(x, dist_tab_num, dist_tab_step, dist_tab);
1921 }
1922
1805 static void model_rd_from_var_lapndz(int var, int n, int qstep, 1923 static void model_rd_from_var_lapndz(int var, int n, int qstep,
1806 int *rate, int *dist) { 1924 int *rate, int *dist) {
1807 // This function models the rate and distortion for a Laplacian 1925 // This function models the rate and distortion for a Laplacian
1808 // source with given variance when quantized with a uniform quantizer 1926 // source with given variance when quantized with a uniform quantizer
1809 // with given stepsize. The closed form expressions are in: 1927 // with given stepsize. The closed form expression is:
1810 // Hang and Chen, "Source Model for transform video coder and its 1928 // Rn(x) = H(sqrt(r)) + sqrt(r)*[1 + H(r)/(1 - r)],
1811 // application - Part I: Fundamental Theory", IEEE Trans. Circ. 1929 // where r = exp(-sqrt(2) * x) and x = qpstep / sqrt(variance)
1812 // Sys. for Video Tech., April 1997.
1813 // The function is implemented as piecewise approximation to the
1814 // exact computation.
1815 // TODO(debargha): Implement the functions by interpolating from a
1816 // look-up table
1817 vp9_clear_system_state(); 1930 vp9_clear_system_state();
1818 if (var == 0 || n == 0) { 1931 if (var == 0 || n == 0) {
1819 *rate = 0; 1932 *rate = 0;
1820 *dist = 0; 1933 *dist = 0;
1821 } else { 1934 } else {
1822 double D, R; 1935 double D, R;
1823 double s2 = (double) var / n; 1936 double s2 = (double) var / n;
1824 double s = sqrt(s2); 1937 double x = qstep / sqrt(s2);
1825 double x = qstep / s; 1938 // TODO(debargha): Make the modeling functions take (qstep^2 / s2)
1826 if (x > 1.0) { 1939 // as argument rather than qstep / sqrt(s2) to obviate the need for
1827 double y = exp(-x / 2); 1940 // the sqrt() operation.
1828 double y2 = y * y; 1941 D = model_dist_norm(x);
1829 D = 2.069981728764738 * y2 - 2.764286806516079 * y + 1.003956960819275; 1942 R = model_rate_norm(x);
1830 R = 0.924056758535089 * y2 + 2.738636469814024 * y - 0.005169662030017; 1943 if (R < 0) {
1831 } else { 1944 R = 0;
1832 double x2 = x * x; 1945 D = var;
1833 D = 0.075303187668830 * x2 + 0.004296954321112 * x - 0.000413209252807;
1834 if (x > 0.125)
1835 R = 1 / (-0.03459733614226 * x2 + 0.36561675733603 * x +
1836 0.1626989668625);
1837 else
1838 R = -1.442252874826093 * log(x) + 1.944647760719664;
1839 } 1946 }
1840 if (R < 0) { 1947 *rate = (n * R * 256 + 0.5);
1841 *rate = 0; 1948 *dist = (n * D * s2 + 0.5);
1842 *dist = var;
1843 } else {
1844 *rate = (n * R * 256 + 0.5);
1845 *dist = (n * D * s2 + 0.5);
1846 }
1847 } 1949 }
1848 vp9_clear_system_state(); 1950 vp9_clear_system_state();
1849 } 1951 }
1850 1952
1851 static enum BlockSize get_plane_block_size(BLOCK_SIZE_TYPE bsize, 1953 static enum BlockSize get_plane_block_size(BLOCK_SIZE_TYPE bsize,
1852 struct macroblockd_plane *pd) { 1954 struct macroblockd_plane *pd) {
1853 return get_block_size(plane_block_width(bsize, pd), 1955 return get_block_size(plane_block_width(bsize, pd),
1854 plane_block_height(bsize, pd)); 1956 plane_block_height(bsize, pd));
1855 } 1957 }
1856 1958
(...skipping 10 matching lines...) Expand all
1867 struct macroblock_plane *const p = &x->plane[i]; 1969 struct macroblock_plane *const p = &x->plane[i];
1868 struct macroblockd_plane *const pd = &xd->plane[i]; 1970 struct macroblockd_plane *const pd = &xd->plane[i];
1869 1971
1870 // TODO(dkovalev) the same code in get_plane_block_size 1972 // TODO(dkovalev) the same code in get_plane_block_size
1871 const int bw = plane_block_width(bsize, pd); 1973 const int bw = plane_block_width(bsize, pd);
1872 const int bh = plane_block_height(bsize, pd); 1974 const int bh = plane_block_height(bsize, pd);
1873 const enum BlockSize bs = get_block_size(bw, bh); 1975 const enum BlockSize bs = get_block_size(bw, bh);
1874 int rate, dist; 1976 int rate, dist;
1875 var = cpi->fn_ptr[bs].vf(p->src.buf, p->src.stride, 1977 var = cpi->fn_ptr[bs].vf(p->src.buf, p->src.stride,
1876 pd->dst.buf, pd->dst.stride, &sse); 1978 pd->dst.buf, pd->dst.stride, &sse);
1877 model_rd_from_var_lapndz(var, bw * bh, pd->dequant[1] >> 3, &rate, &dist); 1979 // sse works better than var, since there is no dc prediction used
1980 model_rd_from_var_lapndz(sse, bw * bh, pd->dequant[1] >> 3, &rate, &dist);
1878 1981
1879 rate_sum += rate; 1982 rate_sum += rate;
1880 dist_sum += dist; 1983 dist_sum += dist;
1881 } 1984 }
1882 1985
1883 *out_rate_sum = rate_sum; 1986 *out_rate_sum = rate_sum;
1884 *out_dist_sum = dist_sum; 1987 *out_dist_sum = dist_sum << 4;
1885 } 1988 }
1886 1989
1887 static INLINE int get_switchable_rate(VP9_COMMON *cm, MACROBLOCK *x) { 1990 static INLINE int get_switchable_rate(VP9_COMMON *cm, MACROBLOCK *x) {
1888 MACROBLOCKD *xd = &x->e_mbd; 1991 MACROBLOCKD *xd = &x->e_mbd;
1889 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; 1992 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
1890 1993
1891 const int c = vp9_get_pred_context(cm, xd, PRED_SWITCHABLE_INTERP); 1994 const int c = vp9_get_pred_context(cm, xd, PRED_SWITCHABLE_INTERP);
1892 const int m = vp9_switchable_interp_map[mbmi->interp_filter]; 1995 const int m = vp9_switchable_interp_map[mbmi->interp_filter];
1893 return SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs[c][m]; 1996 return SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs[c][m];
1894 } 1997 }
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 pred_exists = 0; 2334 pred_exists = 0;
2232 interpolating_intpel_seen = 0; 2335 interpolating_intpel_seen = 0;
2233 // Are all MVs integer pel for Y and UV 2336 // Are all MVs integer pel for Y and UV
2234 intpel_mv = (mbmi->mv[0].as_mv.row & 15) == 0 && 2337 intpel_mv = (mbmi->mv[0].as_mv.row & 15) == 0 &&
2235 (mbmi->mv[0].as_mv.col & 15) == 0; 2338 (mbmi->mv[0].as_mv.col & 15) == 0;
2236 if (is_comp_pred) 2339 if (is_comp_pred)
2237 intpel_mv &= (mbmi->mv[1].as_mv.row & 15) == 0 && 2340 intpel_mv &= (mbmi->mv[1].as_mv.row & 15) == 0 &&
2238 (mbmi->mv[1].as_mv.col & 15) == 0; 2341 (mbmi->mv[1].as_mv.col & 15) == 0;
2239 // Search for best switchable filter by checking the variance of 2342 // Search for best switchable filter by checking the variance of
2240 // pred error irrespective of whether the filter will be used 2343 // pred error irrespective of whether the filter will be used
2241 if (cpi->speed > 4) { 2344 if (cpi->sf.use_8tap_always) {
2242 *best_filter = EIGHTTAP; 2345 *best_filter = EIGHTTAP;
2243 } else { 2346 } else {
2244 int i, newbest; 2347 int i, newbest;
2245 int tmp_rate_sum = 0, tmp_dist_sum = 0; 2348 int tmp_rate_sum = 0, tmp_dist_sum = 0;
2246 for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) { 2349 for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
2247 int rs = 0; 2350 int rs = 0;
2248 const INTERPOLATIONFILTERTYPE filter = vp9_switchable_interp[i]; 2351 const INTERPOLATIONFILTERTYPE filter = vp9_switchable_interp[i];
2249 const int is_intpel_interp = intpel_mv && 2352 const int is_intpel_interp = intpel_mv &&
2250 vp9_is_interpolating_filter[filter]; 2353 vp9_is_interpolating_filter[filter];
2251 mbmi->interp_filter = filter; 2354 mbmi->interp_filter = filter;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 &comp_mode_p); 2634 &comp_mode_p);
2532 vpx_memset(&best_mbmode, 0, sizeof(best_mbmode)); 2635 vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
2533 vpx_memset(&single_newmv, 0, sizeof(single_newmv)); 2636 vpx_memset(&single_newmv, 0, sizeof(single_newmv));
2534 2637
2535 for (i = 0; i < NB_PREDICTION_TYPES; ++i) 2638 for (i = 0; i < NB_PREDICTION_TYPES; ++i)
2536 best_pred_rd[i] = INT64_MAX; 2639 best_pred_rd[i] = INT64_MAX;
2537 for (i = 0; i < NB_TXFM_MODES; i++) 2640 for (i = 0; i < NB_TXFM_MODES; i++)
2538 best_txfm_rd[i] = INT64_MAX; 2641 best_txfm_rd[i] = INT64_MAX;
2539 2642
2540 // Create a mask set to 1 for each frame used by a smaller resolution. 2643 // Create a mask set to 1 for each frame used by a smaller resolution.
2541 if (cpi->speed > 0) { 2644 if (cpi->sf.use_avoid_tested_higherror) {
2542 switch (block_size) { 2645 switch (block_size) {
2543 case BLOCK_64X64: 2646 case BLOCK_64X64:
2544 for (i = 0; i < 4; i++) { 2647 for (i = 0; i < 4; i++) {
2545 for (j = 0; j < 4; j++) { 2648 for (j = 0; j < 4; j++) {
2546 ref_frame_mask |= x->mb_context[i][j].frames_with_high_error; 2649 ref_frame_mask |= x->mb_context[i][j].frames_with_high_error;
2547 mode_mask |= x->mb_context[i][j].modes_with_high_error; 2650 mode_mask |= x->mb_context[i][j].modes_with_high_error;
2548 } 2651 }
2549 } 2652 }
2550 for (i = 0; i < 4; i++) { 2653 for (i = 0; i < 4; i++) {
2551 ref_frame_mask |= x->sb32_context[i].frames_with_high_error; 2654 ref_frame_mask |= x->sb32_context[i].frames_with_high_error;
(...skipping 19 matching lines...) Expand all
2571 2674
2572 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) { 2675 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
2573 if (cpi->ref_frame_flags & flag_list[ref_frame]) { 2676 if (cpi->ref_frame_flags & flag_list[ref_frame]) {
2574 setup_buffer_inter(cpi, x, idx_list[ref_frame], ref_frame, block_size, 2677 setup_buffer_inter(cpi, x, idx_list[ref_frame], ref_frame, block_size,
2575 mi_row, mi_col, frame_mv[NEARESTMV], frame_mv[NEARMV], 2678 mi_row, mi_col, frame_mv[NEARESTMV], frame_mv[NEARMV],
2576 yv12_mb, scale_factor); 2679 yv12_mb, scale_factor);
2577 } 2680 }
2578 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; 2681 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
2579 frame_mv[ZEROMV][ref_frame].as_int = 0; 2682 frame_mv[ZEROMV][ref_frame].as_int = 0;
2580 } 2683 }
2581 if (cpi->speed == 0 2684 if (!cpi->sf.use_avoid_tested_higherror
2582 || (cpi->speed > 0 && (ref_frame_mask & (1 << INTRA_FRAME)))) { 2685 || (cpi->sf.use_avoid_tested_higherror
2686 && (ref_frame_mask & (1 << INTRA_FRAME)))) {
2583 mbmi->mode = DC_PRED; 2687 mbmi->mode = DC_PRED;
2584 mbmi->ref_frame[0] = INTRA_FRAME; 2688 mbmi->ref_frame[0] = INTRA_FRAME;
2585 for (i = 0; i <= (bsize < BLOCK_SIZE_MB16X16 ? TX_4X4 : 2689 for (i = 0; i <= (bsize < BLOCK_SIZE_MB16X16 ? TX_4X4 :
2586 (bsize < BLOCK_SIZE_SB32X32 ? TX_8X8 : 2690 (bsize < BLOCK_SIZE_SB32X32 ? TX_8X8 :
2587 (bsize < BLOCK_SIZE_SB64X64 ? TX_16X16 : TX_32X32))); 2691 (bsize < BLOCK_SIZE_SB64X64 ? TX_16X16 : TX_32X32)));
2588 i++) { 2692 i++) {
2589 mbmi->txfm_size = i; 2693 mbmi->txfm_size = i;
2590 rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra[i], &rate_uv_tokenonly[i], 2694 rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra[i], &rate_uv_tokenonly[i],
2591 &dist_uv[i], &skip_uv[i], 2695 &dist_uv[i], &skip_uv[i],
2592 (bsize < BLOCK_SIZE_SB8X8) ? BLOCK_SIZE_SB8X8 : 2696 (bsize < BLOCK_SIZE_SB8X8) ? BLOCK_SIZE_SB8X8 :
(...skipping 25 matching lines...) Expand all
2618 // Do not allow compound prediction if the segment level reference 2722 // Do not allow compound prediction if the segment level reference
2619 // frame feature is in use as in this case there can only be one reference. 2723 // frame feature is in use as in this case there can only be one reference.
2620 if ((vp9_mode_order[mode_index].second_ref_frame > INTRA_FRAME) && 2724 if ((vp9_mode_order[mode_index].second_ref_frame > INTRA_FRAME) &&
2621 vp9_segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME)) 2725 vp9_segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME))
2622 continue; 2726 continue;
2623 2727
2624 x->skip = 0; 2728 x->skip = 0;
2625 this_mode = vp9_mode_order[mode_index].mode; 2729 this_mode = vp9_mode_order[mode_index].mode;
2626 ref_frame = vp9_mode_order[mode_index].ref_frame; 2730 ref_frame = vp9_mode_order[mode_index].ref_frame;
2627 2731
2628 if (cpi->speed > 0 && bsize >= BLOCK_SIZE_SB8X8) { 2732 if (cpi->sf.use_avoid_tested_higherror && bsize >= BLOCK_SIZE_SB8X8) {
2629 if (!(ref_frame_mask & (1 << ref_frame))) { 2733 if (!(ref_frame_mask & (1 << ref_frame))) {
2630 continue; 2734 continue;
2631 } 2735 }
2632 if (!(mode_mask & (1 << this_mode))) { 2736 if (!(mode_mask & (1 << this_mode))) {
2633 continue; 2737 continue;
2634 } 2738 }
2635 if (vp9_mode_order[mode_index].second_ref_frame != NONE 2739 if (vp9_mode_order[mode_index].second_ref_frame != NONE
2636 && !(ref_frame_mask 2740 && !(ref_frame_mask
2637 & (1 << vp9_mode_order[mode_index].second_ref_frame))) { 2741 & (1 << vp9_mode_order[mode_index].second_ref_frame))) {
2638 continue; 2742 continue;
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 scale_factor); 3352 scale_factor);
3249 store_coding_context(x, ctx, best_mode_index, 3353 store_coding_context(x, ctx, best_mode_index,
3250 &best_partition, 3354 &best_partition,
3251 &mbmi->ref_mvs[mbmi->ref_frame[0]][0], 3355 &mbmi->ref_mvs[mbmi->ref_frame[0]][0],
3252 &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 : 3356 &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 :
3253 mbmi->ref_frame[1]][0], 3357 mbmi->ref_frame[1]][0],
3254 best_pred_diff, best_txfm_diff); 3358 best_pred_diff, best_txfm_diff);
3255 3359
3256 return best_rd; 3360 return best_rd;
3257 } 3361 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_quantize.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698