1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: cx_StreamingUncompression.h
4
5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. 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 $Revision: 36999 $
14 *---------------------------------------------------------------------------*/
15
16 #ifndef NN_CX_STREAMING_UNCOMPRESSION_H_
17 #define NN_CX_STREAMING_UNCOMPRESSION_H_
18
19 #include <nn/types.h>
20 #include <nn/assert.h>
21
22 namespace nn {
23 namespace cx {
24
25 /* Please see man pages for details
26
27 */
28 struct UncompContextRL
29 {
30 u8 *destp; //
31 s32 destCount; //
32 s32 forceDestCount; //
33 u16 length; //
34 u8 flags; //
35 u8 headerSize; //
36 };
37
38
39 /* Please see man pages for details
40
41 */
42 struct UncompContextLZ
43 {
44 u8 *destp; //
45 s32 destCount; //
46 s32 forceDestCount; //
47 s32 length; //
48 u8 lengthFlg; //
49 u8 flags; //
50 u8 flagIndex; //
51 u8 headerSize; //
52 u8 exFormat; //
53 NN_PADDING3;
54 };
55
56
57 /* Please see man pages for details
58
59 */
60 struct UncompContextHuffman
61 {
62 u8 *destp; //
63 s32 destCount; //
64 s32 forceDestCount; //
65 u8 *treep; //
66 u32 srcTmp; //
67 u32 destTmp; //
68 s16 treeSize; //
69 u8 srcTmpCnt; //
70 u8 destTmpCnt; //
71 u8 bitSize; //
72 u8 headerSize; //
73 NN_PADDING2;
74 u8 tree[0x200]; //
75 };
76
77
78 /* Please see man pages for details
79
80 */
81 struct UncompContextLH
82 {
83 u8 *destp; //
84 s32 destCount; //
85 s32 forceDestCount; //
86 u16 huffTable9 [ 1 << (9 + 1) ]; //
87 u16 huffTable12[ 1 << (5 + 1) ]; //
88 u16 *nodep; //
89 s32 tableSize9; //
90 s32 tableSize12; //
91 u32 tableIdx; //
92 u32 stream; //
93 u32 stream_len; //
94 u16 length; //
95 s8 offset_bits; //
96 u8 headerSize; //
97 };
98
99
100 /* Please see man pages for details
101
102 */
103 struct UncompContextLRC
104 {
105 u8 *destp; //
106 s32 destCount; //
107 s32 forceDestCount; //
108 u32 freq9 [ 1 << 9 ]; //
109 u32 low_cnt9 [ 1 << 9 ]; //
110 u32 freq12 [ 1 << 12 ]; //
111 u32 low_cnt12[ 1 << 12 ]; //
112 u32 total9; //
113 u32 total12; //
114 u32 range; //
115 u32 code; //
116 u32 low; //
117 u32 carry_cnt; //
118 u8 carry; //
119 u8 codeLen; //
120 u16 length; //
121 u8 headerSize; //
122 NN_PADDING3;
123 };
124
125 /* Please see man pages for details
126
127
128 */
129
130 /* Please see man pages for details
131
132
133
134 */
135 void InitUncompContextRL( UncompContextRL *context, void *dest );
136
137
138 /* Please see man pages for details
139
140
141
142
143
144
145 */
146 void InitUncompContextLZ( UncompContextLZ *context, void *dest );
147
148
149 /* Please see man pages for details
150
151
152
153 */
154 void InitUncompContextHuffman( UncompContextHuffman *context,
155 void *dest );
156
157 /* Please see man pages for details
158
159
160
161 */
162 void InitUncompContextLH( UncompContextLH * context, void* dest );
163
164
165 /* Please see man pages for details
166
167
168
169 */
170 void InitUncompContextLRC( UncompContextLRC * context, void* dest );
171
172
173 /* Please see man pages for details
174
175
176
177
178
179 */
180 s32 ReadUncompRL( UncompContextRL *context, const void *data, u32 len );
181
182
183 /* Please see man pages for details
184
185
186
187
188
189
190
191
192 */
193 s32 ReadUncompLZ( UncompContextLZ *context, const void *data, u32 len );
194
195
196 /* Please see man pages for details
197
198
199
200
201
202 */
203 s32 ReadUncompHuffman( UncompContextHuffman *context, const void *data, u32 len );
204
205
206 /* Please see man pages for details
207
208
209
210
211
212 */
213 s32 ReadUncompLH( UncompContextLH *context, const void* data, u32 len );
214
215
216 /* Please see man pages for details
217
218
219
220
221
222 */
223 s32 ReadUncompLRC( UncompContextLRC *context, const void* data, u32 len );
224
225
226 /* Please see man pages for details
227
228
229
230
231 */
232 template <typename UncompContext>
IsFinishedUncomp(const UncompContext * context)233 inline bool IsFinishedUncomp( const UncompContext *context )
234 {
235 NN_NULL_TASSERT_(context);
236 return (context->destCount > 0 || context->headerSize > 0)? false : true;
237 }
238
239 /* Please see man pages for details
240
241
242 */
243 template <typename UncompContext>
IsFinishedUncompRL(const UncompContext * context)244 inline bool IsFinishedUncompRL( const UncompContext *context ) NN_ATTRIBUTE_DEPRECATED
245 {
246 NN_NULL_TASSERT_(context);
247 return (context->destCount > 0 || context->headerSize > 0)? false : true;
248 }
249
250
251 /* Please see man pages for details
252
253
254
255
256
257 */
InitUncompContextRLFront(UncompContextRL * context,void * dest,s32 destSize)258 inline void InitUncompContextRLFront( UncompContextRL *context, void *dest, s32 destSize )
259 {
260 NN_ASSERT( destSize > 0 );
261 InitUncompContextRL( context, dest );
262 context->forceDestCount = destSize;
263 }
264
265
266 /* Please see man pages for details
267
268
269
270
271
272
273
274
275 */
InitUncompContextLZFront(UncompContextLZ * context,void * dest,s32 destSize)276 inline void InitUncompContextLZFront( UncompContextLZ *context, void *dest, s32 destSize )
277 {
278 NN_ASSERT( destSize > 0 );
279 InitUncompContextLZ( context, dest );
280 context->forceDestCount = destSize;
281 }
282
283
284 /* Please see man pages for details
285
286
287
288
289
290 */
InitUncompContextHuffmanFront(UncompContextHuffman * context,void * dest,s32 destSize)291 inline void InitUncompContextHuffmanFront( UncompContextHuffman *context, void *dest, s32 destSize )
292 {
293 NN_ASSERT( destSize > 0 );
294 InitUncompContextHuffman( context, dest );
295 context->forceDestCount = destSize;
296 }
297
298
299 /* Please see man pages for details
300
301
302
303
304
305 */
InitUncompContextLHFront(UncompContextLH * context,void * dest,s32 destSize)306 inline void InitUncompContextLHFront( UncompContextLH *context, void *dest, s32 destSize )
307 {
308 NN_ASSERT( destSize > 0 );
309 InitUncompContextLH( context, dest );
310 context->forceDestCount = destSize;
311 }
312
313
314 /* Please see man pages for details
315
316
317
318
319
320 */
InitUncompContextLRCFront(UncompContextLRC * context,void * dest,s32 destSize)321 inline void InitUncompContextLRCFront( UncompContextLRC *context, void *dest, s32 destSize )
322 {
323 NN_ASSERT( destSize > 0 );
324 InitUncompContextLRC( context, dest );
325 context->forceDestCount = destSize;
326 }
327
328 /*
329
330 */
331
332 } // namespace cx
333 } // namespace nn
334
335 /* NN_CX_STREAMING_UNCOMPRESSION_H_ */
336 #endif
337