OpenJPEG 2.1.2

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 #define OPJ_STREAM_STATUS_OUTPUT  0x1U
00074 #define OPJ_STREAM_STATUS_INPUT   0x2U
00075 #define OPJ_STREAM_STATUS_END     0x4U
00076 #define OPJ_STREAM_STATUS_ERROR   0x8U
00077 
00081 typedef struct opj_stream_private
00082 {
00086         void *                                  m_user_data;
00087 
00093         opj_stream_free_user_data_fn            m_free_user_data_fn;
00094 
00098         OPJ_UINT64                              m_user_data_length;
00099 
00103         opj_stream_read_fn              m_read_fn;
00104 
00108         opj_stream_write_fn             m_write_fn;
00109 
00114         opj_stream_skip_fn              m_skip_fn;
00115 
00119         opj_stream_seek_fn              m_seek_fn;
00120 
00125         OPJ_BYTE *                                      m_stored_data;
00126 
00130         OPJ_BYTE *                                      m_current_data;
00131 
00135         OPJ_OFF_T (* m_opj_skip)(struct opj_stream_private * ,OPJ_OFF_T , struct opj_event_mgr *);
00136 
00140         OPJ_BOOL (* m_opj_seek) (struct opj_stream_private * , OPJ_OFF_T , struct opj_event_mgr *);
00141 
00145         OPJ_SIZE_T                      m_bytes_in_buffer;
00146 
00150         OPJ_OFF_T                       m_byte_offset;
00151 
00155         OPJ_SIZE_T                      m_buffer_size;
00156 
00161         OPJ_UINT32 m_status;
00162 
00163 }
00164 opj_stream_private_t;
00165 
00168 /* ----------------------------------------------------------------------- */
00175 void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
00176 
00184 void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
00185 
00193 void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes);
00194 
00202 void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes);
00203 
00204 
00210 void opj_write_double_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
00211 
00212 /***
00213  * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
00214  * @param p_buffer              pointer the data buffer to write data to.
00215  * @param p_value               the value to write
00216  */
00217 void opj_write_double_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT64 p_value);
00218 
00224 void opj_read_double_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
00225 
00231 void opj_read_double_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT64 * p_value);
00232 
00238 void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
00239 
00245 void opj_read_float_BE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value);
00246 
00252 void opj_write_float_LE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
00253 
00254 /***
00255  * Write some bytes to the given data buffer, this function is used in Big Endian cpus.
00256  * @param p_buffer              pointer the data buffer to write data to.
00257  * @param p_value               the value to write
00258  */
00259 void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value);
00260 
00269 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);
00270 
00279 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);
00280 
00287 OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * p_event_mgr);
00288 
00296 OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00297 
00305 OPJ_OFF_T opj_stream_tell (const opj_stream_private_t * p_stream);
00306 
00307 
00315 OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream);
00316 
00324 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);
00325 
00333 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);
00334 
00342 OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00343 
00351 OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00352 
00360 OPJ_BOOL opj_stream_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr);
00361 
00365 OPJ_BOOL opj_stream_has_seek (const opj_stream_private_t * p_stream);
00366 
00370 OPJ_SIZE_T opj_stream_default_read (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
00371 
00375 OPJ_SIZE_T opj_stream_default_write (void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data);
00376 
00380 OPJ_OFF_T opj_stream_default_skip (OPJ_OFF_T p_nb_bytes, void * p_user_data);
00381 
00385 OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data);
00386 
00387 /* ----------------------------------------------------------------------- */
00391 
00392 
00393 #endif /* __CIO_H */
00394