OpenJPEG  2.3.0
Data Structures | Macros | Typedefs | Functions | Variables
dwt.c File Reference
#include <assert.h>
#include "opj_includes.h"

Data Structures

struct  dwt_local
 
union  opj_v4_t
 
struct  v4dwt_local
 
struct  opj_dwd_decode_h_job_t
 
struct  opj_dwd_decode_v_job_t
 

Macros

#define OPJ_SKIP_POISON
 
#define OPJ_WS(i)   v->mem[(i)*2]
 
#define OPJ_WD(i)   v->mem[(1+(i)*2)]
 
#define VREG_INT_COUNT   4
 Number of int32 values in a SSE2 register. More...
 
#define PARALLEL_COLS_53   (2*VREG_INT_COUNT)
 Number of columns that we can process in parallel in the vertical pass. More...
 
#define OPJ_S(i)   a[(i)*2]
 
#define OPJ_D(i)   a[(1+(i)*2)]
 
#define OPJ_S_(i)   ((i)<0?OPJ_S(0):((i)>=sn?OPJ_S(sn-1):OPJ_S(i)))
 
#define OPJ_D_(i)   ((i)<0?OPJ_D(0):((i)>=dn?OPJ_D(dn-1):OPJ_D(i)))
 
#define OPJ_SS_(i)   ((i)<0?OPJ_S(0):((i)>=dn?OPJ_S(dn-1):OPJ_S(i)))
 
#define OPJ_DD_(i)   ((i)<0?OPJ_D(0):((i)>=sn?OPJ_D(sn-1):OPJ_D(i)))
 
#define OPJ_S_off(i, off)   a[(OPJ_UINT32)(i)*2*4+off]
 
#define OPJ_D_off(i, off)   a[(1+(OPJ_UINT32)(i)*2)*4+off]
 
#define OPJ_S__off(i, off)   ((i)<0?OPJ_S_off(0,off):((i)>=sn?OPJ_S_off(sn-1,off):OPJ_S_off(i,off)))
 
#define OPJ_D__off(i, off)   ((i)<0?OPJ_D_off(0,off):((i)>=dn?OPJ_D_off(dn-1,off):OPJ_D_off(i,off)))
 
#define OPJ_SS__off(i, off)   ((i)<0?OPJ_S_off(0,off):((i)>=dn?OPJ_S_off(dn-1,off):OPJ_S_off(i,off)))
 
#define OPJ_DD__off(i, off)   ((i)<0?OPJ_D_off(0,off):((i)>=sn?OPJ_D_off(sn-1,off):OPJ_D_off(i,off)))
 

Typedefs

typedef void(* DWT1DFN) (const opj_dwt_t *v)
 Virtual function type for wavelet transform in 1-D. More...
 

Functions

static void opj_idwt53_h_cas0 (OPJ_INT32 *tmp, const OPJ_INT32 sn, const OPJ_INT32 len, OPJ_INT32 *tiledp)
 
static void opj_idwt53_h_cas1 (OPJ_INT32 *tmp, const OPJ_INT32 sn, const OPJ_INT32 len, OPJ_INT32 *tiledp)
 
static void opj_idwt53_h (const opj_dwt_t *dwt, OPJ_INT32 *tiledp)
 
static void opj_idwt3_v_cas0 (OPJ_INT32 *tmp, const OPJ_INT32 sn, const OPJ_INT32 len, OPJ_INT32 *tiledp_col, const OPJ_SIZE_T stride)
 Vertical inverse 5x3 wavelet transform for one column, when top-most pixel is on even coordinate. More...
 
static void opj_idwt3_v_cas1 (OPJ_INT32 *tmp, const OPJ_INT32 sn, const OPJ_INT32 len, OPJ_INT32 *tiledp_col, const OPJ_SIZE_T stride)
 Vertical inverse 5x3 wavelet transform for one column, when top-most pixel is on odd coordinate. More...
 
