diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-06-09 10:47:13 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-06-09 10:49:03 +0200 |
| commit | 81c5311758a0ae1f1aea349a6ee0bca2a238fa79 (patch) | |
| tree | fc13947b38391ea643455582026d8ade1ce2fa7c /src/lib/openjp2/tcd.c | |
| parent | 53d46fc7330ed652db66aa37b498fbfa27be625c (diff) | |
T1: fix BYPASS/LAZY, TERMALL/RESTART and PTERM/ERTERM encoding modes. (#674)fix_bypass_pterm_termall
There were a number of defects regarding when and how the termination of
passes had to done and the computation of their rate.
Diffstat (limited to 'src/lib/openjp2/tcd.c')
| -rw-r--r-- | src/lib/openjp2/tcd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index f1e1c1c3..e36496e6 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -1162,7 +1162,8 @@ static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t * if (l_data_size > p_code_block->data_size) { if (p_code_block->data) { - opj_free(p_code_block->data - 1); /* again, why -1 */ + /* We refer to data - 1 since below we incremented it */ + opj_free(p_code_block->data - 1); } p_code_block->data = (OPJ_BYTE*) opj_malloc(l_data_size + 1); if (! p_code_block->data) { @@ -1171,6 +1172,10 @@ static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t * } p_code_block->data_size = l_data_size; + /* We reserve the initial byte as a fake byte to a non-FF value */ + /* and increment the data pointer, so that opj_mqc_init_enc() */ + /* can do bp = data - 1, and opj_mqc_byteout() can safely dereference */ + /* it. */ p_code_block->data[0] = 0; p_code_block->data += 1; /*why +1 ?*/ } @@ -1914,6 +1919,8 @@ static void opj_tcd_code_block_enc_deallocate(opj_tcd_precinct_t * p_precinct) for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) { if (l_code_block->data) { + /* We refer to data - 1 since below we incremented it */ + /* in opj_tcd_code_block_enc_allocate_data() */ opj_free(l_code_block->data - 1); l_code_block->data = 00; } |
