OpenJPEG: jp2k_encoder.c File Reference

OpenJPEG 2.5.3

Macros | Functions
jp2k_encoder.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <math.h>`
`#include <assert.h>`
`#include <inttypes.h>`
`#include "jp2k_encoder.h"`
`#include "j2kheader_manager.h"`
`#include "imgreg_manager.h"`

## Macros
#define | FCGI_stdout stdout
#define | FCGI_stderr stderr
#define | logstream stderr

## Functions
message_param_t * | search_message (Byte8_t class_id, Byte8_t in_class_id, Byte8_t csn, message_param_t *msg)
| search a message by class_id
Byte_t * | recons_codestream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *codelen)
| reconstruct j2k codestream from JPT- (in future, JPP-) stream
Byte_t * | recons_j2k (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen)
| reconstruct j2k codestream from message queue
Byte_t * | add_emptyboxstream (placeholder_param_t *phld, Byte_t *jp2stream, Byte8_t *jp2len)
Byte_t * | add_msgstream (message_param_t *message, Byte_t *origstream, Byte_t *j2kstream, Byte8_t *j2klen)
Byte_t * | recons_jp2 (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, Byte8_t *jp2len)
| reconstruct jp2 file codestream from message queue
OPJ_BOOL | isJPPstream (Byte8_t csn, msgqueue_param_t *msgqueue)
Byte_t * | recons_codestream_from_JPTstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen)
Byte_t * | recons_codestream_from_JPPstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, int fw, int fh, Byte8_t *j2klen)
Byte_t * | add_EOC (Byte_t *j2kstream, Byte8_t *j2klen)
Byte_t * | add_mainhead_msgstream (msgqueue_param_t *msgqueue, Byte_t *origstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t *j2klen)
Byte8_t | get_last_tileID (msgqueue_param_t *msgqueue, Byte8_t csn, OPJ_BOOL isJPPstream)
Byte_t * | add_emptytilestream (const Byte8_t tileID, Byte_t *j2kstream, Byte8_t *j2klen)
Byte_t * | add_SOTmkr (Byte_t *j2kstream, Byte8_t *j2klen)
Byte_t * | recons_bitstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, int *max_reslev, Byte8_t *j2klen)
Byte_t * | recons_LRCPbitstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, int *max_reslev, Byte8_t *j2klen)
Byte_t * | recons_RLCPbitstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, int *max_reslev, Byte8_t *j2klen)
Byte_t * | recons_RPCLbitstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, int *max_reslev, Byte8_t *j2klen)
Byte_t * | recons_PCRLbitstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, int *max_reslev, Byte8_t *j2klen)
Byte_t * | recons_CPRLbitstream (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int mindeclev, int *max_reslev, Byte8_t *j2klen)
int | comp_numOfprcts (Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r)
Byte8_t | comp_seqID (Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int r, int p)
Byte_t * | recons_packet (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int *max_reslev, int comp_idx, int res_idx, int prct_idx, int lay_idx, Byte8_t *j2klen)
Byte_t * | recons_precinct (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte_t *j2kstream, Byte8_t csn, Byte8_t tileID, SIZmarker_param_t SIZ, CODmarker_param_t COD, int *max_reslev, int comp_idx, int res_idx, Byte8_t seqID, Byte8_t *j2klen)
Byte_t * | add_padding (Byte8_t padding, Byte_t *j2kstream, Byte8_t *j2klen)
Byte_t * | gene_msgstream (message_param_t *message, Byte_t *stream, Byte8_t *length)
Byte_t * | gene_emptytilestream (const Byte8_t tileID, Byte8_t *length)
Byte_t * | recons_j2kmainhead (msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn, Byte8_t *j2klen)
| reconstruct j2k codestream of mainheader from message queue

## Macro Definition Documentation

## ◆ FCGI_stderr

#define FCGI_stderr stderr

Referenced by isJPPstream(), and recons_bitstream().

## ◆ FCGI_stdout

#define FCGI_stdout stdout

## ◆ logstream

#define logstream stderr

## Function Documentation

## ◆ add_emptyboxstream()

Byte_t * add_emptyboxstream | ( | placeholder_param_t * | phld,
|  | Byte_t * | jp2stream,
|  | Byte8_t * | jp2len )

References big4(), big8(), opj_free(), opj_malloc(), placeholder_param::OrigBH, and placeholder_param::OrigBHlen.

Referenced by recons_jp2().

## ◆ add_emptytilestream()