static void opj_idwt53_v (const opj_dwt_t *dwt, OPJ_INT32 *tiledp_col, OPJ_SIZE_T stride, OPJ_INT32 nb_cols)
 
OPJ_BOOL opj_dwt_encode (opj_tcd_tilecomp_t *tilec)
 Forward 5-3 wavelet transform in 2-D. More...
 
OPJ_BOOL opj_dwt_decode (opj_tcd_t *p_tcd, opj_tcd_tilecomp_t *tilec, OPJ_UINT32 numres)
 Inverse 5-3 wavelet transform in 2-D. More...
 
OPJ_UINT32 opj_dwt_getgain (OPJ_UINT32 orient)
 Get the gain of a subband for the reversible 5-3 DWT. More...
 
OPJ_FLOAT64 opj_dwt_getnorm (OPJ_UINT32 level, OPJ_UINT32 orient)
 Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT. More...
 
OPJ_BOOL opj_dwt_encode_real (opj_tcd_tilecomp_t *tilec)
 Forward 9-7 wavelet transform in 2-D. More...
 
OPJ_UINT32 opj_dwt_getgain_real (OPJ_UINT32 orient)
 Get the gain of a subband for the irreversible 9-7 DWT. More...
 
OPJ_FLOAT64 opj_dwt_getnorm_real (OPJ_UINT32 level, OPJ_UINT32 orient)
 Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT. More...
 
void opj_dwt_calc_explicit_stepsizes (opj_tccp_t *tccp, OPJ_UINT32 prec)
 Explicit calculation of the Quantization Stepsizes. More...
 
static void opj_dwt_decode_h_func (void *user_data, opj_tls_t *tls)
 
static void opj_dwt_decode_v_func (void *user_data, opj_tls_t *tls)
 
static void opj_dwt_interleave_partial_h (OPJ_INT32 *dest, OPJ_INT32 cas, opj_sparse_array_int32_t *sa, OPJ_UINT32 sa_line, OPJ_UINT32 sn, OPJ_UINT32 win_l_x0, OPJ_UINT32 win_l_x1, OPJ_UINT32 win_h_x0, OPJ_UINT32 win_h_x1)
 
static void opj_dwt_interleave_partial_v (OPJ_INT32 *dest, OPJ_INT32 cas, opj_sparse_array_int32_t *sa, OPJ_UINT32 sa_col, OPJ_UINT32 nb_cols, OPJ_UINT32 sn, OPJ_UINT32 win_l_y0, OPJ_UINT32 win_l_y1, OPJ_UINT32 win_h_y0, OPJ_UINT32 win_h_y1)
 
static void opj_dwt_decode_partial_1 (OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas, OPJ_INT32 win_l_x0, OPJ_INT32 win_l_x1, OPJ_INT32 win_h_x0, OPJ_INT32 win_h_x1)
 
static void opj_dwt_decode_partial_1_parallel (OPJ_INT32 *a, OPJ_UINT32 nb_cols, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas, OPJ_INT32 win_l_x0, OPJ_INT32 win_l_x1, OPJ_INT32 win_h_x0, OPJ_INT32 win_h_x1)
 
static void opj_dwt_get_band_coordinates (opj_tcd_tilecomp_t *tilec, OPJ_UINT32 resno, OPJ_UINT32 bandno, OPJ_UINT32 tcx0, OPJ_UINT32 tcy0, OPJ_UINT32 tcx1, OPJ_UINT32 tcy1, OPJ_UINT32 *tbx0, OPJ_UINT32 *tby0, OPJ_UINT32 *tbx1, OPJ_UINT32 *tby1)
 
static void opj_dwt_segment_grow (OPJ_UINT32 filter_width, OPJ_UINT32 max_size, OPJ_UINT32 *start, OPJ_UINT32 *end)
 
static opj_sparse_array_int32_topj_dwt_init_sparse_array (opj_tcd_tilecomp_t *tilec, OPJ_UINT32 numres)
 
static void opj_v4dwt_interleave_partial_h (opj_v4dwt_t *dwt, opj_sparse_array_int32_t *sa, OPJ_UINT32 sa_line, OPJ_UINT32 remaining_height)
 
static void opj_v4dwt_interleave_partial_v (opj_v4dwt_t *OPJ_RESTRICT dwt, opj_sparse_array_int32_t *sa, OPJ_UINT32 sa_col, OPJ_UINT32 nb_elts_read)
 
static OPJ_BOOL opj_dwt_decode_tile_97 (opj_tcd_tilecomp_t *OPJ_RESTRICT tilec, OPJ_UINT32 numres)
 
static OPJ_BOOL opj_dwt_decode_partial_97 (opj_tcd_tilecomp_t *OPJ_RESTRICT tilec, OPJ_UINT32 numres)
 
OPJ_BOOL opj_dwt_decode_real (opj_tcd_t *p_tcd, opj_tcd_tilecomp_t *OPJ_RESTRICT tilec, OPJ_UINT32 numres)
 Inverse 9-7 wavelet transform in 2-D. More...
 
Local static functions
static void opj_dwt_deinterleave_h (OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
 Forward lazy transform (horizontal) More...
 
static void opj_dwt_deinterleave_v (OPJ_INT32 *a, OPJ_INT32 *b, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 x, OPJ_INT32 cas)
 Forward lazy transform (vertical) More...
 
static void opj_dwt_encode_1 (OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
 Forward 5-3 wavelet transform in 1-D. More...
 
static void opj_dwt_encode_1_real (OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn, OPJ_INT32 cas)
 Forward 9-7 wavelet transform in 1-D. More...
 
static void opj_dwt_encode_stepsize (OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize)
 Explicit calculation of the Quantization Stepsizes. More...
 
static OPJ_BOOL opj_dwt_decode_tile (opj_thread_pool_t *tp, opj_tcd_tilecomp_t *tilec, OPJ_UINT32 i)
 Inverse wavelet transform in 2-D. More...
 
static OPJ_BOOL opj_dwt_decode_partial_tile (opj_tcd_tilecomp_t *tilec, OPJ_UINT32 numres)
 
static OPJ_BOOL opj_dwt_encode_procedure (opj_tcd_tilecomp_t *tilec, void(*p_function)(OPJ_INT32 *, OPJ_INT32, OPJ_INT32, OPJ_INT32))
 
static OPJ_UINT32 opj_dwt_max_resolution (opj_tcd_resolution_t *OPJ_RESTRICT r, OPJ_UINT32 i)
 
static void opj_v4dwt_decode (opj_v4dwt_t *OPJ_RESTRICT dwt)
 
static void opj_v4dwt_interleave_h (opj_v4dwt_t *OPJ_RESTRICT dwt, OPJ_FLOAT32 *OPJ_RESTRICT a, OPJ_UINT32 width, OPJ_UINT32 remaining_height)
 
static void opj_v4dwt_interleave_v (opj_v4dwt_t *OPJ_RESTRICT dwt, OPJ_FLOAT32 *OPJ_RESTRICT a, OPJ_UINT32 width, OPJ_UINT32 nb_elts_read)
 
static void opj_v4dwt_decode_step1 (opj_v4_t *w, OPJ_UINT32 start, OPJ_UINT32 end, const OPJ_FLOAT32 c)
 
static void opj_v4dwt_decode_step2 (opj_v4_t *l, opj_v4_t *w, OPJ_UINT32 start, OPJ_UINT32 end, OPJ_UINT32 m, OPJ_FLOAT32 c)
 

Variables

static const OPJ_FLOAT64 opj_dwt_norms [4][10]
 
static const OPJ_FLOAT64 opj_dwt_norms_real [4][10]
 

Local data structures

typedef struct dwt_local opj_dwt_t
 
typedef struct v4dwt_local opj_v4dwt_t
 
static const OPJ_FLOAT32 opj_dwt_alpha = 1.586134342f
 
static const OPJ_FLOAT32 opj_dwt_beta = 0.052980118f
 
static const OPJ_FLOAT32 opj_dwt_gamma = -0.882911075f
 
static const OPJ_FLOAT32 opj_dwt_delta = -0.443506852f
 
static const OPJ_FLOAT32 opj_K = 1.230174105f
 
static const OPJ_FLOAT32 opj_c13318 = 1.625732422f
 

Macro Definition Documentation

#define OPJ_D (   i)    a[(1+(i)*2)]
#define OPJ_D_ (   i)    ((i)<0?OPJ_D(0):((i)>=dn?OPJ_D(dn-1):OPJ_D(i)))
#define OPJ_D__off (   i,
  off 
)    ((i)<0?OPJ_D_off(0,off):((i)>=dn?OPJ_D_off(dn-1,off):OPJ_D_off(i,off)))
#define OPJ_D_off (   i,
  off 
)    a[(1+(OPJ_UINT32)(i)*2)*4+off]
#define OPJ_DD_ (   i)    ((i)<0?OPJ_D(0):((i)>=sn?OPJ_D(sn-1):OPJ_D(i)))
#define OPJ_DD__off (   i,
  off 
)    ((i)<0?OPJ_D_off(0,off):((i)>=sn?OPJ_D_off(sn-1,off):OPJ_D_off(i,off)))
#define OPJ_S (   i)    a[(i)*2]
#define OPJ_S_ (   i)    ((i)<0?OPJ_S(0):((i)>=sn?OPJ_S(sn-1):OPJ_S(i)))
#define OPJ_S__off (   i,
  off 
)    ((i)<0?OPJ_S_off(0,off):((i)>=sn?OPJ_S_off(sn-1,off):OPJ_S_off(i,off)))
#define OPJ_S_off (   i,
  off 
)    a[(OPJ_UINT32)(i)*2*4+off]
#define OPJ_SKIP_POISON
#define OPJ_SS_ (   i)    ((i)<0?OPJ_S(0):((i)>=dn?OPJ_S(dn-1):OPJ_S(i)))
#define OPJ_SS__off (   i,
  off 
)    ((i)<0?OPJ_S_off(0,off):((i)>=dn?OPJ_S_off(dn-1,off):OPJ_S_off(i,off)))

