OpenJPEG 2.1.0

mqc.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, 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 __MQC_H
00040 #define __MQC_H
00041 
00051 
00055 typedef struct opj_mqc_state {
00057         OPJ_UINT32 qeval;
00059         OPJ_UINT32 mps;
00061         struct opj_mqc_state *nmps;
00063         struct opj_mqc_state *nlps;
00064 } opj_mqc_state_t;
00065 
00066 #define MQC_NUMCTXS 19
00067 
00071 typedef struct opj_mqc {
00072         OPJ_UINT32 c;
00073         OPJ_UINT32 a;
00074         OPJ_UINT32 ct;
00075         OPJ_BYTE *bp;
00076         OPJ_BYTE *start;
00077         OPJ_BYTE *end;
00078         opj_mqc_state_t *ctxs[MQC_NUMCTXS];
00079         opj_mqc_state_t **curctx;
00080 #ifdef MQC_PERF_OPT
00081         unsigned char *buffer;
00082 #endif
00083 } opj_mqc_t;
00084 
00087 /* ----------------------------------------------------------------------- */
00092 opj_mqc_t* opj_mqc_create(void);
00097 void opj_mqc_destroy(opj_mqc_t *mqc);
00103 OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc);
00109 void opj_mqc_resetstates(opj_mqc_t *mqc);
00117 void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob);
00123 void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp);
00129 #define opj_mqc_setcurctx(mqc, ctxno)   (mqc)->curctx = &(mqc)->ctxs[(OPJ_UINT32)(ctxno)]
00130 
00135 void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d);
00140 void opj_mqc_flush(opj_mqc_t *mqc);
00147 void opj_mqc_bypass_init_enc(opj_mqc_t *mqc);
00155 void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d);
00162 OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc);
00167 void opj_mqc_reset_enc(opj_mqc_t *mqc);
00173 OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc);
00178 void opj_mqc_restart_init_enc(opj_mqc_t *mqc);
00183 void opj_mqc_erterm_enc(opj_mqc_t *mqc);
00188 void opj_mqc_segmark_enc(opj_mqc_t *mqc);
00195 OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len);
00201 OPJ_INT32 opj_mqc_decode(opj_mqc_t * const mqc);
00202 /* ----------------------------------------------------------------------- */
00206 
00207 #endif /* __MQC_H */