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, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr> 00015 * All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions 00019 * are met: 00020 * 1. Redistributions of source code must retain the above copyright 00021 * notice, this list of conditions and the following disclaimer. 00022 * 2. Redistributions in binary form must reproduce the above copyright 00023 * notice, this list of conditions and the following disclaimer in the 00024 * documentation and/or other materials provided with the distribution. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 */ 00038 00039 #ifndef OPJ_MQC_H 00040 #define OPJ_MQC_H 00041 00042 #include "opj_common.h" 00043 00054 00058 typedef struct opj_mqc_state { 00060 OPJ_UINT32 qeval; 00062 OPJ_UINT32 mps; 00064 const struct opj_mqc_state *nmps; 00066 const struct opj_mqc_state *nlps; 00067 } opj_mqc_state_t; 00068 00069 #define MQC_NUMCTXS 19 00070 00074 typedef struct opj_mqc { 00076 OPJ_UINT32 c; 00078 OPJ_UINT32 a; 00080 OPJ_UINT32 ct; 00081 /* only used by decoder, to count the number of times a terminating 0xFF >0x8F marker is read */ 00082 OPJ_UINT32 end_of_byte_stream_counter; 00084 OPJ_BYTE *bp; 00086 OPJ_BYTE *start; 00088 OPJ_BYTE *end; 00090 const opj_mqc_state_t *ctxs[MQC_NUMCTXS]; 00092 const opj_mqc_state_t **curctx; 00093 /* lut_ctxno_zc shifted by (1 << 9) * bandno */ 00094 const OPJ_BYTE* lut_ctxno_zc_orient; 00096 OPJ_BYTE backup[OPJ_COMMON_CBLK_DATA_EXTRA]; 00097 } opj_mqc_t; 00098 00099 #include "mqc_inl.h" 00100 00103 /* ----------------------------------------------------------------------- */ 00104 00110 OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc); 00116 void opj_mqc_resetstates(opj_mqc_t *mqc); 00124 void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, 00125 OPJ_INT32 prob); 00131 void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp); 00137 #define opj_mqc_setcurctx(mqc, ctxno) (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)] 00138 00143 void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d); 00148 void opj_mqc_flush(opj_mqc_t *mqc); 00154 void opj_mqc_bypass_init_enc(opj_mqc_t *mqc); 00155 00161 OPJ_UINT32 opj_mqc_bypass_get_extra_bytes(opj_mqc_t *mqc, OPJ_BOOL erterm); 00162 00169 void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d); 00175 void opj_mqc_bypass_flush_enc(opj_mqc_t *mqc, OPJ_BOOL erterm); 00180 void opj_mqc_reset_enc(opj_mqc_t *mqc); 00181 00182 #ifdef notdef 00183 00188 OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc); 00189 #endif 00190 00195 void opj_mqc_restart_init_enc(opj_mqc_t *mqc); 00200 void opj_mqc_erterm_enc(opj_mqc_t *mqc); 00205 void opj_mqc_segmark_enc(opj_mqc_t *mqc); 00206 00225 void opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len, 00226 OPJ_UINT32 extra_writable_bytes); 00227 00246 void opj_mqc_raw_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len, 00247 OPJ_UINT32 extra_writable_bytes); 00248 00249 00258 void opq_mqc_finish_dec(opj_mqc_t *mqc); 00259 00265 /*static INLINE OPJ_UINT32 opj_mqc_decode(opj_mqc_t * const mqc);*/ 00266 /* ----------------------------------------------------------------------- */ 00270 00271 #endif /* OPJ_MQC_H */