OpenJPEG: t2.c File Reference

OpenJPEG 2.5.4

t2.c File Reference
`#include "opj_includes.h"`
`#include "opj_common.h"`

## Local static functions
#define | JAS_FPRINTF opj_null_jas_fprintf
static void | opj_t2_putcommacode (opj_bio_t *bio, OPJ_INT32 n)
static OPJ_UINT32 | opj_t2_getcommacode (opj_bio_t *bio)
static void | opj_t2_putnumpasses (opj_bio_t *bio, OPJ_UINT32 n)
| Variable length code for signalling delta Zil (truncation point)
static OPJ_UINT32 | opj_t2_getnumpasses (opj_bio_t *bio)
static OPJ_BOOL | opj_t2_encode_packet (OPJ_UINT32 tileno, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, OPJ_BYTE *dest, OPJ_UINT32 *p_data_written, OPJ_UINT32 len, opj_codestream_info_t *cstr_info, J2K_T2_MODE p_t2_mode, opj_event_mgr_t *p_manager)
| Encode a packet of a tile to a destination buffer.
static OPJ_BOOL | opj_t2_decode_packet (opj_t2_t *t2, opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, OPJ_BYTE *src, OPJ_UINT32 *data_read, OPJ_UINT32 max_length, opj_packet_info_t *pack_info, opj_event_mgr_t *p_manager)
| Decode a packet of a tile from a source buffer.
static OPJ_BOOL | opj_t2_skip_packet (opj_t2_t *p_t2, opj_tcd_tile_t *p_tile, opj_tcp_t *p_tcp, opj_pi_iterator_t *p_pi, OPJ_BYTE *p_src, OPJ_UINT32 *p_data_read, OPJ_UINT32 p_max_length, opj_packet_info_t *p_pack_info, opj_event_mgr_t *p_manager)
static OPJ_BOOL | opj_t2_read_packet_header (opj_t2_t *p_t2, opj_tcd_tile_t *p_tile, opj_tcp_t *p_tcp, opj_pi_iterator_t *p_pi, OPJ_BOOL *p_is_data_present, OPJ_BYTE *p_src_data, OPJ_UINT32 *p_data_read, OPJ_UINT32 p_max_length, opj_packet_info_t *p_pack_info, opj_event_mgr_t *p_manager)
static OPJ_BOOL | opj_t2_read_packet_data (opj_t2_t *p_t2, opj_tcd_tile_t *p_tile, opj_pi_iterator_t *p_pi, OPJ_BYTE *p_src_data, OPJ_UINT32 *p_data_read, OPJ_UINT32 p_max_length, opj_packet_info_t *pack_info, opj_event_mgr_t *p_manager)
static OPJ_BOOL | opj_t2_skip_packet_data (opj_t2_t *p_t2, opj_tcd_tile_t *p_tile, opj_pi_iterator_t *p_pi, OPJ_UINT32 *p_data_read, OPJ_UINT32 p_max_length, opj_packet_info_t *pack_info, opj_event_mgr_t *p_manager)
static OPJ_BOOL | opj_t2_init_seg (opj_tcd_cblk_dec_t *cblk, OPJ_UINT32 index, OPJ_UINT32 cblksty, OPJ_UINT32 first)
OPJ_BOOL | opj_t2_encode_packets (opj_t2_t *p_t2, OPJ_UINT32 p_tile_no, opj_tcd_tile_t *p_tile, OPJ_UINT32 p_maxlayers, OPJ_BYTE *p_dest, OPJ_UINT32 *p_data_written, OPJ_UINT32 p_max_len, opj_codestream_info_t *cstr_info, opj_tcd_marker_info_t *p_marker_info, OPJ_UINT32 p_tp_num, OPJ_INT32 p_tp_pos, OPJ_UINT32 p_pino, J2K_T2_MODE p_t2_mode, opj_event_mgr_t *p_manager)
| Encode the packets of a tile to a destination buffer.
static void | opj_null_jas_fprintf (FILE *file, const char *format,...)
OPJ_BOOL | opj_t2_decode_packets (opj_tcd_t *tcd, opj_t2_t *p_t2, OPJ_UINT32 p_tile_no, opj_tcd_tile_t *p_tile, OPJ_BYTE *p_src, OPJ_UINT32 *p_data_read, OPJ_UINT32 p_max_len, opj_codestream_index_t *p_cstr_index, opj_event_mgr_t *p_manager)
| Decode the packets of a tile from a source buffer.
opj_t2_t * | opj_t2_create (opj_image_t *p_image, opj_cp_t *p_cp)
| Creates a Tier 2 handle.
void | opj_t2_destroy (opj_t2_t *t2)
| Destroy a T2 handle.

## Macro Definition Documentation

## ◆ JAS_FPRINTF

#define JAS_FPRINTF opj_null_jas_fprintf

Referenced by opj_t2_decode_packets(), opj_t2_read_packet_header(), and opj_t2_skip_packet_data().

## Function Documentation

## ◆ opj_null_jas_fprintf()

void opj_null_jas_fprintf | ( | FILE * | file,
|  | const char * | format,
|  |  | ... )
| static

## ◆ opj_t2_create()

opj_t2_t * opj_t2_create | ( | opj_image_t * | p_image,
|  | opj_cp_t * | p_cp )

Creates a Tier 2 handle.

Parameters

  p_image | Source or destination image
  p_cp | Image coding parameters.

Returns
  a new T2 handle if successful, NULL otherwise.

References opj_t2::cp, opj_t2::image, and opj_calloc().

Referenced by opj_tcd_rateallocate(), opj_tcd_t2_decode(), and opj_tcd_t2_encode().

## ◆ opj_t2_decode_packet()

OPJ_BOOL opj_t2_decode_packet | ( | opj_t2_t * | t2,
|  | opj_tcd_tile_t * | tile,
|  | opj_tcp_t * | tcp,
|  | opj_pi_iterator_t * | pi,
|  | OPJ_BYTE * | src,
|  | OPJ_UINT32 * | data_read,
|  | OPJ_UINT32 | max_length,
|  | opj_packet_info_t * | pack_info,
|  | opj_event_mgr_t * | p_manager )
| static

Decode a packet of a tile from a source buffer.

Parameters

  t2 | T2 handle
  tile | Tile for which to write the packets
  tcp | Tile coding parameters
  pi | Packet identity
  src | Source buffer
  data_read | FIXME DOC
  max_length | FIXME DOC
  pack_info | Packet information
  p_manager | the user event manager

Returns
  FIXME DOC

References OPJ_FALSE, opj_t2_read_packet_data(), opj_t2_read_packet_header(), and OPJ_TRUE.

Referenced by opj_t2_decode_packets().

## ◆ opj_t2_decode_packets()

OPJ_BOOL opj_t2_decode_packets | ( | opj_tcd_t * | tcd,
|  | opj_t2_t * | t2,
|  | OPJ_UINT32 | tileno,
|  | opj_tcd_tile_t * | tile,
|  | OPJ_BYTE * | src,
|  | OPJ_UINT32 * | p_data_read,
|  | OPJ_UINT32 | len,
|  | opj_codestream_index_t * | cstr_info,
|  | opj_event_mgr_t * | p_manager )

Decode the packets of a tile from a source buffer.

Parameters

  tcd | TCD handle
  t2 | T2 handle
  tileno | number that identifies the tile for which to decode the packets
  tile | tile for which to decode the packets
  src | FIXME DOC
  p_data_read | the source buffer
  len | length of the source buffer
  cstr_info | FIXME DOC
  p_manager | the user event manager

Returns
  FIXME DOC

