OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 Google Inc. |
| 2 // |
| 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- |
| 7 // |
| 8 // YUV->RGB conversion function |
| 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 |
| 12 #include "yuv.h" |
| 13 |
| 14 #if defined(__cplusplus) || defined(c_plusplus) |
| 15 extern "C" { |
| 16 #endif |
| 17 |
| 18 enum { YUV_HALF = 1 << (YUV_FIX - 1) }; |
| 19 |
| 20 int16_t VP8kVToR[256], VP8kUToB[256]; |
| 21 int32_t VP8kVToG[256], VP8kUToG[256]; |
| 22 uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN]; |
| 23 |
| 24 static int done = 0; |
| 25 |
| 26 void VP8YUVInit() { |
| 27 if (done) { |
| 28 return; |
| 29 } |
| 30 for (int i = 0; i < 256; ++i) { |
| 31 VP8kVToR[i] = (89858 * (i - 128) + YUV_HALF) >> YUV_FIX; |
| 32 VP8kUToG[i] = -22014 * (i - 128) + YUV_HALF; |
| 33 VP8kVToG[i] = -45773 * (i - 128); |
| 34 VP8kUToB[i] = (113618 * (i - 128) + YUV_HALF) >> YUV_FIX; |
| 35 } |
| 36 for (int i = YUV_RANGE_MIN; i < YUV_RANGE_MAX; ++i) { |
| 37 const int j = ((i - 16) * 76283 + YUV_HALF) >> YUV_FIX; |
| 38 VP8kClip[i - YUV_RANGE_MIN] = (j < 0) ? 0 : (j > 255) ? 255 : j; |
| 39 } |
| 40 done = 1; |
| 41 } |
| 42 |
| 43 #if defined(__cplusplus) || defined(c_plusplus) |
| 44 } // extern "C" |
| 45 #endif |
OLD | NEW |