OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |