OpenJPEG: sparse_array.c File Reference

OpenJPEG 2.3.1

Data Structures | Functions
sparse_array.c File Reference
`#include "opj_includes.h"`

## Data Structures
struct | opj_sparse_array_int32

## Functions
opj_sparse_array_int32_t * | opj_sparse_array_int32_create (OPJ_UINT32 width, OPJ_UINT32 height, OPJ_UINT32 block_width, OPJ_UINT32 block_height)
| Creates a new sparse array. More...
void | opj_sparse_array_int32_free (opj_sparse_array_int32_t *sa)
| Frees a sparse array. More...
OPJ_BOOL | opj_sparse_array_is_region_valid (const opj_sparse_array_int32_t *sa, OPJ_UINT32 x0, OPJ_UINT32 y0, OPJ_UINT32 x1, OPJ_UINT32 y1)
| Returns whether region bounds are valid (non empty and within array bounds) More...
static OPJ_BOOL | opj_sparse_array_int32_read_or_write (const opj_sparse_array_int32_t *sa, OPJ_UINT32 x0, OPJ_UINT32 y0, OPJ_UINT32 x1, OPJ_UINT32 y1, OPJ_INT32 *buf, OPJ_UINT32 buf_col_stride, OPJ_UINT32 buf_line_stride, OPJ_BOOL forgiving, OPJ_BOOL is_read_op)
OPJ_BOOL | opj_sparse_array_int32_read (const opj_sparse_array_int32_t *sa, OPJ_UINT32 x0, OPJ_UINT32 y0, OPJ_UINT32 x1, OPJ_UINT32 y1, OPJ_INT32 *dest, OPJ_UINT32 dest_col_stride, OPJ_UINT32 dest_line_stride, OPJ_BOOL forgiving)
| Read the content of a rectangular region of the sparse array into a user buffer. More...
OPJ_BOOL | opj_sparse_array_int32_write (opj_sparse_array_int32_t *sa, OPJ_UINT32 x0, OPJ_UINT32 y0, OPJ_UINT32 x1, OPJ_UINT32 y1, const OPJ_INT32 *src, OPJ_UINT32 src_col_stride, OPJ_UINT32 src_line_stride, OPJ_BOOL forgiving)
| Write the content of a rectangular region into the sparse array from a user buffer. More...

## Function Documentation

## ◆ opj_sparse_array_int32_create()

opj_sparse_array_int32_t* opj_sparse_array_int32_create | ( | OPJ_UINT32 | width,
|  | OPJ_UINT32 | height,
|  | OPJ_UINT32 | block_width,
|  | OPJ_UINT32 | block_height
| ) |  |

Creates a new sparse array.

Parameters

  width | total width of the array.
  height | total height of the array
  block_width | width of a block.
  block_height | height of a block.

Returns
  a new sparse array instance, or NULL in case of failure.

References opj_sparse_array_int32::block_count_hor, opj_sparse_array_int32::block_count_ver, opj_sparse_array_int32::block_height, opj_sparse_array_int32::block_width, opj_sparse_array_int32::data_blocks, opj_sparse_array_int32::height, opj_calloc(), opj_free(), opj_uint_ceildiv(), and opj_sparse_array_int32::width.

Referenced by main(), and opj_dwt_init_sparse_array().

## ◆ opj_sparse_array_int32_free()

void opj_sparse_array_int32_free | ( | opj_sparse_array_int32_t * | sa | ) |

Frees a sparse array.

Parameters

  sa | sparse array instance.

References opj_sparse_array_int32::block_count_hor, opj_sparse_array_int32::block_count_ver, opj_sparse_array_int32::data_blocks, and opj_free().

Referenced by main(), opj_dwt_decode_partial_97(), opj_dwt_decode_partial_tile(), and opj_dwt_init_sparse_array().

## ◆ opj_sparse_array_int32_read()

OPJ_BOOL opj_sparse_array_int32_read | ( | const opj_sparse_array_int32_t * | sa,
|  | OPJ_UINT32 | x0,
|  | OPJ_UINT32 | y0,
|  | OPJ_UINT32 | x1,
|  | OPJ_UINT32 | y1,
|  | OPJ_INT32 * | dest,
|  | OPJ_UINT32 | dest_col_stride,
|  | OPJ_UINT32 | dest_line_stride,
|  | OPJ_BOOL | forgiving
| ) |  |

Read the content of a rectangular region of the sparse array into a user buffer.

Regions not written with opj_sparse_array_int32_write() are read as 0.

