source: svn/newcon3bcm2_21bu/dst/dlib/src/si/DLIB_BitOp.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 8.4 KB
Line 
1/**
2        @file
3                DLIB_BitOp.h
4
5        @brief
6                PHOENIX HAL library
7
8                bitbuf, memchain, huffman
9
10        Copyright 2006~2010 Digital STREAM Technology, Inc.
11        All Rights Reserved
12*/
13
14
15#ifndef __DLIB_BITOP_H__
16#define __DLIB_BITOP_H__
17
18
19#include "DHL_OSAL.h"
20
21
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28
29#if COMMENT
30____Overview____(){}
31#endif
32
33/**
34        @file DLIB_BitOp.h
35       
36        À̰÷¿¡ ÀÌ ¸ðµâ¿¡ ´ëÇØ ¼³¸íÀÌ ÇÊ¿äÇÑ °¢Á¾ ³»¿ë ±â¼ú..
37       
38        module overview
39                - bitbuf
40                - memchain
41                - huffman
42
43        APIs
44       
45*/
46
47
48#if COMMENT
49____Config____(){}
50#endif
51
52/*
53        ÀÌ ºÎºÐÀº º°µµÀÇ DHL_XXX_Config configuration file À»
54        Ȱ¿ëÇÏ´Â °ÍÀÌ ÁÁÀ» °Í °°À½.
55*/
56
57
58#if COMMENT
59____Types____(){}
60#endif
61
62/*
63        ´Ù¸¥ ¸ðµâµé°ú °øÀ¯ µÇ´Â structure ¹× enumerations.
64*/
65
66
67#if COMMENT
68____Defines____(){}
69#endif
70
71
72
73
74
75#if COMMENT
76____BitBuf____(){}
77#endif
78
79
80struct bitBuffer {
81        UINT8*  buffer;
82        UINT32  bufSize;
83        UINT32  bitOffset;
84        BOOLEAN overrunError;
85};
86
87typedef struct bitBuffer bitBuffer_t, *bitBufferPtr_t;
88
89/** @brief
90                Creates a bitBuffer object from the specified byte buffer.
91                After creation, the bitBufferGetBits() function can be called to extract bits.
92
93        @param[out] instance bitBuffer instance passed back to caller.
94        @param[in] buffer pointer to a byte buffer.
95        @param[in] bufSize size of the buffer (in bytes).
96
97        @return
98                - DHL_FAIL_OUT_OF_MEMOERY: out of memory.
99                - DHL_OK: success.
100*/
101DHL_RESULT bitBufferCreate (bitBufferPtr_t *instance, UINT8 *buffer, UINT32 bufSize);
102
103
104/** @brief
105                Destroys the bitBuffer. DOES NOT free the buffer passed by the user in the
106                function bitBufferCreate()!!
107
108        @param[in] instance bitBuffer instance.
109
110        @return
111                - DHL_FAIL_NULL_POINTER: the instance is NULL.
112                - DHL_OK: success.
113*/
114DHL_RESULT bitBufferDestroy (bitBufferPtr_t instance);
115
116
117/** @brief             
118                Extracts the specified number of bits from the bitBuffer.  The number of
119                bits must be less than or equal to 32.  If more bits are requested than
120                are present in the bitBuffer, the overrunError flag is set.
121               
122        @param[in] instance bitBuffer instance.
123        @param[in] numberOfBits the number of bits to be read from bitBuffer.
124
125        @return
126                Extracted the specified number of bits.
127*/
128UINT32 bitBufferGetBits (bitBufferPtr_t instance, UINT8 numberOfBits);
129
130
131/** @brief
132                Skips the specified number of bits in the bitBuffer.  This operation is
133                faster than extracting bits and can be used when a bit field is ignored.
134
135        @param[in] instance bitBuffer instance.
136        @param[in] numberOfBits the number of bits to be skipped.
137*/
138void bitBufferSkipBits (bitBufferPtr_t instance, UINT16 numberOfBits);
139
140
141/** @brief
142                Returns a pointer to the current byte offset.
143
144        @param[in] instance bitBuffer instance.
145
146        @return
147                a pointer to the current byte offset.
148*/
149UINT8* bitBufferGetBytePointer (bitBufferPtr_t instance);
150
151
152/** @brief
153                Returns 'TRUE' if the bitBuffer is in an overrun error state.
154
155        @param[in]  instance bitBuffer instance.
156
157        @return
158                an overrun error state of the bitBuffer.
159*/
160BOOLEAN bitBufferCheckError (bitBufferPtr_t instance);
161
162
163/** @brief
164                Initializes the bitBuffer.      After initialization, the bitBufferGetBits() function can
165                be called to extract bits.
166
167        @param[in] instance bitBuffer instance.
168        @param[in] buffer pointer to a byte buffer.
169        @param[in] bufSize size of the buffer (in bytes).
170*/
171void bitBufferInitialize(bitBufferPtr_t instance, UINT8 *buffer, UINT32 bufSize);
172
173
174
175#if COMMENT
176____Memchain____(){}
177#endif
178
179/**     user-defined malloc */
180typedef void* (*myMalloc_f) (unsigned size, const char *_file, unsigned _line);
181/**     user-defined free */
182typedef void (*myFree_f) (void *ppblock, const char *_file, unsigned _line);
183
184/** memChain Setup Info */
185typedef struct memChainSetup {
186        UINT32          memLimit;
187        myMalloc_f              Malloc;
188        myFree_f                Free;
189} memChainSetup_t, *memChainSetupPtr_t;
190
191typedef struct memChainHead* memId_t;
192
193/** memChain Status Info */
194typedef struct memChainStatus {
195        UINT32          memLimit;
196        UINT32          totalElements;
197        UINT32          totalBytes;
198        UINT32          totalUserBytes; 
199} memChainStatus_t, *memChainStatusPtr_t;
200
201
202#if DHL_OS_USE_HEAP_DEBUG
203
204/**
205        @brief
206                Creates a memChain object which links related memory into a 'chain'. 
207                All     memory associated with this chain can then be easily freed.             
208
209        @param[out] memId memId of the newly created memchain.
210        @param[in] setupPtr Pointer to the memChainSetup information.
211
212        @return
213                - DHL_FAIL_INVALID_PARAM: memId or setupPtr is NULL.
214                - DHL_FAIL_OUT_OF_MEMORY: out of memory.
215                - DHL_OK: success.
216*/
217DHL_RESULT memChainCreateDbg (memId_t *memId, memChainSetupPtr_t setupPtr, const char *_file, unsigned _line);
218
219
220/**
221        @brief
222                Destroys the memChain, freeing all associated memory.
223
224        @param[in] memId memId of the memchain.
225
226        @return
227                -DHL_OK: success
228*/
229DHL_RESULT memChainDestroyDbg (memId_t memId, const char *_file, unsigned _line);
230
231
232/**
233        @brief
234                Allocates a memory block of the requested size and associates it with the
235                specified memChain.  Returns NULL if the OS_Calloc() fails or if memLimit
236                will be exceeded.
237
238        @param[in] memId Memory ID of the memchain.
239        @param[in] size The size of the requested memory chunk.
240
241        @return
242                Pointer to the allocated memory block.
243*/
244void *memChainAllocDbg (memId_t memId, UINT32 size, const char *_file, unsigned _line);
245
246#define memChainCreate(memId, setupPtr) memChainCreateDbg(memId, setupPtr, __FILE__, __LINE__)
247#define memChainDestroy(memId) memChainDestroyDbg(memId, __FILE__, __LINE__)
248#define memChainAlloc(memId, size) memChainAllocDbg(memId, size, __FILE__, __LINE__)
249
250#else
251
252
253/**
254        @brief
255                Creates a memChain object which links related memory into a 'chain'. 
256                All     memory associated with this chain can then be easily freed.             
257
258        @param[out] memId memId of the newly created memchain.
259        @param[in] setupPtr Pointer to the memChainSetup information.
260
261        @return
262                - DHL_FAIL_INVALID_PARAM: memId or setupPtr is NULL.
263                - DHL_FAIL_OUT_OF_MEMORY: out of memory.
264                - DHL_OK: success.
265*/
266DHL_RESULT memChainCreate (memId_t *memId, memChainSetupPtr_t setupPtr);
267
268
269/**
270        @brief
271                Destroys the memChain, freeing all associated memory.
272
273        @param[in] memId memId of the memchain.
274
275        @return
276                -DHL_OK: success
277*/
278DHL_RESULT memChainDestroy (memId_t memId);
279
280
281/**
282        @brief
283                Allocates a memory block of the requested size and associates it with the
284                specified memChain.  Returns NULL if the OS_Calloc() fails or if memLimit
285                will be exceeded.
286
287        @param[in] memId memId of the memchain.
288        @param[in] size The size of the requested memory chunk.
289
290        @return
291                Pointer to the allocated memory block.
292*/
293void* memChainAlloc (memId_t memId, UINT32 size);
294
295#endif
296
297/**
298        @brief
299                Returns memChainStatus..
300               
301        @param[in] memId memId of the memchain.
302        @param[out] pStatus Pointer to the memChainStatus
303
304        @return
305                - DHL_FAIL_INVALID_HANDLE: memId is invalid.
306                - DHL_FAIL_INVALID_PARAM: pStatus is NULL.
307                - DHL_OK: success.
308*/
309DHL_RESULT memChainStatus (memId_t memId, memChainStatus_t *pStatus);
310
311
312
313#if COMMENT
314____Huffman____(){}
315#endif
316
317/** Multiple String Structure */
318typedef enum {
319        cm_None                 = 0x00,
320        cm_Huffman_C4C5         = 0x01,
321        cm_Huffman_C6C7         = 0x02
322} compress_type_k;
323
324/**
325        @brief
326                The DecodeHuffmanString() function is used to decode a Huffman-compressed string
327                found in the Multiple String Structure.  The Huffman coding supports both types
328                as defined in the PSIP A/65 document (Title and Description type strings).  The
329                compression type using to encode the string (as specified in the Multiple String
330                Structure) should be passed to this function.
331
332                The text buffer is supplied by the caller of this function.  The length of the
333                buffer is specified by the 'textlen' parameter.  A decompressed string that is
334                shorter than 'textlen' is terminated with a null character.  A decompressed
335                string that is longer than 'textlen' is truncated to 'textlen-1' and terminated
336                with a null character. 
337               
338        @param[in] compressedStr Huffman-compressed string.     
339        @param[in] length The length of the compressed string.
340        @param[in] type compress_type.
341        @param[out] text Decompressed string.
342        @param[in] textlen The length of the decompressed string.
343
344        @return
345                -DHL_OK: success.
346*/
347DHL_RESULT DecodeHuffmanString (UINT8 *compressedStr, UINT32 length, compress_type_k type,
348                                                        char *text, UINT32 textlen);
349
350
351#ifdef __cplusplus
352} /* extern "C" */
353#endif
354
355
356
357#endif  /* __DLIB_BITOP_H__ */
358
359
Note: See TracBrowser for help on using the repository browser.