Skip to content

Commit

Permalink
MQC: remove disabled MQC_PERF_OPT mode, which brings no performance i…
Browse files Browse the repository at this point in the history
…mprovements (see #923)
  • Loading branch information
rouault committed May 15, 2017
1 parent 4431fa7 commit 83d7a6d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 67 deletions.
54 changes: 0 additions & 54 deletions src/lib/openjp2/mqc.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,22 +275,12 @@ static void opj_mqc_setbits(opj_mqc_t *mqc)
opj_mqc_t* opj_mqc_create(void)
{
opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
#ifdef MQC_PERF_OPT
if (mqc) {
mqc->buffer = NULL;
}
#endif
return mqc;
}

void opj_mqc_destroy(opj_mqc_t *mqc)
{
if (mqc) {
#ifdef MQC_PERF_OPT
if (mqc->buffer) {
opj_free(mqc->buffer);
}
#endif
opj_free(mqc);
}
}
Expand Down Expand Up @@ -463,50 +453,6 @@ OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len)
mqc->c = (OPJ_UINT32)(*mqc->bp << 16);
}

#ifdef MQC_PERF_OPT /* TODO_MSD: check this option and put in experimental */
{
OPJ_UINT32 c;
OPJ_UINT32 *ip;
OPJ_BYTE *end = mqc->end - 1;
void* new_buffer = opj_realloc(mqc->buffer, (len + 1) * sizeof(OPJ_UINT32));
if (! new_buffer) {
opj_free(mqc->buffer);
mqc->buffer = NULL;
return OPJ_FALSE;
}
mqc->buffer = new_buffer;

ip = (OPJ_UINT32 *) mqc->buffer;

while (bp < end) {
c = *(bp + 1);
if (*bp == 0xff) {
if (c > 0x8f) {
break;
} else {
*ip = 0x00000017 | (c << 9);
}
} else {
*ip = 0x00000018 | (c << 8);
}
bp++;
ip++;
}

/* Handle last byte of data */
c = 0xff;
if (*bp == 0xff) {
*ip = 0x0000ff18;
} else {
bp++;
*ip = 0x00000018 | (c << 8);
}
ip++;

*ip = 0x0000ff08;
mqc->bp = mqc->buffer;
}
#endif
opj_mqc_bytein(mqc);
mqc->c <<= 7;
mqc->ct -= 7;
Expand Down
3 changes: 0 additions & 3 deletions src/lib/openjp2/mqc.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ typedef struct opj_mqc {
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
opj_mqc_state_t **curctx;
const OPJ_BYTE *lut_ctxno_zc_orient; /* lut_ctxno_zc shifted by 256 * bandno */
#ifdef MQC_PERF_OPT
unsigned char *buffer;
#endif
} opj_mqc_t;

#include "mqc_inl.h"
Expand Down
10 changes: 0 additions & 10 deletions src/lib/openjp2/mqc_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc)
Input a byte
@param mqc MQC handle
*/
#ifdef MQC_PERF_OPT
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
{
unsigned int i = *((unsigned int *) mqc->bp);
mqc->c += i & 0xffff00;
mqc->ct = i & 0x0f;
mqc->bp += (i >> 2) & 0x04;
}
#else
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
{
/* Implements ISO 15444-1 C.3.4 Compressed image data input (BYTEIN) */
Expand Down Expand Up @@ -123,7 +114,6 @@ static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
mqc->ct = 8;
}
}
#endif

/**
Renormalize mqc->a and mqc->c while decoding
Expand Down

0 comments on commit 83d7a6d

Please sign in to comment.