project64/Source/Project64-video/TextureEnhancer/TxUtil.h

108 lines
3.6 KiB
C
Raw Normal View History

2017-04-26 10:23:36 +00:00
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2007 Hiroshi Morii *
* Copyright (C) 2003 Rice1964 *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
2013-04-17 10:30:38 +00:00
#ifndef __TXUTIL_H__
#define __TXUTIL_H__
/* maximum number of CPU cores allowed */
#define MAX_NUMCORE 8
#include "TxInternal.h"
#include <string>
#ifdef __cplusplus
2017-04-26 10:23:36 +00:00
extern "C" {
2013-04-17 10:30:38 +00:00
#endif
2017-04-26 10:23:36 +00:00
void tx_compress_dxtn(int srccomps, int width, int height,
const void *source, int destformat, void *dest,
int destRowStride);
2013-04-17 10:30:38 +00:00
2017-04-26 10:23:36 +00:00
int fxt1_encode(int width, int height, int comps,
const void *source, int srcRowStride,
void *dest, int destRowStride);
2013-04-17 10:30:38 +00:00
#ifdef __cplusplus
}
#endif
2017-04-26 10:23:36 +00:00
typedef void(*dxtCompressTexFuncExt)(int srccomps, int width,
int height, const void *srcPixData,
int destformat, void *dest,
int dstRowStride);
2013-04-17 10:30:38 +00:00
2017-04-26 10:23:36 +00:00
typedef int(*fxtCompressTexFuncExt)(int width, int height, int comps,
const void *source, int srcRowStride,
void *dest, int destRowStride);
2013-04-17 10:30:38 +00:00
class TxLoadLib
{
private:
2017-04-26 10:23:36 +00:00
fxtCompressTexFuncExt _tx_compress_fxt1;
dxtCompressTexFuncExt _tx_compress_dxtn;
TxLoadLib();
2013-04-17 10:30:38 +00:00
public:
2017-04-26 10:23:36 +00:00
static TxLoadLib* getInstance() {
static TxLoadLib txLoadLib;
return &txLoadLib;
}
~TxLoadLib();
fxtCompressTexFuncExt getfxtCompressTexFuncExt();
dxtCompressTexFuncExt getdxtCompressTexFuncExt();
2013-04-17 10:30:38 +00:00
};
class TxUtil
{
private:
2017-04-26 10:23:36 +00:00
uint32 Adler32(const uint8* data, int Len, uint32 Adler);
uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride);
uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride);
bool RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax);
bool RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax);
int log2(int num);
2013-04-17 10:30:38 +00:00
public:
2017-04-26 10:23:36 +00:00
TxUtil() { }
~TxUtil() { }
int sizeofTx(int width, int height, uint16 format);
uint32 checksumTx(uint8 *data, int width, int height, uint16 format);
2013-04-17 10:30:38 +00:00
#if 0 /* unused */
2017-04-26 10:23:36 +00:00
uint32 chkAlpha(uint32* src, int width, int height);
2013-04-17 10:30:38 +00:00
#endif
2017-04-26 10:23:36 +00:00
uint32 checksum(uint8 *src, int width, int height, int size, int rowStride);
uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);
int grLodLog2(int w, int h);
int grAspectRatioLog2(int w, int h);
int getNumberofProcessors();
2013-04-17 10:30:38 +00:00
};
class TxMemBuf
{
private:
2017-04-26 10:23:36 +00:00
uint8 *_tex[2];
uint32 _size[2];
TxMemBuf();
2013-04-17 10:30:38 +00:00
public:
2017-04-26 10:23:36 +00:00
static TxMemBuf* getInstance() {
static TxMemBuf txMemBuf;
return &txMemBuf;
}
~TxMemBuf();
bool init(int maxwidth, int maxheight);
void shutdown(void);
uint8 *get(unsigned int num);
uint32 size_of(unsigned int num);
2013-04-17 10:30:38 +00:00
};
#endif /* __TXUTIL_H__ */