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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_aq_variance.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) 2013 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 <math.h> 11 #include <math.h>
12 12
13 #include "vpx_ports/mem.h" 13 #include "vpx_ports/mem.h"
14 #include "vpx_ports/system_state.h"
14 15
15 #include "vp9/encoder/vp9_aq_variance.h" 16 #include "vp9/encoder/vp9_aq_variance.h"
16 17
17 #include "vp9/common/vp9_seg_common.h" 18 #include "vp9/common/vp9_seg_common.h"
18 19
19 #include "vp9/encoder/vp9_ratectrl.h" 20 #include "vp9/encoder/vp9_ratectrl.h"
20 #include "vp9/encoder/vp9_rd.h" 21 #include "vp9/encoder/vp9_rd.h"
21 #include "vp9/encoder/vp9_segmentation.h" 22 #include "vp9/encoder/vp9_segmentation.h"
22 #include "vp9/common/vp9_systemdependent.h"
23 23
24 #define ENERGY_MIN (-4) 24 #define ENERGY_MIN (-4)
25 #define ENERGY_MAX (1) 25 #define ENERGY_MAX (1)
26 #define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1) 26 #define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1)
27 #define ENERGY_IN_BOUNDS(energy)\ 27 #define ENERGY_IN_BOUNDS(energy)\
28 assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX) 28 assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX)
29 29
30 static const double rate_ratio[MAX_SEGMENTS] = 30 static const double rate_ratio[MAX_SEGMENTS] =
31 {2.5, 2.0, 1.5, 1.0, 0.75, 1.0, 1.0, 1.0}; 31 {2.5, 2.0, 1.5, 1.0, 0.75, 1.0, 1.0, 1.0};
32 static const int segment_id[ENERGY_SPAN] = {0, 1, 1, 2, 3, 4}; 32 static const int segment_id[ENERGY_SPAN] = {0, 1, 1, 2, 3, 4};
(...skipping 16 matching lines...) Expand all
49 int i; 49 int i;
50 50
51 if (cm->frame_type == KEY_FRAME || 51 if (cm->frame_type == KEY_FRAME ||
52 cpi->refresh_alt_ref_frame || 52 cpi->refresh_alt_ref_frame ||
53 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { 53 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
54 vp9_enable_segmentation(seg); 54 vp9_enable_segmentation(seg);
55 vp9_clearall_segfeatures(seg); 55 vp9_clearall_segfeatures(seg);
56 56
57 seg->abs_delta = SEGMENT_DELTADATA; 57 seg->abs_delta = SEGMENT_DELTADATA;
58 58
59 vp9_clear_system_state(); 59 vpx_clear_system_state();
60 60
61 for (i = 0; i < MAX_SEGMENTS; ++i) { 61 for (i = 0; i < MAX_SEGMENTS; ++i) {
62 int qindex_delta = 62 int qindex_delta =
63 vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex, 63 vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex,
64 rate_ratio[i], cm->bit_depth); 64 rate_ratio[i], cm->bit_depth);
65 65
66 // We don't allow qindex 0 in a segment if the base value is not 0. 66 // We don't allow qindex 0 in a segment if the base value is not 0.
67 // Q index 0 (lossless) implies 4x4 encoding only and in AQ mode a segment 67 // Q index 0 (lossless) implies 4x4 encoding only and in AQ mode a segment
68 // Q delta is sometimes applied without going back around the rd loop. 68 // Q delta is sometimes applied without going back around the rd loop.
69 // This could lead to an illegal combination of partition size and q. 69 // This could lead to an illegal combination of partition size and q.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, 184 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
185 x->plane[0].src.stride, 185 x->plane[0].src.stride,
186 vp9_64_zeros, 0, &sse); 186 vp9_64_zeros, 0, &sse);
187 #endif // CONFIG_VP9_HIGHBITDEPTH 187 #endif // CONFIG_VP9_HIGHBITDEPTH
188 return (256 * var) >> num_pels_log2_lookup[bs]; 188 return (256 * var) >> num_pels_log2_lookup[bs];
189 } 189 }
190 } 190 }
191 191
192 double vp9_log_block_var(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { 192 double vp9_log_block_var(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
193 unsigned int var = block_variance(cpi, x, bs); 193 unsigned int var = block_variance(cpi, x, bs);
194 vp9_clear_system_state(); 194 vpx_clear_system_state();
195 return log(var + 1.0); 195 return log(var + 1.0);
196 } 196 }
197 197
198 #define DEFAULT_E_MIDPOINT 10.0 198 #define DEFAULT_E_MIDPOINT 10.0
199 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { 199 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
200 double energy; 200 double energy;
201 double energy_midpoint; 201 double energy_midpoint;
202 vp9_clear_system_state(); 202 vpx_clear_system_state();
203 energy_midpoint = 203 energy_midpoint =
204 (cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT; 204 (cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT;
205 energy = vp9_log_block_var(cpi, x, bs) - energy_midpoint; 205 energy = vp9_log_block_var(cpi, x, bs) - energy_midpoint;
206 return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX); 206 return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX);
207 } 207 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c ('k') | source/libvpx/vp9/encoder/vp9_bitstream.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698