| 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 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 unsigned int vp9_vaq_segment_id(int energy) { | 38 unsigned int vp9_vaq_segment_id(int energy) { |
| 39 ENERGY_IN_BOUNDS(energy); | 39 ENERGY_IN_BOUNDS(energy); |
| 40 | 40 |
| 41 return SEGMENT_ID(energy); | 41 return SEGMENT_ID(energy); |
| 42 } | 42 } |
| 43 | 43 |
| 44 double vp9_vaq_rdmult_ratio(int energy) { | 44 double vp9_vaq_rdmult_ratio(int energy) { |
| 45 ENERGY_IN_BOUNDS(energy); | 45 ENERGY_IN_BOUNDS(energy); |
| 46 | 46 |
| 47 vp9_clear_system_state(); // __asm emms; | 47 vp9_clear_system_state(); |
| 48 | 48 |
| 49 return RDMULT_RATIO(energy); | 49 return RDMULT_RATIO(energy); |
| 50 } | 50 } |
| 51 | 51 |
| 52 double vp9_vaq_inv_q_ratio(int energy) { | 52 double vp9_vaq_inv_q_ratio(int energy) { |
| 53 ENERGY_IN_BOUNDS(energy); | 53 ENERGY_IN_BOUNDS(energy); |
| 54 | 54 |
| 55 vp9_clear_system_state(); // __asm emms; | 55 vp9_clear_system_state(); |
| 56 | 56 |
| 57 return Q_RATIO(-energy); | 57 return Q_RATIO(-energy); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void vp9_vaq_init() { | 60 void vp9_vaq_init() { |
| 61 int i; | 61 int i; |
| 62 double base_ratio; | 62 double base_ratio; |
| 63 | 63 |
| 64 assert(ENERGY_SPAN <= MAX_SEGMENTS); | 64 assert(ENERGY_SPAN <= MAX_SEGMENTS); |
| 65 | 65 |
| 66 vp9_clear_system_state(); // __asm emms; | 66 vp9_clear_system_state(); |
| 67 | 67 |
| 68 base_ratio = 1.5; | 68 base_ratio = 1.5; |
| 69 | 69 |
| 70 for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { | 70 for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { |
| 71 Q_RATIO(i) = pow(base_ratio, i/3.0); | 71 Q_RATIO(i) = pow(base_ratio, i/3.0); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 void vp9_vaq_frame_setup(VP9_COMP *cpi) { | 75 void vp9_vaq_frame_setup(VP9_COMP *cpi) { |
| 76 VP9_COMMON *cm = &cpi->common; | 76 VP9_COMMON *cm = &cpi->common; |
| 77 struct segmentation *seg = &cm->seg; | 77 struct segmentation *seg = &cm->seg; |
| 78 int base_q = vp9_convert_qindex_to_q(cm->base_qindex); | 78 const double base_q = vp9_convert_qindex_to_q(cm->base_qindex); |
| 79 int base_rdmult = vp9_compute_rd_mult(cpi, cm->base_qindex + | 79 const int base_rdmult = vp9_compute_rd_mult(cpi, cm->base_qindex + |
| 80 cm->y_dc_delta_q); | 80 cm->y_dc_delta_q); |
| 81 int i; | 81 int i; |
| 82 | 82 |
| 83 if (cm->frame_type == KEY_FRAME || | 83 if (cm->frame_type == KEY_FRAME || |
| 84 cpi->refresh_alt_ref_frame || | 84 cpi->refresh_alt_ref_frame || |
| 85 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { | 85 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { |
| 86 vp9_enable_segmentation((VP9_PTR)cpi); | 86 vp9_enable_segmentation(seg); |
| 87 vp9_clearall_segfeatures(seg); | 87 vp9_clearall_segfeatures(seg); |
| 88 | 88 |
| 89 seg->abs_delta = SEGMENT_DELTADATA; | 89 seg->abs_delta = SEGMENT_DELTADATA; |
| 90 | 90 |
| 91 vp9_clear_system_state(); // __asm emms; | 91 vp9_clear_system_state(); |
| 92 | 92 |
| 93 for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { | 93 for (i = ENERGY_MIN; i <= ENERGY_MAX; i++) { |
| 94 int qindex_delta, segment_rdmult; | 94 int qindex_delta, segment_rdmult; |
| 95 | 95 |
| 96 if (Q_RATIO(i) == 1) { | 96 if (Q_RATIO(i) == 1) { |
| 97 // No need to enable SEG_LVL_ALT_Q for this segment | 97 // No need to enable SEG_LVL_ALT_Q for this segment |
| 98 RDMULT_RATIO(i) = 1; | 98 RDMULT_RATIO(i) = 1; |
| 99 continue; | 99 continue; |
| 100 } | 100 } |
| 101 | 101 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 x->plane[0].src.stride, | 134 x->plane[0].src.stride, |
| 135 vp9_64_zeros, 0, &sse); | 135 vp9_64_zeros, 0, &sse); |
| 136 return (256 * var) >> num_pels_log2_lookup[bs]; | 136 return (256 * var) >> num_pels_log2_lookup[bs]; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { | 140 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { |
| 141 double energy; | 141 double energy; |
| 142 unsigned int var = block_variance(cpi, x, bs); | 142 unsigned int var = block_variance(cpi, x, bs); |
| 143 | 143 |
| 144 vp9_clear_system_state(); // __asm emms; | 144 vp9_clear_system_state(); |
| 145 | 145 |
| 146 // if (var <= 1000) | 146 energy = 0.9 * (log(var + 1.0) - 10.0); |
| 147 // return 0; | 147 return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX); |
| 148 | |
| 149 energy = 0.9*(logf(var + 1) - 10.0); | |
| 150 return clamp(round(energy), ENERGY_MIN, ENERGY_MAX); | |
| 151 } | 148 } |
| OLD | NEW |