Go to the documentation of this file.
52 #include "opj_config_private.h"
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
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
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
OPJ_OFF_T opj_stream_write_skip(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, opj_event_mgr_t *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:538
opj_stream_skip_fn m_skip_fn
Pointer to actual skip function (NULL at the initialization of the cio.
Definition: cio.h:113
OPJ_SIZE_T(* opj_stream_read_fn)(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:637
unsigned char OPJ_BYTE
Definition: openjpeg.h:123
OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:671
float OPJ_FLOAT32
Definition: openjpeg.h:121
OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:678
void opj_write_float_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT32 p_value)
Definition: cio.c:127
struct opj_stream_private opj_stream_private_t
Byte input-output stream.
OPJ_SIZE_T opj_stream_write_data(opj_stream_private_t *p_stream, const OPJ_BYTE *p_buffer, OPJ_SIZE_T p_size, opj_event_mgr_t *p_event_mgr)
Writes some bytes to the stream.
Definition: cio.c:385
void * opj_calloc(size_t num, size_t size)
Allocate a memory block with elements initialized to 0.
Definition: opj_malloc.c:198
OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:655
OPJ_OFF_T(* m_opj_skip)(struct opj_stream_private *, OPJ_OFF_T, struct opj_event_mgr *)
FIXME DOC.
Definition: cio.h:134
void * m_user_data
User data, be it files, ...
Definition: cio.h:85
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:58
OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t *p_stream)
Tells if the given stream is seekable.
Definition: cio.c:648
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:579
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:281
OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:678
opj_stream_t *OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, OPJ_BOOL l_is_input)
Creates an abstract stream.
Definition: cio.c:158
OPJ_BOOL opj_event_msg(opj_event_mgr_t *p_event_mgr, OPJ_INT32 event_type, const char *fmt,...)
Write formatted data to a string and send the string to a user callback.
Definition: event.c:91
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:584
#define OPJ_ARG_NOT_USED(x)
Definition: openjpeg.h:142
OPJ_OFF_T m_byte_offset
The number of bytes read/written from the beginning of the stream.
Definition: cio.h:151
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:385
void(* opj_stream_free_user_data_fn)(void *p_user_data)
Definition: openjpeg.h:661
int64_t OPJ_OFF_T
Definition: openjpeg.h:136
OPJ_OFF_T opj_stream_skip(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, opj_event_mgr_t *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:593
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:641
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_stream_t
Definition: openjpeg.h:666
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:579
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:112
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_UINT64 m_user_data_length
User data length.
Definition: cio.h:97
OPJ_BYTE * m_stored_data
Actual data stored into the stream if read from.
Definition: cio.h:124
#define OPJ_STREAM_STATUS_INPUT
Definition: cio.h:74
Byte input-output stream.
Definition: cio.h:81
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:662
double OPJ_FLOAT64
Definition: openjpeg.h:122
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:662
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:118
OPJ_BYTE * m_current_data
Pointer to the current read data.
Definition: cio.h:129
int OPJ_BOOL
Definition: openjpeg.h:116
size_t OPJ_SIZE_T
Definition: openjpeg.h:139
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
void OPJ_CALLCONV opj_stream_set_user_data_length(opj_stream_t *p_stream, OPJ_UINT64 data_length)
Sets the length of the user data for the stream.
Definition: cio.c:271
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:82
void opj_write_double_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT64 p_value)
Definition: cio.c:96
OPJ_BOOL opj_stream_flush(opj_stream_private_t *p_stream, opj_event_mgr_t *p_event_mgr)
Writes the content of the stream buffer to the stream.
Definition: cio.c:433
#define OPJ_STREAM_STATUS_OUTPUT
Definition: cio.h:73
opj_stream_read_fn m_read_fn
Pointer to actual read function (NULL at the initialization of the cio.
Definition: cio.h:102
uint64_t OPJ_UINT64
Definition: openjpeg.h:134
OPJ_BOOL opj_stream_write_seek(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, opj_event_mgr_t *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:620
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:463
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:118
opj_stream_seek_fn m_seek_fn
Pointer to actual seek function (if available).
Definition: cio.h:118
#define OPJ_TRUE
Definition: openjpeg.h:117
void opj_write_double_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT64 p_value)
Definition: cio.c:96
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:149
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:143
void * opj_malloc(size_t size)
Allocate an uninitialized memory block.
Definition: opj_malloc.c:191
#define OPJ_STREAM_STATUS_ERROR
Definition: cio.h:76
OPJ_BOOL opj_stream_read_seek(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, opj_event_mgr_t *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:600
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:71
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:112
void opj_free(void *ptr)
Deallocates or frees a memory block.
Definition: opj_malloc.c:246
OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition: cio.c:671
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:143
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:538
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:620
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:641
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:71
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:133
OPJ_UINT32 m_status
Flags to tell the status of the stream.
Definition: cio.h:162
#define EVT_INFO
Debug event type.
Definition: event.h:68
void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t *p_stream, opj_stream_write_fn p_function)
Sets the given function to be used as a write function.
Definition: cio.c:236
void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t *p_stream, opj_stream_read_fn p_function)
Sets the given function to be used as a read function.
Definition: cio.c:213
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:149
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:58
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:584
OPJ_SIZE_T m_bytes_in_buffer
number of bytes containing in the buffer.
Definition: cio.h:146
OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:649
#define OPJ_STREAM_STATUS_END
Definition: cio.h:75
uint32_t OPJ_UINT32
Definition: openjpeg.h:132
void OPJ_CALLCONV opj_stream_destroy(opj_stream_t *p_stream)
Destroys a stream created by opj_create_stream.
Definition: cio.c:199
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:102
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:133
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:82
#define OPJ_J2K_STREAM_CHUNK_SIZE
Definition: openjpeg.h:156
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:653
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:92
OPJ_SIZE_T(* opj_stream_write_fn)(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
Definition: openjpeg.h:643
#define OPJ_FALSE
Definition: openjpeg.h:118
OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t *p_stream)
Tells if the given stream is seekable.
Definition: cio.c:648
void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t *p_stream, opj_stream_seek_fn p_function)
Sets the given function to be used as a seek function, the stream is then seekable,...
Definition: cio.c:225
OPJ_OFF_T opj_stream_read_skip(opj_stream_private_t *p_stream, OPJ_OFF_T p_size, opj_event_mgr_t *p_event_mgr)
Skips a number of bytes from the stream.
Definition: cio.c:463
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:433
#define OPJ_CALLCONV
Definition: openjpeg.h:98
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:593
void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t *p_stream, void *p_data, opj_stream_free_user_data_fn p_function)
Sets the given data to be used as a user data for the stream.
Definition: cio.c:260
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:102
OPJ_SIZE_T m_buffer_size
The size of the buffer.
Definition: cio.h:156
OPJ_SIZE_T opj_stream_read_data(opj_stream_private_t *p_stream, OPJ_BYTE *p_buffer, OPJ_SIZE_T p_size, opj_event_mgr_t *p_event_mgr)
Reads some bytes from the stream.
Definition: cio.c:281
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:600
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:653
void opj_write_float_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT32 p_value)
Definition: cio.c:127
opj_stream_write_fn m_write_fn
Pointer to actual write function (NULL at the initialization of the cio.
Definition: cio.h:107
opj_stream_t *OPJ_CALLCONV opj_stream_default_create(OPJ_BOOL l_is_input)
Creates an abstract stream.
Definition: cio.c:194
void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t *p_stream, opj_stream_skip_fn p_function)
Sets the given function to be used as a skip function.
Definition: cio.c:248