"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSImageLib/Src/Jpeg/LSIMqc.h

00001 /*
00002  * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
00003  * Copyright (c) 2002-2007, Professor Benoit Macq
00004  * Copyright (c) 2001-2003, David Janssens
00005  * Copyright (c) 2002-2003, Yannick Verschueren
00006  * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
00007  * Copyright (c) 2005, Herve Drolon, FreeImage Team
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 
00033 #ifndef __LSI_MQC_H__
00034 #define __LSI_MQC_H__
00035 
00036 #include "../LSIImageLib.h"
00037 #include "LSIJpegCommonStructs.h"
00038 
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00041 // MACROS
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00043 #define MQC_NUMCTXS                                                             19
00044 #define mqc_setcurctx( _pmMqc, _i32ContextNo )  (_pmMqc)->curctx = &(_pmMqc)->ctxs[static_cast<LSINT32>(_i32ContextNo)]
00045 #define MQC_PERF_OPT
00046 
00047 namespace lsi {
00048 
00055         class CMqc {
00056         public :
00057                 // == Types.
00061                 typedef struct opj_mqc_state_t {
00063                         LSUINT32                                                        qeval;
00065                         LSINT32                                                         mps;
00067                         opj_mqc_state_t *                                       nmps;
00069                         opj_mqc_state_t *                                       nlps;
00070                 } * LPopj_mqc_state_t, * const LPCopj_mqc_state_t;
00071 
00075                 typedef struct opj_mqc {
00076                         LSUINT32                                                        c;
00077                         LSUINT32                                                        a;
00078                         LSUINT32                                                        ct;
00079                         LSUINT8 *                                                       bp;
00080                         LSUINT8 *                                                       start;
00081                         LSUINT8 *                                                       end;
00082                         opj_mqc_state_t *                                       ctxs[MQC_NUMCTXS];
00083                         opj_mqc_state_t **                                      curctx;
00084 #ifdef MQC_PERF_OPT
00085                         LSUINT8 *                                                       buffer;
00086 #endif  // #ifdef MQC_PERF_OPT
00087                 } opj_mqc_t;
00088 
00089 
00090                 // == Functions.
00096                 static opj_mqc_t * LSE_CALL                             mqc_create();
00097                 
00103                 static LSVOID LSE_CALL                                  mqc_destroy( opj_mqc_t * _pmMqc );
00104                 
00111                 static LSINT32 LSE_CALL                                 mqc_numbytes( opj_mqc_t * _pmMqc );
00112                 
00119                 static LSVOID LSE_CALL                                  mqc_resetstates( opj_mqc_t * _pmMqc );
00120                 
00129                 static LSVOID LSE_CALL                                  mqc_setstate( opj_mqc_t * _pmMqc, LSINT32 _i32ContextNo, LSINT32 _i32Msb, LSINT32 _i32Prob );
00130                 
00137                 static LSVOID LSE_CALL                                  mqc_init_enc( opj_mqc_t * _pmMqc, LSUINT8 * _pui8Buffer );
00138                 
00145                 static LSVOID LSE_CALL                                  mqc_encode( opj_mqc_t * _pmMqc, LSINT32 _i32D );
00146                 
00152                 static LSVOID LSE_CALL                                  mqc_flush( opj_mqc_t * _pmMqc );
00153                 
00161                 static LSVOID LSE_CALL                                  mqc_bypass_init_enc( opj_mqc_t * _pmMqc );
00162                 
00171                 static LSVOID LSE_CALL                                  mqc_bypass_enc( opj_mqc_t * _pmMqc, LSINT32 _i32D );
00172                 
00180                 static LSINT32 LSE_CALL                                 mqc_bypass_flush_enc( opj_mqc_t * _pmMqc );
00181                 
00187                 static LSVOID LSE_CALL                                  mqc_reset_enc( opj_mqc_t * _pmMqc );
00188                 
00195                 static LSINT32 LSE_CALL                                 mqc_restart_enc( opj_mqc_t * _pmMqc );
00196                 
00202                 static LSVOID LSE_CALL                                  mqc_restart_init_enc( opj_mqc_t * _pmMqc );
00203                 
00209                 static LSVOID LSE_CALL                                  mqc_erterm_enc( opj_mqc_t * _pmMqc );
00210                 
00216                 static LSVOID LSE_CALL                                  mqc_segmark_enc( opj_mqc_t * _pmMqc );
00217                 
00225                 static LSVOID LSE_CALL                                  mqc_init_dec( opj_mqc_t * _pmMqc, LSUINT8 * _pui8Buffer, LSINT32 _i32Len );
00226                 
00233                 static LSINT32 LSE_CALL                                 mqc_decode( opj_mqc_t * const _pmMqc );
00234 
00235 
00236         protected :
00237                 // == Members.
00241                 static opj_mqc_state_t                                  mqc_states[47*2];
00242 
00243 
00244                 // == Functions.
00251                 static LSVOID LSE_CALL                                  mqc_byteout( opj_mqc_t * _pmMqc );
00252                 
00258                 static LSVOID LSE_CALL                                  mqc_renorme( opj_mqc_t * _pmMqc );
00259                 
00265                 static LSVOID LSE_CALL                                  mqc_codemps( opj_mqc_t * _pmMqc );
00266                 
00272                 static LSVOID LSE_CALL                                  mqc_codelps( opj_mqc_t * _pmMqc );
00273                 
00279                 static LSVOID LSE_CALL                                  mqc_setbits( opj_mqc_t * _pmMqc );
00280                 
00287                 static LSINT32 LSE_CALL                                 mqc_mpsexchange( opj_mqc_t * const _pmMqc );
00288                 
00295                 static LSINT32 LSE_CALL                                 mqc_lpsexchange( opj_mqc_t * const _pmMqc );
00296                 
00302                 static LSVOID LSE_CALL                                  mqc_bytein( opj_mqc_t * const _pmMqc );
00303                 
00309                 static LSVOID LSE_CALL                                  mqc_renormd( opj_mqc_t * const _pmMqc );
00310         };
00311 
00312 }       // namespace lsi
00313 
00314 #endif  // __LSI_MQC_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator