use mode structs in Unpack.c

This commit is contained in:
Yay295 2024-04-22 12:54:15 -05:00
parent 43473101cf
commit ebbe5d844b
4 changed files with 423 additions and 305 deletions

View File

@ -4371,6 +4371,7 @@ setup_module(PyObject *m) {
ImagingAccessInit();
ImagingConvertInit();
ImagingPackInit();
ImagingUnpackInit();
#ifdef HAVE_LIBJPEG
{
@ -4480,6 +4481,7 @@ free_module(void *m) {
ImagingAccessFree();
ImagingConvertFree();
ImagingPackFree();
ImagingUnpackFree();
}
PyMODINIT_FUNC

View File

@ -181,6 +181,11 @@ ImagingPackInit(void);
extern void
ImagingPackFree(void);
extern void
ImagingUnpackInit(void);
extern void
ImagingUnpackFree(void);
/* Objects */
/* ------- */

View File

@ -74,43 +74,136 @@ extern const RawMode * const IMAGING_RAWMODE_I_32L;
extern const RawMode * const IMAGING_RAWMODE_I_32B;
// Rawmodes
extern const RawMode * const IMAGING_RAWMODE_1_8;
extern const RawMode * const IMAGING_RAWMODE_1_I;
extern const RawMode * const IMAGING_RAWMODE_1_IR;
extern const RawMode * const IMAGING_RAWMODE_1_R;
extern const RawMode * const IMAGING_RAWMODE_A;
extern const RawMode * const IMAGING_RAWMODE_ABGR;
extern const RawMode * const IMAGING_RAWMODE_ARGB;
extern const RawMode * const IMAGING_RAWMODE_A_16B;
extern const RawMode * const IMAGING_RAWMODE_A_16L;
extern const RawMode * const IMAGING_RAWMODE_A_16N;
extern const RawMode * const IMAGING_RAWMODE_B;
extern const RawMode * const IMAGING_RAWMODE_BGAR;
extern const RawMode * const IMAGING_RAWMODE_BGR;
extern const RawMode * const IMAGING_RAWMODE_BGRA;
extern const RawMode * const IMAGING_RAWMODE_BGRA_15;
extern const RawMode * const IMAGING_RAWMODE_BGRA_15Z;
extern const RawMode * const IMAGING_RAWMODE_BGRA_16B;
extern const RawMode * const IMAGING_RAWMODE_BGRA_16L;
extern const RawMode * const IMAGING_RAWMODE_BGRX;
extern const RawMode * const IMAGING_RAWMODE_BGR_5;
extern const RawMode * const IMAGING_RAWMODE_BGRa;
extern const RawMode * const IMAGING_RAWMODE_BGXR;
extern const RawMode * const IMAGING_RAWMODE_B_16B;
extern const RawMode * const IMAGING_RAWMODE_B_16L;
extern const RawMode * const IMAGING_RAWMODE_B_16N;
extern const RawMode * const IMAGING_RAWMODE_C;
extern const RawMode * const IMAGING_RAWMODE_CMYKX;
extern const RawMode * const IMAGING_RAWMODE_CMYKXX;
extern const RawMode * const IMAGING_RAWMODE_CMYK_16B;
extern const RawMode * const IMAGING_RAWMODE_CMYK_16L;
extern const RawMode * const IMAGING_RAWMODE_CMYK_16N;
extern const RawMode * const IMAGING_RAWMODE_CMYK_I;
extern const RawMode * const IMAGING_RAWMODE_CMYK_L;
extern const RawMode * const IMAGING_RAWMODE_C_I;
extern const RawMode * const IMAGING_RAWMODE_Cb;
extern const RawMode * const IMAGING_RAWMODE_Cr;
extern const RawMode * const IMAGING_RAWMODE_F_16;
extern const RawMode * const IMAGING_RAWMODE_F_16B;
extern const RawMode * const IMAGING_RAWMODE_F_16BS;
extern const RawMode * const IMAGING_RAWMODE_F_16N;
extern const RawMode * const IMAGING_RAWMODE_F_16NS;
extern const RawMode * const IMAGING_RAWMODE_F_16S;
extern const RawMode * const IMAGING_RAWMODE_F_32;
extern const RawMode * const IMAGING_RAWMODE_F_32B;
extern const RawMode * const IMAGING_RAWMODE_F_32BF;
extern const RawMode * const IMAGING_RAWMODE_F_32BS;
extern const RawMode * const IMAGING_RAWMODE_F_32F;
extern const RawMode * const IMAGING_RAWMODE_F_32N;
extern const RawMode * const IMAGING_RAWMODE_F_32NF;
extern const RawMode * const IMAGING_RAWMODE_F_32NS;
extern const RawMode * const IMAGING_RAWMODE_F_32S;
extern const RawMode * const IMAGING_RAWMODE_F_64BF;
extern const RawMode * const IMAGING_RAWMODE_F_64F;
extern const RawMode * const IMAGING_RAWMODE_F_64NF;
extern const RawMode * const IMAGING_RAWMODE_F_8;
extern const RawMode * const IMAGING_RAWMODE_F_8S;
extern const RawMode * const IMAGING_RAWMODE_G;
extern const RawMode * const IMAGING_RAWMODE_G_16B;
extern const RawMode * const IMAGING_RAWMODE_G_16L;
extern const RawMode * const IMAGING_RAWMODE_G_16N;
extern const RawMode * const IMAGING_RAWMODE_H;
extern const RawMode * const IMAGING_RAWMODE_I_12;
extern const RawMode * const IMAGING_RAWMODE_I_16BS;
extern const RawMode * const IMAGING_RAWMODE_I_16NS;
extern const RawMode * const IMAGING_RAWMODE_I_16R;
extern const RawMode * const IMAGING_RAWMODE_I_16S;
extern const RawMode * const IMAGING_RAWMODE_I_32;
extern const RawMode * const IMAGING_RAWMODE_I_32BS;
extern const RawMode * const IMAGING_RAWMODE_I_32N;
extern const RawMode * const IMAGING_RAWMODE_I_32NS;
extern const RawMode * const IMAGING_RAWMODE_I_32S;
extern const RawMode * const IMAGING_RAWMODE_I_8;
extern const RawMode * const IMAGING_RAWMODE_I_8S;
extern const RawMode * const IMAGING_RAWMODE_K;
extern const RawMode * const IMAGING_RAWMODE_K_I;
extern const RawMode * const IMAGING_RAWMODE_LA_16B;
extern const RawMode * const IMAGING_RAWMODE_LA_L;
extern const RawMode * const IMAGING_RAWMODE_L_16;
extern const RawMode * const IMAGING_RAWMODE_L_16B;
extern const RawMode * const IMAGING_RAWMODE_L_2;
extern const RawMode * const IMAGING_RAWMODE_L_2I;
extern const RawMode * const IMAGING_RAWMODE_L_2IR;
extern const RawMode * const IMAGING_RAWMODE_L_2R;
extern const RawMode * const IMAGING_RAWMODE_L_4;
extern const RawMode * const IMAGING_RAWMODE_L_4I;
extern const RawMode * const IMAGING_RAWMODE_L_4IR;
extern const RawMode * const IMAGING_RAWMODE_L_4R;
extern const RawMode * const IMAGING_RAWMODE_L_I;
extern const RawMode * const IMAGING_RAWMODE_L_R;
extern const RawMode * const IMAGING_RAWMODE_M;
extern const RawMode * const IMAGING_RAWMODE_M_I;
extern const RawMode * const IMAGING_RAWMODE_PA_L;
extern const RawMode * const IMAGING_RAWMODE_PX;
extern const RawMode * const IMAGING_RAWMODE_P_1;
extern const RawMode * const IMAGING_RAWMODE_P_2;
extern const RawMode * const IMAGING_RAWMODE_P_2L;
extern const RawMode * const IMAGING_RAWMODE_P_4;
extern const RawMode * const IMAGING_RAWMODE_P_4L;
extern const RawMode * const IMAGING_RAWMODE_P_R;
extern const RawMode * const IMAGING_RAWMODE_R;
extern const RawMode * const IMAGING_RAWMODE_RGBAX;
extern const RawMode * const IMAGING_RAWMODE_RGBAXX;
extern const RawMode * const IMAGING_RAWMODE_RGBA_15;
extern const RawMode * const IMAGING_RAWMODE_RGBA_16B;
extern const RawMode * const IMAGING_RAWMODE_RGBA_16L;
extern const RawMode * const IMAGING_RAWMODE_RGBA_16N;
extern const RawMode * const IMAGING_RAWMODE_RGBA_4B;
extern const RawMode * const IMAGING_RAWMODE_RGBA_I;
extern const RawMode * const IMAGING_RAWMODE_RGBA_L;
extern const RawMode * const IMAGING_RAWMODE_RGBXX;
extern const RawMode * const IMAGING_RAWMODE_RGBXXX;
extern const RawMode * const IMAGING_RAWMODE_RGBX_16B;
extern const RawMode * const IMAGING_RAWMODE_RGBX_16L;
extern const RawMode * const IMAGING_RAWMODE_RGBX_16N;
extern const RawMode * const IMAGING_RAWMODE_RGBX_L;
extern const RawMode * const IMAGING_RAWMODE_RGB_15;
extern const RawMode * const IMAGING_RAWMODE_RGB_16;
extern const RawMode * const IMAGING_RAWMODE_RGB_16B;
extern const RawMode * const IMAGING_RAWMODE_RGB_16L;
extern const RawMode * const IMAGING_RAWMODE_RGB_16N;
extern const RawMode * const IMAGING_RAWMODE_RGB_4B;
extern const RawMode * const IMAGING_RAWMODE_RGB_L;
extern const RawMode * const IMAGING_RAWMODE_RGB_R;
extern const RawMode * const IMAGING_RAWMODE_RGBaX;
extern const RawMode * const IMAGING_RAWMODE_RGBaXX;
extern const RawMode * const IMAGING_RAWMODE_RGBa_16B;
extern const RawMode * const IMAGING_RAWMODE_RGBa_16L;
extern const RawMode * const IMAGING_RAWMODE_RGBa_16N;
extern const RawMode * const IMAGING_RAWMODE_R_16B;
extern const RawMode * const IMAGING_RAWMODE_R_16L;
extern const RawMode * const IMAGING_RAWMODE_R_16N;
extern const RawMode * const IMAGING_RAWMODE_S;
extern const RawMode * const IMAGING_RAWMODE_V;
@ -118,11 +211,14 @@ extern const RawMode * const IMAGING_RAWMODE_X;
extern const RawMode * const IMAGING_RAWMODE_XBGR;
extern const RawMode * const IMAGING_RAWMODE_XRGB;
extern const RawMode * const IMAGING_RAWMODE_Y;
extern const RawMode * const IMAGING_RAWMODE_YCCA_P;
extern const RawMode * const IMAGING_RAWMODE_YCC_P;
extern const RawMode * const IMAGING_RAWMODE_YCbCrK;
extern const RawMode * const IMAGING_RAWMODE_YCbCrX;
extern const RawMode * const IMAGING_RAWMODE_YCbCr_L;
extern const RawMode * const IMAGING_RAWMODE_Y_I;
extern const RawMode * const IMAGING_RAWMODE_aBGR;
extern const RawMode * const IMAGING_RAWMODE_aRGB;
const RawMode * findRawMode(const char * const name);

View File

@ -1547,13 +1547,35 @@ band316L(UINT8 *out, const UINT8 *in, int pixels) {
}
}
static struct {
const char *mode;
const char *rawmode;
static struct Unpacker {
const Mode *mode;
const RawMode *rawmode;
int bits;
ImagingShuffler unpack;
} unpackers[] = {
} *unpackers = NULL;
ImagingShuffler
ImagingFindUnpacker(const Mode *mode, const RawMode *rawmode, int *bits_out) {
int i;
/* find a suitable pixel unpacker */
for (i = 0; unpackers[i].rawmode; i++) {
if (unpackers[i].mode == mode && unpackers[i].rawmode == rawmode) {
if (bits_out) {
*bits_out = unpackers[i].bits;
}
return unpackers[i].unpack;
}
}
/* FIXME: configure a general unpacker based on the type codes... */
return NULL;
}
void
ImagingUnpackInit(void) {
const struct Unpacker temp[] = {
/* raw mode syntax is "<mode>;<bits><flags>" where "bits" defaults
depending on mode (1 for "1", 8 for "P" and "L", etc), and
"flags" should be given in alphabetical order. if both bits
@ -1566,308 +1588,301 @@ static struct {
/* exception: rawmodes "I" and "F" are always native endian byte order */
/* bilevel */
{"1", "1", 1, unpack1},
{"1", "1;I", 1, unpack1I},
{"1", "1;R", 1, unpack1R},
{"1", "1;IR", 1, unpack1IR},
{"1", "1;8", 8, unpack18},
{IMAGING_MODE_1, IMAGING_RAWMODE_1, 1, unpack1},
{IMAGING_MODE_1, IMAGING_RAWMODE_1_I, 1, unpack1I},
{IMAGING_MODE_1, IMAGING_RAWMODE_1_R, 1, unpack1R},
{IMAGING_MODE_1, IMAGING_RAWMODE_1_IR, 1, unpack1IR},
{IMAGING_MODE_1, IMAGING_RAWMODE_1_8, 8, unpack18},
/* grayscale */
{"L", "L;2", 2, unpackL2},
{"L", "L;2I", 2, unpackL2I},
{"L", "L;2R", 2, unpackL2R},
{"L", "L;2IR", 2, unpackL2IR},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_2, 2, unpackL2},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_2I, 2, unpackL2I},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_2R, 2, unpackL2R},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_2IR, 2, unpackL2IR},
{"L", "L;4", 4, unpackL4},
{"L", "L;4I", 4, unpackL4I},
{"L", "L;4R", 4, unpackL4R},
{"L", "L;4IR", 4, unpackL4IR},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_4, 4, unpackL4},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_4I, 4, unpackL4I},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_4R, 4, unpackL4R},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_4IR, 4, unpackL4IR},
{"L", "L", 8, copy1},
{"L", "L;I", 8, unpackLI},
{"L", "L;R", 8, unpackLR},
{"L", "L;16", 16, unpackL16},
{"L", "L;16B", 16, unpackL16B},
{IMAGING_MODE_L, IMAGING_RAWMODE_L, 8, copy1},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_I, 8, unpackLI},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_R, 8, unpackLR},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_16, 16, unpackL16},
{IMAGING_MODE_L, IMAGING_RAWMODE_L_16B, 16, unpackL16B},
/* grayscale w. alpha */
{"LA", "LA", 16, unpackLA},
{"LA", "LA;L", 16, unpackLAL},
{IMAGING_MODE_LA, IMAGING_RAWMODE_LA, 16, unpackLA},
{IMAGING_MODE_LA, IMAGING_RAWMODE_LA_L, 16, unpackLAL},
/* grayscale w. alpha premultiplied */
{"La", "La", 16, unpackLA},
{IMAGING_MODE_La, IMAGING_RAWMODE_La, 16, unpackLA},
/* palette */
{"P", "P;1", 1, unpackP1},
{"P", "P;2", 2, unpackP2},
{"P", "P;2L", 2, unpackP2L},
{"P", "P;4", 4, unpackP4},
{"P", "P;4L", 4, unpackP4L},
{"P", "P", 8, copy1},
{"P", "P;R", 8, unpackLR},
{"P", "L", 8, copy1},
{"P", "PX", 16, unpackL16B},
{IMAGING_MODE_P, IMAGING_RAWMODE_P_1, 1, unpackP1},
{IMAGING_MODE_P, IMAGING_RAWMODE_P_2, 2, unpackP2},
{IMAGING_MODE_P, IMAGING_RAWMODE_P_2L, 2, unpackP2L},
{IMAGING_MODE_P, IMAGING_RAWMODE_P_4, 4, unpackP4},
{IMAGING_MODE_P, IMAGING_RAWMODE_P_4L, 4, unpackP4L},
{IMAGING_MODE_P, IMAGING_RAWMODE_P, 8, copy1},
{IMAGING_MODE_P, IMAGING_RAWMODE_P_R, 8, unpackLR},
{IMAGING_MODE_P, IMAGING_RAWMODE_L, 8, copy1},
{IMAGING_MODE_P, IMAGING_RAWMODE_PX, 16, unpackL16B},
/* palette w. alpha */
{"PA", "PA", 16, unpackLA},
{"PA", "PA;L", 16, unpackLAL},
{"PA", "LA", 16, unpackLA},
{IMAGING_MODE_PA, IMAGING_RAWMODE_PA, 16, unpackLA},
{IMAGING_MODE_PA, IMAGING_RAWMODE_PA_L, 16, unpackLAL},
{IMAGING_MODE_PA, IMAGING_RAWMODE_LA, 16, unpackLA},
/* true colour */
{"RGB", "RGB", 24, ImagingUnpackRGB},
{"RGB", "RGB;L", 24, unpackRGBL},
{"RGB", "RGB;R", 24, unpackRGBR},
{"RGB", "RGB;16L", 48, unpackRGB16L},
{"RGB", "RGB;16B", 48, unpackRGB16B},
{"RGB", "BGR", 24, ImagingUnpackBGR},
{"RGB", "RGB;15", 16, ImagingUnpackRGB15},
{"RGB", "BGR;15", 16, ImagingUnpackBGR15},
{"RGB", "RGB;16", 16, ImagingUnpackRGB16},
{"RGB", "BGR;16", 16, ImagingUnpackBGR16},
{"RGB", "RGBX;16L", 64, unpackRGBA16L},
{"RGB", "RGBX;16B", 64, unpackRGBA16B},
{"RGB", "RGB;4B", 16, ImagingUnpackRGB4B},
{"RGB", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */
{"RGB", "RGBX", 32, copy4},
{"RGB", "RGBX;L", 32, unpackRGBAL},
{"RGB", "RGBXX", 40, copy4skip1},
{"RGB", "RGBXXX", 48, copy4skip2},
{"RGB", "RGBA;L", 32, unpackRGBAL},
{"RGB", "RGBA;15", 16, ImagingUnpackRGBA15},
{"RGB", "BGRX", 32, ImagingUnpackBGRX},
{"RGB", "BGXR", 32, ImagingUnpackBGXR},
{"RGB", "XRGB", 32, ImagingUnpackXRGB},
{"RGB", "XBGR", 32, ImagingUnpackXBGR},
{"RGB", "YCC;P", 24, ImagingUnpackYCC},
{"RGB", "R", 8, band0},
{"RGB", "G", 8, band1},
{"RGB", "B", 8, band2},
{"RGB", "R;16L", 16, band016L},
{"RGB", "G;16L", 16, band116L},
{"RGB", "B;16L", 16, band216L},
{"RGB", "R;16B", 16, band016B},
{"RGB", "G;16B", 16, band116B},
{"RGB", "B;16B", 16, band216B},
{"RGB", "CMYK", 32, cmyk2rgb},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB, 24, ImagingUnpackRGB},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_L, 24, unpackRGBL},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_R, 24, unpackRGBR},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_16L, 48, unpackRGB16L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_16B, 48, unpackRGB16B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_BGR, 24, ImagingUnpackBGR},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_15, 16, ImagingUnpackRGB15},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_BGR_15, 16, ImagingUnpackBGR15},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_16, 16, ImagingUnpackRGB16},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_BGR_16, 16, ImagingUnpackBGR16},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBX_16L, 64, unpackRGBA16L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBX_16B, 64, unpackRGBA16B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_4B, 16, ImagingUnpackRGB4B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_BGR_5, 16, ImagingUnpackBGR15}, /* compat */
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBX, 32, copy4},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBX_L, 32, unpackRGBAL},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBXX, 40, copy4skip1},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBXXX, 48, copy4skip2},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBA_L, 32, unpackRGBAL},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGBA_15, 16, ImagingUnpackRGBA15},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_BGRX, 32, ImagingUnpackBGRX},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_BGXR, 32, ImagingUnpackBGXR},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_XRGB, 32, ImagingUnpackXRGB},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_XBGR, 32, ImagingUnpackXBGR},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_YCC_P, 24, ImagingUnpackYCC},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_R, 8, band0},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_G, 8, band1},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_B, 8, band2},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_R_16L, 16, band016L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_G_16L, 16, band116L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_B_16L, 16, band216L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_R_16B, 16, band016B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_G_16B, 16, band116B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_B_16B, 16, band216B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_CMYK, 32, cmyk2rgb},
{"BGR;15", "BGR;15", 16, copy2},
{"BGR;16", "BGR;16", 16, copy2},
{"BGR;24", "BGR;24", 24, copy3},
{IMAGING_MODE_BGR_15, IMAGING_RAWMODE_BGR_15, 16, copy2},
{IMAGING_MODE_BGR_16, IMAGING_RAWMODE_BGR_16, 16, copy2},
{IMAGING_MODE_BGR_24, IMAGING_RAWMODE_BGR_24, 24, copy3},
/* true colour w. alpha */
{"RGBA", "LA", 16, unpackRGBALA},
{"RGBA", "LA;16B", 32, unpackRGBALA16B},
{"RGBA", "RGBA", 32, copy4},
{"RGBA", "RGBAX", 40, copy4skip1},
{"RGBA", "RGBAXX", 48, copy4skip2},
{"RGBA", "RGBa", 32, unpackRGBa},
{"RGBA", "RGBaX", 40, unpackRGBaskip1},
{"RGBA", "RGBaXX", 48, unpackRGBaskip2},
{"RGBA", "RGBa;16L", 64, unpackRGBa16L},
{"RGBA", "RGBa;16B", 64, unpackRGBa16B},
{"RGBA", "BGRa", 32, unpackBGRa},
{"RGBA", "RGBA;I", 32, unpackRGBAI},
{"RGBA", "RGBA;L", 32, unpackRGBAL},
{"RGBA", "RGBA;15", 16, ImagingUnpackRGBA15},
{"RGBA", "BGRA;15", 16, ImagingUnpackBGRA15},
{"RGBA", "BGRA;15Z", 16, ImagingUnpackBGRA15Z},
{"RGBA", "RGBA;4B", 16, ImagingUnpackRGBA4B},
{"RGBA", "RGBA;16L", 64, unpackRGBA16L},
{"RGBA", "RGBA;16B", 64, unpackRGBA16B},
{"RGBA", "BGRA", 32, unpackBGRA},
{"RGBA", "BGRA;16L", 64, unpackBGRA16L},
{"RGBA", "BGRA;16B", 64, unpackBGRA16B},
{"RGBA", "BGAR", 32, unpackBGAR},
{"RGBA", "ARGB", 32, unpackARGB},
{"RGBA", "ABGR", 32, unpackABGR},
{"RGBA", "YCCA;P", 32, ImagingUnpackYCCA},
{"RGBA", "R", 8, band0},
{"RGBA", "G", 8, band1},
{"RGBA", "B", 8, band2},
{"RGBA", "A", 8, band3},
{"RGBA", "R;16L", 16, band016L},
{"RGBA", "G;16L", 16, band116L},
{"RGBA", "B;16L", 16, band216L},
{"RGBA", "A;16L", 16, band316L},
{"RGBA", "R;16B", 16, band016B},
{"RGBA", "G;16B", 16, band116B},
{"RGBA", "B;16B", 16, band216B},
{"RGBA", "A;16B", 16, band316B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_LA, 16, unpackRGBALA},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_LA_16B, 32, unpackRGBALA16B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA, 32, copy4},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBAX, 40, copy4skip1},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBAXX, 48, copy4skip2},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBa, 32, unpackRGBa},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBaX, 40, unpackRGBaskip1},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBaXX, 48, unpackRGBaskip2},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBa_16L, 64, unpackRGBa16L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBa_16B, 64, unpackRGBa16B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGRa, 32, unpackBGRa},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_I, 32, unpackRGBAI},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_L, 32, unpackRGBAL},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_15, 16, ImagingUnpackRGBA15},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGRA_15, 16, ImagingUnpackBGRA15},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGRA_15Z, 16, ImagingUnpackBGRA15Z},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_4B, 16, ImagingUnpackRGBA4B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_16L, 64, unpackRGBA16L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_16B, 64, unpackRGBA16B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGRA, 32, unpackBGRA},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGRA_16L, 64, unpackBGRA16L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGRA_16B, 64, unpackBGRA16B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_BGAR, 32, unpackBGAR},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_ARGB, 32, unpackARGB},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_ABGR, 32, unpackABGR},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_YCCA_P, 32, ImagingUnpackYCCA},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_R, 8, band0},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_G, 8, band1},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_B, 8, band2},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_A, 8, band3},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_R_16L, 16, band016L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_G_16L, 16, band116L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_B_16L, 16, band216L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_A_16L, 16, band316L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_R_16B, 16, band016B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_G_16B, 16, band116B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_B_16B, 16, band216B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_A_16B, 16, band316B},
#ifdef WORDS_BIGENDIAN
{"RGB", "RGB;16N", 48, unpackRGB16B},
{"RGBA", "RGBa;16N", 64, unpackRGBa16B},
{"RGBA", "RGBA;16N", 64, unpackRGBA16B},
{"RGBX", "RGBX;16N", 64, unpackRGBA16B},
{"RGB", "R;16N", 16, band016B},
{"RGB", "G;16N", 16, band116B},
{"RGB", "B;16N", 16, band216B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_16N, 48, unpackRGB16B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBa_16N, 64, unpackRGBa16B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_16N, 64, unpackRGBA16B},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBX_16N, 64, unpackRGBA16B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_R_16N, 16, band016B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_G_16N, 16, band116B},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_B_16N, 16, band216B},
{"RGBA", "R;16N", 16, band016B},
{"RGBA", "G;16N", 16, band116B},
{"RGBA", "B;16N", 16, band216B},
{"RGBA", "A;16N", 16, band316B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_R_16N, 16, band016B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_G_16N, 16, band116B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_B_16N, 16, band216B},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_A_16N, 16, band316B},
#else
{"RGB", "RGB;16N", 48, unpackRGB16L},
{"RGBA", "RGBa;16N", 64, unpackRGBa16L},
{"RGBA", "RGBA;16N", 64, unpackRGBA16L},
{"RGBX", "RGBX;16N", 64, unpackRGBA16L},
{"RGB", "R;16N", 16, band016L},
{"RGB", "G;16N", 16, band116L},
{"RGB", "B;16N", 16, band216L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_RGB_16N, 48, unpackRGB16L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBa_16N, 64, unpackRGBa16L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_RGBA_16N, 64, unpackRGBA16L},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBX_16N, 64, unpackRGBA16L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_R_16N, 16, band016L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_G_16N, 16, band116L},
{IMAGING_MODE_RGB, IMAGING_RAWMODE_B_16N, 16, band216L},
{"RGBA", "R;16N", 16, band016L},
{"RGBA", "G;16N", 16, band116L},
{"RGBA", "B;16N", 16, band216L},
{"RGBA", "A;16N", 16, band316L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_R_16N, 16, band016L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_G_16N, 16, band116L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_B_16N, 16, band216L},
{IMAGING_MODE_RGBA, IMAGING_RAWMODE_A_16N, 16, band316L},
#endif
/* true colour w. alpha premultiplied */
{"RGBa", "RGBa", 32, copy4},
{"RGBa", "BGRa", 32, unpackBGRA},
{"RGBa", "aRGB", 32, unpackARGB},
{"RGBa", "aBGR", 32, unpackABGR},
{IMAGING_MODE_RGBa, IMAGING_RAWMODE_RGBa, 32, copy4},
{IMAGING_MODE_RGBa, IMAGING_RAWMODE_BGRa, 32, unpackBGRA},
{IMAGING_MODE_RGBa, IMAGING_RAWMODE_aRGB, 32, unpackARGB},
{IMAGING_MODE_RGBa, IMAGING_RAWMODE_aBGR, 32, unpackABGR},
/* true colour w. padding */
{"RGBX", "RGB", 24, ImagingUnpackRGB},
{"RGBX", "RGB;L", 24, unpackRGBL},
{"RGBX", "RGB;16B", 48, unpackRGB16B},
{"RGBX", "BGR", 24, ImagingUnpackBGR},
{"RGBX", "RGB;15", 16, ImagingUnpackRGB15},
{"RGBX", "BGR;15", 16, ImagingUnpackBGR15},
{"RGBX", "RGB;4B", 16, ImagingUnpackRGB4B},
{"RGBX", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */
{"RGBX", "RGBX", 32, copy4},
{"RGBX", "RGBXX", 40, copy4skip1},
{"RGBX", "RGBXXX", 48, copy4skip2},
{"RGBX", "RGBX;L", 32, unpackRGBAL},
{"RGBX", "RGBX;16L", 64, unpackRGBA16L},
{"RGBX", "RGBX;16B", 64, unpackRGBA16B},
{"RGBX", "BGRX", 32, ImagingUnpackBGRX},
{"RGBX", "XRGB", 32, ImagingUnpackXRGB},
{"RGBX", "XBGR", 32, ImagingUnpackXBGR},
{"RGBX", "YCC;P", 24, ImagingUnpackYCC},
{"RGBX", "R", 8, band0},
{"RGBX", "G", 8, band1},
{"RGBX", "B", 8, band2},
{"RGBX", "X", 8, band3},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGB, 24, ImagingUnpackRGB},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGB_L, 24, unpackRGBL},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGB_16B, 48, unpackRGB16B},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_BGR, 24, ImagingUnpackBGR},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGB_15, 16, ImagingUnpackRGB15},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_BGR_15, 16, ImagingUnpackBGR15},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGB_4B, 16, ImagingUnpackRGB4B},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_BGR_5, 16, ImagingUnpackBGR15}, /* compat */
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBX, 32, copy4},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBXX, 40, copy4skip1},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBXXX, 48, copy4skip2},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBX_L, 32, unpackRGBAL},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBX_16L, 64, unpackRGBA16L},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_RGBX_16B, 64, unpackRGBA16B},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_BGRX, 32, ImagingUnpackBGRX},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_XRGB, 32, ImagingUnpackXRGB},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_XBGR, 32, ImagingUnpackXBGR},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_YCC_P, 24, ImagingUnpackYCC},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_R, 8, band0},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_G, 8, band1},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_B, 8, band2},
{IMAGING_MODE_RGBX, IMAGING_RAWMODE_X, 8, band3},
/* colour separation */
{"CMYK", "CMYK", 32, copy4},
{"CMYK", "CMYKX", 40, copy4skip1},
{"CMYK", "CMYKXX", 48, copy4skip2},
{"CMYK", "CMYK;I", 32, unpackCMYKI},
{"CMYK", "CMYK;L", 32, unpackRGBAL},
{"CMYK", "CMYK;16L", 64, unpackRGBA16L},
{"CMYK", "CMYK;16B", 64, unpackRGBA16B},
{"CMYK", "C", 8, band0},
{"CMYK", "M", 8, band1},
{"CMYK", "Y", 8, band2},
{"CMYK", "K", 8, band3},
{"CMYK", "C;I", 8, band0I},
{"CMYK", "M;I", 8, band1I},
{"CMYK", "Y;I", 8, band2I},
{"CMYK", "K;I", 8, band3I},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK, 32, copy4},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYKX, 40, copy4skip1},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYKXX, 48, copy4skip2},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK_I, 32, unpackCMYKI},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK_L, 32, unpackRGBAL},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK_16L, 64, unpackRGBA16L},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK_16B, 64, unpackRGBA16B},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_C, 8, band0},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_M, 8, band1},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_Y, 8, band2},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_K, 8, band3},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_C_I, 8, band0I},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_M_I, 8, band1I},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_Y_I, 8, band2I},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_K_I, 8, band3I},
#ifdef WORDS_BIGENDIAN
{"CMYK", "CMYK;16N", 64, unpackRGBA16B},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK_16N, 64, unpackRGBA16B},
#else
{"CMYK", "CMYK;16N", 64, unpackRGBA16L},
{IMAGING_MODE_CMYK, IMAGING_RAWMODE_CMYK_16N, 64, unpackRGBA16L},
#endif
/* video (YCbCr) */
{"YCbCr", "YCbCr", 24, ImagingUnpackRGB},
{"YCbCr", "YCbCr;L", 24, unpackRGBL},
{"YCbCr", "YCbCrX", 32, copy4},
{"YCbCr", "YCbCrK", 32, copy4},
{IMAGING_MODE_YCbCr, IMAGING_RAWMODE_YCbCr, 24, ImagingUnpackRGB},
{IMAGING_MODE_YCbCr, IMAGING_RAWMODE_YCbCr_L, 24, unpackRGBL},
{IMAGING_MODE_YCbCr, IMAGING_RAWMODE_YCbCrX, 32, copy4},
{IMAGING_MODE_YCbCr, IMAGING_RAWMODE_YCbCrK, 32, copy4},
/* LAB Color */
{"LAB", "LAB", 24, ImagingUnpackLAB},
{"LAB", "L", 8, band0},
{"LAB", "A", 8, band1},
{"LAB", "B", 8, band2},
{IMAGING_MODE_LAB, IMAGING_RAWMODE_LAB, 24, ImagingUnpackLAB},
{IMAGING_MODE_LAB, IMAGING_RAWMODE_L, 8, band0},
{IMAGING_MODE_LAB, IMAGING_RAWMODE_A, 8, band1},
{IMAGING_MODE_LAB, IMAGING_RAWMODE_B, 8, band2},
/* HSV Color */
{"HSV", "HSV", 24, ImagingUnpackRGB},
{"HSV", "H", 8, band0},
{"HSV", "S", 8, band1},
{"HSV", "V", 8, band2},
{IMAGING_MODE_HSV, IMAGING_RAWMODE_HSV, 24, ImagingUnpackRGB},
{IMAGING_MODE_HSV, IMAGING_RAWMODE_H, 8, band0},
{IMAGING_MODE_HSV, IMAGING_RAWMODE_S, 8, band1},
{IMAGING_MODE_HSV, IMAGING_RAWMODE_V, 8, band2},
/* integer variations */
{"I", "I", 32, copy4},
{"I", "I;8", 8, unpackI8},
{"I", "I;8S", 8, unpackI8S},
{"I", "I;16", 16, unpackI16},
{"I", "I;16S", 16, unpackI16S},
{"I", "I;16B", 16, unpackI16B},
{"I", "I;16BS", 16, unpackI16BS},
{"I", "I;16N", 16, unpackI16N},
{"I", "I;16NS", 16, unpackI16NS},
{"I", "I;32", 32, unpackI32},
{"I", "I;32S", 32, unpackI32S},
{"I", "I;32B", 32, unpackI32B},
{"I", "I;32BS", 32, unpackI32BS},
{"I", "I;32N", 32, unpackI32N},
{"I", "I;32NS", 32, unpackI32NS},
{IMAGING_MODE_I, IMAGING_RAWMODE_I, 32, copy4},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_8, 8, unpackI8},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_8S, 8, unpackI8S},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_16, 16, unpackI16},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_16S, 16, unpackI16S},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_16B, 16, unpackI16B},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_16BS, 16, unpackI16BS},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_16N, 16, unpackI16N},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_16NS, 16, unpackI16NS},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_32, 32, unpackI32},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_32S, 32, unpackI32S},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_32B, 32, unpackI32B},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_32BS, 32, unpackI32BS},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_32N, 32, unpackI32N},
{IMAGING_MODE_I, IMAGING_RAWMODE_I_32NS, 32, unpackI32NS},
/* floating point variations */
{"F", "F", 32, copy4},
{"F", "F;8", 8, unpackF8},
{"F", "F;8S", 8, unpackF8S},
{"F", "F;16", 16, unpackF16},
{"F", "F;16S", 16, unpackF16S},
{"F", "F;16B", 16, unpackF16B},
{"F", "F;16BS", 16, unpackF16BS},
{"F", "F;16N", 16, unpackF16N},
{"F", "F;16NS", 16, unpackF16NS},
{"F", "F;32", 32, unpackF32},
{"F", "F;32S", 32, unpackF32S},
{"F", "F;32B", 32, unpackF32B},
{"F", "F;32BS", 32, unpackF32BS},
{"F", "F;32N", 32, unpackF32N},
{"F", "F;32NS", 32, unpackF32NS},
{"F", "F;32F", 32, unpackF32F},
{"F", "F;32BF", 32, unpackF32BF},
{"F", "F;32NF", 32, unpackF32NF},
{IMAGING_MODE_F, IMAGING_RAWMODE_F, 32, copy4},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_8, 8, unpackF8},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_8S, 8, unpackF8S},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_16, 16, unpackF16},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_16S, 16, unpackF16S},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_16B, 16, unpackF16B},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_16BS, 16, unpackF16BS},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_16N, 16, unpackF16N},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_16NS, 16, unpackF16NS},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32, 32, unpackF32},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32S, 32, unpackF32S},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32B, 32, unpackF32B},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32BS, 32, unpackF32BS},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32N, 32, unpackF32N},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32NS, 32, unpackF32NS},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32F, 32, unpackF32F},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32BF, 32, unpackF32BF},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_32NF, 32, unpackF32NF},
#ifdef FLOAT64
{"F", "F;64F", 64, unpackF64F},
{"F", "F;64BF", 64, unpackF64BF},
{"F", "F;64NF", 64, unpackF64NF},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_64F, 64, unpackF64F},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_64BF, 64, unpackF64BF},
{IMAGING_MODE_F, IMAGING_RAWMODE_F_64NF, 64, unpackF64NF},
#endif
/* storage modes */
{"I;16", "I;16", 16, copy2},
{"I;16B", "I;16B", 16, copy2},
{"I;16L", "I;16L", 16, copy2},
{"I;16N", "I;16N", 16, copy2},
{IMAGING_MODE_I_16, IMAGING_RAWMODE_I_16, 16, copy2},
{IMAGING_MODE_I_16B, IMAGING_RAWMODE_I_16B, 16, copy2},
{IMAGING_MODE_I_16L, IMAGING_RAWMODE_I_16L, 16, copy2},
{IMAGING_MODE_I_16N, IMAGING_RAWMODE_I_16N, 16, copy2},
{"I;16", "I;16B", 16, unpackI16B_I16},
{"I;16", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
{"I;16L", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
{"I;16B", "I;16N", 16, unpackI16N_I16B},
{IMAGING_MODE_I_16, IMAGING_RAWMODE_I_16B, 16, unpackI16B_I16},
{IMAGING_MODE_I_16, IMAGING_RAWMODE_I_16N, 16, unpackI16N_I16}, // LibTiff native->image endian.
{IMAGING_MODE_I_16L, IMAGING_RAWMODE_I_16N, 16, unpackI16N_I16}, // LibTiff native->image endian.
{IMAGING_MODE_I_16B, IMAGING_RAWMODE_I_16N, 16, unpackI16N_I16B},
{"I;16", "I;16R", 16, unpackI16R_I16},
{IMAGING_MODE_I_16, IMAGING_RAWMODE_I_16R, 16, unpackI16R_I16},
{"I;16", "I;12", 12, unpackI12_I16}, // 12 bit Tiffs stored in 16bits.
{IMAGING_MODE_I_16, IMAGING_RAWMODE_I_12, 12, unpackI12_I16}, // 12 bit Tiffs stored in 16bits.
{NULL} /* sentinel */
};
ImagingShuffler
ImagingFindUnpacker(const char *mode, const char *rawmode, int *bits_out) {
int i;
/* find a suitable pixel unpacker */
for (i = 0; unpackers[i].rawmode; i++) {
if (strcmp(unpackers[i].mode, mode) == 0 &&
strcmp(unpackers[i].rawmode, rawmode) == 0) {
if (bits_out) {
*bits_out = unpackers[i].bits;
}
return unpackers[i].unpack;
unpackers = malloc(sizeof(temp));
if (unpackers == NULL) {
fprintf(stderr, "UnpackInit: failed to allocate memory for unpackers table\n");
exit(1);
}
memcpy(unpackers, temp, sizeof(temp));
}
/* FIXME: configure a general unpacker based on the type codes... */
return NULL;
void
ImagingUnpackFree(void) {
free(unpackers);
unpackers = NULL;
}