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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 filt_mid = min_filter_level; | 306 filt_mid = min_filter_level; |
307 else if (filt_mid > max_filter_level) | 307 else if (filt_mid > max_filter_level) |
308 filt_mid = max_filter_level; | 308 filt_mid = max_filter_level; |
309 | 309 |
310 /* Define the initial step size */ | 310 /* Define the initial step size */ |
311 filter_step = (filt_mid < 16) ? 4 : filt_mid / 4; | 311 filter_step = (filt_mid < 16) ? 4 : filt_mid / 4; |
312 | 312 |
313 /* Get baseline error score */ | 313 /* Get baseline error score */ |
314 | 314 |
315 /* Copy the unfiltered / processed recon buffer to the new buffer */ | 315 /* Copy the unfiltered / processed recon buffer to the new buffer */ |
316 vp8_yv12_copy_y(saved_frame, cm->frame_to_show); | 316 vpx_yv12_copy_y(saved_frame, cm->frame_to_show); |
317 | 317 |
318 vp8cx_set_alt_lf_level(cpi, filt_mid); | 318 vp8cx_set_alt_lf_level(cpi, filt_mid); |
319 vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid); | 319 vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid); |
320 | 320 |
321 best_err = vp8_calc_ss_err(sd, cm->frame_to_show); | 321 best_err = vp8_calc_ss_err(sd, cm->frame_to_show); |
322 | 322 |
323 ss_err[filt_mid] = best_err; | 323 ss_err[filt_mid] = best_err; |
324 | 324 |
325 filt_best = filt_mid; | 325 filt_best = filt_mid; |
326 | 326 |
327 while (filter_step > 0) | 327 while (filter_step > 0) |
328 { | 328 { |
329 Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; | 329 Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; |
330 | 330 |
331 if (cpi->twopass.section_intra_rating < 20) | 331 if (cpi->twopass.section_intra_rating < 20) |
332 Bias = Bias * cpi->twopass.section_intra_rating / 20; | 332 Bias = Bias * cpi->twopass.section_intra_rating / 20; |
333 | 333 |
334 filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_l
evel : (filt_mid + filter_step); | 334 filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_l
evel : (filt_mid + filter_step); |
335 filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_le
vel : (filt_mid - filter_step); | 335 filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_le
vel : (filt_mid - filter_step); |
336 | 336 |
337 if ((filt_direction <= 0) && (filt_low != filt_mid)) | 337 if ((filt_direction <= 0) && (filt_low != filt_mid)) |
338 { | 338 { |
339 if(ss_err[filt_low] == 0) | 339 if(ss_err[filt_low] == 0) |
340 { | 340 { |
341 /* Get Low filter error score */ | 341 /* Get Low filter error score */ |
342 vp8_yv12_copy_y(saved_frame, cm->frame_to_show); | 342 vpx_yv12_copy_y(saved_frame, cm->frame_to_show); |
343 vp8cx_set_alt_lf_level(cpi, filt_low); | 343 vp8cx_set_alt_lf_level(cpi, filt_low); |
344 vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low); | 344 vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low); |
345 | 345 |
346 filt_err = vp8_calc_ss_err(sd, cm->frame_to_show); | 346 filt_err = vp8_calc_ss_err(sd, cm->frame_to_show); |
347 ss_err[filt_low] = filt_err; | 347 ss_err[filt_low] = filt_err; |
348 } | 348 } |
349 else | 349 else |
350 filt_err = ss_err[filt_low]; | 350 filt_err = ss_err[filt_low]; |
351 | 351 |
352 /* If value is close to the best so far then bias towards a | 352 /* If value is close to the best so far then bias towards a |
353 * lower loop filter value. | 353 * lower loop filter value. |
354 */ | 354 */ |
355 if ((filt_err - Bias) < best_err) | 355 if ((filt_err - Bias) < best_err) |
356 { | 356 { |
357 /* Was it actually better than the previous best? */ | 357 /* Was it actually better than the previous best? */ |
358 if (filt_err < best_err) | 358 if (filt_err < best_err) |
359 best_err = filt_err; | 359 best_err = filt_err; |
360 | 360 |
361 filt_best = filt_low; | 361 filt_best = filt_low; |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 /* Now look at filt_high */ | 365 /* Now look at filt_high */ |
366 if ((filt_direction >= 0) && (filt_high != filt_mid)) | 366 if ((filt_direction >= 0) && (filt_high != filt_mid)) |
367 { | 367 { |
368 if(ss_err[filt_high] == 0) | 368 if(ss_err[filt_high] == 0) |
369 { | 369 { |
370 vp8_yv12_copy_y(saved_frame, cm->frame_to_show); | 370 vpx_yv12_copy_y(saved_frame, cm->frame_to_show); |
371 vp8cx_set_alt_lf_level(cpi, filt_high); | 371 vp8cx_set_alt_lf_level(cpi, filt_high); |
372 vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high); | 372 vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high); |
373 | 373 |
374 filt_err = vp8_calc_ss_err(sd, cm->frame_to_show); | 374 filt_err = vp8_calc_ss_err(sd, cm->frame_to_show); |
375 ss_err[filt_high] = filt_err; | 375 ss_err[filt_high] = filt_err; |
376 } | 376 } |
377 else | 377 else |
378 filt_err = ss_err[filt_high]; | 378 filt_err = ss_err[filt_high]; |
379 | 379 |
380 /* Was it better than the previous best? */ | 380 /* Was it better than the previous best? */ |
(...skipping 17 matching lines...) Expand all 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 |