cio.h
Go to the documentation of this file.
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
* Copyright (c) 2012, CS Systemes d'Information, France
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_CIO_H
#define OPJ_CIO_H
#include "opj_config_private.h"
/* ----------------------------------------------------------------------- */
#if defined(OPJ_BIG_ENDIAN)
#define opj_write_bytes opj_write_bytes_BE
#define opj_read_bytes opj_read_bytes_BE
#define opj_write_double opj_write_double_BE
#define opj_read_double opj_read_double_BE
#define opj_write_float opj_write_float_BE
#define opj_read_float opj_read_float_BE
#else
#define opj_write_bytes opj_write_bytes_LE
#define opj_read_bytes opj_read_bytes_LE
#define opj_write_double opj_write_double_LE
#define opj_read_double opj_read_double_LE
#define opj_write_float opj_write_float_LE
#define opj_read_float opj_read_float_LE
#endif
#define OPJ_STREAM_STATUS_OUTPUT 0x1U
#define OPJ_STREAM_STATUS_INPUT 0x2U
#define OPJ_STREAM_STATUS_END 0x4U
#define OPJ_STREAM_STATUS_ERROR 0x8U
typedef struct opj_stream_private {
void * m_user_data;
opj_stream_free_user_data_fn m_free_user_data_fn;
OPJ_UINT64 m_user_data_length;
opj_stream_read_fn m_read_fn;
opj_stream_write_fn m_write_fn;
opj_stream_skip_fn m_skip_fn;
opj_stream_seek_fn m_seek_fn;
OPJ_BYTE * m_stored_data;
OPJ_BYTE * m_current_data;
OPJ_OFF_T(* m_opj_skip)(struct opj_stream_private *, OPJ_OFF_T,
struct opj_event_mgr *);
OPJ_BOOL(* m_opj_seek)(struct opj_stream_private *, OPJ_OFF_T,
struct opj_event_mgr *);
OPJ_SIZE_T m_bytes_in_buffer;
OPJ_OFF_T m_byte_offset;
OPJ_SIZE_T m_buffer_size;
OPJ_UINT32 m_status;
}
opj_stream_private_t;
/* ----------------------------------------------------------------------- */
void opj_write_bytes_BE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value,
OPJ_UINT32 p_nb_bytes);
void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value,
OPJ_UINT32 p_nb_bytes);
void opj_write_bytes_LE(OPJ_BYTE * p_buffer, OPJ_UINT32 p_value,
OPJ_UINT32 p_nb_bytes);
void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value,
OPJ_UINT32 p_nb_bytes);
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 Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
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 Big Endian cpus.
* @param p_buffer pointer the data buffer to write data to.
* @param p_value the value to write
*/
void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
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);
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);
OPJ_BOOL opj_stream_flush(opj_stream_private_t * p_stream,
struct opj_event_mgr * p_event_mgr);
OPJ_OFF_T opj_stream_skip(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
struct opj_event_mgr * p_event_mgr);
OPJ_OFF_T opj_stream_tell(const opj_stream_private_t * p_stream);
OPJ_OFF_T opj_stream_get_number_byte_left(const opj_stream_private_t *
p_stream);
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);
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);
OPJ_BOOL opj_stream_read_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
struct opj_event_mgr * p_event_mgr);
OPJ_BOOL opj_stream_write_seek(opj_stream_private_t * p_stream,
OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
OPJ_BOOL opj_stream_seek(opj_stream_private_t * p_stream, OPJ_OFF_T p_size,
struct opj_event_mgr * p_event_mgr);
OPJ_BOOL opj_stream_has_seek(const opj_stream_private_t * p_stream);
OPJ_SIZE_T opj_stream_default_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
void * p_user_data);
OPJ_SIZE_T opj_stream_default_write(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
void * p_user_data);
OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void * p_user_data);
OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void * p_user_data);
/* ----------------------------------------------------------------------- */
#endif /* OPJ_CIO_H */
opj_read_float_LE
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
opj_stream_read_skip
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
opj_write_bytes_LE
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_stream_flush
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
opj_stream_default_skip
OPJ_OFF_T opj_stream_default_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition cio.c:671
opj_write_float_BE
void opj_write_float_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT32 p_value)
Definition cio.c:127
opj_stream_default_seek
OPJ_BOOL opj_stream_default_seek(OPJ_OFF_T p_nb_bytes, void *p_user_data)
FIXME DOC.
Definition cio.c:678
opj_stream_tell
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_stream_read_data
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_stream_default_write
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
opj_stream_read_seek
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_stream_private_t
struct opj_stream_private opj_stream_private_t
Byte input-output stream.
opj_stream_skip
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
opj_stream_write_data
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
opj_stream_seek
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_stream_write_skip
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_read_bytes_BE
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
opj_stream_write_seek
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_write_bytes_BE
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_write_float_LE
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_write_double_LE
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_stream_default_read
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_read_double_LE
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_write_double_BE
void opj_write_double_BE(OPJ_BYTE *p_buffer, OPJ_FLOAT64 p_value)
Definition cio.c:96
opj_read_float_BE
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_stream_has_seek
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_stream_get_number_byte_left
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_read_bytes_LE
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
opj_read_double_BE
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
opj_stream_free_user_data_fn
void(* opj_stream_free_user_data_fn)(void *p_user_data)
Definition openjpeg.h:665
OPJ_BYTE
unsigned char OPJ_BYTE
Definition openjpeg.h:123
opj_stream_seek_fn
OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes, void *p_user_data)
Definition openjpeg.h:659
OPJ_FLOAT64
double OPJ_FLOAT64
Definition openjpeg.h:122
OPJ_UINT32
uint32_t OPJ_UINT32
Definition openjpeg.h:132
opj_stream_write_fn
OPJ_SIZE_T(* opj_stream_write_fn)(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
Definition openjpeg.h:647
OPJ_FLOAT32
float OPJ_FLOAT32
Definition openjpeg.h:121
OPJ_OFF_T
int64_t OPJ_OFF_T
Definition openjpeg.h:136
opj_stream_read_fn
OPJ_SIZE_T(* opj_stream_read_fn)(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
Definition openjpeg.h:641
OPJ_SIZE_T
size_t OPJ_SIZE_T
Definition openjpeg.h:139
OPJ_BOOL
int OPJ_BOOL
Definition openjpeg.h:116
OPJ_UINT64
uint64_t OPJ_UINT64
Definition openjpeg.h:134
opj_stream_skip_fn
OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes, void *p_user_data)
Definition openjpeg.h:653
opj_event_mgr
Message handler object used for.
Definition event.h:50
opj_stream_private
Byte input-output stream.
Definition cio.h:81
opj_stream_private::m_free_user_data_fn
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_stream_private::m_opj_skip
OPJ_OFF_T(* m_opj_skip)(struct opj_stream_private *, OPJ_OFF_T, struct opj_event_mgr *)
FIXME DOC.
Definition cio.h:134
opj_stream_private::m_skip_fn
opj_stream_skip_fn m_skip_fn
Pointer to actual skip function (NULL at the initialization of the cio.
Definition cio.h:113
opj_stream_private::m_user_data
void * m_user_data
User data, be it files, ... The actual data depends on the type of the stream.
Definition cio.h:85
opj_stream_private::m_user_data_length
OPJ_UINT64 m_user_data_length
User data length.
Definition cio.h:97
opj_stream_private::m_byte_offset
OPJ_OFF_T m_byte_offset
The number of bytes read/written from the beginning of the stream.
Definition cio.h:151
opj_stream_private::m_opj_seek
OPJ_BOOL(* m_opj_seek)(struct opj_stream_private *, OPJ_OFF_T, struct opj_event_mgr *)
FIXME DOC.
Definition cio.h:140
opj_stream_private::m_buffer_size
OPJ_SIZE_T m_buffer_size
The size of the buffer.
Definition cio.h:156
opj_stream_private::m_bytes_in_buffer
OPJ_SIZE_T m_bytes_in_buffer
number of bytes containing in the buffer.
Definition cio.h:146
opj_stream_private::m_current_data
OPJ_BYTE * m_current_data
Pointer to the current read data.
Definition cio.h:129
opj_stream_private::m_write_fn
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_private::m_status
OPJ_UINT32 m_status
Flags to tell the status of the stream.
Definition cio.h:162
opj_stream_private::m_stored_data
OPJ_BYTE * m_stored_data
Actual data stored into the stream if read from.
Definition cio.h:124
opj_stream_private::m_read_fn
opj_stream_read_fn m_read_fn
Pointer to actual read function (NULL at the initialization of the cio.
Definition cio.h:102
opj_stream_private::m_seek_fn
opj_stream_seek_fn m_seek_fn
Pointer to actual seek function (if available).
Definition cio.h:118