References opj_tcd_band::bandno, opj_tcd_resolution::bands, opj_pi_iterator::compno, opj_image::comps, opj_tcd_tile::comps, opj_t2::cp, opj_packet_info::end_ph_pos, opj_packet_info::end_pos, opj_t2::image, JAS_FPRINTF, opj_pi_iterator::layno, opj_cp::m_enc, opj_cp::m_specific_param, opj_encoding_param::m_tp_on, opj_tcd_tilecomp::minimum_num_resolutions, opj_tcp::num_layers_to_decode, opj_tcd_resolution::numbands, opj_image::numcomps, opj_tcp::numpocs, OPJ_ARG_NOT_USED, OPJ_FALSE, opj_free(), opj_malloc(), opj_pi_create_decode(), opj_pi_destroy(), opj_pi_next(), OPJ_PROG_UNKNOWN, opj_t2_decode_packet(), opj_t2_skip_packet(), opj_tcd_is_subband_area_of_interest(), OPJ_TRUE, opj_uint_max(), opj_pi_iterator::poc, opj_tcd_band::precincts, opj_pi_iterator::precno, opj_poc::prg, opj_poc::prg1, opj_pi_iterator::resno, opj_image_comp::resno_decoded, opj_tcd_tilecomp::resolutions, opj_packet_info::start_pos, opj_cp::tcps, opj_codestream_index::tile_index, opj_tcd_precinct::x0, opj_tcd_precinct::x1, opj_tcd_precinct::y0, and opj_tcd_precinct::y1.

Referenced by opj_tcd_t2_decode().

## ◆ opj_t2_destroy()

void opj_t2_destroy | ( | opj_t2_t * | t2 | ) |

Destroy a T2 handle.

Parameters

  t2 | T2 handle to destroy

References opj_free().

Referenced by opj_tcd_rateallocate(), opj_tcd_t2_decode(), and opj_tcd_t2_encode().

## ◆ opj_t2_encode_packet()

OPJ_BOOL opj_t2_encode_packet | ( | OPJ_UINT32 | tileno,
|  | opj_tcd_tile_t * | tile,
|  | opj_tcp_t * | tcp,
|  | opj_pi_iterator_t * | pi,
|  | OPJ_BYTE * | dest,
|  | OPJ_UINT32 * | p_data_written,
|  | OPJ_UINT32 | len,
|  | opj_codestream_info_t * | cstr_info,
|  | J2K_T2_MODE | p_t2_mode,
|  | opj_event_mgr_t * | p_manager )
| static

Encode a packet of a tile to a destination buffer.

Parameters

  tileno | Number of the tile encoded
  tile | Tile for which to write the packets
  tcp | Tile coding parameters
  pi | Packet identity
  dest | Destination buffer
  p_data_written | FIXME DOC
  len | Length of the destination buffer
  cstr_info | Codestream information structure
  p_t2_mode | If == THRESH_CALC In Threshold calculation ,If == FINAL_PASS Final pass
  p_manager | the user event manager

Returns

References opj_tcd_resolution::bands, opj_tcd_precinct::cblks, opj_tcd_precinct::ch, opj_pi_iterator::compno, opj_tcd_tile::comps, opj_tcd_precinct::cw, opj_codestream_info::D_max, opj_tcd_layer::data, opj_packet_info::disto, opj_tcd_layer::disto, opj_tcd_precinct::enc, opj_packet_info::end_ph_pos, EVT_ERROR, FINAL_PASS, opj_tcd_precinct::imsbtree, opj_tcd_precinct::incltree, opj_codestream_info::index_write, J2K_CP_CSTY_EPH, J2K_CP_CSTY_SOP, opj_tcd_cblk_enc::layers, opj_pi_iterator::layno, opj_tcd_layer::len, opj_tcd_pass::len, opj_tcd_resolution::numbands, opj_tcd_band::numbps, opj_tcd_cblk_enc::numbps, opj_tcd_cblk_enc::numlenbits, opj_tcd_cblk_enc::numpasses, opj_tcd_layer::numpasses, opj_bio_create(), opj_bio_destroy(), opj_bio_flush(), opj_bio_init_enc(), opj_bio_numbytes(), opj_bio_putbit(), opj_bio_write(), opj_event_msg(), OPJ_FALSE, opj_int_floorlog2(), opj_int_max(), opj_t2_putcommacode(), opj_t2_putnumpasses(), opj_tcd_is_band_empty(), opj_tgt_encode(), opj_tgt_reset(), opj_tgt_setvalue(), OPJ_TRUE, opj_tile_info::packet, opj_codestream_info::packno, opj_tcd_tile::packno, opj_tcd_cblk_enc::passes, opj_tcd_resolution::ph, opj_tcd_band::precincts, opj_pi_iterator::precno, opj_tcd_resolution::pw, opj_pi_iterator::resno, opj_tcd_tilecomp::resolutions, tcp, opj_tcd_pass::term, and opj_codestream_info::tile.

