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

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

Issue 290653003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 7 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
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
11 #include <assert.h> 11 #include <assert.h>
12 #include <limits.h> 12 #include <limits.h>
13 13
14 #include "./vpx_scale_rtcd.h" 14 #include "./vpx_scale_rtcd.h"
15 15
16 #include "vpx_mem/vpx_mem.h" 16 #include "vpx_mem/vpx_mem.h"
17 17
18 #include "vp9/common/vp9_loopfilter.h" 18 #include "vp9/common/vp9_loopfilter.h"
19 #include "vp9/common/vp9_onyxc_int.h" 19 #include "vp9/common/vp9_onyxc_int.h"
20 #include "vp9/common/vp9_quant_common.h" 20 #include "vp9/common/vp9_quant_common.h"
21 21
22 #include "vp9/encoder/vp9_encoder.h" 22 #include "vp9/encoder/vp9_encoder.h"
23 #include "vp9/encoder/vp9_picklpf.h" 23 #include "vp9/encoder/vp9_picklpf.h"
24 #include "vp9/encoder/vp9_quantize.h" 24 #include "vp9/encoder/vp9_quantize.h"
25 25
26 static int get_max_filter_level(const VP9_COMP *cpi) { 26 static int get_max_filter_level(const VP9_COMP *cpi) {
27 return cpi->twopass.section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4 27 if (cpi->pass == 2) {
28 : MAX_LOOP_FILTER; 28 return cpi->twopass.section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4
29 : MAX_LOOP_FILTER;
30 } else {
31 return MAX_LOOP_FILTER;
32 }
29 } 33 }
30 34
31 35
32 static int try_filter_frame(const YV12_BUFFER_CONFIG *sd, VP9_COMP *const cpi, 36 static int try_filter_frame(const YV12_BUFFER_CONFIG *sd, VP9_COMP *const cpi,
33 int filt_level, int partial_frame) { 37 int filt_level, int partial_frame) {
34 VP9_COMMON *const cm = &cpi->common; 38 VP9_COMMON *const cm = &cpi->common;
35 int filt_err; 39 int filt_err;
36 40
37 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_level, 1, partial_frame); 41 vp9_loop_filter_frame(cm->frame_to_show, cm, &cpi->mb.e_mbd, filt_level, 1,
42 partial_frame);
38 filt_err = vp9_get_y_sse(sd, cm->frame_to_show); 43 filt_err = vp9_get_y_sse(sd, cm->frame_to_show);
39 44
40 // Re-instate the unfiltered frame 45 // Re-instate the unfiltered frame
41 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); 46 vpx_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
42 47
43 return filt_err; 48 return filt_err;
44 } 49 }
45 50
46 static int search_filter_level(const YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, 51 static int search_filter_level(const YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi,
47 int partial_frame) { 52 int partial_frame) {
(...skipping 22 matching lines...) Expand all
70 ss_err[filt_mid] = best_err; 75 ss_err[filt_mid] = best_err;
71 76
72 while (filter_step > 0) { 77 while (filter_step > 0) {
73 const int filt_high = MIN(filt_mid + filter_step, max_filter_level); 78 const int filt_high = MIN(filt_mid + filter_step, max_filter_level);
74 const int filt_low = MAX(filt_mid - filter_step, min_filter_level); 79 const int filt_low = MAX(filt_mid - filter_step, min_filter_level);
75 int filt_err; 80 int filt_err;
76 81
77 // Bias against raising loop filter in favor of lowering it. 82 // Bias against raising loop filter in favor of lowering it.
78 int bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; 83 int bias = (best_err >> (15 - (filt_mid / 8))) * filter_step;
79 84
80 if (cpi->twopass.section_intra_rating < 20) 85 if ((cpi->pass == 2) && (cpi->twopass.section_intra_rating < 20))
81 bias = bias * cpi->twopass.section_intra_rating / 20; 86 bias = (bias * cpi->twopass.section_intra_rating) / 20;
82 87
83 // yx, bias less for large block size 88 // yx, bias less for large block size
84 if (cm->tx_mode != ONLY_4X4) 89 if (cm->tx_mode != ONLY_4X4)
85 bias >>= 1; 90 bias >>= 1;
86 91
87 if (filt_direction <= 0 && filt_low != filt_mid) { 92 if (filt_direction <= 0 && filt_low != filt_mid) {
88 // Get Low filter error score 93 // Get Low filter error score
89 if (ss_err[filt_low] < 0) { 94 if (ss_err[filt_low] < 0) {
90 filt_err = try_filter_frame(sd, cpi, filt_low, partial_frame); 95 filt_err = try_filter_frame(sd, cpi, filt_low, partial_frame);
91 ss_err[filt_low] = filt_err; 96 ss_err[filt_low] = filt_err;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // searched level, filt_guess = q * 0.316206 + 3.87252 152 // searched level, filt_guess = q * 0.316206 + 3.87252
148 int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18); 153 int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18);
149 if (cm->frame_type == KEY_FRAME) 154 if (cm->frame_type == KEY_FRAME)
150 filt_guess -= 4; 155 filt_guess -= 4;
151 lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level); 156 lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level);
152 } else { 157 } else {
153 lf->filter_level = search_filter_level(sd, cpi, 158 lf->filter_level = search_filter_level(sd, cpi,
154 method == LPF_PICK_FROM_SUBIMAGE); 159 method == LPF_PICK_FROM_SUBIMAGE);
155 } 160 }
156 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698