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

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