| OLD | NEW |
| 1 // Copyright 2010 Google Inc. | 1 // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- | 6 // ----------------------------------------------------------------------------- |
| 7 // | 7 // |
| 8 // Quantizer initialization | 8 // Quantizer initialization |
| 9 // | 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 11 |
| 12 #include "vp8i.h" | 12 #include "./vp8i.h" |
| 13 | 13 |
| 14 #if defined(__cplusplus) || defined(c_plusplus) | 14 #if defined(__cplusplus) || defined(c_plusplus) |
| 15 extern "C" { | 15 extern "C" { |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 static inline int clip(int v, int M) { | 18 static WEBP_INLINE int clip(int v, int M) { |
| 19 return v < 0 ? 0 : v > M ? M : v; | 19 return v < 0 ? 0 : v > M ? M : v; |
| 20 } | 20 } |
| 21 | 21 |
| 22 // Paragraph 14.1 | 22 // Paragraph 14.1 |
| 23 static const uint8_t kDcTable[128] = { | 23 static const uint8_t kDcTable[128] = { |
| 24 4, 5, 6, 7, 8, 9, 10, 10, | 24 4, 5, 6, 7, 8, 9, 10, 10, |
| 25 11, 12, 13, 14, 15, 16, 17, 17, | 25 11, 12, 13, 14, 15, 16, 17, 17, |
| 26 18, 19, 20, 20, 21, 21, 22, 22, | 26 18, 19, 20, 20, 21, 21, 22, 22, |
| 27 23, 23, 24, 25, 25, 26, 27, 28, | 27 23, 23, 24, 25, 25, 26, 27, 28, |
| 28 29, 30, 31, 32, 33, 34, 35, 36, | 28 29, 30, 31, 32, 33, 34, 35, 36, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } else { | 87 } else { |
| 88 q = base_q0; | 88 q = base_q0; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 { | 91 { |
| 92 VP8QuantMatrix* const m = &dec->dqm_[i]; | 92 VP8QuantMatrix* const m = &dec->dqm_[i]; |
| 93 m->y1_mat_[0] = kDcTable[clip(q + dqy1_dc, 127)]; | 93 m->y1_mat_[0] = kDcTable[clip(q + dqy1_dc, 127)]; |
| 94 m->y1_mat_[1] = kAcTable[clip(q + 0, 127)]; | 94 m->y1_mat_[1] = kAcTable[clip(q + 0, 127)]; |
| 95 | 95 |
| 96 m->y2_mat_[0] = kDcTable[clip(q + dqy2_dc, 127)] * 2; | 96 m->y2_mat_[0] = kDcTable[clip(q + dqy2_dc, 127)] * 2; |
| 97 // TODO(skal): make it another table? | 97 // For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16. |
| 98 m->y2_mat_[1] = kAcTable[clip(q + dqy2_ac, 127)] * 155 / 100; | 98 // The smallest precision for that is '(x*6349) >> 12' but 16 is a good |
| 99 // word size. |
| 100 m->y2_mat_[1] = (kAcTable[clip(q + dqy2_ac, 127)] * 101581) >> 16; |
| 99 if (m->y2_mat_[1] < 8) m->y2_mat_[1] = 8; | 101 if (m->y2_mat_[1] < 8) m->y2_mat_[1] = 8; |
| 100 | 102 |
| 101 m->uv_mat_[0] = kDcTable[clip(q + dquv_dc, 117)]; | 103 m->uv_mat_[0] = kDcTable[clip(q + dquv_dc, 117)]; |
| 102 m->uv_mat_[1] = kAcTable[clip(q + dquv_ac, 127)]; | 104 m->uv_mat_[1] = kAcTable[clip(q + dquv_ac, 127)]; |
| 103 } | 105 } |
| 104 } | 106 } |
| 105 } | 107 } |
| 106 | 108 |
| 107 //------------------------------------------------------------------------------ | 109 //------------------------------------------------------------------------------ |
| 108 | 110 |
| 109 #if defined(__cplusplus) || defined(c_plusplus) | 111 #if defined(__cplusplus) || defined(c_plusplus) |
| 110 } // extern "C" | 112 } // extern "C" |
| 111 #endif | 113 #endif |
| OLD | NEW |