2 * Copyright (c) 2001-2003, David Janssens
\r
3 * Copyright (c) 2002-2003, Yannick Verschueren
\r
4 * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
\r
5 * Copyright (c) 2005, Hervé Drolon, FreeImage Team
\r
6 * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
\r
7 * All rights reserved.
\r
9 * Redistribution and use in source and binary forms, with or without
\r
10 * modification, are permitted provided that the following conditions
\r
12 * 1. Redistributions of source code must retain the above copyright
\r
13 * notice, this list of conditions and the following disclaimer.
\r
14 * 2. Redistributions in binary form must reproduce the above copyright
\r
15 * notice, this list of conditions and the following disclaimer in the
\r
16 * documentation and/or other materials provided with the distribution.
\r
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
\r
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
28 * POSSIBILITY OF SUCH DAMAGE.
\r
35 @brief Implementation of an individual bit input-output (BIO)
\r
37 The functions in BIO.C have for goal to realize an individual bit input - output.
\r
40 /** @defgroup BIO BIO - Individual bit input-output stream */
\r
44 Individual bit input-output stream (BIO)
\r
46 typedef struct opj_bio {
\r
47 /** pointer to the start of the buffer */
\r
48 unsigned char *start;
\r
49 /** pointer to the end of the buffer */
\r
51 /** pointer to the present position in the buffer */
\r
53 /** temporary place where each byte is read or written */
\r
55 /** coder : number of bits free to write. decoder : number of bits read */
\r
59 /** @name Exported functions */
\r
61 /* ----------------------------------------------------------------------- */
\r
63 Create a new BIO handle
\r
64 @return Returns a new BIO handle if successful, returns NULL otherwise
\r
66 opj_bio_t* bio_create();
\r
68 Destroy a previously created BIO handle
\r
69 @param bio BIO handle to destroy
\r
71 void bio_destroy(opj_bio_t *bio);
\r
73 Number of bytes written.
\r
74 @param bio BIO handle
\r
75 @return Returns the number of bytes written
\r
77 int bio_numbytes(opj_bio_t *bio);
\r
80 @param bio BIO handle
\r
81 @param bp Output buffer
\r
82 @param len Output buffer length
\r
84 void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len);
\r
87 @param bio BIO handle
\r
88 @param bp Input buffer
\r
89 @param len Input buffer length
\r
91 void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len);
\r
94 @param bio BIO handle
\r
95 @param v Value of bits
\r
96 @param n Number of bits to write
\r
98 void bio_write(opj_bio_t *bio, int v, int n);
\r
101 @param bio BIO handle
\r
102 @param n Number of bits to read
\r
103 @return Returns the corresponding read number
\r
105 int bio_read(opj_bio_t *bio, int n);
\r
108 @param bio BIO handle
\r
109 @return Returns 1 if successful, returns 0 otherwise
\r
111 int bio_flush(opj_bio_t *bio);
\r
113 Passes the ending bits (coming from flushing)
\r
114 @param bio BIO handle
\r
115 @return Returns 1 if successful, returns 0 otherwise
\r
117 int bio_inalign(opj_bio_t *bio);
\r
118 /* ----------------------------------------------------------------------- */
\r
123 #endif /* __BIO_H */
\r