Parameters

  sa | sparse array instance.
  x0 | left x coordinate of the region to read in the sparse array.
  y0 | top x coordinate of the region to read in the sparse array.
  x1 | right x coordinate (not included) of the region to read in the sparse array. Must be greater than x0.
  y1 | bottom y coordinate (not included) of the region to read in the sparse array. Must be greater than y0.
  dest | user buffer to fill. Must be at least sizeof(int32) * ( (y1 - y0 - 1) * dest_line_stride + (x1 - x0 - 1) * dest_col_stride + 1) bytes large.
  dest_col_stride | spacing (in elements, not in bytes) in x dimension between consecutive elements of the user buffer.
  dest_line_stride | spacing (in elements, not in bytes) in y dimension between consecutive elements of the user buffer.
  forgiving | if set to TRUE and the region is invalid, OPJ_TRUE will still be returned.

Returns
  OPJ_TRUE in case of success.

References opj_sparse_array_int32_read_or_write(), and OPJ_TRUE.

Referenced by main(), opj_dwt_decode_partial_97(), opj_dwt_decode_partial_tile(), opj_dwt_interleave_partial_h(), opj_dwt_interleave_partial_v(), opj_v8dwt_interleave_partial_h(), and opj_v8dwt_interleave_partial_v().

## ◆ opj_sparse_array_int32_read_or_write()

static OPJ_BOOL opj_sparse_array_int32_read_or_write | ( | const opj_sparse_array_int32_t * | sa,
|  | OPJ_UINT32 | x0,
|  | OPJ_UINT32 | y0,
|  | OPJ_UINT32 | x1,
|  | OPJ_UINT32 | y1,
|  | OPJ_INT32 * | buf,
|  | OPJ_UINT32 | buf_col_stride,
|  | OPJ_UINT32 | buf_line_stride,
|  | OPJ_BOOL | forgiving,
|  | OPJ_BOOL | is_read_op
| ) |  |
| static

References opj_sparse_array_int32::block_count_hor, opj_sparse_array_int32::block_height, opj_sparse_array_int32::block_width, opj_sparse_array_int32::data_blocks, opj_calloc(), OPJ_FALSE, OPJ_RESTRICT, opj_sparse_array_is_region_valid(), OPJ_TRUE, and opj_uint_min().

Referenced by opj_sparse_array_int32_read(), and opj_sparse_array_int32_write().

## ◆ opj_sparse_array_int32_write()

OPJ_BOOL opj_sparse_array_int32_write | ( | opj_sparse_array_int32_t * | sa,
|  | OPJ_UINT32 | x0,
|  | OPJ_UINT32 | y0,
|  | OPJ_UINT32 | x1,
|  | OPJ_UINT32 | y1,
|  | const OPJ_INT32 * | src,
|  | OPJ_UINT32 | src_col_stride,
|  | OPJ_UINT32 | src_line_stride,
|  | OPJ_BOOL | forgiving
| ) |  |

Write the content of a rectangular region into the sparse array from a user buffer.

Blocks intersecting the region are allocated, if not already done.

Parameters

  sa | sparse array instance.
  x0 | left x coordinate of the region to write into the sparse array.
  y0 | top x coordinate of the region to write into the sparse array.
  x1 | right x coordinate (not included) of the region to write into the sparse array. Must be greater than x0.
  y1 | bottom y coordinate (not included) of the region to write into the sparse array. Must be greater than y0.
  src | user buffer to fill. Must be at least sizeof(int32) * ( (y1 - y0 - 1) * src_line_stride + (x1 - x0 - 1) * src_col_stride + 1) bytes large.
  src_col_stride | spacing (in elements, not in bytes) in x dimension between consecutive elements of the user buffer.
  src_line_stride | spacing (in elements, not in bytes) in y dimension between consecutive elements of the user buffer.
  forgiving | if set to TRUE and the region is invalid, OPJ_TRUE will still be returned.

Returns
  OPJ_TRUE in case of success.

References OPJ_FALSE, and opj_sparse_array_int32_read_or_write().

Referenced by main(), opj_dwt_decode_partial_97(), opj_dwt_decode_partial_tile(), and opj_dwt_init_sparse_array().

## ◆ opj_sparse_array_is_region_valid()

OPJ_BOOL opj_sparse_array_is_region_valid | ( | const opj_sparse_array_int32_t * | sa,
|  | OPJ_UINT32 | x0,
|  | OPJ_UINT32 | y0,
|  | OPJ_UINT32 | x1,
|  | OPJ_UINT32 | y1
| ) |  |

Returns whether region bounds are valid (non empty and within array bounds)

Parameters

  sa | sparse array instance.
  x0 | left x coordinate of the region.
  y0 | top x coordinate of the region.
  x1 | right x coordinate (not included) of the region. Must be greater than x0.
  y1 | bottom y coordinate (not included) of the region. Must be greater than y0.

Returns
  OPJ_TRUE or OPJ_FALSE.

References opj_sparse_array_int32::height, and opj_sparse_array_int32::width.

Referenced by opj_sparse_array_int32_read_or_write().