OpenJPEG: opj_intmath.h File Reference

OpenJPEG 2.5.3

opj_intmath.h File Reference

Implementation of operations on integers (INT) More...

Go to the source code of this file.

## Functions
Exported functions (see also openjpeg.h)
static INLINE OPJ_INT32 | opj_int_min (OPJ_INT32 a, OPJ_INT32 b)
| Get the minimum of two integers.
static INLINE OPJ_UINT32 | opj_uint_min (OPJ_UINT32 a, OPJ_UINT32 b)
| Get the minimum of two integers.
static INLINE OPJ_INT32 | opj_int_max (OPJ_INT32 a, OPJ_INT32 b)
| Get the maximum of two integers.
static INLINE OPJ_UINT32 | opj_uint_max (OPJ_UINT32 a, OPJ_UINT32 b)
| Get the maximum of two integers.
static INLINE OPJ_UINT32 | opj_uint_adds (OPJ_UINT32 a, OPJ_UINT32 b)
| Get the saturated sum of two unsigned integers.
static INLINE OPJ_UINT32 | opj_uint_subs (OPJ_UINT32 a, OPJ_UINT32 b)
| Get the saturated difference of two unsigned integers.
static INLINE OPJ_INT32 | opj_int_clamp (OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max)
| Clamp an integer inside an interval.
static INLINE OPJ_INT64 | opj_int64_clamp (OPJ_INT64 a, OPJ_INT64 min, OPJ_INT64 max)
| Clamp an integer inside an interval.
static INLINE OPJ_INT32 | opj_int_abs (OPJ_INT32 a)
static INLINE OPJ_INT32 | opj_int_ceildiv (OPJ_INT32 a, OPJ_INT32 b)
| Divide an integer and round upwards.
static INLINE OPJ_UINT32 | opj_uint_ceildiv (OPJ_UINT32 a, OPJ_UINT32 b)
| Divide an integer and round upwards.
static INLINE OPJ_UINT32 | opj_uint64_ceildiv_res_uint32 (OPJ_UINT64 a, OPJ_UINT64 b)
| Divide an integer and round upwards.
static INLINE OPJ_INT32 | opj_int_ceildivpow2 (OPJ_INT32 a, OPJ_INT32 b)
| Divide an integer by a power of 2 and round upwards.
static INLINE OPJ_INT32 | opj_int64_ceildivpow2 (OPJ_INT64 a, OPJ_INT32 b)
| Divide a 64bits integer by a power of 2 and round upwards.
static INLINE OPJ_UINT32 | opj_uint_ceildivpow2 (OPJ_UINT32 a, OPJ_UINT32 b)
| Divide an integer by a power of 2 and round upwards.
static INLINE OPJ_INT32 | opj_int_floordivpow2 (OPJ_INT32 a, OPJ_INT32 b)
| Divide an integer by a power of 2 and round downwards.
static INLINE OPJ_UINT32 | opj_uint_floordivpow2 (OPJ_UINT32 a, OPJ_UINT32 b)
| Divide an integer by a power of 2 and round downwards.
static INLINE OPJ_INT32 | opj_int_floorlog2 (OPJ_INT32 a)
| Get logarithm of an integer and round downwards.
static INLINE OPJ_UINT32 | opj_uint_floorlog2 (OPJ_UINT32 a)
| Get logarithm of an integer and round downwards.
static INLINE OPJ_INT32 | opj_int_fix_mul (OPJ_INT32 a, OPJ_INT32 b)
| Multiply two fixed-precision rational numbers.
static INLINE OPJ_INT32 | opj_int_fix_mul_t1 (OPJ_INT32 a, OPJ_INT32 b)
static INLINE OPJ_INT32 | opj_int_add_no_overflow (OPJ_INT32 a, OPJ_INT32 b)
| Addition two signed integers with a wrap-around behaviour.
static INLINE OPJ_INT32 | opj_int_sub_no_overflow (OPJ_INT32 a, OPJ_INT32 b)
| Subtract two signed integers with a wrap-around behaviour.

## Detailed Description

Implementation of operations on integers (INT)

The functions in OPJ_INTMATH.H have for goal to realize operations on integers.

## Function Documentation

## ◆ opj_int64_ceildivpow2()

static INLINE OPJ_INT32 opj_int64_ceildivpow2 | ( | OPJ_INT64 | a,
|  | OPJ_INT32 | b )
| static

Divide a 64bits integer by a power of 2 and round upwards.

Returns
  Returns a divided by 2^b

Referenced by opj_tcd_init_tile().

## ◆ opj_int64_clamp()

static INLINE OPJ_INT64 opj_int64_clamp | ( | OPJ_INT64 | a,
|  | OPJ_INT64 | min,
|  | OPJ_INT64 | max )
| static

Clamp an integer inside an interval.

Returns
  - Returns a if (min < a < max)
  - Returns max if (a > max)
  - Returns min if (a < min)

References max(), and min().

Referenced by opj_tcd_dc_level_shift_decode().

## ◆ opj_int_abs()

static INLINE OPJ_INT32 opj_int_abs | ( | OPJ_INT32 | a | ) |
| static

Returns
  Get absolute value of integer

Referenced by opj_dwt_encode_step1_combined().

## ◆ opj_int_add_no_overflow()

static INLINE OPJ_INT32 opj_int_add_no_overflow | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Addition two signed integers with a wrap-around behaviour.

Assumes complement-to-two signed integers.

Parameters

  a |
  b |

Returns
  Returns a + b

Referenced by opj_dwt_decode_partial_1(), opj_dwt_decode_partial_1_parallel(), opj_idwt3_v_cas0(), opj_idwt53_h_cas0(), and opj_idwt53_h_cas1().

## ◆ opj_int_ceildiv()

static INLINE OPJ_INT32 opj_int_ceildiv | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Divide an integer and round upwards.

Returns
  Returns a divided by b

Referenced by opj_j2k_get_tile(), opj_j2k_update_image_dimensions(), and opj_tcd_init_tile().

## ◆ opj_int_ceildivpow2()

static INLINE OPJ_INT32 opj_int_ceildivpow2 | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Divide an integer by a power of 2 and round upwards.

Returns
  Returns a divided by 2^b

Referenced by init_tilec(), opj_j2k_get_tile(), opj_j2k_update_image_dimensions(), and opj_tcd_init_tile().

## ◆ opj_int_clamp()

static INLINE OPJ_INT32 opj_int_clamp | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | min,
|  | OPJ_INT32 | max )
| static

Clamp an integer inside an interval.

Returns
  - Returns a if (min < a < max)
  - Returns max if (a > max)
  - Returns min if (a < min)

References max(), and min().

Referenced by opj_tcd_dc_level_shift_decode().

## ◆ opj_int_fix_mul()

static INLINE OPJ_INT32 opj_int_fix_mul | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Multiply two fixed-precision rational numbers.

Parameters

  a |
  b |

Returns
  Returns a * b

Referenced by opj_mct_encode_custom().

## ◆ opj_int_fix_mul_t1()

static INLINE OPJ_INT32 opj_int_fix_mul_t1 | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

References T1_NMSEDEC_FRACBITS.

## ◆ opj_int_floordivpow2()

static INLINE OPJ_INT32 opj_int_floordivpow2 | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Divide an integer by a power of 2 and round downwards.

Returns
  Returns a divided by 2^b

Referenced by opj_tcd_init_tile().

## ◆ opj_int_floorlog2()

static INLINE OPJ_INT32 opj_int_floorlog2 | ( | OPJ_INT32 | a | ) |
| static

Get logarithm of an integer and round downwards.

Returns
  Returns log2(a)

Referenced by opj_dwt_encode_stepsize(), opj_j2k_setup_encoder(), opj_t1_encode_cblk(), and opj_t2_encode_packet().

## ◆ opj_int_max()

static INLINE OPJ_INT32 opj_int_max | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Get the maximum of two integers.

Returns
  Returns a if a > b else b

Referenced by main(), opj_j2k_update_rates(), opj_t1_encode_cblk(), opj_t2_encode_packet(), and opj_tcd_init_tile().

## ◆ opj_int_min()

static INLINE OPJ_INT32 opj_int_min | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Get the minimum of two integers.

Returns
  Returns a if a < b else b

Referenced by opj_dwt_encode_1_real(), opj_dwt_encode_and_deinterleave_v_real(), opj_j2k_update_rates(), opj_j2k_write_poc_in_memory(), opj_t2_read_packet_header(), opj_tcd_init_tile(), opj_v8dwt_decode(), t1_init_ctxno_sc(), and t1_init_spb().

## ◆ opj_int_sub_no_overflow()

static INLINE OPJ_INT32 opj_int_sub_no_overflow | ( | OPJ_INT32 | a,
|  | OPJ_INT32 | b )
| static

Subtract two signed integers with a wrap-around behaviour.

Assumes complement-to-two signed integers.

Parameters

  a |
  b |

Returns
  Returns a - b

Referenced by opj_dwt_decode_partial_1(), opj_dwt_decode_partial_1_parallel(), and opj_idwt3_v_cas0().

## ◆ opj_uint64_ceildiv_res_uint32()

static INLINE OPJ_UINT32 opj_uint64_ceildiv_res_uint32 | ( | OPJ_UINT64 | a,
|  | OPJ_UINT64 | b )
| static

Divide an integer and round upwards.

Returns
  Returns a divided by b

Referenced by opj_pi_next_cprl(), opj_pi_next_pcrl(), and opj_pi_next_rpcl().

