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 |
11 | 11 |
12 #include "./vpx_scale_rtcd.h" | 12 #include "./vpx_scale_rtcd.h" |
13 #include "vp8/common/onyxc_int.h" | 13 #include "vp8/common/onyxc_int.h" |
14 #include "onyx_int.h" | 14 #include "onyx_int.h" |
15 #include "quantize.h" | 15 #include "quantize.h" |
16 #include "vpx_mem/vpx_mem.h" | 16 #include "vpx_mem/vpx_mem.h" |
17 #include "vpx_scale/vpx_scale.h" | 17 #include "vpx_scale/vpx_scale.h" |
18 #include "vp8/common/alloccommon.h" | 18 #include "vp8/common/alloccommon.h" |
19 #include "vp8/common/loopfilter.h" | 19 #include "vp8/common/loopfilter.h" |
20 #if ARCH_ARM | 20 #if ARCH_ARM |
21 #include "vpx_ports/arm.h" | 21 #include "vpx_ports/arm.h" |
22 #endif | 22 #endif |
23 | 23 |
24 extern int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest)
; | 24 extern int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest)
; |
25 | 25 |
26 void vp8_yv12_copy_partial_frame_c(YV12_BUFFER_CONFIG *src_ybc, | 26 static void yv12_copy_partial_frame(YV12_BUFFER_CONFIG *src_ybc, |
27 YV12_BUFFER_CONFIG *dst_ybc) | 27 YV12_BUFFER_CONFIG *dst_ybc) |
28 { | 28 { |
29 unsigned char *src_y, *dst_y; | 29 unsigned char *src_y, *dst_y; |
30 int yheight; | 30 int yheight; |
31 int ystride; | 31 int ystride; |
32 int yoffset; | 32 int yoffset; |
33 int linestocopy; | 33 int linestocopy; |
34 | 34 |
35 yheight = src_ybc->y_height; | 35 yheight = src_ybc->y_height; |
36 ystride = src_ybc->y_stride; | 36 ystride = src_ybc->y_stride; |
37 | 37 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 cm->filter_level = min_filter_level; | 166 cm->filter_level = min_filter_level; |
167 else if (cm->filter_level > max_filter_level) | 167 else if (cm->filter_level > max_filter_level) |
168 cm->filter_level = max_filter_level; | 168 cm->filter_level = max_filter_level; |
169 | 169 |
170 filt_val = cm->filter_level; | 170 filt_val = cm->filter_level; |
171 best_filt_val = filt_val; | 171 best_filt_val = filt_val; |
172 | 172 |
173 /* Get the err using the previous frame's filter value. */ | 173 /* Get the err using the previous frame's filter value. */ |
174 | 174 |
175 /* Copy the unfiltered / processed recon buffer to the new buffer */ | 175 /* Copy the unfiltered / processed recon buffer to the new buffer */ |
176 vp8_yv12_copy_partial_frame(saved_frame, cm->frame_to_show); | 176 yv12_copy_partial_frame(saved_frame, cm->frame_to_show); |
177 vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 177 vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); |
178 | 178 |
179 best_err = calc_partial_ssl_err(sd, cm->frame_to_show); | 179 best_err = calc_partial_ssl_err(sd, cm->frame_to_show); |
180 | 180 |
181 filt_val -= 1 + (filt_val > 10); | 181 filt_val -= 1 + (filt_val > 10); |
182 | 182 |
183 /* Search lower filter levels */ | 183 /* Search lower filter levels */ |
184 while (filt_val >= min_filter_level) | 184 while (filt_val >= min_filter_level) |
185 { | 185 { |
186 /* Apply the loop filter */ | 186 /* Apply the loop filter */ |
187 vp8_yv12_copy_partial_frame(saved_frame, cm->frame_to_show); | 187 yv12_copy_partial_frame(saved_frame, cm->frame_to_show); |
188 vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 188 vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); |
189 | 189 |
190 /* Get the err for filtered frame */ | 190 /* Get the err for filtered frame */ |
191 filt_err = calc_partial_ssl_err(sd, cm->frame_to_show); | 191 filt_err = calc_partial_ssl_err(sd, cm->frame_to_show); |
192 | 192 |
193 /* Update the best case record or exit loop. */ | 193 /* Update the best case record or exit loop. */ |
194 if (filt_err < best_err) | 194 if (filt_err < best_err) |
195 { | 195 { |
196 best_err = filt_err; | 196 best_err = filt_err; |
197 best_filt_val = filt_val; | 197 best_filt_val = filt_val; |
198 } | 198 } |
199 else | 199 else |
200 break; | 200 break; |
201 | 201 |
202 /* Adjust filter level */ | 202 /* Adjust filter level */ |
203 filt_val -= 1 + (filt_val > 10); | 203 filt_val -= 1 + (filt_val > 10); |
204 } | 204 } |
205 | 205 |
206 /* Search up (note that we have already done filt_val = cm->filter_level) */ | 206 /* Search up (note that we have already done filt_val = cm->filter_level) */ |
207 filt_val = cm->filter_level + 1 + (filt_val > 10); | 207 filt_val = cm->filter_level + 1 + (filt_val > 10); |
208 | 208 |
209 if (best_filt_val == cm->filter_level) | 209 if (best_filt_val == cm->filter_level) |
210 { | 210 { |
211 /* Resist raising filter level for very small gains */ | 211 /* Resist raising filter level for very small gains */ |
212 best_err -= (best_err >> 10); | 212 best_err -= (best_err >> 10); |
213 | 213 |
214 while (filt_val < max_filter_level) | 214 while (filt_val < max_filter_level) |
215 { | 215 { |
216 /* Apply the loop filter */ | 216 /* Apply the loop filter */ |
217 vp8_yv12_copy_partial_frame(saved_frame, cm->frame_to_show); | 217 yv12_copy_partial_frame(saved_frame, cm->frame_to_show); |
218 | 218 |
219 vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 219 vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); |
220 | 220 |
221 /* Get the err for filtered frame */ | 221 /* Get the err for filtered frame */ |
222 filt_err = calc_partial_ssl_err(sd, cm->frame_to_show); | 222 filt_err = calc_partial_ssl_err(sd, cm->frame_to_show); |
223 | 223 |
224 /* Update the best case record or exit loop. */ | 224 /* Update the best case record or exit loop. */ |
225 if (filt_err < best_err) | 225 if (filt_err < best_err) |
226 { | 226 { |
227 /* Do not raise filter level if improvement is < 1 part | 227 /* Do not raise filter level if improvement is < 1 part |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 filt_direction = (filt_best < filt_mid) ? -1 : 1; | 398 filt_direction = (filt_best < filt_mid) ? -1 : 1; |
399 filt_mid = filt_best; | 399 filt_mid = filt_best; |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 cm->filter_level = filt_best; | 403 cm->filter_level = filt_best; |
404 | 404 |
405 /* restore unfiltered frame pointer */ | 405 /* restore unfiltered frame pointer */ |
406 cm->frame_to_show = saved_frame; | 406 cm->frame_to_show = saved_frame; |
407 } | 407 } |
OLD | NEW |