Referenced by opj_t2_encode_packets().

## ◆ opj_t2_encode_packets()

OPJ_BOOL opj_t2_encode_packets | ( | opj_t2_t * | t2,
|  | OPJ_UINT32 | tileno,
|  | opj_tcd_tile_t * | tile,
|  | OPJ_UINT32 | maxlayers,
|  | OPJ_BYTE * | dest,
|  | OPJ_UINT32 * | p_data_written,
|  | OPJ_UINT32 | len,
|  | opj_codestream_info_t * | cstr_info,
|  | opj_tcd_marker_info_t * | p_marker_info,
|  | OPJ_UINT32 | tpnum,
|  | OPJ_INT32 | tppos,
|  | OPJ_UINT32 | pino,
|  | J2K_T2_MODE | t2_mode,
|  | opj_event_mgr_t * | p_manager )

Encode the packets of a tile to a destination buffer.

Parameters

  t2 | T2 handle
  tileno | number of the tile encoded
  tile | the tile for which to write the packets
  maxlayers | maximum number of layers
  dest | the destination buffer
  p_data_written | FIXME DOC
  len | the length of the destination buffer
  cstr_info | Codestream information structure
  p_marker_info | Marker information structure
  tpnum | Tile part number of the current tile
  tppos | The position of the tile part flag in the progression order
  pino | FIXME DOC
  t2_mode | If == THRESH_CALC In Threshold calculation ,If == FINAL_PASS Final pass
  p_manager | the user event manager

References opj_t2::cp, opj_tile_info::end_header, opj_packet_info::end_ph_pos, opj_packet_info::end_pos, opj_t2::image, opj_codestream_info::index_write, opj_pi_iterator::layno, opj_cp::m_enc, opj_encoding_param::m_max_comp_size, opj_cp::m_specific_param, opj_encoding_param::m_tp_on, opj_tcd_marker_info::need_PLT, opj_image::numcomps, opj_tcp::numpocs, OPJ_FALSE, opj_get_encoding_packet_count(), opj_malloc(), opj_pi_create_encode(), opj_pi_destroy(), opj_pi_initialise_encode(), opj_pi_next(), OPJ_PROFILE_CINEMA_4K, OPJ_PROG_UNKNOWN, opj_t2_encode_packet(), OPJ_TRUE, opj_tcd_marker_info::p_packet_size, opj_tile_info::packet, opj_tcd_marker_info::packet_count, opj_codestream_info::packno, opj_tcd_tile::packno, opj_tcp::POC, opj_pi_iterator::poc, opj_poc::prg, opj_cp::rsiz, opj_packet_info::start_pos, opj_cp::tcps, THRESH_CALC, and opj_codestream_info::tile.

Referenced by opj_tcd_rateallocate(), and opj_tcd_t2_encode().

## ◆ opj_t2_getcommacode()

OPJ_UINT32 opj_t2_getcommacode | ( | opj_bio_t * | bio | ) |
| static

References opj_bio_read().

Referenced by opj_t2_read_packet_header().

## ◆ opj_t2_getnumpasses()

OPJ_UINT32 opj_t2_getnumpasses | ( | opj_bio_t * | bio | ) |
| static

References opj_bio_read().

Referenced by opj_t2_read_packet_header().

## ◆ opj_t2_init_seg()

OPJ_BOOL opj_t2_init_seg | ( | opj_tcd_cblk_dec_t * | cblk,
|  | OPJ_UINT32 | index,
|  | OPJ_UINT32 | cblksty,
|  | OPJ_UINT32 | first )
| static

Parameters

  cblk |
  index |
  cblksty |
  first |