Byte_t * add_emptytilestream | ( | const Byte8_t | tileID,
|  | Byte_t * | j2kstream,
|  | Byte8_t * | j2klen )

References gene_emptytilestream(), opj_free(), and opj_malloc().

Referenced by recons_codestream_from_JPPstream(), and recons_codestream_from_JPTstream().

## ◆ add_EOC()

Byte_t * add_EOC | ( | Byte_t * | j2kstream,
|  | Byte8_t * | j2klen )

References opj_free(), and opj_malloc().

Referenced by recons_codestream_from_JPPstream(), and recons_codestream_from_JPTstream().

## ◆ add_mainhead_msgstream()

Byte_t * add_mainhead_msgstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | origstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t * | j2klen )

References add_msgstream(), message_param::bin_offset, msgqueue_param::first, message_param::length, MAINHEADER_MSG, message_param::next, and search_message().

Referenced by recons_codestream_from_JPPstream(), recons_codestream_from_JPTstream(), and recons_j2kmainhead().

## ◆ add_msgstream()

Byte_t * add_msgstream | ( | message_param_t * | message,
|  | Byte_t * | origstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t * | j2klen )

References gene_msgstream(), opj_free(), and opj_malloc().

Referenced by add_mainhead_msgstream(), recons_codestream_from_JPPstream(), recons_codestream_from_JPTstream(), recons_jp2(), recons_packet(), and recons_precinct().

## ◆ add_padding()

Byte_t * add_padding | ( | Byte8_t | padding,
|  | Byte_t * | j2kstream,
|  | Byte8_t * | j2klen )

References opj_free(), and opj_malloc().

Referenced by recons_packet(), and recons_precinct().

## ◆ add_SOTmkr()

Byte_t * add_SOTmkr | ( | Byte_t * | j2kstream,
|  | Byte8_t * | j2klen )

References opj_free(), and opj_malloc().

Referenced by recons_codestream_from_JPPstream().

## ◆ comp_numOfprcts()

int comp_numOfprcts | ( | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | r )

References get_tile_XSiz(), get_tile_YSiz(), CODmarker_param::numOfdecomp, CODmarker_param::XPsiz, and CODmarker_param::YPsiz.

Referenced by comp_seqID(), recons_CPRLbitstream(), recons_LRCPbitstream(), recons_PCRLbitstream(), recons_RLCPbitstream(), and recons_RPCLbitstream().

## ◆ comp_seqID()

Byte8_t comp_seqID | ( | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | r,
|  | int | p )

References comp_numOfprcts().

Referenced by recons_CPRLbitstream(), recons_packet(), and recons_PCRLbitstream().

## ◆ gene_emptytilestream()

Byte_t * gene_emptytilestream | ( | const Byte8_t | tileID,
|  | Byte8_t * | length )

References opj_malloc().

Referenced by add_emptytilestream().

## ◆ gene_msgstream()

Byte_t * gene_msgstream | ( | message_param_t * | message,
|  | Byte_t * | stream,
|  | Byte8_t * | length )

References message_param::length, opj_malloc(), and message_param::res_offset.

Referenced by add_msgstream().

## ◆ get_last_tileID()

Byte8_t get_last_tileID | ( | msgqueue_param_t * | msgqueue,
|  | Byte8_t | csn,
|  | OPJ_BOOL | isJPPstream )

References message_param::class_id, message_param::csn, EXT_TILE_MSG, msgqueue_param::first, message_param::in_class_id, message_param::next, TILE_HEADER_MSG, and TILE_MSG.

Referenced by recons_codestream_from_JPPstream(), and recons_codestream_from_JPTstream().

## ◆ isJPPstream()

OPJ_BOOL isJPPstream | ( | Byte8_t | csn,
|  | msgqueue_param_t * | msgqueue )

References message_param::class_id, message_param::csn, FCGI_stderr, msgqueue_param::first, message_param::next, OPJ_FALSE, and OPJ_TRUE.

Referenced by recons_codestream().

## ◆ recons_bitstream()

Byte_t * recons_bitstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | mindeclev,
|  | int * | max_reslev,
|  | Byte8_t * | j2klen )

References FCGI_stderr, OPJ_CPRL, OPJ_LRCP, OPJ_PCRL, OPJ_RLCP, OPJ_RPCL, CODmarker_param::prog_order, recons_CPRLbitstream(), recons_LRCPbitstream(), recons_PCRLbitstream(), recons_RLCPbitstream(), and recons_RPCLbitstream().

