1ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* 2ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * The copyright in this software is being made available under the 2-clauses 3ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * BSD License, included below. This software may be subject to other third 4ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * party and contributor rights, including patent rights, and no such rights 5ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * are granted under this license. 6ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 7ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium 8ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2002-2014, Professor Benoit Macq 9ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2001-2003, David Janssens 10ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2002-2003, Yannick Verschueren 11ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2003-2007, Francois-Olivier Devaux 12ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2003-2014, Antonin Descampe 13ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2005, Herve Drolon, FreeImage Team 14ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 15ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2012, CS Systemes d'Information, France 16ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * All rights reserved. 17ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 18ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Redistribution and use in source and binary forms, with or without 19ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * modification, are permitted provided that the following conditions 20ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * are met: 21ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 1. Redistributions of source code must retain the above copyright 22ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * notice, this list of conditions and the following disclaimer. 23ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 2. Redistributions in binary form must reproduce the above copyright 24ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * notice, this list of conditions and the following disclaimer in the 25ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * documentation and/or other materials provided with the distribution. 26ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 27ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' 28ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 31ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * POSSIBILITY OF SUCH DAMAGE. 38ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 39ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 40ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef __CIO_H 41ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define __CIO_H 42ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 43ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@file cio.h 44ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@brief Implementation of a byte input-output process (CIO) 45ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 46ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovThe functions in CIO.C have for goal to realize a byte input / output process. 47ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/ 48ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 49ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** @defgroup CIO CIO - byte input-output stream */ 50ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@{*/ 51ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 52ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include "opj_config.h" 53ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 54ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* ----------------------------------------------------------------------- */ 55ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 56ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if defined(OPJ_BIG_ENDIAN) 57ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_write_bytes opj_write_bytes_BE 58ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_read_bytes opj_read_bytes_BE 59ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_write_double opj_write_double_BE 60ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_read_double opj_read_double_BE 61ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_write_float opj_write_float_BE 62ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_read_float opj_read_float_BE 63ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else 64ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_write_bytes opj_write_bytes_LE 65ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_read_bytes opj_read_bytes_LE 66ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_write_double opj_write_double_LE 67ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_read_double opj_read_double_LE 68ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_write_float opj_write_float_LE 69ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov #define opj_read_float opj_read_float_LE 70ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif 71ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 72ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 73ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 74ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum 75ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov{ 76ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_signed_sentinel = -1, /* do not use in code */ 77ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_e_output = 0x1, 78ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_e_input = 0x2, 79ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_e_end = 0x4, 80ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_e_error = 0x8 81ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} 82ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovopj_stream_flag ; 83ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 84ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 85ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovByte input-output stream. 86ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/ 87ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct opj_stream_private 88ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov{ 89ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 90ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * User data, be it files, ... The actual data depends on the type of the stream. 91ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 92ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov void * m_user_data; 93ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 94ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 95ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Pointer to function to free m_user_data (NULL at initialization) 96ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * when destroying the stream. If pointer is NULL the function is not 97ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * called and the m_user_data is not freed (even if non-NULL). 98ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 99ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_free_user_data_fn m_free_user_data_fn; 100ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 101ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 102ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * User data length 103ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 104ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_UINT64 m_user_data_length; 105ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 106ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 107ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Pointer to actual read function (NULL at the initialization of the cio. 108ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 109ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_read_fn m_read_fn; 110ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 111ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 112ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Pointer to actual write function (NULL at the initialization of the cio. 113ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 114ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_write_fn m_write_fn; 115ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 116ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 117ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Pointer to actual skip function (NULL at the initialization of the cio. 118ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * There is no seek function to prevent from back and forth slow procedures. 119ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 120ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_skip_fn m_skip_fn; 121ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 122ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 123ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Pointer to actual seek function (if available). 124ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 125ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_seek_fn m_seek_fn; 126ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 127ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 128ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Actual data stored into the stream if readed from. Data is read by chunk of fixed size. 129ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * you should never access this data directly. 130ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 131ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_BYTE * m_stored_data; 132ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 133ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 134ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Pointer to the current read data. 135ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 136ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_BYTE * m_current_data; 137ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 138ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 139ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * FIXME DOC. 140ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 141ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *); 142ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 143ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 144ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * FIXME DOC. 145ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 146ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *); 147ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 148ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 149ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * number of bytes containing in the buffer. 150ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 151ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_SIZE_T m_bytes_in_buffer; 152ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 153ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 154ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * The number of bytes read/written from the beginning of the stream 155ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 156ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_OFF_T m_byte_offset; 157ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 158ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 159ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * The size of the buffer. 160ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 161ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov OPJ_SIZE_T m_buffer_size; 162ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 163ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /** 164ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Flags to tell the status of the stream. 165ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 166ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov opj_stream_flag m_status; 167ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 168ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} 169ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovopj_stream_private_t; 170ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 171ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** @name Exported functions (see also openjpeg.h) */ 172ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@{*/ 173ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* ----------------------------------------------------------------------- */ 174ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 175ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Write some bytes to the given data buffer, this function is used in Big Endian cpus. 176ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to write data to. 177ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value the value to write 178ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_nb_bytes the number of bytes to write 179ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/ 180ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes); 181ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 182ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 183ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the given data buffer, this function is used in Big Endian cpus. 184ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to read data from. 185ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value pointer to the value that will store the data. 186ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_nb_bytes the nb bytes to read. 187ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes read or -1 if an error occured. 188ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 189ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes); 190ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 191ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 192ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Write some bytes to the given data buffer, this function is used in Little Endian cpus. 193ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to write data to. 194ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value the value to write 195ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_nb_bytes the number of bytes to write 196ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes written or -1 if an error occured 197ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/ 198ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes); 199ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 200ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 201ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the given data buffer, this function is used in Little Endian cpus. 202ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to read data from. 203ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value pointer to the value that will store the data. 204ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_nb_bytes the nb bytes to read. 205ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes read or -1 if an error occured. 206ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 207ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes); 208ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 209ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 210ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 211ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Write some bytes to the given data buffer, this function is used in Little Endian cpus. 212ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to write data to. 213ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value the value to write 214ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 215ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value); 216ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 217ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*** 218ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Write some bytes to the given data buffer, this function is used in Big Endian cpus. 219ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to write data to. 220ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value the value to write 221ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 222ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value); 223ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 224ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 225ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the given data buffer, this function is used in Little Endian cpus. 226ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to read data from. 227ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value pointer to the value that will store the data. 228ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 229ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value); 230ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 231ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 232ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the given data buffer, this function is used in Big Endian cpus. 233ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to read data from. 234ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value pointer to the value that will store the data. 235ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 236ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value); 237ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 238ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 239ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the given data buffer, this function is used in Little Endian cpus. 240ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to read data from. 241ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value pointer to the value that will store the data. 242ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 243ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value); 244ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 245ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 246ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the given data buffer, this function is used in Big Endian cpus. 247ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to read data from. 248ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value pointer to the value that will store the data. 249ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 250ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value); 251ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 252ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 253ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Write some bytes to the given data buffer, this function is used in Little Endian cpus. 254ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to write data to. 255ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value the value to write 256ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 257ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value); 258ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 259ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*** 260ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Write some bytes to the given data buffer, this function is used in Big Endian cpus. 261ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer the data buffer to write data to. 262ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_value the value to write 263ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 264ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value); 265ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 266ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 267ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Reads some bytes from the stream. 268ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to read data from. 269ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer to the data buffer that will receive the data. 270ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size number of bytes to read. 271ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 272ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes read, or -1 if an error occured or if the stream is at the end. 273ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 274ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_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); 275ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 276ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 277ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Writes some bytes to the stream. 278ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to write data to. 279ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_buffer pointer to the data buffer holds the data to be writtent. 280ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size number of bytes to write. 281ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 282ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes writtent, or -1 if an error occured. 283ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 284ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_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); 285ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 286ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 287ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Writes the content of the stream buffer to the stream. 288ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to write data to. 289ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 290ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return true if the data could be flushed, false else. 291ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 292ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr); 293ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 294ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 295ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Skips a number of bytes from the stream. 296ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to skip data from. 297ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size the number of bytes to skip. 298ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 299ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes skipped, or -1 if an error occured. 300ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 301ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); 302ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 303ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 304ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Tells the byte offset on the stream (similar to ftell). 305ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 306ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to get the information from. 307ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 308ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the current position o fthe stream. 309ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 310ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_OFF_T opj_stream_tell (const opj_stream_private_t * p_stream); 311ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 312ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 313ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 314ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Get the number of bytes left before the end of the stream (similar to cio_numbytesleft). 315ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 316ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to get the information from. 317ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 318ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return Number of bytes left before the end of the stream. 319ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 320ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream); 321ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 322ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 323ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Skips a number of bytes from the stream. 324ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to skip data from. 325ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size the number of bytes to skip. 326ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 327ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes skipped, or -1 if an error occured. 328ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 329ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); 330ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 331ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 332ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Skips a number of bytes from the stream. 333ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to skip data from. 334ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size the number of bytes to skip. 335ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 336ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes skipped, or -1 if an error occured. 337ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 338ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); 339ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 340ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 341ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Skips a number of bytes from the stream. 342ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to skip data from. 343ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size the number of bytes to skip. 344ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 345ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return OPJ_TRUE if success, or OPJ_FALSE if an error occured. 346ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 347ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); 348ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 349ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 350ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Skips a number of bytes from the stream. 351ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to skip data from. 352ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size the number of bytes to skip. 353ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 354ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return the number of bytes skipped, or -1 if an error occured. 355ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 356ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); 357ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 358ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 359ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Seeks a number of bytes from the stream. 360ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_stream the stream to skip data from. 361ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_size the number of bytes to skip. 362ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @param p_event_mgr the user event manager to be notified of special events. 363ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * @return true if the stream is seekable. 364ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 365ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); 366ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 367ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 368ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Tells if the given stream is seekable. 369ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 370ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream); 371ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 372ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 373ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * FIXME DOC. 374ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 375ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data); 376ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 377ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 378ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * FIXME DOC. 379ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 380ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data); 381ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 382ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 383ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * FIXME DOC. 384ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 385ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data); 386ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 387ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** 388ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * FIXME DOC. 389ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 390ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data); 391ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 392ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* ----------------------------------------------------------------------- */ 393ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@}*/ 394ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 395ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@}*/ 396ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 397ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 398ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif /* __CIO_H */ 399ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 400