References J2K_CCP_CBLKSTY_LAZY, J2K_CCP_CBLKSTY_TERMALL, opj_tcd_cblk_dec::m_current_max_segs, opj_tcd_seg::maxpasses, OPJ_FALSE, OPJ_J2K_DEFAULT_NB_SEGS, opj_realloc(), opj_tcd_reinit_segment(), OPJ_TRUE, and opj_tcd_cblk_dec::segs.

Referenced by opj_t2_read_packet_header().

## ◆ opj_t2_putcommacode()

void opj_t2_putcommacode | ( | opj_bio_t * | bio,
|  | OPJ_INT32 | n )
| static

References opj_bio_putbit().

Referenced by opj_t2_encode_packet().

## ◆ opj_t2_putnumpasses()

void opj_t2_putnumpasses | ( | opj_bio_t * | bio,
|  | OPJ_UINT32 | n )
| static

Variable length code for signalling delta Zil (truncation point)

Parameters

  bio | Bit Input/Output component
  n | delta Zil

References opj_bio_putbit(), and opj_bio_write().

Referenced by opj_t2_encode_packet().

## ◆ opj_t2_read_packet_data()

OPJ_BOOL opj_t2_read_packet_data | ( | opj_t2_t * | p_t2,
|  | opj_tcd_tile_t * | p_tile,
|  | opj_pi_iterator_t * | p_pi,
|  | OPJ_BYTE * | p_src_data,
|  | OPJ_UINT32 * | p_data_read,
|  | OPJ_UINT32 | p_max_length,
|  | opj_packet_info_t * | pack_info,
|  | opj_event_mgr_t * | p_manager )
| static

References opj_tcd_resolution::bands, opj_tcd_precinct::cblks, opj_tcd_precinct::ch, opj_tcd_cblk_dec::chunks, opj_pi_iterator::compno, opj_tcd_tile::comps, opj_tcd_cblk_dec::corrupted, opj_t2::cp, opj_tcd_precinct::cw, opj_tcd_seg_data_chunk::data, opj_tcd_precinct::dec, EVT_ERROR, EVT_WARNING, opj_tcd_seg::len, opj_tcd_seg_data_chunk::len, opj_tcd_seg::maxpasses, opj_tcd_seg::newlen, opj_tcd_resolution::numbands, opj_tcd_cblk_dec::numchunks, opj_tcd_cblk_dec::numchunksalloc, opj_tcd_cblk_dec::numnewpasses, opj_tcd_seg::numnewpasses, opj_tcd_seg::numpasses, opj_tcd_cblk_dec::numsegs, OPJ_ARG_NOT_USED, opj_event_msg(), OPJ_FALSE, opj_realloc(), OPJ_TRUE, opj_tcd_band::precincts, opj_pi_iterator::precno, opj_tcd_seg::real_num_passes, opj_tcd_cblk_dec::real_num_segs, opj_pi_iterator::resno, opj_tcd_tilecomp::resolutions, opj_tcd_cblk_dec::segs, opj_cp::strict, opj_tcd_band::x0, opj_tcd_band::x1, opj_tcd_band::y0, and opj_tcd_band::y1.

Referenced by opj_t2_decode_packet().

## ◆ opj_t2_read_packet_header()

OPJ_BOOL opj_t2_read_packet_header | ( | opj_t2_t * | p_t2,
|  | opj_tcd_tile_t * | p_tile,
|  | opj_tcp_t * | p_tcp,
|  | opj_pi_iterator_t * | p_pi,
|  | OPJ_BOOL * | p_is_data_present,
|  | OPJ_BYTE * | p_src_data,
|  | OPJ_UINT32 * | p_data_read,
|  | OPJ_UINT32 | p_max_length,
|  | opj_packet_info_t * | p_pack_info,
|  | opj_event_mgr_t * | p_manager )
| static

TODO : check the Nsop value

