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

Side by Side Diff: third_party/libwebp/dsp/yuv.c

Issue 12942006: libwebp: update snapshot to v0.3.0-rc6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « third_party/libwebp/dsp/yuv.h ('k') | third_party/libwebp/enc/alpha.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 Google Inc. All Rights Reserved. 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 // YUV->RGB conversion function 8 // YUV->RGB conversion function
9 // 9 //
10 // Author: Skal (pascal.massimino@gmail.com) 10 // Author: Skal (pascal.massimino@gmail.com)
11 11
12 #include "./yuv.h" 12 #include "./yuv.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 enum { YUV_HALF = 1 << (YUV_FIX - 1) }; 18 #ifdef WEBP_YUV_USE_TABLE
19 19
20 int16_t VP8kVToR[256], VP8kUToB[256]; 20 int16_t VP8kVToR[256], VP8kUToB[256];
21 int32_t VP8kVToG[256], VP8kUToG[256]; 21 int32_t VP8kVToG[256], VP8kUToG[256];
22 uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN]; 22 uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN];
23 uint8_t VP8kClip4Bits[YUV_RANGE_MAX - YUV_RANGE_MIN]; 23 uint8_t VP8kClip4Bits[YUV_RANGE_MAX - YUV_RANGE_MIN];
24 24
25 static int done = 0; 25 static int done = 0;
26 26
27 static WEBP_INLINE uint8_t clip(int v, int max_value) { 27 static WEBP_INLINE uint8_t clip(int v, int max_value) {
28 return v < 0 ? 0 : v > max_value ? max_value : v; 28 return v < 0 ? 0 : v > max_value ? max_value : v;
29 } 29 }
30 30
31 void VP8YUVInit(void) { 31 void VP8YUVInit(void) {
32 int i; 32 int i;
33 if (done) { 33 if (done) {
34 return; 34 return;
35 } 35 }
36 #ifndef USE_YUVj
36 for (i = 0; i < 256; ++i) { 37 for (i = 0; i < 256; ++i) {
37 VP8kVToR[i] = (89858 * (i - 128) + YUV_HALF) >> YUV_FIX; 38 VP8kVToR[i] = (89858 * (i - 128) + YUV_HALF) >> YUV_FIX;
38 VP8kUToG[i] = -22014 * (i - 128) + YUV_HALF; 39 VP8kUToG[i] = -22014 * (i - 128) + YUV_HALF;
39 VP8kVToG[i] = -45773 * (i - 128); 40 VP8kVToG[i] = -45773 * (i - 128);
40 VP8kUToB[i] = (113618 * (i - 128) + YUV_HALF) >> YUV_FIX; 41 VP8kUToB[i] = (113618 * (i - 128) + YUV_HALF) >> YUV_FIX;
41 } 42 }
42 for (i = YUV_RANGE_MIN; i < YUV_RANGE_MAX; ++i) { 43 for (i = YUV_RANGE_MIN; i < YUV_RANGE_MAX; ++i) {
43 const int k = ((i - 16) * 76283 + YUV_HALF) >> YUV_FIX; 44 const int k = ((i - 16) * 76283 + YUV_HALF) >> YUV_FIX;
44 VP8kClip[i - YUV_RANGE_MIN] = clip(k, 255); 45 VP8kClip[i - YUV_RANGE_MIN] = clip(k, 255);
45 VP8kClip4Bits[i - YUV_RANGE_MIN] = clip((k + 8) >> 4, 15); 46 VP8kClip4Bits[i - YUV_RANGE_MIN] = clip((k + 8) >> 4, 15);
46 } 47 }
48 #else
49 for (i = 0; i < 256; ++i) {
50 VP8kVToR[i] = (91881 * (i - 128) + YUV_HALF) >> YUV_FIX;
51 VP8kUToG[i] = -22554 * (i - 128) + YUV_HALF;
52 VP8kVToG[i] = -46802 * (i - 128);
53 VP8kUToB[i] = (116130 * (i - 128) + YUV_HALF) >> YUV_FIX;
54 }
55 for (i = YUV_RANGE_MIN; i < YUV_RANGE_MAX; ++i) {
56 const int k = i;
57 VP8kClip[i - YUV_RANGE_MIN] = clip(k, 255);
58 VP8kClip4Bits[i - YUV_RANGE_MIN] = clip((k + 8) >> 4, 15);
59 }
60 #endif
61
47 done = 1; 62 done = 1;
48 } 63 }
49 64
65 #else
66
67 void VP8YUVInit(void) {}
68
69 #endif // WEBP_YUV_USE_TABLE
70
50 #if defined(__cplusplus) || defined(c_plusplus) 71 #if defined(__cplusplus) || defined(c_plusplus)
51 } // extern "C" 72 } // extern "C"
52 #endif 73 #endif
OLDNEW
« no previous file with comments | « third_party/libwebp/dsp/yuv.h ('k') | third_party/libwebp/enc/alpha.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698