MQC - Implementation of an MQ-Coder

Data Structures

struct  opj_mqc_state
 This struct defines the state of a context. More...
struct  opj_mqc
 MQ coder. More...

Defines

#define MQC_NUMCTXS   19

Typedefs

typedef struct opj_mqc_state opj_mqc_state_t
 This struct defines the state of a context.
typedef struct opj_mqc opj_mqc_t
 MQ coder.

Local static functions



static void mqc_byteout (opj_mqc_t *mqc)
 Output a byte, doing bit-stuffing if necessary.
static void mqc_renorme (opj_mqc_t *mqc)
 Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000.
static void mqc_codemps (opj_mqc_t *mqc)
 Encode the most probable symbol.
static void mqc_codelps (opj_mqc_t *mqc)
 Encode the most least symbol.
static void mqc_setbits (opj_mqc_t *mqc)
 Fill mqc->c with 1's for flushing.
static void mqc_bytein (opj_mqc_t *mqc)
 FIXME: documentation ???
static void mqc_renormd (opj_mqc_t *mqc)
 Renormalize mqc->a and mqc->c while decoding.

Exported functions



opj_mqc_tmqc_create (void)
 Create a new MQC handle.
void mqc_destroy (opj_mqc_t *mqc)
 Destroy a previously created MQC handle.
int mqc_numbytes (opj_mqc_t *mqc)
 Return the number of bytes written/read since initialisation.
void mqc_resetstates (opj_mqc_t *mqc)
 Reset the states of all the context of the coder/decoder (each context is set to a state where 0 and 1 are more or less equiprobable).
void mqc_setstate (opj_mqc_t *mqc, int ctxno, int msb, int prob)
 Set the state of a particular context.
void mqc_init_enc (opj_mqc_t *mqc, unsigned char *bp)
 Initialize the encoder.
void mqc_encode (opj_mqc_t *mqc, int d)
 Encode a symbol using the MQ-coder.
void mqc_flush (opj_mqc_t *mqc)
 Flush the encoder, so that all remaining data is written.
void mqc_bypass_init_enc (opj_mqc_t *mqc)
 BYPASS mode switch, initialization operation.
void mqc_bypass_enc (opj_mqc_t *mqc, int d)
 BYPASS mode switch, coding operation.
int mqc_bypass_flush_enc (opj_mqc_t *mqc)
 BYPASS mode switch, flush operation.
void mqc_reset_enc (opj_mqc_t *mqc)
 RESET mode switch.
int mqc_restart_enc (opj_mqc_t *mqc)
 RESTART mode switch (TERMALL).
void mqc_restart_init_enc (opj_mqc_t *mqc)
 RESTART mode switch (TERMALL) reinitialisation.
void mqc_erterm_enc (opj_mqc_t *mqc)
 ERTERM mode switch (PTERM).
void mqc_segmark_enc (opj_mqc_t *mqc)
 SEGMARK mode switch (SEGSYM).
void mqc_init_dec (opj_mqc_t *mqc, unsigned char *bp, int len)
 Initialize the decoder.
int mqc_decode (opj_mqc_t *mqc)
 Decode a symbol.
#define mqc_setcurctx(mqc, ctxno)   (mqc)->curctx = &(mqc)->ctxs[(int)(ctxno)]
 Set the current context used for coding/decoding.

Define Documentation

#define MQC_NUMCTXS   19

Referenced by mqc_resetstates().

#define mqc_setcurctx ( mqc,
ctxno   )     (mqc)->curctx = &(mqc)->ctxs[(int)(ctxno)]

Set the current context used for coding/decoding.

Parameters:
mqc MQC handle
Parameters:
ctxno Number that identifies the context

Referenced by mqc_init_dec(), mqc_init_enc(), mqc_restart_init_enc(), mqc_segmark_enc(), t1_dec_clnpass(), t1_dec_clnpass_step(), t1_dec_refpass_step(), t1_dec_sigpass_step(), t1_enc_clnpass(), t1_enc_clnpass_step(), t1_enc_refpass_step(), and t1_enc_sigpass_step().


Typedef Documentation

This struct defines the state of a context.

typedef struct opj_mqc opj_mqc_t

MQ coder.


Function Documentation

void mqc_bypass_enc ( opj_mqc_t mqc,
int  d 
)

