Merge pull request #750 from mayeut/issue-729-2
Allow to read/write 3/5/7/9/11/13/15 bpp TIF files
This commit is contained in:
commit
a9feb9addd
|
@ -56,6 +56,229 @@
|
|||
TIFF IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
#define PUTBITS2(s, nb) \
|
||||
trailing <<= remaining; \
|
||||
trailing |= (unsigned int)((s) >> (nb - remaining)); \
|
||||
*pDst++ = (OPJ_BYTE)trailing; \
|
||||
trailing = (unsigned int)((s) & ((1U << (nb - remaining)) - 1U)); \
|
||||
if (nb >= (remaining + 8)) { \
|
||||
*pDst++ = (OPJ_BYTE)(trailing >> (nb - (remaining + 8))); \
|
||||
trailing &= (unsigned int)((1U << (nb - (remaining + 8))) - 1U); \
|
||||
remaining += 16 - nb; \
|
||||
} else { \
|
||||
remaining += 8 - nb; \
|
||||
}
|
||||
|
||||
#define PUTBITS(s, nb) \
|
||||
if (nb >= remaining) { \
|
||||
PUTBITS2(s, nb) \
|
||||
} else { \
|
||||
trailing <<= nb; \
|
||||
trailing |= (unsigned int)(s); \
|
||||
remaining -= nb; \
|
||||
}
|
||||
#define FLUSHBITS() \
|
||||
if (remaining != 8) { \
|
||||
trailing <<= remaining; \
|
||||
*pDst++ = (OPJ_BYTE)trailing; \
|
||||
}
|
||||
|
||||
static void tif_32sto3u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 5) | (src1 << 2) | (src2 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 7) | (src3 << 4) | (src4 << 1) | (src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 << 3) | (src7));
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 3)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 3)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 3)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 3)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 3)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 3)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto5u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 3) | (src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 << 1) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 7) | (src5 << 2) | (src6 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 5) | (src7));
|
||||
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 5)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 5)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 5)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 5)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 5)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 5)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto7u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 1) | (src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 3) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 5) | (src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 7) | (src7));
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 7)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 7)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 7)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 7)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 7)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 7)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto9u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 7) | (src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 5) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 3) | (src5 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 2) | (src6 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 1) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 9)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 9)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 9)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 9)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 9)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 9)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
|
@ -95,6 +318,59 @@ static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto11u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 5) | (src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src2 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 7) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 1) | (src5 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 3) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 11)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 11)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 11)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 11)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 11)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 11)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 11)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -113,6 +389,61 @@ static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
|||
*pDst++ = (OPJ_BYTE)(((src0 & 0xFU) << 4));
|
||||
}
|
||||
}
|
||||
static void tif_32sto13u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 3) | (src1 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 1) | (src3 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)((src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src4 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 7) | (src5 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 2) | (src6 >> 11));
|
||||
*pDst++ = (OPJ_BYTE)((src6 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 5) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 13)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 13)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 13)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 13)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 13)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 13)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -155,6 +486,63 @@ static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto15u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 1) | (src1 >> 14));
|
||||
*pDst++ = (OPJ_BYTE)((src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 13));
|
||||
*pDst++ = (OPJ_BYTE)((src2 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 3) | (src3 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)((src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 11));
|
||||
*pDst++ = (OPJ_BYTE)((src4 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 5) | (src5 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src6 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 7) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 15)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 15)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 15)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 15)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 15)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 15)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto16u(const OPJ_INT32* pSrc, OPJ_UINT16* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -223,10 +611,10 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
|
||||
if(bps > 16) bps = 0;
|
||||
if(bps == 0)
|
||||
{
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1 to 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -248,15 +636,36 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
case 8:
|
||||
cvt32sToTif = convert_32sXXu_C1R_LUT[bps];
|
||||
break;
|
||||
case 3:
|
||||
cvt32sToTif = tif_32sto3u;
|
||||
break;
|
||||
case 5:
|
||||
cvt32sToTif = tif_32sto5u;
|
||||
break;
|
||||
case 7:
|
||||
cvt32sToTif = tif_32sto7u;
|
||||
break;
|
||||
case 9:
|
||||
cvt32sToTif = tif_32sto9u;
|
||||
break;
|
||||
case 10:
|
||||
cvt32sToTif = tif_32sto10u;
|
||||
break;
|
||||
case 11:
|
||||
cvt32sToTif = tif_32sto11u;
|
||||
break;
|
||||
case 12:
|
||||
cvt32sToTif = tif_32sto12u;
|
||||
break;
|
||||
case 13:
|
||||
cvt32sToTif = tif_32sto13u;
|
||||
break;
|
||||
case 14:
|
||||
cvt32sToTif = tif_32sto14u;
|
||||
break;
|
||||
case 15:
|
||||
cvt32sToTif = tif_32sto15u;
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToTif = (convert_32sXXx_C1R)tif_32sto16u;
|
||||
break;
|
||||
|
@ -313,6 +722,221 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
return 0;
|
||||
}/* imagetotif() */
|
||||
|
||||
#define GETBITS(dest, nb) { \
|
||||
int needed = (nb); \
|
||||
unsigned int dst = 0U; \
|
||||
if (available == 0) { \
|
||||
val = *pSrc++; \
|
||||
available = 8; \
|
||||
} \
|
||||
while (needed > available) { \
|
||||
dst |= val & ((1U << available) - 1U); \
|
||||
needed -= available; \
|
||||
dst <<= needed; \
|
||||
val = *pSrc++; \
|
||||
available = 8; \
|
||||
} \
|
||||
dst |= (val >> (available - needed)) & ((1U << needed) - 1U); \
|
||||
available -= needed; \
|
||||
dest = (OPJ_INT32)dst; \
|
||||
}
|
||||
|
||||
static void tif_3uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 5));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x1FU) >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val0 & 0x3U) << 1) | (val1 >> 7));
|
||||
pDst[i+3] = (OPJ_INT32)(((val1 & 0x7FU) >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val1 & 0xFU) >> 1));
|
||||
pDst[i+5] = (OPJ_INT32)(((val1 & 0x1U) << 2) | (val2 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val2 & 0x3FU) >> 3));
|
||||
pDst[i+7] = (OPJ_INT32)(((val2 & 0x7U)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 3)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 3)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 3)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 3)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 3)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 3)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_5uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 3));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x7U) << 2) | (val1 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val1 & 0x3FU) >> 1));
|
||||
pDst[i+3] = (OPJ_INT32)(((val1 & 0x1U) << 4) | (val2 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val2 & 0xFU) << 1) | (val3 >> 7));
|
||||
pDst[i+5] = (OPJ_INT32)(((val3 & 0x7FU) >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val3 & 0x3U) << 3) | (val4 >> 5));
|
||||
pDst[i+7] = (OPJ_INT32)(((val4 & 0x1FU)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 5)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 5)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 5)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 5)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 5)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 5)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_7uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 1));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x1U) << 6) | (val1 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val1 & 0x3U) << 5) | (val2 >> 3));
|
||||
pDst[i+3] = (OPJ_INT32)(((val2 & 0x7U) << 4) | (val3 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val3 & 0xFU) << 3) | (val4 >> 5));
|
||||
pDst[i+5] = (OPJ_INT32)(((val4 & 0x1FU) << 2) | (val5 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val5 & 0x3FU) << 1) | (val6 >> 7));
|
||||
pDst[i+7] = (OPJ_INT32)(((val6 & 0x7FU)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 7)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 7)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 7)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 7)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 7)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 7)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_9uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 1) | (val1 >> 7));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x7FU) << 2) | (val2 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0x3FU) << 3) | (val3 >> 5));
|
||||
pDst[i+3] = (OPJ_INT32)(((val3 & 0x1FU) << 4) | (val4 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val4 & 0xFU) << 5) | (val5 >> 3));
|
||||
pDst[i+5] = (OPJ_INT32)(((val5 & 0x7U) << 6) | (val6 >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val6 & 0x3U) << 7) | (val7 >> 1));
|
||||
pDst[i+7] = (OPJ_INT32)(((val7 & 0x1U) << 8) | (val8));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 9)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 9)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 9)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 9)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 9)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 9)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -345,6 +969,60 @@ static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_11uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 3) | (val1 >> 5));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x1FU) << 6) | (val2 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0x3U) << 9) | (val3 << 1) | (val4 >> 7));
|
||||
pDst[i+3] = (OPJ_INT32)(((val4 & 0x7FU) << 4) | (val5 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val5 & 0xFU) << 7) | (val6 >> 1));
|
||||
pDst[i+5] = (OPJ_INT32)(((val6 & 0x1U) << 10) | (val7 << 2) | (val8 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val8 & 0x3FU) << 5) | (val9 >> 3));
|
||||
pDst[i+7] = (OPJ_INT32)(((val9 & 0x7U) << 8) | (val10));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 11)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 11)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 11)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 11)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 11)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 11)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 11)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -362,6 +1040,62 @@ static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
|||
pDst[i+0] = (OPJ_INT32)((val0 << 4) | (val1 >> 4));
|
||||
}
|
||||
}
|
||||
static void tif_13uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
OPJ_UINT32 val11 = *pSrc++;
|
||||
OPJ_UINT32 val12 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 5) | (val1 >> 3));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x7U) << 10) | (val2 << 2) | (val3 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0x3FU) << 7) | (val4 >> 1));
|
||||
pDst[i+3] = (OPJ_INT32)(((val4 & 0x1U) << 12) | (val5 << 4) | (val6 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val6 & 0xFU) << 9) | (val7 << 1) | (val8 >> 7));
|
||||
pDst[i+5] = (OPJ_INT32)(((val8 & 0x7FU) << 6) | (val9 >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val9 & 0x3U) << 11) | (val10 << 3) | (val11 >> 5));
|
||||
pDst[i+7] = (OPJ_INT32)(((val11 & 0x1FU) << 8) | (val12));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 13)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 13)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 13)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 13)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 13)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 13)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
@ -398,6 +1132,64 @@ static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
|||
}
|
||||
}
|
||||
}
|
||||
static void tif_15uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
OPJ_UINT32 val11 = *pSrc++;
|
||||
OPJ_UINT32 val12 = *pSrc++;
|
||||
OPJ_UINT32 val13 = *pSrc++;
|
||||
OPJ_UINT32 val14 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 7) | (val1 >> 1));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x1U) << 14) | (val2 << 6) | (val3 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0x3U) << 13) | (val4 << 5) | (val5 >> 3));
|
||||
pDst[i+3] = (OPJ_INT32)(((val5 & 0x7U) << 12) | (val6 << 4) | (val7 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val7 & 0xFU) << 11) | (val8 << 3) | (val9 >> 5));
|
||||
pDst[i+5] = (OPJ_INT32)(((val9 & 0x1FU) << 10) | (val10 << 2) | (val11 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val11 & 0x3FU) << 9) | (val12 << 1) | (val13 >> 7));
|
||||
pDst[i+7] = (OPJ_INT32)(((val13 & 0x7FU) << 8) | (val14));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 15)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 15)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 15)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 15)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 15)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 15)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* seems that libtiff decodes this to machine endianness */
|
||||
static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
|
@ -454,8 +1246,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||
w= (int)tiWidth;
|
||||
h= (int)tiHeight;
|
||||
|
||||
if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
|
||||
if(tiBps > 16U) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1 to 16 bits implemented\n",tiBps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
|
@ -476,15 +1268,36 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||
cvtTifTo32s = convert_XXu32s_C1R_LUT[tiBps];
|
||||
break;
|
||||
/* others are specific to TIFF */
|
||||
case 3:
|
||||
cvtTifTo32s = tif_3uto32s;
|
||||
break;
|
||||
case 5:
|
||||
cvtTifTo32s = tif_5uto32s;
|
||||
break;
|
||||
case 7:
|
||||
cvtTifTo32s = tif_7uto32s;
|
||||
break;
|
||||
case 9:
|
||||
cvtTifTo32s = tif_9uto32s;
|
||||
break;
|
||||
case 10:
|
||||
cvtTifTo32s = tif_10uto32s;
|
||||
break;
|
||||
case 11:
|
||||
cvtTifTo32s = tif_11uto32s;
|
||||
break;
|
||||
case 12:
|
||||
cvtTifTo32s = tif_12uto32s;
|
||||
break;
|
||||
case 13:
|
||||
cvtTifTo32s = tif_13uto32s;
|
||||
break;
|
||||
case 14:
|
||||
cvtTifTo32s = tif_14uto32s;
|
||||
break;
|
||||
case 15:
|
||||
cvtTifTo32s = tif_15uto32s;
|
||||
break;
|
||||
case 16:
|
||||
cvtTifTo32s = (convert_XXx32s_C1R)tif_16uto32s;
|
||||
break;
|
||||
|
|
|
@ -182,40 +182,68 @@ d33fb5dbddb9b9b4438eb51fa27445a3 issue495.jp2_0.pgx
|
|||
97da625d2f2d0b75bf891d8083ce8bfb issue495.jp2_2.pgx
|
||||
86729c5f2b74b2dfd42cb0d8e47aef79 a1_mono_tif-1.tif
|
||||
fa9b7b896536b25a7a1d8eeeacb59141 a1_mono_tif-10.tif
|
||||
e1f194f69d1c58ce8bed62cd4f1d5b6a a1_mono_tif-11.tif
|
||||
b0ee13aa90ca4421e09a3b7b41f410c0 a1_mono_tif-12.tif
|
||||
de53251a33356e206a793fbdbaf90db2 a1_mono_tif-13.tif
|
||||
4699894fedd3758727d8288cd7adb56c a1_mono_tif-14.tif
|
||||
012958af4207f4a779c0cdc9e18bc9be a1_mono_tif-15.tif
|
||||
4ad682c58e63d3223914c10a6656c8ae a1_mono_tif-16.tif
|
||||
22c2fa09a4d7b9fade6a3cddc6c6a4dc a1_mono_tif-2.tif
|
||||
7aea003d047d6c26475d0d257a0cfdfc a1_mono_tif-3.tif
|
||||
996c5e67a663218be90e86bff8ecad89 a1_mono_tif-4.tif
|
||||
0489a5d490588fa603a8e59af60ef8fc a1_mono_tif-5.tif
|
||||
7f451a5ac89915c5cdc023fd8c813a3c a1_mono_tif-6.tif
|
||||
e164a6c0219737ee05a3d55d6e3a3104 a1_mono_tif-7.tif
|
||||
c3ebfcf478b1c4fc786748813f2b5d53 a1_mono_tif-8.tif
|
||||
67adb084f1fe234f240a1d0b2698507e a1_mono_tif-9.tif
|
||||
31650ec40241737634179fff6ad306f8 basn4a08_tif-1.tif
|
||||
abf884080bcfbf58c044a9d86bfa5e5d basn4a08_tif-10.tif
|
||||
b0d82c12aa2c9b3ecd96c6a5b5663a8c basn4a08_tif-11.tif
|
||||
916d97c098d9792993cc91fee4a83f77 basn4a08_tif-12.tif
|
||||
90cabbb0f401b75dcfa64e4fbb987020 basn4a08_tif-13.tif
|
||||
57643174986481d336db6ddf04b970df basn4a08_tif-14.tif
|
||||
3cbf7868617a0dfdbeddd5c50ea96b31 basn4a08_tif-15.tif
|
||||
fb5cf848d63c61dc485c87c9246ee9c7 basn4a08_tif-16.tif
|
||||
5d7b01d98c82ad563bb28c2d83484a2a basn4a08_tif-2.tif
|
||||
7928de544e7d9731572a625beeb2b3ee basn4a08_tif-3.tif
|
||||
2401cebbb1d5494fcbe0d899484c342d basn4a08_tif-4.tif
|
||||
05ea9dfd48a6cd613bf935394988ec38 basn4a08_tif-5.tif
|
||||
6dbeb5b708bbde76e204c0887da61f6b basn4a08_tif-6.tif
|
||||
18a59ac6036ee64e92af19b7e3cd3d64 basn4a08_tif-7.tif
|
||||
dc40cc1da6de28e7e973c8ba796ca189 basn4a08_tif-8.tif
|
||||
824b776a5aa3459b77894b5f77621311 basn4a08_tif-9.tif
|
||||
59e32c45591fd3bb44fe99381a116ba1 basn6a08_tif-1.tif
|
||||
630e6fb6deba0b3efd93b610561d607a basn6a08_tif-10.tif
|
||||
5419fec92f0e0e5907d838dacf9712b4 basn6a08_tif-11.tif
|
||||
765555e75e59de27f7b2177d04f36bc1 basn6a08_tif-12.tif
|
||||
7d20d3e026fc1ac25be16dd44e9fb2e5 basn6a08_tif-13.tif
|
||||
62384c112d5fe40aefd0a9b0b9a4bcc6 basn6a08_tif-14.tif
|
||||
325de66e18e133f2ad865fc1faa20439 basn6a08_tif-15.tif
|
||||
d725d41557658a28ab31dff74e2467fa basn6a08_tif-16.tif
|
||||
96d91df6b10e866ea26ebbf0b8ddc7da basn6a08_tif-2.tif
|
||||
36690c1fe565b6efc229f5c7e486de31 basn6a08_tif-3.tif
|
||||
a324032339808d5fe85d6e354f14c183 basn6a08_tif-4.tif
|
||||
64dfb6af672ea8e890e24cfb208c6755 basn6a08_tif-5.tif
|
||||
d60864a6a5c8a49a202d98ae6f5165c7 basn6a08_tif-6.tif
|
||||
086fd12fec963995fe2e405dcef7e477 basn6a08_tif-7.tif
|
||||
c3e93f61125f82a9832d0b9440468034 basn6a08_tif-8.tif
|
||||
a9723dcc0732e74c9e8cd2bf93474a7d basn6a08_tif-9.tif
|
||||
cfe04d15cf9d615fc36357dcb3b3956b p0_14_tif-1.tif
|
||||
9ad87e7fddc77ac85e2e92509bee2365 p0_14_tif-10.tif
|
||||
f144e26d6d5aa24d98f0415f10751025 p0_14_tif-11.tif
|
||||
38e67f9d573e61166761d5eee0104448 p0_14_tif-12.tif
|
||||
4e804903537e4c52a7e4c15bd74eb15c p0_14_tif-13.tif
|
||||
77486f0468694b94290d0b55361498a0 p0_14_tif-14.tif
|
||||
2aa3211823a8ee41cc5061f401dfd52d p0_14_tif-15.tif
|
||||
51be675689949dd08b6ee1427af3eb4a p0_14_tif-16.tif
|
||||
3e34e94bd8f7380c8d159676fee9ea57 p0_14_tif-2.tif
|
||||
f623c6b98711ba8582f2b60620c6494a p0_14_tif-3.tif
|
||||
b6f71c941e3a5b8d2547792ccec58d54 p0_14_tif-4.tif
|
||||
5a8498d473cc57318ab9d216fdc5dcc9 p0_14_tif-5.tif
|
||||
81fcdd90917efb95aed94c6522d1c188 p0_14_tif-6.tif
|
||||
951c99efbd922d8f3feb015e9ef8e350 p0_14_tif-7.tif
|
||||
6808377b760b4ef3559ba8b14ed9b91a p0_14_tif-8.tif
|
||||
96aa7dafa873d0ce33f84bb1ff78fa9b p0_14_tif-9.tif
|
||||
dd15b3d487d36a3682be0679300a4319 issue235.jp2_0.pgx
|
||||
b9cd6dc76b141fb1fec15f50c1f70e01 issue235.jp2_1.pgx
|
||||
3edef2ae197ef30b08deda1b28825399 issue235.jp2_2.pgx
|
||||
|
|
|
@ -137,6 +137,16 @@ opj_compress -i @INPUT_NR_PATH@/pngsuite/ftp1n3p08.png -o @TEMP_PATH@/ftp1n3p08.
|
|||
# issue 571 Lossless is not lossless on linux x86
|
||||
opj_compress -i @INPUT_NR_PATH@/issue571.tif -o @TEMP_PATH@/issue571.tif.j2k
|
||||
|
||||
# issue 729 Allow to read 3/5/7/9/11/13/15 bpp tif files
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-03.tif -o @TEMP_PATH@/flower-minisblack-03.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-05.tif -o @TEMP_PATH@/flower-minisblack-05.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-07.tif -o @TEMP_PATH@/flower-minisblack-07.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-09.tif -o @TEMP_PATH@/flower-minisblack-09.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-11.tif -o @TEMP_PATH@/flower-minisblack-11.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-13.tif -o @TEMP_PATH@/flower-minisblack-13.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-15.tif -o @TEMP_PATH@/flower-minisblack-15.tif.jp2
|
||||
|
||||
|
||||
# DECODER TEST SUITE
|
||||
opj_decompress -i @INPUT_NR_PATH@/Bretagne2.j2k -o @TEMP_PATH@/Bretagne2.j2k.pgx
|
||||
opj_decompress -i @INPUT_NR_PATH@/_00042.j2k -o @TEMP_PATH@/_00042.j2k.pgx
|
||||
|
@ -508,3 +518,37 @@ opj_decompress -i @INPUT_NR_PATH@/issue559-eci-091-CIELab.jp2 -o @TEMP_PATH@/iss
|
|||
|
||||
# issue 653 Last box of undefined size byg
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue653-zero-unknownbox.jp2 -o @TEMP_PATH@/issue653-zero-unknownbox.jp2.png -p 8S
|
||||
|
||||
# issue 729 decompress 3/5/7/9/11/13/15 bits precision to tiff
|
||||
# GRAYSCALE
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-15.tif -p 15S
|
||||
# GRAYSCALE ALPHA
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-15.tif -p 15S
|
||||
# RGB
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-15.tif -p 15S
|
||||
# RGBA
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-15.tif -p 15S
|
||||
|
|
Loading…
Reference in New Issue