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

Side by Side Diff: third_party/libwebp/yuv.h

Issue 3614010: Add WebP library to Chromium... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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/webp/decode_vp8.h ('k') | third_party/libwebp/yuv.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // inline YUV->RGB conversion function
9 //
10 // Author: Skal (pascal.massimino@gmail.com)
11
12 #ifndef WEBP_DECODE_YUV_H_
13 #define WEBP_DECODE_YUV_H_
14
15 #include "webp/decode_vp8.h"
16
17 #if defined(__cplusplus) || defined(c_plusplus)
18 extern "C" {
19 #endif
20
21 enum { YUV_FIX = 16, // fixed-point precision
22 YUV_RANGE_MIN = -227, // min value of r/g/b output
23 YUV_RANGE_MAX = 256 + 226 // max value of r/g/b output
24 };
25 extern int16_t VP8kVToR[256], VP8kUToB[256];
26 extern int32_t VP8kVToG[256], VP8kUToG[256];
27 extern uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN];
28
29 inline static void VP8YuvToRgb(uint8_t y, uint8_t u, uint8_t v,
30 uint8_t* const rgb) {
31 const int r_off = VP8kVToR[v];
32 const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
33 const int b_off = VP8kUToB[u];
34 rgb[0] = VP8kClip[y + r_off - YUV_RANGE_MIN];
35 rgb[1] = VP8kClip[y + g_off - YUV_RANGE_MIN];
36 rgb[2] = VP8kClip[y + b_off - YUV_RANGE_MIN];
37 }
38
39 inline static void VP8YuvToRgba(int y, int u, int v, uint8_t* const rgba) {
40 VP8YuvToRgb(y, u, v, rgba);
41 rgba[3] = 0xff;
42 }
43
44 inline static void VP8YuvToBgr(uint8_t y, uint8_t u, uint8_t v,
45 uint8_t* const bgr) {
46 const int r_off = VP8kVToR[v];
47 const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
48 const int b_off = VP8kUToB[u];
49 bgr[0] = VP8kClip[y + b_off - YUV_RANGE_MIN];
50 bgr[1] = VP8kClip[y + g_off - YUV_RANGE_MIN];
51 bgr[2] = VP8kClip[y + r_off - YUV_RANGE_MIN];
52 }
53
54 inline static void VP8YuvToBgra(int y, int u, int v, uint8_t* const bgra) {
55 VP8YuvToBgr(y, u, v, bgra);
56 bgra[3] = 0xff;
57 }
58
59 // Must be called before everything, to initialize the tables.
60 void VP8YUVInit();
61
62 #if defined(__cplusplus) || defined(c_plusplus)
63 } // extern "C"
64 #endif
65
66 #endif // WEBP_DECODE_YUV_H_
OLDNEW
« no previous file with comments | « third_party/libwebp/webp/decode_vp8.h ('k') | third_party/libwebp/yuv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698