Referenced by recons_codestream_from_JPPstream().

## ◆ recons_codestream()

Byte_t * recons_codestream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte8_t | csn,
|  | int | fw,
|  | int | fh,
|  | Byte8_t * | codelen )

reconstruct j2k codestream from JPT- (in future, JPP-) stream

Parameters

  [in] | msgqueue | message queue pointer
  [in] | jpipstream | original JPT- JPP- stream
  [in] | csn | codestream number
  [in] | fw | reconstructing image frame width
  [in] | fh | reconstructing image frame height
  [out] | codelen | codestream length

Returns
  generated reconstructed j2k codestream

References isJPPstream(), recons_codestream_from_JPPstream(), and recons_codestream_from_JPTstream().

Referenced by recons_j2k(), and recons_jp2().

## ◆ recons_codestream_from_JPPstream()

Byte_t * recons_codestream_from_JPPstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte8_t | csn,
|  | int | fw,
|  | int | fh,
|  | Byte8_t * | j2klen )

References add_emptytilestream(), add_EOC(), add_mainhead_msgstream(), add_msgstream(), add_SOTmkr(), message_param::bin_offset, comp_decomplev(), SIZmarker_param::Csiz, delete_COD(), msgqueue_param::first, get_last_tileID(), get_mainheader_from_j2kstream(), message_param::length, modify_mainheader(), modify_tileheader(), message_param::next, CODmarker_param::numOfdecomp, OPJ_FALSE, OPJ_TRUE, recons_bitstream(), search_message(), TILE_HEADER_MSG, SIZmarker_param::Xsiz, and SIZmarker_param::Ysiz.

Referenced by recons_codestream().

## ◆ recons_codestream_from_JPTstream()

Byte_t * recons_codestream_from_JPTstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte8_t | csn,
|  | int | fw,
|  | int | fh,
|  | Byte8_t * | j2klen )

References add_emptytilestream(), add_EOC(), add_mainhead_msgstream(), add_msgstream(), message_param::aux, message_param::bin_offset, comp_decomplev(), EXT_TILE_MSG, msgqueue_param::first, get_last_tileID(), get_mainheader_from_j2kstream(), message_param::length, message_param::next, OPJ_FALSE, OPJ_TRUE, search_message(), TILE_MSG, SIZmarker_param::Xsiz, and SIZmarker_param::Ysiz.

Referenced by recons_codestream().

## ◆ recons_CPRLbitstream()

Byte_t * recons_CPRLbitstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | mindeclev,
|  | int * | max_reslev,
|  | Byte8_t * | j2klen )

References comp_numOfprcts(), comp_seqID(), SIZmarker_param::Csiz, CODmarker_param::numOfdecomp, recons_precinct(), and CODmarker_param::Scod.

Referenced by recons_bitstream().

## ◆ recons_j2k()

Byte_t * recons_j2k | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte8_t | csn,
|  | int | fw,
|  | int | fh,
|  | Byte8_t * | j2klen )

reconstruct j2k codestream from message queue

Parameters

  [in] | msgqueue | message queue pointer
  [in] | jpipstream | original jpt- jpp- stream
  [in] | csn | codestream number
  [in] | fw | reconstructing image frame width
  [in] | fh | reconstructing image frame height
  [out] | j2klen | pointer to the j2k codestream length

Returns
  generated reconstructed j2k codestream

References recons_codestream().

Referenced by decode_jpip(), and jpipstream_to_pnm().

## ◆ recons_j2kmainhead()

Byte_t * recons_j2kmainhead | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte8_t | csn,
|  | Byte8_t * | j2klen )

reconstruct j2k codestream of mainheader from message queue

Parameters

  [in] | msgqueue | message queue pointer
  [in] | jpipstream | original jpt- jpp- stream
  [in] | csn | codestream number
  [out] | j2klen | pointer to the j2k codestream length

Returns
  generated reconstructed j2k codestream

References add_mainhead_msgstream().

Referenced by get_SIZ_from_jpipstream().

## ◆ recons_jp2()

Byte_t * recons_jp2 | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte8_t | csn,
|  | Byte8_t * | jp2len )

reconstruct jp2 file codestream from message queue

Parameters

  [in] | msgqueue | message queue pointer
  [in] | jpipstream | original jpt- jpp- stream
  [in] | csn | codestream number
  [out] | jp2len | pointer to the jp2 codestream length

Returns
  generated reconstructed jp2 codestream

