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

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

Issue 54923004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 1 month 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/encoder/vp9_psnr.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 linestocopy <<= 4; 48 linestocopy <<= 4;
49 49
50 50
51 srcoffset = source->y_stride * (dest->y_height >> 5) * 16; 51 srcoffset = source->y_stride * (dest->y_height >> 5) * 16;
52 dstoffset = dest->y_stride * (dest->y_height >> 5) * 16; 52 dstoffset = dest->y_stride * (dest->y_height >> 5) * 16;
53 53
54 src += srcoffset; 54 src += srcoffset;
55 dst += dstoffset; 55 dst += dstoffset;
56 56
57 // Loop through the Y plane raw and reconstruction data summing (square differ ences) 57 // Loop through the raw Y plane and reconstruction data summing the square
58 // differences.
58 for (i = 0; i < linestocopy; i += 16) { 59 for (i = 0; i < linestocopy; i += 16) {
59 for (j = 0; j < source->y_width; j += 16) { 60 for (j = 0; j < source->y_width; j += 16) {
60 unsigned int sse; 61 unsigned int sse;
61 Total += vp9_mse16x16(src + j, source->y_stride, dst + j, dest->y_stride, 62 Total += vp9_mse16x16(src + j, source->y_stride, dst + j, dest->y_stride,
62 &sse); 63 &sse);
63 } 64 }
64 65
65 src += 16 * source->y_stride; 66 src += 16 * source->y_stride;
66 dst += 16 * dest->y_stride; 67 dst += 16 * dest->y_stride;
67 } 68 }
68 69
69 return Total; 70 return Total;
70 } 71 }
71 72
72 // Enforce a minimum filter level based upon baseline Q 73 // Enforce a minimum filter level based upon baseline Q
73 static int get_min_filter_level(VP9_COMP *cpi, int base_qindex) { 74 static int get_min_filter_level(VP9_COMP *cpi, int base_qindex) {
74 int min_filter_level; 75 int min_filter_level;
75 /*int q = (int) vp9_convert_qindex_to_q(base_qindex);
76
77 if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame && !cpi->co mmon.refresh_alt_ref_frame)
78 min_filter_level = 0;
79 else
80 {
81 if (q <= 10)
82 min_filter_level = 0;
83 else if (q <= 64)
84 min_filter_level = 1;
85 else
86 min_filter_level = (q >> 6);
87 }
88 */
89 min_filter_level = 0; 76 min_filter_level = 0;
90 77
91 return min_filter_level; 78 return min_filter_level;
92 } 79 }
93 80
94 // Enforce a maximum filter level based upon baseline Q 81 // Enforce a maximum filter level based upon baseline Q
95 static int get_max_filter_level(VP9_COMP *cpi, int base_qindex) { 82 static int get_max_filter_level(VP9_COMP *cpi, int base_qindex) {
96 // PGW August 2006: Highest filter values almost always a bad idea 83 int max_filter_level = MAX_LOOP_FILTER;
97
98 // jbb chg: 20100118 - not so any more with this overquant stuff allow high va lues
99 // with lots of intra coming in.
100 int max_filter_level = MAX_LOOP_FILTER;// * 3 / 4;
101 (void)base_qindex; 84 (void)base_qindex;
102 85
103 if (cpi->twopass.section_intra_rating > 8) 86 if (cpi->twopass.section_intra_rating > 8)
104 max_filter_level = MAX_LOOP_FILTER * 3 / 4; 87 max_filter_level = MAX_LOOP_FILTER * 3 / 4;
105 88
106 return max_filter_level; 89 return max_filter_level;
107 } 90 }
108 91
109 92
110 // Stub function for now Alt LF not used 93 // Stub function for now Alt LF not used
(...skipping 10 matching lines...) Expand all
121 const int max_filter_level = get_max_filter_level(cpi, cm->base_qindex); 104 const int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
122 105
123 int filter_step; 106 int filter_step;
124 int filt_high = 0; 107 int filt_high = 0;
125 // Start search at previous frame filter level 108 // Start search at previous frame filter level
126 int filt_mid = lf->filter_level; 109 int filt_mid = lf->filter_level;
127 int filt_low = 0; 110 int filt_low = 0;
128 int filt_best; 111 int filt_best;
129 int filt_direction = 0; 112 int filt_direction = 0;
130 113
131 int Bias = 0; // Bias against raising loop filter and in favour of lowering it 114 int Bias = 0; // Bias against raising loop filter in favor of lowering it.
132 115
133 // Make a copy of the unfiltered / processed recon buffer 116 // Make a copy of the unfiltered / processed recon buffer
134 vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf); 117 vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
135 118
136 lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0 119 lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0
137 : cpi->oxcf.Sharpness; 120 : cpi->oxcf.Sharpness;
138 121
139 // Start the search at the previous frame filter level unless it is now out of range. 122 // Start the search at the previous frame filter level unless it is now out of
123 // range.
140 filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level); 124 filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level);
141 125
142 // Define the initial step size 126 // Define the initial step size
143 filter_step = filt_mid < 16 ? 4 : filt_mid / 4; 127 filter_step = filt_mid < 16 ? 4 : filt_mid / 4;
144 128
145 // Get baseline error score 129 // Get baseline error score
146 vp9_set_alt_lf_level(cpi, filt_mid); 130 vp9_set_alt_lf_level(cpi, filt_mid);
147 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1, partial); 131 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1, partial);
148 132
149 best_err = vp9_calc_ss_err(sd, cm->frame_to_show); 133 best_err = vp9_calc_ss_err(sd, cm->frame_to_show);
150 filt_best = filt_mid; 134 filt_best = filt_mid;
151 135
152 // Re-instate the unfiltered frame 136 // Re-instate the unfiltered frame
153 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); 137 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
154 138
155 while (filter_step > 0) { 139 while (filter_step > 0) {
156 Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; // PGW change 12/1 2/06 for small images 140 Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step;
157 141
158 // jbb chg: 20100118 - in sections with lots of new material coming in don't bias as much to a low filter value
159 if (cpi->twopass.section_intra_rating < 20) 142 if (cpi->twopass.section_intra_rating < 20)
160 Bias = Bias * cpi->twopass.section_intra_rating / 20; 143 Bias = Bias * cpi->twopass.section_intra_rating / 20;
161 144
162 // yx, bias less for large block size 145 // yx, bias less for large block size
163 if (cpi->common.tx_mode != ONLY_4X4) 146 if (cpi->common.tx_mode != ONLY_4X4)
164 Bias >>= 1; 147 Bias >>= 1;
165 148
166 filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_level : (filt_mid + filter_step); 149 filt_high = ((filt_mid + filter_step) > max_filter_level)
167 filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step); 150 ? max_filter_level
151 : (filt_mid + filter_step);
152 filt_low = ((filt_mid - filter_step) < min_filter_level)
153 ? min_filter_level
154 : (filt_mid - filter_step);
168 155
169 if ((filt_direction <= 0) && (filt_low != filt_mid)) { 156 if ((filt_direction <= 0) && (filt_low != filt_mid)) {
170 // Get Low filter error score 157 // Get Low filter error score
171 vp9_set_alt_lf_level(cpi, filt_low); 158 vp9_set_alt_lf_level(cpi, filt_low);
172 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1, partial); 159 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1, partial);
173 160
174 filt_err = vp9_calc_ss_err(sd, cm->frame_to_show); 161 filt_err = vp9_calc_ss_err(sd, cm->frame_to_show);
175 162
176 // Re-instate the unfiltered frame 163 // Re-instate the unfiltered frame
177 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); 164 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
178 165
179 // If value is close to the best so far then bias towards a lower loop fil ter value. 166 // If value is close to the best so far then bias towards a lower loop
167 // filter value.
180 if ((filt_err - Bias) < best_err) { 168 if ((filt_err - Bias) < best_err) {
181 // Was it actually better than the previous best? 169 // Was it actually better than the previous best?
182 if (filt_err < best_err) 170 if (filt_err < best_err)
183 best_err = filt_err; 171 best_err = filt_err;
184 172
185 filt_best = filt_low; 173 filt_best = filt_low;
186 } 174 }
187 } 175 }
188 176
189 // Now look at filt_high 177 // Now look at filt_high
(...skipping 18 matching lines...) Expand all
208 filter_step = filter_step / 2; 196 filter_step = filter_step / 2;
209 filt_direction = 0; 197 filt_direction = 0;
210 } else { 198 } else {
211 filt_direction = (filt_best < filt_mid) ? -1 : 1; 199 filt_direction = (filt_best < filt_mid) ? -1 : 1;
212 filt_mid = filt_best; 200 filt_mid = filt_best;
213 } 201 }
214 } 202 }
215 203
216 lf->filter_level = filt_best; 204 lf->filter_level = filt_best;
217 } 205 }
218
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_onyx_int.h ('k') | source/libvpx/vp9/encoder/vp9_psnr.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698