BYPASS mode switch, coding operation.

JPEG 2000 p 505.

Not fully implemented and tested !!

Parameters:
mqc MQC handle
Parameters:
d The symbol to be encoded (0 or 1)

References opj_mqc::bp, opj_mqc::c, and opj_mqc::ct.

Referenced by t1_enc_refpass_step(), and t1_enc_sigpass_step().

int mqc_bypass_flush_enc ( opj_mqc_t mqc  ) 

BYPASS mode switch, flush operation.

Not fully implemented and tested !!

Parameters:
mqc MQC handle
Returns:
Returns 1 (always)

References opj_mqc::bp, opj_mqc::c, and opj_mqc::ct.

void mqc_bypass_init_enc ( opj_mqc_t mqc  ) 

BYPASS mode switch, initialization operation.

JPEG 2000 p 505.

Not fully implemented and tested !!

Parameters:
mqc MQC handle

References opj_mqc::c, and opj_mqc::ct.

Referenced by t1_encode_cblk().

static void mqc_bytein ( opj_mqc_t mqc  )  [static]

FIXME: documentation ???

Parameters:
mqc MQC handle
Returns:
FIXME: documentation ???
Parameters:
mqc MQC handle
Returns:
Input a byte
Parameters:
mqc MQC handle

References opj_mqc::bp, opj_mqc::c, opj_mqc::ct, and opj_mqc::end.

Referenced by mqc_init_dec(), and mqc_renormd().

static void mqc_byteout ( opj_mqc_t mqc  )  [static]

Output a byte, doing bit-stuffing if necessary.

After a 0xff byte, the next byte must be smaller than 0x90.

Parameters:
mqc MQC handle

References opj_mqc::bp, opj_mqc::c, and opj_mqc::ct.

Referenced by mqc_erterm_enc(), mqc_flush(), mqc_renorme(), and mqc_restart_enc().

static void mqc_codelps ( opj_mqc_t mqc  )  [static]

Encode the most least symbol.

Parameters:
mqc MQC handle

References opj_mqc::a, opj_mqc::c, opj_mqc::curctx, and mqc_renorme().

Referenced by mqc_encode().

static void mqc_codemps ( opj_mqc_t mqc  )  [static]

Encode the most probable symbol.

Parameters:
mqc MQC handle

References opj_mqc::a, opj_mqc::c, opj_mqc::curctx, and mqc_renorme().

Referenced by mqc_encode().

opj_mqc_t* mqc_create ( void   ) 

Create a new MQC handle.

Returns:
Returns a new MQC handle if successful, returns NULL otherwise

References opj_malloc.

Referenced by t1_create().

int mqc_decode ( opj_mqc_t mqc  ) 

Decode a symbol.

Parameters:
mqc MQC handle
Returns:
Returns the decoded symbol (0 or 1)

References opj_mqc::a, opj_mqc::c, opj_mqc::curctx, and mqc_renormd().

Referenced by t1_dec_clnpass(), t1_dec_clnpass_step(), t1_dec_refpass_step(), and t1_dec_sigpass_step().

void mqc_destroy ( opj_mqc_t mqc  ) 

Destroy a previously created MQC handle.

Parameters:
mqc MQC handle to destroy

References opj_free.

Referenced by t1_destroy().

void mqc_encode ( opj_mqc_t mqc,
int  d 
)

Encode a symbol using the MQ-coder.

Parameters:
mqc MQC handle
Parameters:
d The symbol to be encoded (0 or 1)

References opj_mqc::curctx, mqc_codelps(), and mqc_codemps().

Referenced by mqc_segmark_enc(), t1_enc_clnpass(), t1_enc_clnpass_step(), t1_enc_refpass_step(), and t1_enc_sigpass_step().

void mqc_erterm_enc ( opj_mqc_t mqc  ) 

ERTERM mode switch (PTERM).

Parameters:
mqc MQC handle

References opj_mqc::bp, opj_mqc::c, opj_mqc::ct, and mqc_byteout().

Referenced by t1_encode_cblk().

void mqc_flush ( opj_mqc_t mqc  ) 

Flush the encoder, so that all remaining data is written.

Parameters:
mqc MQC handle

References opj_mqc::bp, opj_mqc::c, opj_mqc::ct, mqc_byteout(), and mqc_setbits().