References add_emptyboxstream(), add_msgstream(), msgqueue_param::first, METADATA_MSG, message_param::next, opj_free(), placeholder_param::OrigBH, placeholder_param::OrigBHlen, message_param::phld, recons_codestream(), and search_message().

Referenced by decode_jpip(), and handle_JP2saveMSG().

## ◆ recons_LRCPbitstream()

Byte_t * recons_LRCPbitstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | mindeclev,
|  | int * | max_reslev,
|  | Byte8_t * | j2klen )

References comp_numOfprcts(), SIZmarker_param::Csiz, CODmarker_param::numOfdecomp, CODmarker_param::numOflayers, recons_packet(), and CODmarker_param::Scod.

Referenced by recons_bitstream().

## ◆ recons_packet()

Byte_t * recons_packet | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int * | max_reslev,
|  | int | comp_idx,
|  | int | res_idx,
|  | int | prct_idx,
|  | int | lay_idx,
|  | Byte8_t * | j2klen )

References add_msgstream(), add_padding(), message_param::bin_offset, comp_precinct_id(), comp_seqID(), SIZmarker_param::Csiz, msgqueue_param::first, message_param::length, message_param::next, OPJ_FALSE, OPJ_TRUE, PRECINCT_MSG, CODmarker_param::Scod, search_message(), SIZmarker_param::XTnum, and SIZmarker_param::YTnum.

Referenced by recons_LRCPbitstream(), and recons_RLCPbitstream().

## ◆ recons_PCRLbitstream()

Byte_t * recons_PCRLbitstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | mindeclev,
|  | int * | max_reslev,
|  | Byte8_t * | j2klen )

References comp_numOfprcts(), comp_seqID(), SIZmarker_param::Csiz, CODmarker_param::numOfdecomp, recons_precinct(), and CODmarker_param::Scod.

Referenced by recons_bitstream().

## ◆ recons_precinct()

Byte_t * recons_precinct | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int * | max_reslev,
|  | int | comp_idx,
|  | int | res_idx,
|  | Byte8_t | seqID,
|  | Byte8_t * | j2klen )

References add_msgstream(), add_padding(), message_param::bin_offset, comp_precinct_id(), SIZmarker_param::Csiz, msgqueue_param::first, message_param::last_byte, message_param::length, message_param::next, CODmarker_param::numOflayers, OPJ_FALSE, OPJ_TRUE, PRECINCT_MSG, CODmarker_param::Scod, search_message(), SIZmarker_param::XTnum, and SIZmarker_param::YTnum.

Referenced by recons_CPRLbitstream(), recons_PCRLbitstream(), and recons_RPCLbitstream().

## ◆ recons_RLCPbitstream()

Byte_t * recons_RLCPbitstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | mindeclev,
|  | int * | max_reslev,
|  | Byte8_t * | j2klen )

References comp_numOfprcts(), SIZmarker_param::Csiz, CODmarker_param::numOfdecomp, CODmarker_param::numOflayers, recons_packet(), and CODmarker_param::Scod.

Referenced by recons_bitstream().

## ◆ recons_RPCLbitstream()

Byte_t * recons_RPCLbitstream | ( | msgqueue_param_t * | msgqueue,
|  | Byte_t * | jpipstream,
|  | Byte_t * | j2kstream,
|  | Byte8_t | csn,
|  | Byte8_t | tileID,
|  | SIZmarker_param_t | SIZ,
|  | CODmarker_param_t | COD,
|  | int | mindeclev,
|  | int * | max_reslev,
|  | Byte8_t * | j2klen )

References comp_numOfprcts(), SIZmarker_param::Csiz, CODmarker_param::numOfdecomp, recons_precinct(), and CODmarker_param::Scod.

Referenced by recons_bitstream().

## ◆ search_message()

message_param_t * search_message | ( | Byte8_t | class_id,
|  | Byte8_t | in_class_id,
|  | Byte8_t | csn,
|  | message_param_t * | msg )

search a message by class_id

Parameters

  [in] | class_id | class identifiers
  [in] | in_class_id | in-class identifiers, -1 means any
  [in] | csn | codestream number
  [in] | msg | first message pointer of the searching list

Returns
  found message pointer

References message_param::class_id, message_param::csn, message_param::in_class_id, and message_param::next.

Referenced by add_mainhead_msgstream(), recons_codestream_from_JPPstream(), recons_codestream_from_JPTstream(), recons_jp2(), recons_packet(), and recons_precinct().