Function Documentation

static void opj_dwt_decode_h_func ( void *  user_data,
opj_tls_t tls 
)
static
static void opj_dwt_decode_partial_1 ( OPJ_INT32 a,
OPJ_INT32  dn,
OPJ_INT32  sn,
OPJ_INT32  cas,
OPJ_INT32  win_l_x0,
OPJ_INT32  win_l_x1,
OPJ_INT32  win_h_x0,
OPJ_INT32  win_h_x1 
)
static

References OPJ_D, OPJ_D_, OPJ_DD_, OPJ_S, OPJ_S_, and OPJ_SS_.

Referenced by opj_dwt_decode_partial_tile().

static void opj_dwt_decode_partial_1_parallel ( OPJ_INT32 a,
OPJ_UINT32  nb_cols,
OPJ_INT32  dn,
OPJ_INT32  sn,
OPJ_INT32  cas,
OPJ_INT32  win_l_x0,
OPJ_INT32  win_l_x1,
OPJ_INT32  win_h_x0,
OPJ_INT32  win_h_x1 
)
static
static OPJ_BOOL opj_dwt_decode_partial_97 ( opj_tcd_tilecomp_t *OPJ_RESTRICT  tilec,
OPJ_UINT32  numres 
)
static
static OPJ_BOOL opj_dwt_decode_tile_97 ( opj_tcd_tilecomp_t *OPJ_RESTRICT  tilec,
OPJ_UINT32  numres 
)
static
static void opj_dwt_decode_v_func ( void *  user_data,
opj_tls_t tls 
)
static
static void opj_dwt_get_band_coordinates ( opj_tcd_tilecomp_t tilec,
OPJ_UINT32  resno,
OPJ_UINT32  bandno,
OPJ_UINT32  tcx0,
OPJ_UINT32  tcy0,
OPJ_UINT32  tcx1,
OPJ_UINT32  tcy1,
OPJ_UINT32 tbx0,
OPJ_UINT32 tby0,
OPJ_UINT32 tbx1,
OPJ_UINT32 tby1 
)
static
static opj_sparse_array_int32_t* opj_dwt_init_sparse_array ( opj_tcd_tilecomp_t tilec,
OPJ_UINT32  numres 
)
static
static void opj_dwt_interleave_partial_h ( OPJ_INT32 dest,
OPJ_INT32  cas,
opj_sparse_array_int32_t sa,
OPJ_UINT32  sa_line,
OPJ_UINT32  sn,
OPJ_UINT32  win_l_x0,
OPJ_UINT32  win_l_x1,
OPJ_UINT32  win_h_x0,
OPJ_UINT32  win_h_x1 
)
static
static void opj_dwt_interleave_partial_v ( OPJ_INT32 dest,
OPJ_INT32  cas,
opj_sparse_array_int32_t sa,
OPJ_UINT32  sa_col,
OPJ_UINT32  nb_cols,
OPJ_UINT32  sn,
OPJ_UINT32  win_l_y0,
OPJ_UINT32  win_l_y1,
OPJ_UINT32  win_h_y0,
OPJ_UINT32  win_h_y1 
)
static
static void opj_dwt_segment_grow ( OPJ_UINT32  filter_width,
OPJ_UINT32  max_size,
OPJ_UINT32 start,
OPJ_UINT32 end 
)
static
static void opj_idwt3_v_cas0 ( OPJ_INT32 tmp,
const OPJ_INT32  sn,
const OPJ_INT32  len,
OPJ_INT32 tiledp_col,
const OPJ_SIZE_T  stride 
)
static

