initial release of jp3d library and codec
[openjpeg.git] / libjp3dvm / raw.h
1 /*\r
2  * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe\r
3  * Copyright (c) 2005, Herv� Drolon, FreeImage Team\r
4  * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium\r
5  * All rights reserved.\r
6  *\r
7  * Redistribution and use in source and binary forms, with or without\r
8  * modification, are permitted provided that the following conditions\r
9  * are met:\r
10  * 1. Redistributions of source code must retain the above copyright\r
11  *    notice, this list of conditions and the following disclaimer.\r
12  * 2. Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'\r
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
26  * POSSIBILITY OF SUCH DAMAGE.\r
27  */\r
28 \r
29 #ifndef __RAW_H\r
30 #define __RAW_H\r
31 /**\r
32 @file raw.h\r
33 @brief Implementation of operations for raw encoding (RAW)\r
34 \r
35 The functions in RAW.C have for goal to realize the operation of raw encoding linked\r
36 with the corresponding mode switch.\r
37 */\r
38 \r
39 /** @defgroup RAW RAW - Implementation of operations for raw encoding */\r
40 /*@{*/\r
41 \r
42 /**\r
43 RAW encoding operations\r
44 */\r
45 typedef struct opj_raw {\r
46 /** Temporary buffer where bits are coded or decoded */\r
47         unsigned char c;                \r
48 /** Number of bits already read or free to write */\r
49         unsigned int ct;                \r
50 /** Maximum length to decode */\r
51         unsigned int lenmax;    \r
52 /** Length decoded */\r
53         unsigned int len;               \r
54 /** Pointer to the current position in the buffer */\r
55         unsigned char *bp;              \r
56 /** Pointer to the start of the buffer */\r
57         unsigned char *start;   \r
58 /** Pointer to the end of the buffer */\r
59         unsigned char *end;             \r
60 } opj_raw_t;\r
61 \r
62 /** @name Funciones generales */\r
63 /*@{*/\r
64 /* ----------------------------------------------------------------------- */\r
65 /**\r
66 Create a new RAW handle \r
67 @return Returns a new RAW handle if successful, returns NULL otherwise\r
68 */\r
69 opj_raw_t* raw_create();\r
70 /**\r
71 Destroy a previously created RAW handle\r
72 @param raw RAW handle to destroy\r
73 */\r
74 void raw_destroy(opj_raw_t *raw);\r
75 /**\r
76 Return the number of bytes written/read since initialisation\r
77 @param raw RAW handle to destroy\r
78 @return Returns the number of bytes already encoded\r
79 */\r
80 int raw_numbytes(opj_raw_t *raw);\r
81 /**\r
82 Initialize the decoder\r
83 @param raw RAW handle\r
84 @param bp Pointer to the start of the buffer from which the bytes will be read\r
85 @param len Length of the input buffer\r
86 */\r
87 void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len);\r
88 /**\r
89 Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN\r
90 @param raw RAW handle\r
91 @return Returns the decoded symbol (0 or 1)\r
92 */\r
93 int raw_decode(opj_raw_t *raw);\r
94 /* ----------------------------------------------------------------------- */\r
95 /*@}*/\r
96 \r
97 /*@}*/\r
98 \r
99 #endif /* __RAW_H */\r