2003-11-27 11:10:17 +01:00
|
|
|
/*
|
2007-01-15 10:55:40 +01:00
|
|
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
|
|
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
2005-12-02 14:34:15 +01:00
|
|
|
* Copyright (c) 2001-2003, David Janssens
|
2003-11-27 11:10:17 +01:00
|
|
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
2007-01-15 10:55:40 +01:00
|
|
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
|
|
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
2007-05-21 11:44:10 +02:00
|
|
|
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
2003-11-27 11:10:17 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2005-12-02 14:34:15 +01:00
|
|
|
#include "opj_includes.h"
|
2007-05-21 11:44:10 +02:00
|
|
|
#include "t1_luts.h"
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/** @defgroup T1 T1 - Implementation of the tier-1 coding */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/** @name Local static functions */
|
|
|
|
/*@{*/
|
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
static INLINE OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient);
|
|
|
|
static OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f);
|
|
|
|
static INLINE OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f);
|
|
|
|
static OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f);
|
|
|
|
static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos);
|
|
|
|
static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos);
|
2012-10-24 16:06:10 +02:00
|
|
|
static void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride);
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Encode significant pass
|
|
|
|
*/
|
2012-08-17 16:56:42 +02:00
|
|
|
static void opj_t1_enc_sigpass_step(opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-08-17 16:56:42 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 one,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc);
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Decode significant pass
|
|
|
|
*/
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
static void opj_t1_dec_sigpass_step(opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc);
|
|
|
|
|
2012-10-25 19:23:54 +02:00
|
|
|
static INLINE void opj_t1_dec_sigpass_step_raw(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_INT32 vsc);
|
2012-10-25 19:23:54 +02:00
|
|
|
static INLINE void opj_t1_dec_sigpass_step_mqc(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf);
|
2012-10-25 19:23:54 +02:00
|
|
|
static INLINE void opj_t1_dec_sigpass_step_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_INT32 vsc);
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Encode significant pass
|
|
|
|
*/
|
2012-08-17 16:56:42 +02:00
|
|
|
static void opj_t1_enc_sigpass( opj_t1_t *t1,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 cblksty);
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Decode significant pass
|
|
|
|
*/
|
2012-10-25 19:23:54 +02:00
|
|
|
static void opj_t1_dec_sigpass_raw(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 cblksty);
|
2012-10-25 19:23:54 +02:00
|
|
|
static void opj_t1_dec_sigpass_mqc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient);
|
2012-10-25 19:23:54 +02:00
|
|
|
static void opj_t1_dec_sigpass_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient);
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
|
2011-09-19 18:09:19 +02:00
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Encode refinement pass
|
|
|
|
*/
|
2012-09-27 15:56:48 +02:00
|
|
|
static void opj_t1_enc_refpass_step(opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-09-27 15:56:48 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 one,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc);
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
|
2010-04-08 19:22:58 +02:00
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Encode refinement pass
|
|
|
|
*/
|
2012-09-27 15:56:48 +02:00
|
|
|
static void opj_t1_enc_refpass( opj_t1_t *t1,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 cblksty);
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Decode refinement pass
|
|
|
|
*/
|
2012-10-25 19:23:54 +02:00
|
|
|
static void opj_t1_dec_refpass_raw(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 cblksty);
|
2012-10-25 19:23:54 +02:00
|
|
|
static void opj_t1_dec_refpass_mqc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno);
|
2012-10-25 19:23:54 +02:00
|
|
|
static void opj_t1_dec_refpass_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno);
|
2012-10-25 19:23:54 +02:00
|
|
|
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Decode refinement pass
|
|
|
|
*/
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
static void opj_t1_dec_refpass_step(opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc);
|
2011-09-19 18:09:19 +02:00
|
|
|
|
2012-10-26 12:04:55 +02:00
|
|
|
static INLINE void opj_t1_dec_refpass_step_raw(
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf,
|
|
|
|
OPJ_INT32 vsc);
|
2012-10-26 12:04:55 +02:00
|
|
|
static INLINE void opj_t1_dec_refpass_step_mqc(
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf);
|
2012-10-26 12:04:55 +02:00
|
|
|
static INLINE void opj_t1_dec_refpass_step_mqc_vsc(
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf,
|
|
|
|
OPJ_INT32 vsc);
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Encode clean-up pass
|
|
|
|
*/
|
2012-09-27 16:09:41 +02:00
|
|
|
static void opj_t1_enc_clnpass_step(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-09-27 16:09:41 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 one,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_UINT32 partial,
|
|
|
|
OPJ_UINT32 vsc);
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Decode clean-up pass
|
|
|
|
*/
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass_step_partial(
|
2010-04-08 19:22:58 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf);
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass_step(
|
2010-04-08 19:22:58 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf);
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass_step_vsc(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_INT32 partial,
|
|
|
|
OPJ_INT32 vsc);
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Encode clean-up pass
|
|
|
|
*/
|
2012-09-27 16:09:41 +02:00
|
|
|
static void opj_t1_enc_clnpass(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-09-27 16:09:41 +02:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_UINT32 cblksty);
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Decode clean-up pass
|
|
|
|
*/
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 cblksty);
|
2012-03-15 11:23:20 +01:00
|
|
|
|
2012-10-25 19:27:22 +02:00
|
|
|
static OPJ_FLOAT64 opj_t1_getwmsedec(
|
2012-03-15 11:23:20 +01:00
|
|
|
OPJ_INT32 nmsedec,
|
|
|
|
OPJ_UINT32 compno,
|
|
|
|
OPJ_UINT32 level,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_UINT32 qmfbid,
|
|
|
|
OPJ_FLOAT64 stepsize,
|
|
|
|
OPJ_UINT32 numcomps,
|
|
|
|
const OPJ_FLOAT64 * mct_norms);
|
|
|
|
|
2012-09-27 15:51:01 +02:00
|
|
|
static void opj_t1_encode_cblk( opj_t1_t *t1,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_cblk_enc_t* cblk,
|
2012-09-27 15:51:01 +02:00
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_UINT32 compno,
|
|
|
|
OPJ_UINT32 level,
|
|
|
|
OPJ_UINT32 qmfbid,
|
|
|
|
OPJ_FLOAT64 stepsize,
|
|
|
|
OPJ_UINT32 cblksty,
|
|
|
|
OPJ_UINT32 numcomps,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_tile_t * tile,
|
2012-09-27 15:51:01 +02:00
|
|
|
const OPJ_FLOAT64 * mct_norms);
|
2012-03-15 11:23:20 +01:00
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/**
|
|
|
|
Decode 1 code-block
|
|
|
|
@param t1 T1 handle
|
|
|
|
@param cblk Code-block coding parameters
|
|
|
|
@param orient
|
|
|
|
@param roishift Region of interest shifting value
|
|
|
|
@param cblksty Code-block style
|
|
|
|
*/
|
2012-11-15 14:13:36 +01:00
|
|
|
static OPJ_BOOL opj_t1_decode_cblk( opj_t1_t *t1,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_cblk_dec_t* cblk,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_UINT32 roishift,
|
|
|
|
OPJ_UINT32 cblksty);
|
2005-12-08 10:38:47 +01:00
|
|
|
|
2012-11-15 14:13:36 +01:00
|
|
|
OPJ_BOOL opj_t1_allocate_buffers( opj_t1_t *t1,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_UINT32 w,
|
|
|
|
OPJ_UINT32 h);
|
2011-09-27 14:32:28 +02:00
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/*@}*/
|
|
|
|
|
2005-12-02 14:34:15 +01:00
|
|
|
/* ----------------------------------------------------------------------- */
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient) {
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)];
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f) {
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f) {
|
|
|
|
OPJ_UINT32 tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
|
|
|
|
OPJ_UINT32 tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1;
|
2007-08-21 14:42:55 +02:00
|
|
|
return (tmp2);
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f) {
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
|
2005-12-08 10:38:47 +01:00
|
|
|
if (bitpos > T1_NMSEDEC_FRACBITS) {
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-09-27 16:16:05 +02:00
|
|
|
OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) {
|
2005-12-08 10:38:47 +01:00
|
|
|
if (bitpos > T1_NMSEDEC_FRACBITS) {
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & ((1 << T1_NMSEDEC_BITS) - 1)];
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
2005-12-02 14:34:15 +01:00
|
|
|
|
2007-05-21 11:44:10 +02:00
|
|
|
return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)];
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-10-24 16:06:10 +02:00
|
|
|
void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride) {
|
|
|
|
opj_flag_t *np = flagsp - stride;
|
|
|
|
opj_flag_t *sp = flagsp + stride;
|
2007-05-22 15:14:13 +02:00
|
|
|
|
2012-10-24 16:06:10 +02:00
|
|
|
static const opj_flag_t mod[] = {
|
2007-08-21 14:30:08 +02:00
|
|
|
T1_SIG_S, T1_SIG_S|T1_SGN_S,
|
|
|
|
T1_SIG_E, T1_SIG_E|T1_SGN_E,
|
|
|
|
T1_SIG_W, T1_SIG_W|T1_SGN_W,
|
|
|
|
T1_SIG_N, T1_SIG_N|T1_SGN_N
|
2007-05-22 15:14:13 +02:00
|
|
|
};
|
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
np[-1] |= T1_SIG_SE;
|
2007-05-22 15:14:13 +02:00
|
|
|
np[0] |= mod[s];
|
|
|
|
np[1] |= T1_SIG_SW;
|
|
|
|
|
|
|
|
flagsp[-1] |= mod[s+2];
|
2007-08-21 14:30:08 +02:00
|
|
|
flagsp[0] |= T1_SIG;
|
|
|
|
flagsp[1] |= mod[s+4];
|
2007-05-22 15:14:13 +02:00
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
sp[-1] |= T1_SIG_NE;
|
2007-08-21 14:30:08 +02:00
|
|
|
sp[0] |= mod[s+6];
|
2007-05-22 15:14:13 +02:00
|
|
|
sp[1] |= T1_SIG_NW;
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-08-17 16:56:42 +02:00
|
|
|
void opj_t1_enc_sigpass_step( opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-08-17 16:56:42 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 one,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc
|
|
|
|
)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-08-17 16:56:42 +02:00
|
|
|
OPJ_INT32 v;
|
|
|
|
OPJ_UINT32 flag;
|
2005-12-08 10:38:47 +01:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
2007-05-21 14:50:03 +02:00
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
2005-12-08 10:38:47 +01:00
|
|
|
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
2012-10-05 11:10:15 +02:00
|
|
|
v = opj_int_abs(*datap) & one ? 1 : 0;
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient)); /* ESSAI */
|
2005-12-08 10:38:47 +01:00
|
|
|
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_bypass_enc(mqc, v);
|
2005-12-08 10:38:47 +01:00
|
|
|
} else {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_encode(mqc, v);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
if (v) {
|
2007-05-22 15:14:13 +02:00
|
|
|
v = *datap < 0 ? 1 : 0;
|
2012-10-05 11:10:15 +02:00
|
|
|
*nmsedec += opj_t1_getnmsedec_sig(opj_int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag)); /* ESSAI */
|
2005-12-08 10:38:47 +01:00
|
|
|
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_bypass_enc(mqc, v);
|
2005-12-08 10:38:47 +01:00
|
|
|
} else {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_encode(mqc, v ^ opj_t1_getspb(flag));
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
2007-05-21 14:50:03 +02:00
|
|
|
*flagsp |= T1_VISIT;
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
static INLINE void opj_t1_dec_sigpass_step_raw(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_INT32 vsc)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, flag;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_raw_t *raw = t1->raw; /* RAW component */
|
2012-10-26 12:04:55 +02:00
|
|
|
OPJ_ARG_NOT_USED(orient);
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
|
|
|
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
|
|
|
if (opj_raw_decode(raw)) {
|
|
|
|
v = opj_raw_decode(raw); /* ESSAI */
|
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
|
|
|
}
|
|
|
|
*flagsp |= T1_VISIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
INLINE void opj_t1_dec_sigpass_step_mqc(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, flag;
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
flag = *flagsp;
|
|
|
|
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
|
|
|
if (opj_mqc_decode(mqc)) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
|
|
|
v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
|
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
|
|
|
}
|
|
|
|
*flagsp |= T1_VISIT;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
INLINE void opj_t1_dec_sigpass_step_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_INT32 vsc)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, flag;
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
|
|
|
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
|
|
|
if (opj_mqc_decode(mqc)) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
|
|
|
v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
|
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
|
|
|
}
|
|
|
|
*flagsp |= T1_VISIT;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-17 16:56:42 +02:00
|
|
|
void opj_t1_enc_sigpass(opj_t1_t *t1,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 cblksty
|
|
|
|
)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-08-17 16:56:42 +02:00
|
|
|
OPJ_UINT32 i, j, k, vsc;
|
|
|
|
OPJ_INT32 one;
|
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
*nmsedec = 0;
|
|
|
|
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
|
2007-05-22 15:14:13 +02:00
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
2012-08-17 16:56:42 +02:00
|
|
|
opj_t1_enc_sigpass_step(
|
2007-05-21 15:08:10 +02:00
|
|
|
t1,
|
2007-05-22 15:14:13 +02:00
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
2007-05-21 15:08:10 +02:00
|
|
|
orient,
|
|
|
|
bpno,
|
|
|
|
one,
|
|
|
|
nmsedec,
|
|
|
|
type,
|
|
|
|
vsc);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 19:23:54 +02:00
|
|
|
void opj_t1_dec_sigpass_raw(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 cblksty)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, half, oneplushalf, vsc;
|
2012-10-25 19:23:54 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
|
|
|
one = 1 << bpno;
|
|
|
|
half = one >> 1;
|
|
|
|
oneplushalf = one | half;
|
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
|
|
|
opj_t1_dec_sigpass_step_raw(
|
|
|
|
t1,
|
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
|
|
|
orient,
|
|
|
|
oneplushalf,
|
|
|
|
vsc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
void opj_t1_dec_sigpass_mqc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, half, oneplushalf;
|
2012-10-25 19:23:54 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data1 = t1->data;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_flag_t *flags1 = &t1->flags[1];
|
|
|
|
one = 1 << bpno;
|
|
|
|
half = one >> 1;
|
|
|
|
oneplushalf = one | half;
|
|
|
|
for (k = 0; k < (t1->h & ~3); k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data2 = data1 + i;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_flag_t *flags2 = flags1 + i;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
data1 += t1->w << 2;
|
|
|
|
flags1 += t1->flags_stride << 2;
|
|
|
|
}
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data2 = data1 + i;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_flag_t *flags2 = flags1 + i;
|
|
|
|
for (j = k; j < t1->h; ++j) {
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
void opj_t1_dec_sigpass_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, half, oneplushalf, vsc;
|
2012-10-25 19:23:54 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
|
|
|
one = 1 << bpno;
|
|
|
|
half = one >> 1;
|
|
|
|
oneplushalf = one | half;
|
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0;
|
|
|
|
opj_t1_dec_sigpass_step_mqc_vsc(
|
|
|
|
t1,
|
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
|
|
|
orient,
|
|
|
|
oneplushalf,
|
|
|
|
vsc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2012-09-27 15:56:48 +02:00
|
|
|
void opj_t1_enc_refpass_step( opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-09-27 15:56:48 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 one,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-09-27 15:56:48 +02:00
|
|
|
OPJ_INT32 v;
|
|
|
|
OPJ_UINT32 flag;
|
2005-12-08 10:38:47 +01:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
2007-05-21 14:50:03 +02:00
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
2005-12-08 10:38:47 +01:00
|
|
|
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
2012-10-05 11:10:15 +02:00
|
|
|
*nmsedec += opj_t1_getnmsedec_ref(opj_int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
|
|
|
|
v = opj_int_abs(*datap) & one ? 1 : 0;
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI */
|
2005-12-08 10:38:47 +01:00
|
|
|
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_bypass_enc(mqc, v);
|
2005-12-08 10:38:47 +01:00
|
|
|
} else {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_encode(mqc, v);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
2007-05-21 14:50:03 +02:00
|
|
|
*flagsp |= T1_REFINE;
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 19:23:54 +02:00
|
|
|
INLINE void opj_t1_dec_refpass_step_raw(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf,
|
|
|
|
OPJ_INT32 vsc)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, t, flag;
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
opj_raw_t *raw = t1->raw; /* RAW component */
|
|
|
|
|
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
|
|
|
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
|
|
|
v = opj_raw_decode(raw);
|
|
|
|
t = v ? poshalf : neghalf;
|
|
|
|
*datap += *datap < 0 ? -t : t;
|
|
|
|
*flagsp |= T1_REFINE;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
INLINE void opj_t1_dec_refpass_step_mqc(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, t, flag;
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
flag = *flagsp;
|
|
|
|
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI */
|
|
|
|
v = opj_mqc_decode(mqc);
|
|
|
|
t = v ? poshalf : neghalf;
|
|
|
|
*datap += *datap < 0 ? -t : t;
|
|
|
|
*flagsp |= T1_REFINE;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
INLINE void opj_t1_dec_refpass_step_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf,
|
|
|
|
OPJ_INT32 vsc)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, t, flag;
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
|
|
|
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI */
|
|
|
|
v = opj_mqc_decode(mqc);
|
|
|
|
t = v ? poshalf : neghalf;
|
|
|
|
*datap += *datap < 0 ? -t : t;
|
|
|
|
*flagsp |= T1_REFINE;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2012-09-27 15:56:48 +02:00
|
|
|
void opj_t1_enc_refpass(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-09-27 15:56:48 +02:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 cblksty)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-09-27 15:56:48 +02:00
|
|
|
OPJ_UINT32 i, j, k, vsc;
|
|
|
|
OPJ_INT32 one;
|
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
*nmsedec = 0;
|
|
|
|
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
|
2007-05-22 15:14:13 +02:00
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
2012-09-27 15:56:48 +02:00
|
|
|
opj_t1_enc_refpass_step(
|
2007-05-21 15:08:10 +02:00
|
|
|
t1,
|
2007-05-22 15:14:13 +02:00
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
2007-05-21 15:08:10 +02:00
|
|
|
bpno,
|
|
|
|
one,
|
|
|
|
nmsedec,
|
|
|
|
type,
|
|
|
|
vsc);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 19:23:54 +02:00
|
|
|
void opj_t1_dec_refpass_raw(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 cblksty)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, poshalf, neghalf;
|
2012-10-25 19:23:54 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 vsc;
|
2012-10-25 19:23:54 +02:00
|
|
|
one = 1 << bpno;
|
|
|
|
poshalf = one >> 1;
|
|
|
|
neghalf = bpno > 0 ? -poshalf : -1;
|
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
|
|
|
opj_t1_dec_refpass_step_raw(
|
|
|
|
t1,
|
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
|
|
|
poshalf,
|
|
|
|
neghalf,
|
|
|
|
vsc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
void opj_t1_dec_refpass_mqc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, poshalf, neghalf;
|
2012-10-25 19:23:54 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data1 = t1->data;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_flag_t *flags1 = &t1->flags[1];
|
|
|
|
one = 1 << bpno;
|
|
|
|
poshalf = one >> 1;
|
|
|
|
neghalf = bpno > 0 ? -poshalf : -1;
|
|
|
|
for (k = 0; k < (t1->h & ~3); k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data2 = data1 + i;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_flag_t *flags2 = flags1 + i;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
data1 += t1->w << 2;
|
|
|
|
flags1 += t1->flags_stride << 2;
|
|
|
|
}
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data2 = data1 + i;
|
2012-10-25 19:23:54 +02:00
|
|
|
opj_flag_t *flags2 = flags1 + i;
|
|
|
|
for (j = k; j < t1->h; ++j) {
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf);
|
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
|
|
|
void opj_t1_dec_refpass_mqc_vsc(
|
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno)
|
2012-10-25 19:23:54 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, poshalf, neghalf;
|
2012-10-25 19:23:54 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 vsc;
|
2012-10-25 19:23:54 +02:00
|
|
|
one = 1 << bpno;
|
|
|
|
poshalf = one >> 1;
|
|
|
|
neghalf = bpno > 0 ? -poshalf : -1;
|
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
|
|
|
opj_t1_dec_refpass_step_mqc_vsc(
|
|
|
|
t1,
|
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
|
|
|
poshalf,
|
|
|
|
neghalf,
|
|
|
|
vsc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2012-09-27 16:09:41 +02:00
|
|
|
void opj_t1_enc_clnpass_step(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-09-27 16:09:41 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 one,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_UINT32 partial,
|
|
|
|
OPJ_UINT32 vsc)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-09-27 16:09:41 +02:00
|
|
|
OPJ_INT32 v;
|
|
|
|
OPJ_UINT32 flag;
|
2005-12-08 10:38:47 +01:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
2007-05-21 14:50:03 +02:00
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
2005-12-08 10:38:47 +01:00
|
|
|
if (partial) {
|
|
|
|
goto LABEL_PARTIAL;
|
|
|
|
}
|
2007-05-21 14:50:03 +02:00
|
|
|
if (!(*flagsp & (T1_SIG | T1_VISIT))) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
2012-10-05 11:10:15 +02:00
|
|
|
v = opj_int_abs(*datap) & one ? 1 : 0;
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_encode(mqc, v);
|
2005-12-08 10:38:47 +01:00
|
|
|
if (v) {
|
2005-12-02 14:34:15 +01:00
|
|
|
LABEL_PARTIAL:
|
2012-10-05 11:10:15 +02:00
|
|
|
*nmsedec += opj_t1_getnmsedec_sig(opj_int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
2007-05-22 15:14:13 +02:00
|
|
|
v = *datap < 0 ? 1 : 0;
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_encode(mqc, v ^ opj_t1_getspb(flag));
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
2007-05-21 14:50:03 +02:00
|
|
|
*flagsp &= ~T1_VISIT;
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass_step_partial(
|
2010-04-08 19:22:58 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf)
|
2010-04-08 19:22:58 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, flag;
|
2010-04-08 19:22:58 +02:00
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
2011-08-10 10:12:10 +02:00
|
|
|
OPJ_ARG_NOT_USED(orient);
|
|
|
|
|
2010-04-08 19:22:58 +02:00
|
|
|
flag = *flagsp;
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
|
|
|
v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
|
2010-04-08 19:22:58 +02:00
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2010-04-08 19:22:58 +02:00
|
|
|
*flagsp &= ~T1_VISIT;
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass_step(
|
2010-04-08 19:22:58 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf)
|
2010-04-08 19:22:58 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, flag;
|
2010-04-08 19:22:58 +02:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
flag = *flagsp;
|
|
|
|
if (!(flag & (T1_SIG | T1_VISIT))) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
|
|
|
if (opj_mqc_decode(mqc)) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
|
|
|
v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
|
2010-04-08 19:22:58 +02:00
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2010-04-08 19:22:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*flagsp &= ~T1_VISIT;
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass_step_vsc(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_INT32 partial,
|
|
|
|
OPJ_INT32 vsc)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v, flag;
|
2005-12-08 10:38:47 +01:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
2007-05-21 14:50:03 +02:00
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
2005-12-08 10:38:47 +01:00
|
|
|
if (partial) {
|
|
|
|
goto LABEL_PARTIAL;
|
|
|
|
}
|
|
|
|
if (!(flag & (T1_SIG | T1_VISIT))) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
|
|
|
if (opj_mqc_decode(mqc)) {
|
2005-12-02 14:34:15 +01:00
|
|
|
LABEL_PARTIAL:
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
|
|
|
v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
|
2007-05-22 15:14:13 +02:00
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
2007-05-21 14:50:03 +02:00
|
|
|
*flagsp &= ~T1_VISIT;
|
2010-04-08 19:22:58 +02:00
|
|
|
}
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2012-09-27 16:09:41 +02:00
|
|
|
void opj_t1_enc_clnpass(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-09-27 16:09:41 +02:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 *nmsedec,
|
|
|
|
OPJ_UINT32 cblksty)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-09-27 16:09:41 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
|
|
|
OPJ_INT32 one;
|
|
|
|
OPJ_UINT32 agg, runlen, vsc;
|
2005-12-08 10:38:47 +01:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
*nmsedec = 0;
|
|
|
|
one = 1 << (bpno + T1_NMSEDEC_FRACBITS);
|
2007-05-22 15:14:13 +02:00
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
if (k + 3 < t1->h) {
|
2005-12-08 10:38:47 +01:00
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_VSC) {
|
2007-05-22 15:14:13 +02:00
|
|
|
agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| (MACRO_t1_flags(1 + k + 3,1 + i)
|
2005-12-08 10:38:47 +01:00
|
|
|
& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
|
|
|
|
} else {
|
2007-05-22 15:14:13 +02:00
|
|
|
agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
agg = 0;
|
|
|
|
}
|
|
|
|
if (agg) {
|
2007-05-21 15:08:10 +02:00
|
|
|
for (runlen = 0; runlen < 4; ++runlen) {
|
2012-10-05 11:10:15 +02:00
|
|
|
if (opj_int_abs(t1->data[((k + runlen)*t1->w) + i]) & one)
|
2005-12-08 10:38:47 +01:00
|
|
|
break;
|
|
|
|
}
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
|
|
|
|
opj_mqc_encode(mqc, runlen != 4);
|
2005-12-08 10:38:47 +01:00
|
|
|
if (runlen == 4) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
|
|
|
|
opj_mqc_encode(mqc, runlen >> 1);
|
|
|
|
opj_mqc_encode(mqc, runlen & 1);
|
2005-12-08 10:38:47 +01:00
|
|
|
} else {
|
|
|
|
runlen = 0;
|
|
|
|
}
|
2007-05-22 15:14:13 +02:00
|
|
|
for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
2012-09-27 16:09:41 +02:00
|
|
|
opj_t1_enc_clnpass_step(
|
2007-05-22 15:14:13 +02:00
|
|
|
t1,
|
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
|
|
|
orient,
|
|
|
|
bpno,
|
|
|
|
one,
|
|
|
|
nmsedec,
|
|
|
|
agg && (j == k + runlen),
|
|
|
|
vsc);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-27 11:10:17 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 17:50:58 +02:00
|
|
|
static void opj_t1_dec_clnpass(
|
2007-05-21 15:08:10 +02:00
|
|
|
opj_t1_t *t1,
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_INT32 orient,
|
|
|
|
OPJ_INT32 cblksty)
|
2007-05-21 15:08:10 +02:00
|
|
|
{
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 one, half, oneplushalf, agg, runlen, vsc;
|
2012-10-25 19:31:18 +02:00
|
|
|
OPJ_UINT32 i, j, k;
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 segsym = cblksty & J2K_CCP_CBLKSTY_SEGSYM;
|
2005-12-08 10:38:47 +01:00
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
one = 1 << bpno;
|
|
|
|
half = one >> 1;
|
|
|
|
oneplushalf = one | half;
|
2010-04-08 19:22:58 +02:00
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_VSC) {
|
2007-05-22 15:14:13 +02:00
|
|
|
for (k = 0; k < t1->h; k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
|
|
|
if (k + 3 < t1->h) {
|
|
|
|
agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| (MACRO_t1_flags(1 + k + 3,1 + i)
|
2005-12-08 10:38:47 +01:00
|
|
|
& (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
|
|
|
|
} else {
|
|
|
|
agg = 0;
|
|
|
|
}
|
|
|
|
if (agg) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
|
|
|
|
if (!opj_mqc_decode(mqc)) {
|
2005-12-08 10:38:47 +01:00
|
|
|
continue;
|
|
|
|
}
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
|
|
|
|
runlen = opj_mqc_decode(mqc);
|
|
|
|
runlen = (runlen << 1) | opj_mqc_decode(mqc);
|
2005-12-08 10:38:47 +01:00
|
|
|
} else {
|
|
|
|
runlen = 0;
|
|
|
|
}
|
2007-05-22 15:14:13 +02:00
|
|
|
for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
|
2010-04-08 19:22:58 +02:00
|
|
|
vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0;
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step_vsc(
|
2007-05-21 15:08:10 +02:00
|
|
|
t1,
|
2007-05-22 15:14:13 +02:00
|
|
|
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
|
|
|
&t1->data[(j * t1->w) + i],
|
2007-05-21 15:08:10 +02:00
|
|
|
orient,
|
|
|
|
oneplushalf,
|
|
|
|
agg && (j == k + runlen),
|
|
|
|
vsc);
|
2005-12-08 10:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-04-08 19:22:58 +02:00
|
|
|
} else {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data1 = t1->data;
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flags1 = &t1->flags[1];
|
2010-04-08 19:22:58 +02:00
|
|
|
for (k = 0; k < (t1->h & ~3); k += 4) {
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data2 = data1 + i;
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flags2 = flags1 + i;
|
2010-04-08 19:22:58 +02:00
|
|
|
agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)
|
|
|
|
|| MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH));
|
|
|
|
if (agg) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
|
|
|
|
if (!opj_mqc_decode(mqc)) {
|
2010-04-08 19:22:58 +02:00
|
|
|
continue;
|
|
|
|
}
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
|
|
|
|
runlen = opj_mqc_decode(mqc);
|
|
|
|
runlen = (runlen << 1) | opj_mqc_decode(mqc);
|
2010-04-08 19:22:58 +02:00
|
|
|
flags2 += runlen * t1->flags_stride;
|
|
|
|
data2 += runlen * t1->w;
|
|
|
|
for (j = k + runlen; j < k + 4 && j < t1->h; ++j) {
|
|
|
|
flags2 += t1->flags_stride;
|
|
|
|
if (agg && (j == k + runlen)) {
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step_partial(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
} else {
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
}
|
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
flags2 += t1->flags_stride;
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
data2 += t1->w;
|
|
|
|
flags2 += t1->flags_stride;
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data1 += t1->w << 2;
|
|
|
|
flags1 += t1->flags_stride << 2;
|
|
|
|
}
|
|
|
|
for (i = 0; i < t1->w; ++i) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 *data2 = data1 + i;
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flags2 = flags1 + i;
|
2010-04-08 19:22:58 +02:00
|
|
|
for (j = k; j < t1->h; ++j) {
|
|
|
|
flags2 += t1->flags_stride;
|
2012-10-25 17:50:58 +02:00
|
|
|
opj_t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf);
|
2010-04-08 19:22:58 +02:00
|
|
|
data2 += t1->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-08 10:38:47 +01:00
|
|
|
if (segsym) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32 v = 0;
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, T1_CTXNO_UNI);
|
|
|
|
v = opj_mqc_decode(mqc);
|
|
|
|
v = (v << 1) | opj_mqc_decode(mqc);
|
|
|
|
v = (v << 1) | opj_mqc_decode(mqc);
|
|
|
|
v = (v << 1) | opj_mqc_decode(mqc);
|
2005-12-08 10:38:47 +01:00
|
|
|
/*
|
|
|
|
if (v!=0xa) {
|
|
|
|
opj_event_msg(t1->cinfo, EVT_WARNING, "Bad segmentation symbol %x\n", v);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
2005-12-02 14:34:15 +01:00
|
|
|
|
2003-11-27 11:10:17 +01:00
|
|
|
|
2005-12-02 14:34:15 +01:00
|
|
|
/** mod fixed_quality */
|
2012-10-25 19:27:22 +02:00
|
|
|
static OPJ_FLOAT64 opj_t1_getwmsedec(
|
2012-03-15 11:23:20 +01:00
|
|
|
OPJ_INT32 nmsedec,
|
|
|
|
OPJ_UINT32 compno,
|
|
|
|
OPJ_UINT32 level,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 bpno,
|
|
|
|
OPJ_UINT32 qmfbid,
|
|
|
|
OPJ_FLOAT64 stepsize,
|
|
|
|
OPJ_UINT32 numcomps,
|
|
|
|
const OPJ_FLOAT64 * mct_norms)
|
|
|
|
{
|
|
|
|
OPJ_FLOAT64 w1 = 1, w2, wmsedec;
|
2012-10-26 12:04:55 +02:00
|
|
|
OPJ_ARG_NOT_USED(numcomps);
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
if (mct_norms) {
|
|
|
|
w1 = mct_norms[compno];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qmfbid == 1) {
|
2012-08-17 10:27:57 +02:00
|
|
|
w2 = opj_dwt_getnorm(level, orient);
|
2012-03-15 11:23:20 +01:00
|
|
|
} else { /* if (qmfbid == 0) */
|
2012-08-17 10:27:57 +02:00
|
|
|
w2 = opj_dwt_getnorm_real(level, orient);
|
2012-03-15 11:23:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
wmsedec = w1 * w2 * stepsize * (1 << bpno);
|
|
|
|
wmsedec *= wmsedec * nmsedec / 8192.0;
|
|
|
|
|
|
|
|
return wmsedec;
|
|
|
|
}
|
|
|
|
|
2012-11-15 14:13:36 +01:00
|
|
|
OPJ_BOOL opj_t1_allocate_buffers(
|
2007-05-22 15:14:13 +02:00
|
|
|
opj_t1_t *t1,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_UINT32 w,
|
|
|
|
OPJ_UINT32 h)
|
2007-05-22 15:14:13 +02:00
|
|
|
{
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_UINT32 datasize=w * h;
|
|
|
|
OPJ_UINT32 flagssize;
|
2007-05-22 15:14:13 +02:00
|
|
|
|
|
|
|
if(datasize > t1->datasize){
|
2007-08-21 14:13:54 +02:00
|
|
|
opj_aligned_free(t1->data);
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
t1->data = (OPJ_INT32*) opj_aligned_malloc(datasize * sizeof(OPJ_INT32));
|
2007-05-22 15:14:13 +02:00
|
|
|
if(!t1->data){
|
2011-05-18 13:02:27 +02:00
|
|
|
return OPJ_FALSE;
|
2007-05-22 15:14:13 +02:00
|
|
|
}
|
|
|
|
t1->datasize=datasize;
|
|
|
|
}
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
memset(t1->data,0,datasize * sizeof(OPJ_INT32));
|
2007-05-22 15:14:13 +02:00
|
|
|
|
|
|
|
t1->flags_stride=w+2;
|
2007-08-21 14:30:08 +02:00
|
|
|
flagssize=t1->flags_stride * (h+2);
|
2007-05-22 15:14:13 +02:00
|
|
|
|
|
|
|
if(flagssize > t1->flagssize){
|
2007-08-21 14:13:54 +02:00
|
|
|
opj_aligned_free(t1->flags);
|
2012-10-24 16:06:10 +02:00
|
|
|
t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(opj_flag_t));
|
2007-05-22 15:14:13 +02:00
|
|
|
if(!t1->flags){
|
2011-05-18 13:02:27 +02:00
|
|
|
return OPJ_FALSE;
|
2007-05-22 15:14:13 +02:00
|
|
|
}
|
|
|
|
t1->flagssize=flagssize;
|
|
|
|
}
|
2012-10-24 16:06:10 +02:00
|
|
|
memset(t1->flags,0,flagssize * sizeof(opj_flag_t));
|
2007-05-22 15:14:13 +02:00
|
|
|
|
|
|
|
t1->w=w;
|
|
|
|
t1->h=h;
|
2007-08-21 14:13:54 +02:00
|
|
|
|
2011-05-18 13:02:27 +02:00
|
|
|
return OPJ_TRUE;
|
2007-05-22 15:14:13 +02:00
|
|
|
}
|
|
|
|
|
2005-12-02 14:34:15 +01:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
|
2011-09-19 15:04:04 +02:00
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Creates a new Tier 1 handle
|
|
|
|
* and initializes the look-up tables of the Tier-1 coder/decoder
|
|
|
|
* @return a new T1 handle if successful, returns NULL otherwise
|
|
|
|
*/
|
2012-08-17 16:28:50 +02:00
|
|
|
opj_t1_t* opj_t1_create()
|
2011-09-19 15:04:04 +02:00
|
|
|
{
|
|
|
|
opj_t1_t *l_t1 = 00;
|
|
|
|
|
|
|
|
l_t1 = (opj_t1_t*) opj_malloc(sizeof(opj_t1_t));
|
2012-03-15 11:23:20 +01:00
|
|
|
if (!l_t1) {
|
2011-09-19 15:04:04 +02:00
|
|
|
return 00;
|
|
|
|
}
|
|
|
|
memset(l_t1,0,sizeof(opj_t1_t));
|
|
|
|
|
|
|
|
/* create MQC and RAW handles */
|
2012-10-03 14:12:33 +02:00
|
|
|
l_t1->mqc = opj_mqc_create();
|
2012-03-15 11:23:20 +01:00
|
|
|
if (! l_t1->mqc) {
|
2012-08-17 16:28:50 +02:00
|
|
|
opj_t1_destroy(l_t1);
|
2011-09-19 15:04:04 +02:00
|
|
|
return 00;
|
|
|
|
}
|
2012-03-15 11:23:20 +01:00
|
|
|
|
2012-10-24 15:18:12 +02:00
|
|
|
l_t1->raw = opj_raw_create();
|
2012-03-15 11:23:20 +01:00
|
|
|
if (! l_t1->raw) {
|
2012-08-17 16:28:50 +02:00
|
|
|
opj_t1_destroy(l_t1);
|
2011-09-19 15:04:04 +02:00
|
|
|
return 00;
|
|
|
|
}
|
2012-03-15 11:23:20 +01:00
|
|
|
|
2011-09-19 15:04:04 +02:00
|
|
|
return l_t1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys a previously created T1 handle
|
|
|
|
*
|
|
|
|
* @param p_t1 Tier 1 handle to destroy
|
|
|
|
*/
|
2012-08-17 16:28:50 +02:00
|
|
|
void opj_t1_destroy(opj_t1_t *p_t1)
|
2011-09-19 15:04:04 +02:00
|
|
|
{
|
2012-08-17 16:28:50 +02:00
|
|
|
if (! p_t1) {
|
2011-09-19 15:04:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* destroy MQC and RAW handles */
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_destroy(p_t1->mqc);
|
2011-09-19 15:04:04 +02:00
|
|
|
p_t1->mqc = 00;
|
2012-10-24 15:18:12 +02:00
|
|
|
opj_raw_destroy(p_t1->raw);
|
2011-09-19 15:04:04 +02:00
|
|
|
p_t1->raw = 00;
|
2012-08-17 16:28:50 +02:00
|
|
|
|
|
|
|
if (p_t1->data) {
|
2011-09-19 15:04:04 +02:00
|
|
|
opj_aligned_free(p_t1->data);
|
|
|
|
p_t1->data = 00;
|
|
|
|
}
|
2012-08-17 16:28:50 +02:00
|
|
|
|
|
|
|
if (p_t1->flags) {
|
2011-09-19 15:04:04 +02:00
|
|
|
opj_aligned_free(p_t1->flags);
|
|
|
|
p_t1->flags = 00;
|
|
|
|
}
|
2012-08-17 16:28:50 +02:00
|
|
|
|
2011-09-19 15:04:04 +02:00
|
|
|
opj_free(p_t1);
|
|
|
|
}
|
2011-09-19 18:09:19 +02:00
|
|
|
|
2012-11-15 14:13:36 +01:00
|
|
|
OPJ_BOOL opj_t1_decode_cblks( opj_t1_t* t1,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_tilecomp_t* tilec,
|
2012-08-17 16:28:50 +02:00
|
|
|
opj_tccp_t* tccp
|
|
|
|
)
|
2011-09-19 18:09:19 +02:00
|
|
|
{
|
|
|
|
OPJ_UINT32 resno, bandno, precno, cblkno;
|
|
|
|
OPJ_UINT32 tile_w = tilec->x1 - tilec->x0;
|
|
|
|
|
|
|
|
for (resno = 0; resno < tilec->minimum_num_resolutions; ++resno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_resolution_t* res = &tilec->resolutions[resno];
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
for (bandno = 0; bandno < res->numbands; ++bandno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_band_t* restrict band = &res->bands[bandno];
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
for (precno = 0; precno < res->pw * res->ph; ++precno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_precinct_t* precinct = &band->precincts[precno];
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
|
2011-09-19 18:09:19 +02:00
|
|
|
OPJ_INT32* restrict datap;
|
2012-10-25 19:23:54 +02:00
|
|
|
/*void* restrict tiledp;*/
|
2011-09-19 18:09:19 +02:00
|
|
|
OPJ_UINT32 cblk_w, cblk_h;
|
|
|
|
OPJ_INT32 x, y;
|
|
|
|
OPJ_UINT32 i, j;
|
|
|
|
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
if (OPJ_FALSE == opj_t1_decode_cblk(
|
|
|
|
t1,
|
|
|
|
cblk,
|
|
|
|
band->bandno,
|
|
|
|
tccp->roishift,
|
|
|
|
tccp->cblksty)) {
|
|
|
|
return OPJ_FALSE;
|
|
|
|
}
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
x = cblk->x0 - band->x0;
|
|
|
|
y = cblk->y0 - band->y0;
|
|
|
|
if (band->bandno & 1) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
|
2011-09-19 18:09:19 +02:00
|
|
|
x += pres->x1 - pres->x0;
|
|
|
|
}
|
|
|
|
if (band->bandno & 2) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
|
2011-09-19 18:09:19 +02:00
|
|
|
y += pres->y1 - pres->y0;
|
|
|
|
}
|
|
|
|
|
|
|
|
datap=t1->data;
|
|
|
|
cblk_w = t1->w;
|
|
|
|
cblk_h = t1->h;
|
|
|
|
|
|
|
|
if (tccp->roishift) {
|
|
|
|
OPJ_INT32 thresh = 1 << tccp->roishift;
|
|
|
|
for (j = 0; j < cblk_h; ++j) {
|
|
|
|
for (i = 0; i < cblk_w; ++i) {
|
|
|
|
OPJ_INT32 val = datap[(j * cblk_w) + i];
|
|
|
|
OPJ_INT32 mag = abs(val);
|
|
|
|
if (mag >= thresh) {
|
|
|
|
mag >>= tccp->roishift;
|
|
|
|
datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 19:23:54 +02:00
|
|
|
/*tiledp=(void*)&tilec->data[(y * tile_w) + x];*/
|
2011-09-19 18:09:19 +02:00
|
|
|
if (tccp->qmfbid == 1) {
|
2012-11-15 17:46:08 +01:00
|
|
|
OPJ_INT32* restrict tiledp = &tilec->data[(y * tile_w) + x];
|
2011-09-19 18:09:19 +02:00
|
|
|
for (j = 0; j < cblk_h; ++j) {
|
|
|
|
for (i = 0; i < cblk_w; ++i) {
|
|
|
|
OPJ_INT32 tmp = datap[(j * cblk_w) + i];
|
|
|
|
((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { /* if (tccp->qmfbid == 0) */
|
2012-11-16 09:29:43 +01:00
|
|
|
OPJ_FLOAT32* restrict tiledp = (OPJ_FLOAT32*) &tilec->data[(y * tile_w) + x];
|
2011-09-19 18:09:19 +02:00
|
|
|
for (j = 0; j < cblk_h; ++j) {
|
2012-11-16 09:29:43 +01:00
|
|
|
OPJ_FLOAT32* restrict tiledp2 = tiledp;
|
2011-09-19 18:09:19 +02:00
|
|
|
for (i = 0; i < cblk_w; ++i) {
|
2012-11-16 09:29:43 +01:00
|
|
|
OPJ_FLOAT32 tmp = *datap * band->stepsize;
|
2012-10-25 19:23:54 +02:00
|
|
|
*tiledp2 = tmp;
|
|
|
|
datap++;
|
|
|
|
tiledp2++;
|
|
|
|
/*float tmp = datap[(j * cblk_w) + i] * band->stepsize;
|
|
|
|
((float*)tiledp)[(j * tile_w) + i] = tmp;*/
|
|
|
|
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
2012-10-25 19:23:54 +02:00
|
|
|
tiledp += tile_w;
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-26 12:04:55 +02:00
|
|
|
/*opj_free(cblk->data);
|
|
|
|
opj_free(cblk->segs);*/
|
2012-09-10 11:04:47 +02:00
|
|
|
/*cblk->segs = 00;*/
|
2011-09-19 18:09:19 +02:00
|
|
|
} /* cblkno */
|
2012-10-26 12:04:55 +02:00
|
|
|
/*opj_free(precinct->cblks.dec);*/
|
2011-09-19 18:09:19 +02:00
|
|
|
} /* precno */
|
|
|
|
} /* bandno */
|
|
|
|
} /* resno */
|
2012-08-22 20:45:31 +02:00
|
|
|
return OPJ_TRUE;
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-15 14:13:36 +01:00
|
|
|
OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_cblk_dec_t* cblk,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_UINT32 roishift,
|
|
|
|
OPJ_UINT32 cblksty)
|
2011-09-19 18:09:19 +02:00
|
|
|
{
|
|
|
|
opj_raw_t *raw = t1->raw; /* RAW component */
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
OPJ_INT32 bpno;
|
|
|
|
OPJ_UINT32 passtype;
|
|
|
|
OPJ_UINT32 segno, passno;
|
|
|
|
OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */
|
|
|
|
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
if(!opj_t1_allocate_buffers(
|
2011-09-19 18:09:19 +02:00
|
|
|
t1,
|
|
|
|
cblk->x1 - cblk->x0,
|
|
|
|
cblk->y1 - cblk->y0))
|
|
|
|
{
|
2012-08-23 21:34:41 +02:00
|
|
|
return OPJ_FALSE;
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bpno = roishift + cblk->numbps - 1;
|
|
|
|
passtype = 2;
|
|
|
|
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_resetstates(mqc);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
for (segno = 0; segno < cblk->real_num_segs; ++segno) {
|
|
|
|
opj_tcd_seg_t *seg = &cblk->segs[segno];
|
|
|
|
|
|
|
|
/* BYPASS mode */
|
|
|
|
type = ((bpno <= ((OPJ_INT32) (cblk->numbps) - 1) - 4) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
|
|
|
|
/* FIXME: slviewer gets here with a null pointer. Why? Partially downloaded and/or corrupt textures? */
|
|
|
|
if(seg->data == 00){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (type == T1_TYPE_RAW) {
|
2012-10-24 15:18:12 +02:00
|
|
|
opj_raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
|
2011-09-19 18:09:19 +02:00
|
|
|
} else {
|
2012-10-03 14:12:33 +02:00
|
|
|
if (OPJ_FALSE == opj_mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len)) {
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
return OPJ_FALSE;
|
|
|
|
}
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (passno = 0; passno < seg->real_num_passes; ++passno) {
|
2012-10-25 19:23:54 +02:00
|
|
|
switch (passtype) {
|
|
|
|
case 0:
|
|
|
|
if (type == T1_TYPE_RAW) {
|
|
|
|
opj_t1_dec_sigpass_raw(t1, bpno+1, orient, cblksty);
|
|
|
|
} else {
|
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_VSC) {
|
|
|
|
opj_t1_dec_sigpass_mqc_vsc(t1, bpno+1, orient);
|
|
|
|
} else {
|
|
|
|
opj_t1_dec_sigpass_mqc(t1, bpno+1, orient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (type == T1_TYPE_RAW) {
|
|
|
|
opj_t1_dec_refpass_raw(t1, bpno+1, cblksty);
|
|
|
|
} else {
|
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_VSC) {
|
|
|
|
opj_t1_dec_refpass_mqc_vsc(t1, bpno+1);
|
|
|
|
} else {
|
|
|
|
opj_t1_dec_refpass_mqc(t1, bpno+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
opj_t1_dec_clnpass(t1, bpno+1, orient, cblksty);
|
|
|
|
break;
|
|
|
|
}
|
2011-09-19 18:09:19 +02:00
|
|
|
|
|
|
|
if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_resetstates(mqc);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
if (++passtype == 3) {
|
|
|
|
passtype = 0;
|
|
|
|
bpno--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-22 20:45:31 +02:00
|
|
|
return OPJ_TRUE;
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 19:23:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-15 14:13:36 +01:00
|
|
|
OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_tile_t *tile,
|
2012-10-25 17:15:02 +02:00
|
|
|
opj_tcp_t *tcp,
|
2012-08-17 16:28:50 +02:00
|
|
|
const OPJ_FLOAT64 * mct_norms
|
|
|
|
)
|
2012-03-15 11:23:20 +01:00
|
|
|
{
|
|
|
|
OPJ_UINT32 compno, resno, bandno, precno, cblkno;
|
|
|
|
|
|
|
|
tile->distotile = 0; /* fixed_quality */
|
|
|
|
|
|
|
|
for (compno = 0; compno < tile->numcomps; ++compno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
|
2012-03-15 11:23:20 +01:00
|
|
|
opj_tccp_t* tccp = &tcp->tccps[compno];
|
|
|
|
OPJ_UINT32 tile_w = tilec->x1 - tilec->x0;
|
|
|
|
|
|
|
|
for (resno = 0; resno < tilec->numresolutions; ++resno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
for (bandno = 0; bandno < res->numbands; ++bandno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_band_t* restrict band = &res->bands[bandno];
|
2012-08-17 16:28:50 +02:00
|
|
|
OPJ_INT32 bandconst = 8192 * 8192 / ((OPJ_INT32) floor(band->stepsize * 8192));
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
for (precno = 0; precno < res->pw * res->ph; ++precno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_precinct_t *prc = &band->precincts[precno];
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
|
2012-03-15 11:23:20 +01:00
|
|
|
OPJ_INT32 * restrict datap;
|
|
|
|
OPJ_INT32* restrict tiledp;
|
|
|
|
OPJ_UINT32 cblk_w;
|
|
|
|
OPJ_UINT32 cblk_h;
|
|
|
|
OPJ_UINT32 i, j;
|
|
|
|
|
|
|
|
OPJ_INT32 x = cblk->x0 - band->x0;
|
|
|
|
OPJ_INT32 y = cblk->y0 - band->y0;
|
|
|
|
if (band->bandno & 1) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
|
2012-03-15 11:23:20 +01:00
|
|
|
x += pres->x1 - pres->x0;
|
|
|
|
}
|
|
|
|
if (band->bandno & 2) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
|
2012-03-15 11:23:20 +01:00
|
|
|
y += pres->y1 - pres->y0;
|
|
|
|
}
|
|
|
|
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
if(!opj_t1_allocate_buffers(
|
2012-03-15 11:23:20 +01:00
|
|
|
t1,
|
|
|
|
cblk->x1 - cblk->x0,
|
|
|
|
cblk->y1 - cblk->y0))
|
|
|
|
{
|
|
|
|
return OPJ_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
datap=t1->data;
|
|
|
|
cblk_w = t1->w;
|
|
|
|
cblk_h = t1->h;
|
|
|
|
|
|
|
|
tiledp=&tilec->data[(y * tile_w) + x];
|
|
|
|
if (tccp->qmfbid == 1) {
|
|
|
|
for (j = 0; j < cblk_h; ++j) {
|
|
|
|
for (i = 0; i < cblk_w; ++i) {
|
|
|
|
OPJ_INT32 tmp = tiledp[(j * tile_w) + i];
|
|
|
|
datap[(j * cblk_w) + i] = tmp << T1_NMSEDEC_FRACBITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { /* if (tccp->qmfbid == 0) */
|
|
|
|
for (j = 0; j < cblk_h; ++j) {
|
|
|
|
for (i = 0; i < cblk_w; ++i) {
|
|
|
|
OPJ_INT32 tmp = tiledp[(j * tile_w) + i];
|
|
|
|
datap[(j * cblk_w) + i] =
|
2012-10-05 11:10:15 +02:00
|
|
|
opj_int_fix_mul(
|
2012-03-15 11:23:20 +01:00
|
|
|
tmp,
|
2012-08-17 16:28:50 +02:00
|
|
|
bandconst) >> (11 - T1_NMSEDEC_FRACBITS);
|
2012-03-15 11:23:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-27 15:51:01 +02:00
|
|
|
opj_t1_encode_cblk(
|
2012-03-15 11:23:20 +01:00
|
|
|
t1,
|
|
|
|
cblk,
|
|
|
|
band->bandno,
|
|
|
|
compno,
|
|
|
|
tilec->numresolutions - 1 - resno,
|
|
|
|
tccp->qmfbid,
|
|
|
|
band->stepsize,
|
|
|
|
tccp->cblksty,
|
|
|
|
tile->numcomps,
|
|
|
|
tile,
|
|
|
|
mct_norms);
|
|
|
|
|
|
|
|
} /* cblkno */
|
|
|
|
} /* precno */
|
|
|
|
} /* bandno */
|
|
|
|
} /* resno */
|
|
|
|
} /* compno */
|
|
|
|
return OPJ_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** mod fixed_quality */
|
2012-09-27 15:51:01 +02:00
|
|
|
void opj_t1_encode_cblk(opj_t1_t *t1,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_cblk_enc_t* cblk,
|
2012-09-27 15:51:01 +02:00
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_UINT32 compno,
|
|
|
|
OPJ_UINT32 level,
|
|
|
|
OPJ_UINT32 qmfbid,
|
|
|
|
OPJ_FLOAT64 stepsize,
|
|
|
|
OPJ_UINT32 cblksty,
|
|
|
|
OPJ_UINT32 numcomps,
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_tile_t * tile,
|
2012-09-27 15:51:01 +02:00
|
|
|
const OPJ_FLOAT64 * mct_norms)
|
2012-03-15 11:23:20 +01:00
|
|
|
{
|
|
|
|
OPJ_FLOAT64 cumwmsedec = 0.0;
|
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
OPJ_UINT32 passno;
|
|
|
|
OPJ_INT32 bpno;
|
|
|
|
OPJ_UINT32 passtype;
|
|
|
|
OPJ_INT32 nmsedec = 0;
|
|
|
|
OPJ_INT32 max;
|
|
|
|
OPJ_UINT32 i;
|
|
|
|
OPJ_BYTE type = T1_TYPE_MQ;
|
|
|
|
OPJ_FLOAT64 tempwmsedec;
|
|
|
|
|
|
|
|
max = 0;
|
|
|
|
for (i = 0; i < t1->w * t1->h; ++i) {
|
|
|
|
OPJ_INT32 tmp = abs(t1->data[i]);
|
2012-10-05 11:10:15 +02:00
|
|
|
max = opj_int_max(max, tmp);
|
2012-03-15 11:23:20 +01:00
|
|
|
}
|
|
|
|
|
2012-10-05 11:10:15 +02:00
|
|
|
cblk->numbps = max ? (opj_int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
bpno = cblk->numbps - 1;
|
|
|
|
passtype = 2;
|
|
|
|
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_resetstates(mqc);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
|
|
|
|
opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
|
|
|
|
opj_mqc_init_enc(mqc, cblk->data);
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
for (passno = 0; bpno >= 0; ++passno) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_pass_t *pass = &cblk->passes[passno];
|
2012-03-15 11:23:20 +01:00
|
|
|
OPJ_UINT32 correction = 3;
|
|
|
|
type = ((bpno < ((OPJ_INT32) (cblk->numbps) - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
|
|
|
|
|
|
|
|
switch (passtype) {
|
|
|
|
case 0:
|
2012-08-17 16:56:42 +02:00
|
|
|
opj_t1_enc_sigpass(t1, bpno, orient, &nmsedec, type, cblksty);
|
2012-03-15 11:23:20 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-09-27 15:56:48 +02:00
|
|
|
opj_t1_enc_refpass(t1, bpno, &nmsedec, type, cblksty);
|
2012-03-15 11:23:20 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-09-27 16:09:41 +02:00
|
|
|
opj_t1_enc_clnpass(t1, bpno, orient, &nmsedec, cblksty);
|
2012-03-15 11:23:20 +01:00
|
|
|
/* code switch SEGMARK (i.e. SEGSYM) */
|
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_SEGSYM)
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_segmark_enc(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fixed_quality */
|
2012-10-25 19:27:22 +02:00
|
|
|
tempwmsedec = opj_t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps,mct_norms) ;
|
2012-03-15 11:23:20 +01:00
|
|
|
cumwmsedec += tempwmsedec;
|
|
|
|
tile->distotile += tempwmsedec;
|
|
|
|
|
|
|
|
/* Code switch "RESTART" (i.e. TERMALL) */
|
|
|
|
if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) && !((passtype == 2) && (bpno - 1 < 0))) {
|
|
|
|
if (type == T1_TYPE_RAW) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_flush(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
correction = 1;
|
|
|
|
/* correction = mqc_bypass_flush_enc(); */
|
|
|
|
} else { /* correction = mqc_restart_enc(); */
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_flush(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
correction = 1;
|
|
|
|
}
|
|
|
|
pass->term = 1;
|
|
|
|
} else {
|
|
|
|
if (((bpno < ((OPJ_INT32) (cblk->numbps) - 4) && (passtype > 0))
|
2012-11-13 16:16:35 +01:00
|
|
|
|| ((bpno == ((OPJ_INT32)cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) {
|
2012-03-15 11:23:20 +01:00
|
|
|
if (type == T1_TYPE_RAW) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_flush(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
correction = 1;
|
|
|
|
/* correction = mqc_bypass_flush_enc(); */
|
|
|
|
} else { /* correction = mqc_restart_enc(); */
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_flush(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
correction = 1;
|
|
|
|
}
|
|
|
|
pass->term = 1;
|
|
|
|
} else {
|
|
|
|
pass->term = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (++passtype == 3) {
|
|
|
|
passtype = 0;
|
|
|
|
bpno--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pass->term && bpno > 0) {
|
|
|
|
type = ((bpno < ((OPJ_INT32) (cblk->numbps) - 4)) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
|
|
|
|
if (type == T1_TYPE_RAW)
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_bypass_init_enc(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
else
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_restart_init_enc(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pass->distortiondec = cumwmsedec;
|
2012-10-03 14:12:33 +02:00
|
|
|
pass->rate = opj_mqc_numbytes(mqc) + correction; /* FIXME */
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
/* Code-switch "RESET" */
|
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_RESET)
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_reset_enc(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Code switch "ERTERM" (i.e. PTERM) */
|
|
|
|
if (cblksty & J2K_CCP_CBLKSTY_PTERM)
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_erterm_enc(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
else /* Default coding */ if (!(cblksty & J2K_CCP_CBLKSTY_LAZY))
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_flush(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
|
|
|
|
cblk->totalpasses = passno;
|
|
|
|
|
|
|
|
for (passno = 0; passno<cblk->totalpasses; passno++) {
|
2012-10-25 16:49:10 +02:00
|
|
|
opj_tcd_pass_t *pass = &cblk->passes[passno];
|
2012-10-03 14:12:33 +02:00
|
|
|
if (pass->rate > opj_mqc_numbytes(mqc))
|
|
|
|
pass->rate = opj_mqc_numbytes(mqc);
|
2012-03-15 11:23:20 +01:00
|
|
|
/*Preventing generation of FF as last data byte of a pass*/
|
|
|
|
if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){
|
|
|
|
pass->rate--;
|
|
|
|
}
|
|
|
|
pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
void opj_t1_dec_refpass_step( opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_INT32 poshalf,
|
|
|
|
OPJ_INT32 neghalf,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc)
|
2011-09-19 18:09:19 +02:00
|
|
|
{
|
|
|
|
OPJ_INT32 t;
|
|
|
|
OPJ_UINT32 v,flag;
|
|
|
|
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
opj_raw_t *raw = t1->raw; /* RAW component */
|
|
|
|
|
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
|
|
|
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI */
|
2011-09-19 18:09:19 +02:00
|
|
|
if (type == T1_TYPE_RAW) {
|
2012-10-24 15:18:12 +02:00
|
|
|
v = opj_raw_decode(raw);
|
2011-09-19 18:09:19 +02:00
|
|
|
} else {
|
2012-10-03 14:12:33 +02:00
|
|
|
v = opj_mqc_decode(mqc);
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
t = v ? poshalf : neghalf;
|
|
|
|
*datap += *datap < 0 ? -t : t;
|
|
|
|
*flagsp |= T1_REFINE;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|
2012-10-26 11:39:52 +02:00
|
|
|
|
2011-09-19 18:09:19 +02:00
|
|
|
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
void opj_t1_dec_sigpass_step( opj_t1_t *t1,
|
2012-10-24 16:06:10 +02:00
|
|
|
opj_flag_t *flagsp,
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
OPJ_INT32 *datap,
|
|
|
|
OPJ_UINT32 orient,
|
|
|
|
OPJ_INT32 oneplushalf,
|
|
|
|
OPJ_BYTE type,
|
|
|
|
OPJ_UINT32 vsc)
|
2011-09-19 18:09:19 +02:00
|
|
|
{
|
|
|
|
OPJ_UINT32 v, flag;
|
|
|
|
|
|
|
|
opj_raw_t *raw = t1->raw; /* RAW component */
|
|
|
|
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
|
|
|
|
|
|
|
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
|
|
|
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
|
|
|
if (type == T1_TYPE_RAW) {
|
2012-10-24 15:18:12 +02:00
|
|
|
if (opj_raw_decode(raw)) {
|
|
|
|
v = opj_raw_decode(raw); /* ESSAI */
|
2011-09-19 18:09:19 +02:00
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
} else {
|
2012-10-03 14:12:33 +02:00
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
|
|
|
|
if (opj_mqc_decode(mqc)) {
|
|
|
|
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
|
|
|
|
v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag);
|
2011-09-19 18:09:19 +02:00
|
|
|
*datap = v ? -oneplushalf : oneplushalf;
|
[trunk] remove old v1 style t1_decode_cblk function and rename t1_decode_cblk_v2 to opj_t1_decode_cblk
rename t1_dec_sigpass t1_dec_sigpass_step, t1_updateflags, t1_dec_refpass, t1_dec_refpass_step with opj_prefix and v2 type
delete unused functions in new V2 t1 framework: t1_dec_refpass_raw, t1_dec_refpass_mqc, t1_dec_refpass_mqc_vsc, t1_dec_refpass_step_raw, t1_dec_refpass_step_mqc, t1_dec_refpass_step_mqc_vsc, t1_dec_sigpass_raw, t1_dec_sigpass_mqc, t1_dec_sigpass_mqc_vsc, t1_dec_sigpass_step_raw, t1_dec_sigpass_step_mqc, t1_dec_sigpass_step_mqc_vsc
2012-09-27 15:28:44 +02:00
|
|
|
opj_t1_updateflags(flagsp, v, t1->flags_stride);
|
2011-09-19 18:09:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*flagsp |= T1_VISIT;
|
|
|
|
}
|
|
|
|
} /* VSC and BYPASS by Antonin */
|
|
|
|
|