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

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

Issue 1302353004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 <limits.h> 11 #include <limits.h>
12 #include <math.h> 12 #include <math.h>
13 #include "vpx_ports/system_state.h"
13 14
14 #include "vp9/encoder/vp9_aq_complexity.h" 15 #include "vp9/encoder/vp9_aq_complexity.h"
15 #include "vp9/encoder/vp9_aq_variance.h" 16 #include "vp9/encoder/vp9_aq_variance.h"
16 #include "vp9/encoder/vp9_encodeframe.h" 17 #include "vp9/encoder/vp9_encodeframe.h"
17 #include "vp9/common/vp9_seg_common.h" 18 #include "vp9/common/vp9_seg_common.h"
18 #include "vp9/encoder/vp9_segmentation.h" 19 #include "vp9/encoder/vp9_segmentation.h"
19 20
20 #define AQ_C_SEGMENTS 5 21 #define AQ_C_SEGMENTS 5
21 #define DEFAULT_AQ2_SEG 3 // Neutral Q segment 22 #define DEFAULT_AQ2_SEG 3 // Neutral Q segment
22 #define AQ_C_STRENGTHS 3 23 #define AQ_C_STRENGTHS 3
(...skipping 17 matching lines...) Expand all
40 // Approximate base quatizer (truncated to int) 41 // Approximate base quatizer (truncated to int)
41 const int base_quant = vp9_ac_quant(q_index, 0, bit_depth) / 4; 42 const int base_quant = vp9_ac_quant(q_index, 0, bit_depth) / 4;
42 return (base_quant > 10) + (base_quant > 25); 43 return (base_quant > 10) + (base_quant > 25);
43 } 44 }
44 45
45 void vp9_setup_in_frame_q_adj(VP9_COMP *cpi) { 46 void vp9_setup_in_frame_q_adj(VP9_COMP *cpi) {
46 VP9_COMMON *const cm = &cpi->common; 47 VP9_COMMON *const cm = &cpi->common;
47 struct segmentation *const seg = &cm->seg; 48 struct segmentation *const seg = &cm->seg;
48 49
49 // Make SURE use of floating point in this function is safe. 50 // Make SURE use of floating point in this function is safe.
50 vp9_clear_system_state(); 51 vpx_clear_system_state();
51 52
52 if (cm->frame_type == KEY_FRAME || 53 if (cm->frame_type == KEY_FRAME ||
53 cpi->refresh_alt_ref_frame || 54 cpi->refresh_alt_ref_frame ||
54 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { 55 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
55 int segment; 56 int segment;
56 const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth); 57 const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth);
57 58
58 // Clear down the segment map. 59 // Clear down the segment map.
59 memset(cpi->segmentation_map, DEFAULT_AQ2_SEG, cm->mi_rows * cm->mi_cols); 60 memset(cpi->segmentation_map, DEFAULT_AQ2_SEG, cm->mi_rows * cm->mi_cols);
60 61
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Select a segment for the current block. 110 // Select a segment for the current block.
110 // The choice of segment for a block depends on the ratio of the projected 111 // The choice of segment for a block depends on the ratio of the projected
111 // bits for the block vs a target average and its spatial complexity. 112 // bits for the block vs a target average and its spatial complexity.
112 void vp9_caq_select_segment(VP9_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs, 113 void vp9_caq_select_segment(VP9_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
113 int mi_row, int mi_col, int projected_rate) { 114 int mi_row, int mi_col, int projected_rate) {
114 VP9_COMMON *const cm = &cpi->common; 115 VP9_COMMON *const cm = &cpi->common;
115 116
116 const int mi_offset = mi_row * cm->mi_cols + mi_col; 117 const int mi_offset = mi_row * cm->mi_cols + mi_col;
117 const int bw = num_8x8_blocks_wide_lookup[BLOCK_64X64]; 118 const int bw = num_8x8_blocks_wide_lookup[BLOCK_64X64];
118 const int bh = num_8x8_blocks_high_lookup[BLOCK_64X64]; 119 const int bh = num_8x8_blocks_high_lookup[BLOCK_64X64];
119 const int xmis = MIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[bs]); 120 const int xmis = VPXMIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[bs]);
120 const int ymis = MIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[bs]); 121 const int ymis = VPXMIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[bs]);
121 int x, y; 122 int x, y;
122 int i; 123 int i;
123 unsigned char segment; 124 unsigned char segment;
124 125
125 if (0) { 126 if (0) {
126 segment = DEFAULT_AQ2_SEG; 127 segment = DEFAULT_AQ2_SEG;
127 } else { 128 } else {
128 // Rate depends on fraction of a SB64 in frame (xmis * ymis / bw * bh). 129 // Rate depends on fraction of a SB64 in frame (xmis * ymis / bw * bh).
129 // It is converted to bits * 256 units. 130 // It is converted to bits * 256 units.
130 const int target_rate = (cpi->rc.sb64_target_rate * xmis * ymis * 256) / 131 const int target_rate = (cpi->rc.sb64_target_rate * xmis * ymis * 256) /
131 (bw * bh); 132 (bw * bh);
132 double logvar; 133 double logvar;
133 double low_var_thresh; 134 double low_var_thresh;
134 const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth); 135 const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth);
135 136
136 vp9_clear_system_state(); 137 vpx_clear_system_state();
137 low_var_thresh = (cpi->oxcf.pass == 2) 138 low_var_thresh = (cpi->oxcf.pass == 2)
138 ? MAX(cpi->twopass.mb_av_energy, MIN_DEFAULT_LV_THRESH) 139 ? VPXMAX(cpi->twopass.mb_av_energy, MIN_DEFAULT_LV_THRESH)
139 : DEFAULT_LV_THRESH; 140 : DEFAULT_LV_THRESH;
140 141
141 vp9_setup_src_planes(mb, cpi->Source, mi_row, mi_col); 142 vp9_setup_src_planes(mb, cpi->Source, mi_row, mi_col);
142 logvar = vp9_log_block_var(cpi, mb, bs); 143 logvar = vp9_log_block_var(cpi, mb, bs);
143 144
144 segment = AQ_C_SEGMENTS - 1; // Just in case no break out below. 145 segment = AQ_C_SEGMENTS - 1; // Just in case no break out below.
145 for (i = 0; i < AQ_C_SEGMENTS; ++i) { 146 for (i = 0; i < AQ_C_SEGMENTS; ++i) {
146 // Test rate against a threshold value and variance against a threshold. 147 // Test rate against a threshold value and variance against a threshold.
147 // Increasing segment number (higher variance and complexity) = higher Q. 148 // Increasing segment number (higher variance and complexity) = higher Q.
148 if ((projected_rate < 149 if ((projected_rate <
149 target_rate * aq_c_transitions[aq_strength][i]) && 150 target_rate * aq_c_transitions[aq_strength][i]) &&
150 (logvar < (low_var_thresh + aq_c_var_thresholds[aq_strength][i]))) { 151 (logvar < (low_var_thresh + aq_c_var_thresholds[aq_strength][i]))) {
151 segment = i; 152 segment = i;
152 break; 153 break;
153 } 154 }
154 } 155 }
155 } 156 }
156 157
157 // Fill in the entires in the segment map corresponding to this SB64. 158 // Fill in the entires in the segment map corresponding to this SB64.
158 for (y = 0; y < ymis; y++) { 159 for (y = 0; y < ymis; y++) {
159 for (x = 0; x < xmis; x++) { 160 for (x = 0; x < xmis; x++) {
160 cpi->segmentation_map[mi_offset + y * cm->mi_cols + x] = segment; 161 cpi->segmentation_map[mi_offset + y * cm->mi_cols + x] = segment;
161 } 162 }
162 } 163 }
163 } 164 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/arm/neon/vp9_avg_neon.c ('k') | source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698