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

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

Issue 812033011: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 5 years, 11 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_mcomp.c ('k') | source/libvpx/vp9/encoder/vp9_pickmode.h » ('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 15 matching lines...) Expand all
26 static int get_max_filter_level(const VP9_COMP *cpi) { 26 static int get_max_filter_level(const VP9_COMP *cpi) {
27 if (cpi->oxcf.pass == 2) { 27 if (cpi->oxcf.pass == 2) {
28 return cpi->twopass.section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4 28 return cpi->twopass.section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4
29 : MAX_LOOP_FILTER; 29 : MAX_LOOP_FILTER;
30 } else { 30 } else {
31 return MAX_LOOP_FILTER; 31 return MAX_LOOP_FILTER;
32 } 32 }
33 } 33 }
34 34
35 35
36 static int try_filter_frame(const YV12_BUFFER_CONFIG *sd, VP9_COMP *const cpi, 36 static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd,
37 int filt_level, int partial_frame) { 37 VP9_COMP *const cpi,
38 int filt_level, int partial_frame) {
38 VP9_COMMON *const cm = &cpi->common; 39 VP9_COMMON *const cm = &cpi->common;
39 int filt_err; 40 int64_t filt_err;
40 41
41 vp9_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, filt_level, 1, 42 vp9_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, filt_level, 1,
42 partial_frame); 43 partial_frame);
43 #if CONFIG_VP9_HIGHBITDEPTH 44 #if CONFIG_VP9_HIGHBITDEPTH
44 if (cm->use_highbitdepth) { 45 if (cm->use_highbitdepth) {
45 filt_err = vp9_highbd_get_y_sse(sd, cm->frame_to_show, cm->bit_depth); 46 filt_err = vp9_highbd_get_y_sse(sd, cm->frame_to_show);
46 } else { 47 } else {
47 filt_err = vp9_get_y_sse(sd, cm->frame_to_show); 48 filt_err = vp9_get_y_sse(sd, cm->frame_to_show);
48 } 49 }
49 #else 50 #else
50 filt_err = vp9_get_y_sse(sd, cm->frame_to_show); 51 filt_err = vp9_get_y_sse(sd, cm->frame_to_show);
51 #endif // CONFIG_VP9_HIGHBITDEPTH 52 #endif // CONFIG_VP9_HIGHBITDEPTH
52 53
53 // Re-instate the unfiltered frame 54 // Re-instate the unfiltered frame
54 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); 55 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
55 56
56 return filt_err; 57 return filt_err;
57 } 58 }
58 59
59 static int search_filter_level(const YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, 60 static int search_filter_level(const YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi,
60 int partial_frame) { 61 int partial_frame) {
61 const VP9_COMMON *const cm = &cpi->common; 62 const VP9_COMMON *const cm = &cpi->common;
62 const struct loopfilter *const lf = &cm->lf; 63 const struct loopfilter *const lf = &cm->lf;
63 const int min_filter_level = 0; 64 const int min_filter_level = 0;
64 const int max_filter_level = get_max_filter_level(cpi); 65 const int max_filter_level = get_max_filter_level(cpi);
65 int filt_direction = 0; 66 int filt_direction = 0;
66 int best_err, filt_best; 67 int64_t best_err;
68 int filt_best;
67 69
68 // Start the search at the previous frame filter level unless it is now out of 70 // Start the search at the previous frame filter level unless it is now out of
69 // range. 71 // range.
70 int filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level); 72 int filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level);
71 int filter_step = filt_mid < 16 ? 4 : filt_mid / 4; 73 int filter_step = filt_mid < 16 ? 4 : filt_mid / 4;
72 // Sum squared error at each filter level 74 // Sum squared error at each filter level
73 int ss_err[MAX_LOOP_FILTER + 1]; 75 int64_t ss_err[MAX_LOOP_FILTER + 1];
74 76
75 // Set each entry to -1 77 // Set each entry to -1
76 vpx_memset(ss_err, 0xFF, sizeof(ss_err)); 78 vpx_memset(ss_err, 0xFF, sizeof(ss_err));
77 79
78 // Make a copy of the unfiltered / processed recon buffer 80 // Make a copy of the unfiltered / processed recon buffer
79 vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf); 81 vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
80 82
81 best_err = try_filter_frame(sd, cpi, filt_mid, partial_frame); 83 best_err = try_filter_frame(sd, cpi, filt_mid, partial_frame);
82 filt_best = filt_mid; 84 filt_best = filt_mid;
83 ss_err[filt_mid] = best_err; 85 ss_err[filt_mid] = best_err;
84 86
85 while (filter_step > 0) { 87 while (filter_step > 0) {
86 const int filt_high = MIN(filt_mid + filter_step, max_filter_level); 88 const int filt_high = MIN(filt_mid + filter_step, max_filter_level);
87 const int filt_low = MAX(filt_mid - filter_step, min_filter_level); 89 const int filt_low = MAX(filt_mid - filter_step, min_filter_level);
88 90
89 // Bias against raising loop filter in favor of lowering it. 91 // Bias against raising loop filter in favor of lowering it.
90 int bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; 92 int64_t bias = (best_err >> (15 - (filt_mid / 8))) * filter_step;
91 93
92 if ((cpi->oxcf.pass == 2) && (cpi->twopass.section_intra_rating < 20)) 94 if ((cpi->oxcf.pass == 2) && (cpi->twopass.section_intra_rating < 20))
93 bias = (bias * cpi->twopass.section_intra_rating) / 20; 95 bias = (bias * cpi->twopass.section_intra_rating) / 20;
94 96
95 // yx, bias less for large block size 97 // yx, bias less for large block size
96 if (cm->tx_mode != ONLY_4X4) 98 if (cm->tx_mode != ONLY_4X4)
97 bias >>= 1; 99 bias >>= 1;
98 100
99 if (filt_direction <= 0 && filt_low != filt_mid) { 101 if (filt_direction <= 0 && filt_low != filt_mid) {
100 // Get Low filter error score 102 // Get Low filter error score
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 : cpi->oxcf.sharpness; 148 : cpi->oxcf.sharpness;
147 149
148 if (method == LPF_PICK_MINIMAL_LPF && lf->filter_level) { 150 if (method == LPF_PICK_MINIMAL_LPF && lf->filter_level) {
149 lf->filter_level = 0; 151 lf->filter_level = 0;
150 } else if (method >= LPF_PICK_FROM_Q) { 152 } else if (method >= LPF_PICK_FROM_Q) {
151 const int min_filter_level = 0; 153 const int min_filter_level = 0;
152 const int max_filter_level = get_max_filter_level(cpi); 154 const int max_filter_level = get_max_filter_level(cpi);
153 const int q = vp9_ac_quant(cm->base_qindex, 0, cm->bit_depth); 155 const int q = vp9_ac_quant(cm->base_qindex, 0, cm->bit_depth);
154 // These values were determined by linear fitting the result of the 156 // These values were determined by linear fitting the result of the
155 // searched level, filt_guess = q * 0.316206 + 3.87252 157 // searched level, filt_guess = q * 0.316206 + 3.87252
156 #if CONFIG_VP9_HIGHDEPTH 158 #if CONFIG_VP9_HIGHBITDEPTH
157 int filt_guess; 159 int filt_guess;
158 switch (cm->bit_depth) { 160 switch (cm->bit_depth) {
159 case VPX_BITS_8: 161 case VPX_BITS_8:
160 filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18); 162 filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18);
161 break; 163 break;
162 case VPX_BITS_10: 164 case VPX_BITS_10:
163 filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 4060632, 20); 165 filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 4060632, 20);
164 break; 166 break;
165 case VPX_BITS_12: 167 case VPX_BITS_12:
166 filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 16242526, 22); 168 filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 16242526, 22);
167 break; 169 break;
168 default: 170 default:
169 assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 " 171 assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 "
170 "or VPX_BITS_12"); 172 "or VPX_BITS_12");
171 return; 173 return;
172 } 174 }
173 #else 175 #else
174 int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18); 176 int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18);
175 #endif // CONFIG_VP9_HIGHBITDEPTH 177 #endif // CONFIG_VP9_HIGHBITDEPTH
176 if (cm->frame_type == KEY_FRAME) 178 if (cm->frame_type == KEY_FRAME)
177 filt_guess -= 4; 179 filt_guess -= 4;
178 lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level); 180 lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level);
179 } else { 181 } else {
180 lf->filter_level = search_filter_level(sd, cpi, 182 lf->filter_level = search_filter_level(sd, cpi,
181 method == LPF_PICK_FROM_SUBIMAGE); 183 method == LPF_PICK_FROM_SUBIMAGE);
182 } 184 }
183 } 185 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.c ('k') | source/libvpx/vp9/encoder/vp9_pickmode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698