References opj_tcd_resolution::bands, opj_tcd_precinct::cblks, opj_tccp::cblksty, opj_tcd_precinct::ch, opj_pi_iterator::compno, opj_tcd_tile::comps, opj_t2::cp, opj_tcp::csty, opj_tcd_precinct::cw, opj_tcd_precinct::dec, opj_packet_info::end_ph_pos, EVT_ERROR, EVT_WARNING, opj_tcd_precinct::imsbtree, opj_tcd_precinct::incltree, J2K_CCP_CBLKSTY_HT, J2K_CP_CSTY_EPH, J2K_CP_CSTY_SOP, JAS_FPRINTF, opj_pi_iterator::layno, opj_tcd_seg::maxpasses, opj_tcd_cblk_dec::Mb, opj_tcd_seg::newlen, opj_tcd_resolution::numbands, opj_tcd_band::numbps, opj_tcd_cblk_dec::numbps, opj_tcd_cblk_dec::numlenbits, opj_tcd_cblk_dec::numnewpasses, opj_tcd_seg::numnewpasses, opj_tcd_seg::numpasses, opj_tcd_cblk_dec::numsegs, opj_bio_create(), opj_bio_destroy(), opj_bio_inalign(), opj_bio_init_dec(), opj_bio_numbytes(), opj_bio_read(), opj_event_msg(), OPJ_FALSE, opj_int_min(), opj_t2_getcommacode(), opj_t2_getnumpasses(), opj_t2_init_seg(), opj_tcd_is_band_empty(), opj_tgt_decode(), opj_tgt_reset(), OPJ_TRUE, opj_uint_floorlog2(), opj_cp::ppm, opj_cp::ppm_data, opj_cp::ppm_len, opj_tcp::ppt, opj_tcp::ppt_data, opj_tcp::ppt_len, opj_tcd_band::precincts, opj_tcd_band::precincts_data_size, opj_pi_iterator::precno, opj_tcd_cblk_dec::real_num_segs, opj_pi_iterator::resno, opj_tcd_tilecomp::resolutions, opj_tcd_cblk_dec::segs, and opj_tcp::tccps.

Referenced by opj_t2_decode_packet(), and opj_t2_skip_packet().

## ◆ opj_t2_skip_packet()

OPJ_BOOL opj_t2_skip_packet | ( | opj_t2_t * | p_t2,
|  | opj_tcd_tile_t * | p_tile,
|  | opj_tcp_t * | p_tcp,
|  | opj_pi_iterator_t * | p_pi,
|  | OPJ_BYTE * | p_src,
|  | OPJ_UINT32 * | p_data_read,
|  | OPJ_UINT32 | p_max_length,
|  | opj_packet_info_t * | p_pack_info,
|  | opj_event_mgr_t * | p_manager )
| static

References OPJ_FALSE, opj_t2_read_packet_header(), opj_t2_skip_packet_data(), and OPJ_TRUE.

Referenced by opj_t2_decode_packets().

## ◆ opj_t2_skip_packet_data()

OPJ_BOOL opj_t2_skip_packet_data | ( | opj_t2_t * | p_t2,
|  | opj_tcd_tile_t * | p_tile,
|  | opj_pi_iterator_t * | p_pi,
|  | OPJ_UINT32 * | p_data_read,
|  | OPJ_UINT32 | p_max_length,
|  | opj_packet_info_t * | pack_info,
|  | opj_event_mgr_t * | p_manager )
| static

References opj_tcd_resolution::bands, opj_tcd_precinct::cblks, opj_tcd_precinct::ch, opj_pi_iterator::compno, opj_tcd_tile::comps, opj_t2::cp, opj_tcd_precinct::cw, opj_tcd_precinct::dec, EVT_ERROR, EVT_WARNING, JAS_FPRINTF, opj_tcd_seg::maxpasses, opj_tcd_seg::newlen, opj_tcd_resolution::numbands, opj_tcd_cblk_dec::numnewpasses, opj_tcd_seg::numnewpasses, opj_tcd_seg::numpasses, opj_tcd_cblk_dec::numsegs, OPJ_ARG_NOT_USED, opj_event_msg(), OPJ_FALSE, OPJ_TRUE, opj_tcd_band::precincts, opj_pi_iterator::precno, opj_pi_iterator::resno, opj_tcd_tilecomp::resolutions, opj_tcd_cblk_dec::segs, opj_cp::strict, opj_tcd_band::x0, opj_tcd_band::x1, opj_tcd_band::y0, and opj_tcd_band::y1.

Referenced by opj_t2_skip_packet().