/* * The copyright in this software is being made available under the 2-clauses * BSD License, included below. This software may be subject to other third * party and contributor rights, including patent rights, and no such rights * are granted under this license. * * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2014, Professor Benoit Macq * Copyright (c) 2001-2003, David Janssens * Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2003-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include "opj_includes.h" #include <assert.h> /** @defgroup MQC MQC - Implementation of an MQ-Coder */ /*@{*/ /** @name Local static functions */ /*@{*/ /** Fill mqc->c with 1's for flushing @param mqc MQC handle */ static void opj_mqc_setbits(opj_mqc_t *mqc); /*@}*/ /*@}*/ /* <summary> */ /* This array defines all the possible states for a context. */ /* </summary> */ static const opj_mqc_state_t mqc_states[47 * 2] = …; /* ========================================================== local functions ========================================================== */ static void opj_mqc_setbits(opj_mqc_t *mqc) { … } /* ========================================================== MQ-Coder interface ========================================================== */ OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc) { … } void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) { … } void opj_mqc_flush(opj_mqc_t *mqc) { … } void opj_mqc_bypass_init_enc(opj_mqc_t *mqc) { … } void opj_mqc_bypass_enc(opj_mqc_t *mqc, OPJ_UINT32 d) { … } OPJ_UINT32 opj_mqc_bypass_get_extra_bytes(opj_mqc_t *mqc, OPJ_BOOL erterm) { … } void opj_mqc_bypass_flush_enc(opj_mqc_t *mqc, OPJ_BOOL erterm) { … } void opj_mqc_reset_enc(opj_mqc_t *mqc) { … } #ifdef notdef OPJ_UINT32 opj_mqc_restart_enc(opj_mqc_t *mqc) { OPJ_UINT32 correction = 1; /* <flush part> */ OPJ_INT32 n = (OPJ_INT32)(27 - 15 - mqc->ct); mqc->c <<= mqc->ct; while (n > 0) { opj_mqc_byteout(mqc); n -= (OPJ_INT32)mqc->ct; mqc->c <<= mqc->ct; } opj_mqc_byteout(mqc); return correction; } #endif void opj_mqc_restart_init_enc(opj_mqc_t *mqc) { … } void opj_mqc_erterm_enc(opj_mqc_t *mqc) { … } /** Encode the most probable symbol @param mqc MQC handle */ static INLINE void opj_mqc_codemps(opj_mqc_t *mqc) { … } /** Encode the most least symbol @param mqc MQC handle */ static INLINE void opj_mqc_codelps(opj_mqc_t *mqc) { … } /** Encode a symbol using the MQ-coder @param mqc MQC handle @param d The symbol to be encoded (0 or 1) */ static INLINE void opj_mqc_encode(opj_mqc_t *mqc, OPJ_UINT32 d) { … } void opj_mqc_segmark_enc(opj_mqc_t *mqc) { … } static void opj_mqc_init_dec_common(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len, OPJ_UINT32 extra_writable_bytes) { … } void opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len, OPJ_UINT32 extra_writable_bytes) { … } void opj_mqc_raw_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len, OPJ_UINT32 extra_writable_bytes) { … } void opq_mqc_finish_dec(opj_mqc_t *mqc) { … } void opj_mqc_resetstates(opj_mqc_t *mqc) { … } void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT32 prob) { … } void opj_mqc_byteout(opj_mqc_t *mqc) { … }