1 /*---------------------------------------------------------------------------*
2   Project:     compress/uncompress library
3   File:        CXCompression.h
4 
5   Copyright 2005 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: CXCompression.h,v $
14   Revision 1.5  07/06/2006 09:19:14  takano_makoto
15   Changed the include guard to the REVOLUTION_SDK format
16 
17   Revision 1.4  07/05/2006 11:14:34  takano_makoto
18   Changed MI_LZ_COMPRESS_WORK_SIZE to CX_LZ_COMPRESS_WORK_SIZE
19   revised the include guard
20 
21   Revision 1.3  07/04/2006 13:19:40  takano_makoto
22   changed LZ compressed to a high-speed version using the work buffer
23 
24   Revision 1.2  07/04/2006 08:25:25  takano_makoto
25   changed the prefix from the DS version
26 
27   $NoKeywords: $
28  *---------------------------------------------------------------------------*/
29 
30 
31 #ifndef __CX_COMPRESS_H__
32 #define __CX_COMPRESS_H__
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include <dolphin/types.h>
39 
40 
41 #define CX_LZ_COMPRESS_WORK_SIZE   ( (4096 + 256 + 256) * sizeof(s16) )
42 
43 /*---------------------------------------------------------------------------*
44   Name:         CXCompressLZ
45 
46   Description:  Function that performs LZ77 compression
47 
48   Arguments:    srcp            Pointer to compression source data
49                 size            Size of compression source data
50                 dstp            Pointer to destination for compressed data
51                                 Buffer must be larger than size of compression source data.
52                 work            Temporary buffer for comprerssion
53                                 A region for the size of  CX_LZ_COMPRESS_WORK_SIZE is necessary.
54 
55   Returns:      The data size after compression.
56                 If compressed data is larger than original data, compression is terminated and 0 gets returned.
57  *---------------------------------------------------------------------------*/
58 u32 CXCompressLZ( const u8 *srcp, u32 size, u8 *dstp, void* work );
59 
60 
61 /*---------------------------------------------------------------------------*
62   Name:         CXCompressRL
63 
64   Description:  Function that performs runlength compression
65 
66   Arguments:    srcp            Pointer to compression source data
67                 size            Size of compression source data
68                 dstp            Pointer to destination for compressed data
69                                 Buffer must be larger than size of compression source data.
70 
71   Returns:      The data size after compression.
72                 If compressed data is larger than original data, compression is terminated and 0 gets returned.
73  *---------------------------------------------------------------------------*/
74 u32 CXCompressRL( const u8 *srcp, u32 size, u8 *dstp );
75 
76 
77 #define CX_HUFFMAN_COMPRESS_WORK_SIZE   ( 12288 + 512 + 1536 )
78 
79 
80 /*---------------------------------------------------------------------------*
81   Name:         CXCompressHuffman
82 
83   Description:  Function that performs Huffman compression
84 
85   Arguments:    srcp            Pointer to compression source data
86                 size            Size of compression source data
87                 dstp            Pointer to destination for compressed data
88                                 Buffer must be larger than size of compression source data.
89                 huffBitSize    The number of bits to encode
90                 work           The work buffer for compression which requires the size of CX_HUFFMAN_COMPRESS_WORK_SIZE.
91 
92   Returns:      The data size after compression.
93                 If compressed data is larger than original data, compression is terminated and 0 gets returned.
94  *---------------------------------------------------------------------------*/
95 u32 CXCompressHuffman( const u8 *srcp, u32 size, u8 *dstp, u8 huffBitSize, void *work );
96 
97 
98 #ifdef __cplusplus
99 } /* extern "C"*/
100 #endif
101 
102 /* __CX_COMPRESS_H__*/
103 #endif
104