[gs-commits] ghostpdl branch, master, updated. ghostpdl-9.02-1006-gbdcf6ae
Alex Cherepanov
alexcher at ghostscript.com
Tue Mar 13 06:00:39 UTC 2012
The ghostpdl branch, master has been updated
via bdcf6ae7c1dab92c48715982ae804211dc558a78 (commit)
from 5352d4cf5b3fd17a22b4a126fe5d5fdceb0ad7b6 (commit)
----------------------------------------------------------------------
commit bdcf6ae7c1dab92c48715982ae804211dc558a78
Author: Alex Cherepanov <alex.cherepanov at artifex.com>
Date: Mon Mar 12 21:57:09 2012 -0400
Bug 692851: Implement the case of bps < 8 for Luratech JPX decoder
Implement a missing case of Luratech JPX with components > 1, and
bps < 8. Also fix incorrect bit shift calculation in OpenJpeg
part.
diff --git a/gs/base/sjpx_luratech.c b/gs/base/sjpx_luratech.c
index 294594d..632c94b 100644
--- a/gs/base/sjpx_luratech.c
+++ b/gs/base/sjpx_luratech.c
@@ -177,7 +177,31 @@ s_jpxd_write_data(unsigned char * pucData,
if (ulNum & 1)
*dst++ = pucData[ulNum - 1] << 4;
} else
- return cJP2_Error_Not_Yet_Supported;
+ {
+ unsigned int bt=0; unsigned long i;
+ int bit_pos = state->bpc * ulStart; /* starting bit position to fill for this component */
+ int bit_cnt; /* bit count for current byte */
+ unsigned char *p = &state->image[state->stride * ulRow + bit_pos/8]; /* starting byte to fill */;
+ bit_cnt = bit_pos % 8;
+ for (i = 0; i < ulNum; i++)
+ {
+ bt <<= state->bpc;
+ bt |= pucData[i];
+ bit_cnt += state->bpc;
+ if (bit_cnt >= 8)
+ {
+ *(p++) |= bt >> (bit_cnt-8);
+ bit_cnt -= 8;
+ bt &= (1<<bit_cnt)-1;
+ }
+ }
+ /* end of row */
+ if (bit_cnt > 0)
+ {
+ *p |= bt<<(8-bit_cnt);
+ bt = 0;
+ }
+ }
}
else if (comp >= 0) {
unsigned long cw, ch, i, hstep, vstep, x, y;
@@ -217,8 +241,37 @@ s_jpxd_write_data(unsigned char * pucData,
}
row += state->stride;
}
- } else
- return cJP2_Error_Not_Yet_Supported;
+ } else {
+ unsigned int bt=0;
+ int bit_pos = state->bpc * state->ncomp * ulStart * hstep + state->bpc * comp; /* starting bit position to fill for this component */
+ int bit_cnt; /* bit count for current byte */
+
+ row = &state->image[state->stride * ulRow * vstep + bit_pos/8]; /* starting byte to fill */
+ for (y = 0; y < vstep; y++) {
+ unsigned char *p = row;
+ bit_cnt = bit_pos % 8;
+ for (i = 0; i < ulNum; i++) {
+ for (x = 0; x < hstep; x++) {
+ bt <<= state->bpc * state->ncomp;
+ bt |= pucData[i];
+ bit_cnt += state->bpc;
+ while (bit_cnt >= 8) {
+ *(p++) |= bt >> (bit_cnt-8);
+ bit_cnt -= 8;
+ bt &= (1<<bit_cnt)-1;
+ }
+ bit_cnt += state->bpc * (state->ncomp - 1); /* skip other components */
+ }
+ }
+ /* end of row */
+ bit_cnt -= state->bpc * (state->ncomp - 1); /* return the last extra count */
+ if (bit_cnt > 0) {
+ *p |= bt<<(8-bit_cnt);
+ bt = 0;
+ }
+ row += state->stride;
+ }
+ }
}
return cJP2_Error_OK;
}
diff --git a/gs/base/sjpx_openjpeg.c b/gs/base/sjpx_openjpeg.c
index 4e5fd61..0589063 100644
--- a/gs/base/sjpx_openjpeg.c
+++ b/gs/base/sjpx_openjpeg.c
@@ -356,7 +356,7 @@ static int process_one_trunk(stream_jpxd_state * const state, stream_cursor_writ
{
*(pw->ptr++) = bt >> (bit_pos-8);
bit_pos -= 8;
- bt &= (1<<(bit_pos-8))-1;
+ bt &= (1<<bit_pos)-1;
}
}
}
@@ -374,7 +374,7 @@ static int process_one_trunk(stream_jpxd_state * const state, stream_cursor_writ
{
*(pw->ptr++) = bt >> (bit_pos-8);
bit_pos -= 8;
- bt &= (1<<(bit_pos-8))-1;
+ bt &= (1<<bit_pos)-1;
}
}
state->img_offset++;
Summary of changes:
gs/base/sjpx_luratech.c | 59 ++++++++++++++++++++++++++++++++++++++++++++--
gs/base/sjpx_openjpeg.c | 4 +-
2 files changed, 58 insertions(+), 5 deletions(-)
More information about the gs-commits
mailing list