source: trunk/src/testing/app/hd-video-player/YuvToRGB.h @ 4

Revision 4, 3.5 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Copyright (C) 2004 Electronic Visualization Laboratory,
5 * University of Illinois at Chicago
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above
15 *    copyright notice, this list of conditions and the following disclaimer
16 *    in the documentation and/or other materials provided with the distribution.
17 *  * Neither the name of the University of Illinois at Chicago nor
18 *    the names of its contributors may be used to endorse or promote
19 *    products derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
34 *
35 *****************************************************************************/
36
37#ifndef _YUVTORGB_
38#define _YUVTORGB_
39
40#define PTW32_STATIC_LIB 1
41#include <pthread.h>
42
43
44
45#include <windows.h>
46#include <stdio.h>
47
48#define LOG_INT         0
49#define LOG_STR         1
50
51class CYUVTable
52{
53public :
54        // Static methods
55        static BYTE GetY(const BYTE p_nR, const BYTE p_nG, const BYTE p_nB)
56        {
57                int y = (int)(0.299 * p_nR + 0.587 * p_nG + 0.114 * p_nB);
58                return max(0, min(y, 255));
59        };
60        static BYTE GetU(const BYTE p_nR, const BYTE p_nG, const BYTE p_nB)
61        {
62                int u = (int)(-0.169 * p_nR - 0.311 * p_nG + 0.500 * p_nB) + 128;
63                return max(0, min(u, 255));
64        };
65        static BYTE GetV(const BYTE p_nR, const BYTE p_nG, const BYTE p_nB)
66        {
67                int v = (int)(0.500 * p_nR - 0.419 * p_nG - 0.081 * p_nB) + 128;
68                return max(0, min(v, 255));
69        };
70
71//              pbRGB[i*3] = Y+0.956U+0.621V
72//              pbRGB[i*3+1] = Y+0.272U+0.647V
73//              pbRGB[i*3+2] = Y+1.1061U+1.703V
74
75        static BYTE GetR(const int p_nY, const int p_nU, const int p_nV)
76        {
77                int r = (int)(p_nY - 0.001 * (p_nU - 128) + 1.402 * (p_nV - 128));
78                return max(0, min(r, 255));
79        };
80        static BYTE GetG(const int p_nY, const int p_nU, const int p_nV)
81        {
82                int g = (int)(p_nY - 0.344 * (p_nU - 128) - 0.714 * (p_nV - 128));
83                return max(0, min(g, 255));
84        };
85        static BYTE GetB(const int p_nY, const int p_nU, const int p_nV)
86        {
87                int b = (int)(p_nY + 1.772 * (p_nU - 128) + 0.001 * (p_nV - 128));
88                return max(0, min(b, 255));
89        };
90};
91
92void YUV422UYVY_ToRGB24(unsigned char* pbYUV, unsigned char* pbRGB, DWORD yuv_len);
93
94void SaveToBmp(char *Path, unsigned char* img_buff, int width, int height, int bitcount);
95
96void SaveToLog(void* string, int type);
97
98#endif
Note: See TracBrowser for help on using the repository browser.