Debian Codegraph @

support/hqx/init.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2010 Cameron Zemek ( [email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include <stdint.h>
20 #include "hqx.h"
21
22 uint32_t RGBtoYUV[16777216];
23 uint32_t YUV1, YUV2;
24
25 HQX_API void HQX_CALLCONV hqxInit(void)
26 {
27 /* Initalize RGB to YUV lookup table */
28 uint32_t c, r, g, b, y, u, v;
29 for (c = 0; c < 16777216; c++) {
30 r = (c & 0xFF0000) >> 16;
31 g = (c & 0x00FF00) >> 8;
32 b = c & 0x0000FF;
33 y = (uint32_t)(0.299*r + 0.587*g + 0.114*b);
34 u = (uint32_t)(-0.169*r - 0.331*g + 0.5*b) + 128;
35 v = (uint32_t)(0.5*r - 0.419*g - 0.081*b) + 128;
36 RGBtoYUV[c] = (y << 16) + (u << 8) + v;
37 }
38 }