📄 overview of the j2000 coder-decoder modules.htm
字号:
transform. The DWT module provides a reversible transform using the 5-3
wavelet and an irreversible transform using the 9-7 wavelet. The DWT module is
used by the TCD module. <PRE><FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply a reversible DWT transform to a component of an image </FONT>
<FONT color=#0000ff> * a: samples of the component</FONT>
<FONT color=#0000ff> * w: width of the component</FONT>
<FONT color=#0000ff> * h: height of the component</FONT>
<FONT color=#0000ff> * l: number of decomposition levels in the DWT</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> dwt_encode(<FONT color=#2e8b57><B>int</B></FONT>* a, <FONT color=#2e8b57><B>int</B></FONT> w, <FONT color=#2e8b57><B>int</B></FONT> h, <FONT color=#2e8b57><B>int</B></FONT> l);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply a reversible inverse DWT transform to a component of an image </FONT>
<FONT color=#0000ff> * a: samples of the component</FONT>
<FONT color=#0000ff> * w: width of the component</FONT>
<FONT color=#0000ff> * h: height of the component</FONT>
<FONT color=#0000ff> * l: number of decomposition levels in the DWT</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> dwt_decode(<FONT color=#2e8b57><B>int</B></FONT>* a, <FONT color=#2e8b57><B>int</B></FONT> w, <FONT color=#2e8b57><B>int</B></FONT> h, <FONT color=#2e8b57><B>int</B></FONT> l);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Get the gain of a subband for the reversible DWT</FONT>
<FONT color=#0000ff> * orient: number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> dwt_getgain(<FONT color=#2e8b57><B>int</B></FONT> orient);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Get the norm of a wavelet function of a subband at a specified level for the reversible DWT</FONT>
<FONT color=#0000ff> * level: level of the wavelet function</FONT>
<FONT color=#0000ff> * orient: band of the wavelet function</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>double</B></FONT> dwt_getnorm(<FONT color=#2e8b57><B>int</B></FONT> level, <FONT color=#2e8b57><B>int</B></FONT> orient);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply an irreversible DWT transform to a component of an image </FONT>
<FONT color=#0000ff> * a: samples of the component</FONT>
<FONT color=#0000ff> * w: width of the component</FONT>
<FONT color=#0000ff> * h: height of the component</FONT>
<FONT color=#0000ff> * l: number of decomposition levels in the DWT</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> dwt_encode_real(<FONT color=#2e8b57><B>int</B></FONT>* a, <FONT color=#2e8b57><B>int</B></FONT> w, <FONT color=#2e8b57><B>int</B></FONT> h, <FONT color=#2e8b57><B>int</B></FONT> l);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Apply an irreversible inverse DWT transform to a component of an image </FONT>
<FONT color=#0000ff> * a: samples of the component</FONT>
<FONT color=#0000ff> * w: width of the component</FONT>
<FONT color=#0000ff> * h: height of the component</FONT>
<FONT color=#0000ff> * l: number of decomposition levels in the DWT</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> dwt_decode_real(<FONT color=#2e8b57><B>int</B></FONT>* a, <FONT color=#2e8b57><B>int</B></FONT> w, <FONT color=#2e8b57><B>int</B></FONT> h, <FONT color=#2e8b57><B>int</B></FONT> l);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Get the gain of a subband for the irreversible DWT</FONT>
<FONT color=#0000ff> * orient: number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> dwt_getgain_real(<FONT color=#2e8b57><B>int</B></FONT> orient);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Get the norm of a wavelet function of a subband at a specified level for the irreversible DWT</FONT>
<FONT color=#0000ff> * level: level of the wavelet function</FONT>
<FONT color=#0000ff> * orient: band of the wavelet function</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>double</B></FONT> dwt_getnorm_real(<FONT color=#2e8b57><B>int</B></FONT> level, <FONT color=#2e8b57><B>int</B></FONT> orient);
</PRE>
<H3>
<LI>The Tier-1 Coder/Decoder (T1)</H3>The Tier-1 module implements the entropy
coding of the wavelet coefficients. Each wavelet subband is partitionned in
code-blocks of a fixed size. The T1 modules produces a compressed
representation for each of these codeblocks. Moreover, the compressed
representations are scalable in distortion, meaning they can be truncated to
produce an approximation of lesser fidelity. The T1 module is used by the TCD
module. <PRE><FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Initialize the look-up tables of the Tier-1 coder/decoder</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> t1_init_luts();
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Encode the code-blocks of a tile</FONT>
<FONT color=#0000ff> * tile: the tile to encode</FONT>
<FONT color=#0000ff> * tcp: tile coding parameters</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> t1_encode_cblks(tcd_tile_t *tile, j2k_tcp_t *tcp);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Decode the code-blocks of a tile</FONT>
<FONT color=#0000ff> * tile: the tile to encode</FONT>
<FONT color=#0000ff> * tcp: tile coding parameters</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> t1_decode_cblks(tcd_tile_t *tile, j2k_tcp_t *tcp);
</PRE>
<H3>
<LI>The MQ-Coder (MQC)</H3>The MQC module implements a MQ-Coder. The MQ-Coder
is used for entropy coding of sequences of bits. The MQ-Coder can have several
contexts, each context having an independant state (the state of a context is
the probability distribution of the symbols to encode, based on the values of
previously encoded symbols). The MQC module is used by the T1 module. <PRE><FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Return the number of bytes written/read since initialisation</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> mqc_numbytes();
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Reset the states of all the context of the coder/decoder</FONT>
<FONT color=#0000ff> * (each context is set to a state where 0 and 1 are more or less equiprobable)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_resetstates();
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Set the state of a particular context</FONT>
<FONT color=#0000ff> * ctxno: number that identifies the context</FONT>
<FONT color=#0000ff> * msb: the MSB of the new state of the context</FONT>
<FONT color=#0000ff> * prob: number that identifies the probability of the symbols for the new state of the context</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_setstate(<FONT color=#2e8b57><B>int</B></FONT> ctxno, <FONT color=#2e8b57><B>int</B></FONT> msb, <FONT color=#2e8b57><B>int</B></FONT> prob);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Initialize the encoder</FONT>
<FONT color=#0000ff> * bp: pointer to the start of the buffer where the bytes will be written</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_init_enc(<FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *bp);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Set the current context used for coding/decoding</FONT>
<FONT color=#0000ff> * ctxno: number that identifies the context</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_setcurctx(<FONT color=#2e8b57><B>int</B></FONT> ctxno);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Encode a bit</FONT>
<FONT color=#0000ff> * d: bit to encode (0 or 1)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_encode(<FONT color=#2e8b57><B>int</B></FONT> d);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Flush the encoder, so that all remaining data is written</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_flush();
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Initialize the decoder</FONT>
<FONT color=#0000ff> * bp: pointer to the start of the buffer from which the bytes will be read</FONT>
<FONT color=#0000ff> * len: length of the input buffer</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>void</B></FONT> mqc_init_dec(<FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *bp, <FONT color=#2e8b57><B>int</B></FONT> len);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Decode a bit (returns 0 or 1)</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> mqc_decode();
</PRE>
<H3>
<LI>The Tier-2 Coder/Decoder (T2)</H3>The Tier-2 coder is used to paquetize
the encoded data of the codeblocks of each tile. The codeblocks are grouped in
precincts for which all the data are encoded in a single paquet. The order in
which the paquets are output is specified in the coding parameters. The T2
module is used by the TCD module. <PRE><FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Encode the packets of a tile to a destination buffer</FONT>
<FONT color=#0000ff> * img: the source image</FONT>
<FONT color=#0000ff> * cp: the image coding parameters</FONT>
<FONT color=#0000ff> * tile: the tile for which to write the packets</FONT>
<FONT color=#0000ff> * dest: the destination buffer</FONT>
<FONT color=#0000ff> * len: the length of the destination buffer</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> t2_encode_packets(j2k_image_t *img, j2k_cp_t *cp, <FONT color=#2e8b57><B>int</B></FONT> tileno, tcd_tile_t *tile, <FONT color=#2e8b57><B>int</B></FONT> maxlayers, <FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *dest, <FONT color=#2e8b57><B>int</B></FONT> len);
<FONT color=#0000ff>/*</FONT>
<FONT color=#0000ff> * Decode the packets of a tile from a source buffer</FONT>
<FONT color=#0000ff> * src: the source buffer</FONT>
<FONT color=#0000ff> * len: length of the source buffer</FONT>
<FONT color=#0000ff> * img: destination image</FONT>
<FONT color=#0000ff> * cp: image coding parameters</FONT>
<FONT color=#0000ff> * tileno: number that identifies the tile for which to decode the packets</FONT>
<FONT color=#0000ff> * tile: tile for which to decode the packets</FONT>
<FONT color=#0000ff> */</FONT>
<FONT color=#2e8b57><B>int</B></FONT> t2_decode_packets(<FONT color=#2e8b57><B>unsigned</B></FONT> <FONT color=#2e8b57><B>char</B></FONT> *src, <FONT color=#2e8b57><B>int</B></FONT> len, j2k_image_t *img, j2k_cp_t *cp, <FONT color=#2e8b57><B>int</B></FONT> tileno, tcd_tile_t *tile);
</PRE>
<H3>
<LI>The Packet Iterator (PI)</H3>The Packet Iterator module is used to list
all the packets used to encode an image in a given progression order. The PI
module is used by the T2 module. <PRE><FONT color=#2e8b57><B>typedef</B></FONT> <FONT color=#2e8b57><B>struct</B></FONT> {
<FONT color=#2e8b57><B>int</B></FONT> compno, resno, precno, layno; <FONT color=#0000ff>// component, resolution, precinct and layer that indentify the packet</FONT>
<FONT color=#2e8b57><B>int</B></FONT> first;
j2k_poc_t poc;
<FONT color=#2e8b57><B>int</B></FONT> numcomps;
pi_comp_t *comps;
<FONT color=#2e8b57><B>int</B></FONT> tx0, ty0, tx1, ty1;
<FONT color=#2e8b57><B>int</B></FONT> x, y, dx, dy;
} pi_iterator_t; <FONT color=#0000ff>// packet iterator</FONT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -