source: trunk/src/testing/app/qshare/FastDXT/dxt.h @ 4

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

Added modified SAGE sources

Line 
1/******************************************************************************
2 * Fast DXT - a realtime DXT compression tool
3 *
4 * Author : Luc Renambot
5 *
6 * Copyright (C) 2007 Electronic Visualization Laboratory,
7 * University of Illinois at Chicago
8 *
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 *  * Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 *  * Redistributions in binary form must reproduce the above
17 *    copyright notice, this list of conditions and the following disclaimer
18 *    in the documentation and/or other materials provided with the distribution.
19 *  * Neither the name of the University of Illinois at Chicago nor
20 *    the names of its contributors may be used to endorse or promote
21 *    products derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
36 *
37 *****************************************************************************/
38
39// From:
40//    Real-Time DXT Compression
41//    May 20th 2006 J.M.P. van Waveren
42//    (c) 2006, Id Software, Inc.
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <string.h>
47#include <string.h>
48#include <math.h>
49
50typedef unsigned char byte;
51typedef unsigned short word;
52typedef unsigned int dword;
53
54#define C565_5_MASK 0xF8 // 0xFF minus last three bits
55#define C565_6_MASK 0xFC // 0xFF minus last two bits
56
57#define INSET_SHIFT 4 // inset the bounding box with ( range >> shift )
58
59#if !defined(MAX_INT)
60#define       MAX_INT         2147483647      /* max value for an int 32 */
61#define       MIN_INT         (-2147483647-1) /* min value for an int 32 */
62#endif
63
64
65#if defined(__GNUC__)
66#define   ALIGN16(_x)   _x __attribute((aligned(16)))
67#else
68#define   ALIGN16( x ) __declspec(align(16)) x
69#endif
70
71
72// Compress to DXT1 format
73void CompressImageDXT1( const byte *inBuf, byte *outBuf, int width, int height, int &outputBytes );
74
75// Compress to DXT5 format
76void CompressImageDXT5( const byte *inBuf, byte *outBuf, int width, int height, int &outputBytes );
77
78// Compress to DXT5 format, first convert to YCoCg color space
79void CompressImageDXT5YCoCg( const byte *inBuf, byte *outBuf, int width, int height, int &outputBytes );
80
81// Compute error between two images
82double ComputeError( const byte *original, const byte *dxt, int width, int height);
Note: See TracBrowser for help on using the repository browser.