OpenJPEG  2.1.2
cio.h
Go to the documentation of this file.
1 /*
2  * The copyright in this software is being made available under the 2-clauses
3  * BSD License, included below. This software may be subject to other third
4  * party and contributor rights, including patent rights, and no such rights
5  * are granted under this license.
6  *
7  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8  * Copyright (c) 2002-2014, Professor Benoit Macq
9  * Copyright (c) 2001-2003, David Janssens
10  * Copyright (c) 2002-2003, Yannick Verschueren
11  * Copyright (c) 2003-2007, Francois-Olivier Devaux
12  * Copyright (c) 2003-2014, Antonin Descampe
13  * Copyright (c) 2005, Herve Drolon, FreeImage Team
14  * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
15  * Copyright (c) 2012, CS Systemes d'Information, France
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions
20  * are met:
21  * 1. Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  * 2. Redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 #ifndef __CIO_H
41 #define __CIO_H
42 
51 
52 #include "opj_config_private.h"
53 
54 /* ----------------------------------------------------------------------- */
55 
56 #if defined(OPJ_BIG_ENDIAN)
57  #define opj_write_bytes opj_write_bytes_BE
58  #define opj_read_bytes opj_read_bytes_BE
59  #define opj_write_double opj_write_double_BE
60  #define opj_read_double opj_read_double_BE
61  #define opj_write_float opj_write_float_BE
62  #define opj_read_float opj_read_float_BE
63 #else
64  #define opj_write_bytes opj_write_bytes_LE
65  #define opj_read_bytes opj_read_bytes_LE
66  #define opj_write_double opj_write_double_LE
67  #define opj_read_double opj_read_double_LE
68  #define opj_write_float opj_write_float_LE
69  #define opj_read_float opj_read_float_LE
70 #endif
71 
72 
73 #define OPJ_STREAM_STATUS_OUTPUT 0x1U
74 #define OPJ_STREAM_STATUS_INPUT 0x2U
75 #define OPJ_STREAM_STATUS_END 0x4U
76 #define OPJ_STREAM_STATUS_ERROR 0x8U
77 
81 typedef struct opj_stream_private
82 {
86  void * m_user_data;
87 
94 
99 
104 
109 
115 
120 
126 
131 
136 
141 
146 
150  OPJ_OFF_T m_byte_offset;
151 
156 
162 
163 }
165 
168 /* ----------------------------------------------------------------------- */
175 void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
176 
184 void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
185 
193 void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
194 
202 void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
203 
204 
210 void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
211 
212 /***
213  * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
214  * @param p_buffer pointer the data buffer to write data to.
215  * @param p_value the value to write
216  */
217 void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
218 
224 void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
225 
231 void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
232 
238 void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
239 
245 void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
246 
252 void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
253 
254 /***
255  * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
256  * @param p_buffer pointer the data buffer to write data to.
257  * @param p_value the value to write
258  */
259 void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
260 
269 OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
270 
279 OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr);
280 
287 OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
288 
296 OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
297 
306 
307 
316 
324 OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
325 
333 OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
334 
342 OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
343 
351 OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
352 
360 OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
361 
366 
370 OPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
371 
375 OPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
376 
380 OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data);
381 
385 OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data);
386 
387 /* ----------------------------------------------------------------------- */
391 
392 
393 #endif /* __CIO_H */
394 
void * m_user_data
User data, be it files, ...
Definition: cio.h:86
OPJ_OFF_T opj_stream_tell(const opj_stream_private_t *p_stream)
Tells the byte offset on the stream (similar to ftell).
Definition: cio.c:544
OPJ_SIZE_T opj_stream_read_data(opj_stream_private_t *p_stream, OPJ_BYTE *p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr *p_event_mgr)
Reads some bytes from the stream.
Definition: cio.c:266
int64_t OPJ_OFF_T
Definition: openjpeg.h:130
OPJ_OFF_T(* m_opj_skip)(struct opj_stream_private *, OPJ_OFF_T, struct opj_event_mgr *)
FIXME DOC.
Definition: cio.h:135
opj_stream_write_fn m_write_fn
Pointer to actual write function (NULL at the initialization of the cio.
Definition: cio.h:108
OPJ_SIZE_T opj_stream_write_data(opj_stream_private_t *p_stream, const OPJ_BYTE *p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr *p_event_mgr)
Writes some bytes to the stream.
Definition: cio.c:373
struct opj_stream_private opj_stream_private_t
Byte input-output stream.
double OPJ_FLOAT64
Definition: openjpeg.h:116
OPJ_BOOL opj_stream_read_seek(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, struct opj_event_mgr *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:564
OPJ_BOOL(* m_opj_seek)(struct opj_stream_private *, OPJ_OFF_T, struct opj_event_mgr *)
FIXME DOC.
Definition: cio.h:140
Message handler object used for.
Definition: event.h:50
void opj_read_float_LE(const OPJ_BYTE *p_buffer, OPJ_FLOAT32 *p_value)
Reads some bytes from the given data buffer, this function is used in Little Endian cpus...
Definition: cio.c:142
int OPJ_BOOL
Definition: openjpeg.h:110
OPJ_SIZE_T m_buffer_size
The size of the buffer.
Definition: cio.h:155
opj_stream_free_user_data_fn m_free_user_data_fn
Pointer to function to free m_user_data (NULL at initialization) when destroying the stream...
Definition: cio.h:93
Byte input-output stream.
Definition: cio.h:81
unsigned char OPJ_BYTE
Definition: openjpeg.h:117
OPJ_OFF_T opj_stream_read_skip(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, struct opj_event_mgr *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:450
OPJ_SIZE_T opj_stream_default_write(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:624
OPJ_BOOL opj_stream_seek(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, struct opj_event_mgr *p_event_mgr)
Seeks a number of bytes from the stream.
Definition: cio.c:605
OPJ_UINT32 m_status
Flags to tell the status of the stream.
Definition: cio.h:161
OPJ_OFF_T opj_stream_write_skip(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, struct opj_event_mgr *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:504
size_t OPJ_SIZE_T
Definition: openjpeg.h:133
OPJ_BOOL opj_stream_write_seek(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, struct opj_event_mgr *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:584
uint64_t OPJ_UINT64
Definition: openjpeg.h:128
void opj_read_bytes_LE(const OPJ_BYTE *p_buffer, OPJ_UINT32 *p_value, OPJ_UINT32 p_nb_bytes)
Reads some bytes from the given data buffer, this function is used in Little Endian cpus...
Definition: cio.c:78
OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:639
float OPJ_FLOAT32
Definition: openjpeg.h:115
opj_stream_skip_fn m_skip_fn
Pointer to actual skip function (NULL at the initialization of the cio.
Definition: cio.h:114
void opj_write_float_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT32 p_value)
Definition: cio.c:121
OPJ_SIZE_T(* opj_stream_write_fn)(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:598
opj_stream_read_fn m_read_fn
Pointer to actual read function (NULL at the initialization of the cio.
Definition: cio.h:103
OPJ_OFF_T opj_stream_skip(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, struct opj_event_mgr *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:558
OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:632
void opj_read_double_BE(const OPJ_BYTE *p_buffer, OPJ_FLOAT64 *p_value)
Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
Definition: cio.c:106
void opj_write_float_LE(OPJ_BYTE *p_buffer, OPJ_FLOAT32 p_value)
Write some bytes to the given data buffer, this function is used in Little Endian cpus...
Definition: cio.c:127
void(* opj_stream_free_user_data_fn)(void *p_user_data)
Definition: openjpeg.h:613
OPJ_SIZE_T m_bytes_in_buffer
number of bytes containing in the buffer.
Definition: cio.h:145
void opj_read_bytes_BE(const OPJ_BYTE *p_buffer, OPJ_UINT32 *p_value, OPJ_UINT32 p_nb_bytes)
Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
Definition: cio.c:68
OPJ_BOOL opj_stream_flush(opj_stream_private_t *p_stream, struct opj_event_mgr *p_event_mgr)
Writes the content of the stream buffer to the stream.
Definition: cio.c:421
OPJ_OFF_T m_byte_offset
The number of bytes read/written from the beginning of the stream.
Definition: cio.h:150
OPJ_BYTE * m_stored_data
Actual data stored into the stream if readed from.
Definition: cio.h:125
OPJ_UINT64 m_user_data_length
User data length.
Definition: cio.h:98
OPJ_SIZE_T opj_stream_default_read(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:616
void opj_read_float_BE(const OPJ_BYTE *p_buffer, OPJ_FLOAT32 *p_value)
Reads some bytes from the given data buffer, this function is used in Big Endian cpus.
Definition: cio.c:136
void opj_write_double_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT64 p_value)
Definition: cio.c:91
uint32_t OPJ_UINT32
Definition: openjpeg.h:126
OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t *p_stream)
Tells if the given stream is seekable.
Definition: cio.c:611
OPJ_SIZE_T(* opj_stream_read_fn)(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:593
void opj_write_bytes_LE(OPJ_BYTE *p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
Write some bytes to the given data buffer, this function is used in Little Endian cpus...
Definition: cio.c:56
OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:603
OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:608
void opj_read_double_LE(const OPJ_BYTE *p_buffer, OPJ_FLOAT64 *p_value)
Reads some bytes from the given data buffer, this function is used in Little Endian cpus...
Definition: cio.c:112
void opj_write_double_LE(OPJ_BYTE *p_buffer, OPJ_FLOAT64 p_value)
Write some bytes to the given data buffer, this function is used in Little Endian cpus...
Definition: cio.c:97
OPJ_OFF_T opj_stream_get_number_byte_left(const opj_stream_private_t *p_stream)
Get the number of bytes left before the end of the stream (similar to cio_numbytesleft).
Definition: cio.c:549
void opj_write_bytes_BE(OPJ_BYTE *p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes)
Write some bytes to the given data buffer, this function is used in Big Endian cpus.
Definition: cio.c:47
opj_stream_seek_fn m_seek_fn
Pointer to actual seek function (if available).
Definition: cio.h:119
OPJ_BYTE * m_current_data
Pointer to the current read data.
Definition: cio.h:130