OpenJPEG 2.1.0

cio.h

Go to the documentation of this file.
00001 /*
00002  * The copyright in this software is being made available under the 2-clauses 
00003  * BSD License, included below. This software may be subject to other third 
00004  * party and contributor rights, including patent rights, and no such rights
00005  * are granted under this license.
00006  *
00007  * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
00008  * Copyright (c) 2002-2014, Professor Benoit Macq
00009  * Copyright (c) 2001-2003, David Janssens
00010  * Copyright (c) 2002-2003, Yannick Verschueren
00011  * Copyright (c) 2003-2007, Francois-Olivier Devaux 
00012  * Copyright (c) 2003-2014, Antonin Descampe
00013  * Copyright (c) 2005, Herve Drolon, FreeImage Team
00014  * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR 
00015  * Copyright (c) 2012, CS Systemes d'Information, France
00016  * All rights reserved.
00017  *
00018  * Redistribution and use in source and binary forms, with or without
00019  * modification, are permitted provided that the following conditions
00020  * are met:
00021  * 1. Redistributions of source code must retain the above copyright
00022  *    notice, this list of conditions and the following disclaimer.
00023  * 2. Redistributions in binary form must reproduce the above copyright
00024  *    notice, this list of conditions and the following disclaimer in the
00025  *    documentation and/or other materials provided with the distribution.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  */
00039 
00040 #ifndef __CIO_H
00041 #define __CIO_H
00042 
00051 
00052 #include "opj_config_private.h"
00053 
00054 /* ----------------------------------------------------------------------- */
00055 
00056 #if defined(OPJ_BIG_ENDIAN)
00057         #define opj_write_bytes         opj_write_bytes_BE
00058         #define opj_read_bytes          opj_read_bytes_BE
00059         #define opj_write_double        opj_write_double_BE
00060         #define opj_read_double         opj_read_double_BE
00061         #define opj_write_float         opj_write_float_BE
00062         #define opj_read_float          opj_read_float_BE
00063 #else
00064         #define opj_write_bytes         opj_write_bytes_LE
00065         #define opj_read_bytes          opj_read_bytes_LE
00066         #define opj_write_double        opj_write_double_LE
00067         #define opj_read_double         opj_read_double_LE
00068         #define opj_write_float         opj_write_float_LE
00069         #define opj_read_float          opj_read_float_LE
00070 #endif
00071 
00072 
00073 
00074 typedef enum
00075 {
00076         opj_signed_sentinel             = -1, /* do not use in code */
00077         opj_stream_e_output             = 0x1,
00078         opj_stream_e_input              = 0x2,
00079         opj_stream_e_end                = 0x4,
00080         opj_stream_e_error              = 0x8
00081 }
00082 opj_stream_flag ;
00083 
00087 typedef struct opj_stream_private
00088 {
00092         void *                                  m_user_data;
00093 
00099         opj_stream_free_user_data_fn            m_free_user_data_fn;
00100 
00104         OPJ_UINT64                              m_user_data_length;
00105 
00109         opj_stream_read_fn              m_read_fn;
00110 
00114         opj_stream_write_fn             m_write_fn;
00115 
00120         opj_stream_skip_fn              m_skip_fn;
00121 
00125         opj_stream_seek_fn              m_seek_fn;
00126 
00131         OPJ_BYTE *                                      m_stored_data;
00132 
00136         OPJ_BYTE *                                      m_current_data;
00137 
00141         OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *);
00142 
00146         OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
00147 
00151         OPJ_SIZE_T                      m_bytes_in_buffer;
00152 
00156         OPJ_OFF_T                       m_byte_offset;
00157 
00161         OPJ_SIZE_T                      m_buffer_size;
00162 
00166         opj_stream_flag m_status;
00167 
00168 }
00169 opj_stream_private_t;
00170 
00173 /* ----------------------------------------------------------------------- */
00180 void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
00181 
00189 void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
00190 
00198 void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
00199 
00207 void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
00208 
00209 
00215 void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
00216 
00217 /***
00218  * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
00219  * @param p_buffer              pointer the data buffer to write data to.
00220  * @param p_value               the value to write
00221  */
00222 void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
00223 
00229 void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
00230 
00236 void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
00237 
00243 void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
00244 
00250 void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
00251 
00257 void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
00258 
00259 /***
00260  * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
00261  * @param p_buffer              pointer the data buffer to write data to.
00262  * @param p_value               the value to write
00263  */
00264 void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
00265 
00274 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);
00275 
00284 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);
00285 
00292 OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
00293 
00301 OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00302 
00310 OPJ_OFF_T opj_stream_tell (const opj_stream_private_t * p_stream);
00311 
00312 
00320 OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream);
00321 
00329 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);
00330 
00338 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);
00339 
00347 OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00348 
00356 OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00357 
00365 OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00366 
00370 OPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream);
00371 
00375 OPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
00376 
00380 OPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
00381 
00385 OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data);
00386 
00390 OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data);
00391 
00392 /* ----------------------------------------------------------------------- */
00396 
00397 
00398 #endif /* __CIO_H */
00399