Vertical inverse 5x3 wavelet transform for one column, when top-most pixel is on even coordinate.

Referenced by opj_idwt53_v().

static void opj_idwt3_v_cas1 ( OPJ_INT32 tmp,
const OPJ_INT32  sn,
const OPJ_INT32  len,
OPJ_INT32 tiledp_col,
const OPJ_SIZE_T  stride 
)
static

Vertical inverse 5x3 wavelet transform for one column, when top-most pixel is on odd coordinate.

Referenced by opj_idwt53_v().

static void opj_idwt53_h ( const opj_dwt_t dwt,
OPJ_INT32 tiledp 
)
static
static void opj_idwt53_h_cas0 ( OPJ_INT32 tmp,
const OPJ_INT32  sn,
const OPJ_INT32  len,
OPJ_INT32 tiledp 
)
static

Referenced by opj_idwt53_h().

static void opj_idwt53_h_cas1 ( OPJ_INT32 tmp,
const OPJ_INT32  sn,
const OPJ_INT32  len,
OPJ_INT32 tiledp 
)
static

Referenced by opj_idwt53_h().

static void opj_idwt53_v ( const opj_dwt_t dwt,
OPJ_INT32 tiledp_col,
OPJ_SIZE_T  stride,
OPJ_INT32  nb_cols 
)
static
static void opj_v4dwt_interleave_partial_h ( opj_v4dwt_t dwt,
opj_sparse_array_int32_t sa,
OPJ_UINT32  sa_line,
OPJ_UINT32  remaining_height 
)
static
static void opj_v4dwt_interleave_partial_v ( opj_v4dwt_t *OPJ_RESTRICT  dwt,
opj_sparse_array_int32_t sa,
OPJ_UINT32  sa_col,
OPJ_UINT32  nb_elts_read 
)
static

Variable Documentation

const OPJ_FLOAT64 opj_dwt_norms[4][10]
static
Initial value:
= {
{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
}
const OPJ_FLOAT64 opj_dwt_norms_real[4][10]
static
Initial value:
= {
{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
}