Referenced by t1_encode_cblk().

void mqc_init_dec ( opj_mqc_t mqc,
unsigned char *  bp,
int  len 
)

Initialize the decoder.

Parameters:
mqc MQC handle
Parameters:
bp Pointer to the start of the buffer from which the bytes will be read
Parameters:
len Length of the input buffer

References opj_mqc::a, opj_mqc::bp, opj_mqc::c, opj_mqc::ct, opj_mqc::end, mqc_bytein(), mqc_setcurctx, and opj_mqc::start.

Referenced by t1_decode_cblk().

void mqc_init_enc ( opj_mqc_t mqc,
unsigned char *  bp 
)

Initialize the encoder.

Parameters:
mqc MQC handle
Parameters:
bp Pointer to the start of the buffer where the bytes will be written

References opj_mqc::a, opj_mqc::bp, opj_mqc::c, opj_mqc::ct, mqc_setcurctx, and opj_mqc::start.

Referenced by t1_encode_cblk().

int mqc_numbytes ( opj_mqc_t mqc  ) 

Return the number of bytes written/read since initialisation.

Parameters:
mqc MQC handle
Returns:
Returns the number of bytes already encoded

References opj_mqc::bp, and opj_mqc::start.

Referenced by t1_encode_cblk().

static void mqc_renormd ( opj_mqc_t mqc  )  [static]

Renormalize mqc->a and mqc->c while decoding.

Parameters:
mqc MQC handle

References opj_mqc::a, opj_mqc::c, opj_mqc::ct, and mqc_bytein().

Referenced by mqc_decode().

static void mqc_renorme ( opj_mqc_t mqc  )  [static]

Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000.

Parameters:
mqc MQC handle

References opj_mqc::a, opj_mqc::c, opj_mqc::ct, and mqc_byteout().

Referenced by mqc_codelps(), and mqc_codemps().

void mqc_reset_enc ( opj_mqc_t mqc  ) 

RESET mode switch.

Parameters:
mqc MQC handle

References mqc_resetstates(), mqc_setstate(), T1_CTXNO_AGG, T1_CTXNO_UNI, and T1_CTXNO_ZC.

Referenced by t1_encode_cblk().

void mqc_resetstates ( opj_mqc_t mqc  ) 

Reset the states of all the context of the coder/decoder (each context is set to a state where 0 and 1 are more or less equiprobable).

Parameters:
mqc MQC handle

References opj_mqc::ctxs, and MQC_NUMCTXS.

Referenced by mqc_reset_enc(), t1_decode_cblk(), and t1_encode_cblk().

int mqc_restart_enc ( opj_mqc_t mqc  ) 

RESTART mode switch (TERMALL).

Parameters:
mqc MQC handle
Returns:
Returns 1 (always)

References opj_mqc::c, opj_mqc::ct, and mqc_byteout().

void mqc_restart_init_enc ( opj_mqc_t mqc  ) 

RESTART mode switch (TERMALL) reinitialisation.

Parameters:
mqc MQC handle

References opj_mqc::a, opj_mqc::bp, opj_mqc::c, opj_mqc::ct, and mqc_setcurctx.

Referenced by t1_encode_cblk().

void mqc_segmark_enc ( opj_mqc_t mqc  ) 

SEGMARK mode switch (SEGSYM).

Parameters:
mqc MQC handle

References mqc_encode(), and mqc_setcurctx.

Referenced by t1_encode_cblk().

static void mqc_setbits ( opj_mqc_t mqc  )  [static]

Fill mqc->c with 1's for flushing.

Parameters:
mqc MQC handle

References opj_mqc::a, and opj_mqc::c.

Referenced by mqc_flush().

void mqc_setstate ( opj_mqc_t mqc,
int  ctxno,
int  msb,
int  prob 
)

Set the state of a particular context.

Parameters:
mqc MQC handle
Parameters:
ctxno Number that identifies the context
Parameters:
msb The MSB of the new state of the context
Parameters:
prob Number that identifies the probability of the symbols for the new state of the context

References opj_mqc::ctxs.

Referenced by mqc_reset_enc(), t1_decode_cblk(), and t1_encode_cblk().

Generated on Sat Jan 22 13:23:00 2011 for OpenJPEG by  doxygen 1.6.3