fixed some uninitialised memory access, mitigated BYPASS/RESTART-mode issues

This commit is contained in:
David Barina 2017-02-15 16:33:16 +01:00
parent 7113c4e3bb
commit fcb95513c2
2 changed files with 6 additions and 2 deletions

View File

@ -324,10 +324,12 @@ void opj_mqc_flush(opj_mqc_t *mqc) {
if (*mqc->bp != 0xff) { if (*mqc->bp != 0xff) {
mqc->bp++; mqc->bp++;
*mqc->bp = 0;
} }
} }
void opj_mqc_bypass_init_enc(opj_mqc_t *mqc) { void opj_mqc_bypass_init_enc(opj_mqc_t *mqc) {
opj_mqc_byteout(mqc);
mqc->c = 0; mqc->c = 0;
mqc->ct = 8; mqc->ct = 8;
/*if (*mqc->bp == 0xff) { /*if (*mqc->bp == 0xff) {
@ -362,6 +364,8 @@ OPJ_UINT32 opj_mqc_bypass_flush_enc(opj_mqc_t *mqc) {
} }
mqc->bp++; mqc->bp++;
*mqc->bp = (OPJ_BYTE)mqc->c; *mqc->bp = (OPJ_BYTE)mqc->c;
mqc->bp++;
*mqc->bp = 0;
mqc->ct = 8; mqc->ct = 8;
mqc->c = 0; mqc->c = 0;
} }

View File

@ -2102,7 +2102,7 @@ static void opj_t1_encode_cblk(opj_t1_t *t1,
/* Code switch "RESTART" (i.e. TERMALL) */ /* Code switch "RESTART" (i.e. TERMALL) */
if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) && !((passtype == 2) && (bpno - 1 < 0))) { if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) && !((passtype == 2) && (bpno - 1 < 0))) {
if (type == T1_TYPE_RAW) { if (type == T1_TYPE_RAW) {
opj_mqc_flush(mqc); opj_mqc_bypass_flush_enc(mqc);
correction = 1; correction = 1;
/* correction = mqc_bypass_flush_enc(); */ /* correction = mqc_bypass_flush_enc(); */
} else { /* correction = mqc_restart_enc(); */ } else { /* correction = mqc_restart_enc(); */
@ -2114,7 +2114,7 @@ static void opj_t1_encode_cblk(opj_t1_t *t1,
if (((bpno < ((OPJ_INT32) (cblk->numbps) - 4) && (passtype > 0)) if (((bpno < ((OPJ_INT32) (cblk->numbps) - 4) && (passtype > 0))
|| ((bpno == ((OPJ_INT32)cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) { || ((bpno == ((OPJ_INT32)cblk->numbps - 4)) && (passtype == 2))) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) {
if (type == T1_TYPE_RAW) { if (type == T1_TYPE_RAW) {
opj_mqc_flush(mqc); opj_mqc_bypass_flush_enc(mqc);
correction = 1; correction = 1;
/* correction = mqc_bypass_flush_enc(); */ /* correction = mqc_bypass_flush_enc(); */
} else { /* correction = mqc_restart_enc(); */ } else { /* correction = mqc_restart_enc(); */