## ◆ opj_uint_adds()

static INLINE OPJ_UINT32 opj_uint_adds | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Get the saturated sum of two unsigned integers.

Returns
  Returns saturated sum of a+b

Referenced by opj_dwt_segment_grow(), opj_get_all_encoding_parameters(), opj_get_encoding_parameters(), opj_image_comp_header_update(), opj_j2k_read_siz(), opj_tcd_init_tile(), and opj_tcd_is_subband_area_of_interest().

## ◆ opj_uint_ceildiv()

static INLINE OPJ_UINT32 opj_uint_ceildiv | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Divide an integer and round upwards.

Returns
  Returns a divided by b

Referenced by opj_get_all_encoding_parameters(), opj_get_encoding_parameters(), opj_get_tile_dimensions(), opj_image_comp_header_update(), opj_j2k_get_specific_header_sizes(), opj_j2k_get_tile(), opj_j2k_read_siz(), opj_j2k_set_decode_area(), opj_j2k_setup_encoder(), opj_j2k_update_image_dimensions(), opj_j2k_update_rates(), opj_sparse_array_int32_create(), opj_tcd_decode_tile(), opj_tcd_is_subband_area_of_interest(), and opj_tcd_is_whole_tilecomp_decoding().

## ◆ opj_uint_ceildivpow2()

static INLINE OPJ_UINT32 opj_uint_ceildivpow2 | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Divide an integer by a power of 2 and round upwards.

Returns
  Returns a divided by 2^b

Referenced by opj_dwt_get_band_coordinates(), opj_get_all_encoding_parameters(), opj_get_encoding_parameters(), opj_image_comp_header_update(), opj_j2k_update_image_data(), opj_tcd_decode_tile(), and opj_tcd_is_subband_area_of_interest().

## ◆ opj_uint_floordivpow2()

static INLINE OPJ_UINT32 opj_uint_floordivpow2 | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Divide an integer by a power of 2 and round downwards.

Returns
  Returns a divided by 2^b

Referenced by opj_get_all_encoding_parameters(), opj_get_encoding_parameters(), opj_pi_next_cprl(), opj_pi_next_pcrl(), and opj_pi_next_rpcl().

## ◆ opj_uint_floorlog2()

static INLINE OPJ_UINT32 opj_uint_floorlog2 | ( | OPJ_UINT32 | a | ) |
| static

Get logarithm of an integer and round downwards.

Returns
  Returns log2(a)

Referenced by opj_t2_read_packet_header().

## ◆ opj_uint_max()

static INLINE OPJ_UINT32 opj_uint_max | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Get the maximum of two integers.

Returns
  Returns a if a > b else b

Referenced by opj_dwt_decode_partial_97(), opj_dwt_decode_partial_tile(), opj_dwt_decode_tile_97(), opj_get_all_encoding_parameters(), opj_get_encoding_parameters(), opj_image_comp_header_update(), opj_j2k_get_max_coc_size(), opj_j2k_get_max_poc_size(), opj_j2k_get_max_toc_size(), opj_j2k_get_specific_header_sizes(), opj_t2_decode_packets(), opj_tcd_decode_tile(), opj_tcd_init_tile(), opj_tcd_is_subband_area_of_interest(), and opj_tcd_is_whole_tilecomp_decoding().

## ◆ opj_uint_min()

static INLINE OPJ_UINT32 opj_uint_min | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Get the minimum of two integers.

Returns
  Returns a if a < b else b

Referenced by opj_dwt_decode_partial_97(), opj_dwt_decode_partial_tile(), opj_dwt_encode_step1_combined(), opj_dwt_encode_step2(), opj_dwt_init_sparse_array(), opj_dwt_segment_grow(), opj_get_all_encoding_parameters(), opj_get_encoding_parameters(), opj_image_comp_header_update(), opj_j2k_check_poc_val(), opj_j2k_read_poc(), opj_j2k_setup_encoder(), opj_pi_next_cprl(), opj_pi_next_pcrl(), opj_pi_next_rpcl(), opj_pi_update_decode_poc(), opj_sparse_array_int32_read_or_write(), opj_tcd_decode_tile(), opj_tcd_init_tile(), opj_tcd_is_subband_area_of_interest(), opj_tcd_is_whole_tilecomp_decoding(), opj_tcd_rateallocate(), opj_v8dwt_decode_step2(), and opj_v8dwt_encode_step2().

## ◆ opj_uint_subs()

static INLINE OPJ_UINT32 opj_uint_subs | ( | OPJ_UINT32 | a,
|  | OPJ_UINT32 | b )
| static

Get the saturated difference of two unsigned integers.

Returns
  Returns saturated sum of a-b

Referenced by opj_dwt_decode_partial_97(), opj_dwt_decode_partial_tile(), and opj_dwt_segment_grow().