diff options
author | AlexSm <alex@ydb.tech> | 2024-01-26 16:00:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-26 16:00:50 +0100 |
commit | 7ebcfd058d924bcc8c23da70e034f7415687885c (patch) | |
tree | e4f00d163c77528c1855f2d7af54a8be83fc1ccb /contrib/python/Pillow/py3/libImaging | |
parent | 64ca2dcd06312b9eef624054ceb5f787e11be79a (diff) | |
parent | 6d79e7793c2c462134f4b4a7d911abc7b9b0766f (diff) | |
download | ydb-7ebcfd058d924bcc8c23da70e034f7415687885c.tar.gz |
Merge pull request #1260 from ydb-platform/mergelibs10
mergelibs10
Diffstat (limited to 'contrib/python/Pillow/py3/libImaging')
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Convert.c | 16 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Dib.c | 6 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Jpeg.h | 7 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/JpegEncode.c | 33 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Pack.c | 6 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Palette.c | 2 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Quant.c | 2 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Storage.c | 6 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/TiffDecode.c | 4 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/TiffDecode.h | 6 | ||||
-rw-r--r-- | contrib/python/Pillow/py3/libImaging/Unpack.c | 14 |
11 files changed, 67 insertions, 35 deletions
diff --git a/contrib/python/Pillow/py3/libImaging/Convert.c b/contrib/python/Pillow/py3/libImaging/Convert.c index b08519d304..99d2a4ada7 100644 --- a/contrib/python/Pillow/py3/libImaging/Convert.c +++ b/contrib/python/Pillow/py3/libImaging/Convert.c @@ -1013,7 +1013,7 @@ static struct { static void p2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; - /* FIXME: precalculate greyscale palette? */ + /* FIXME: precalculate grayscale palette? */ for (x = 0; x < xsize; x++) { *out++ = (L(&palette->palette[in[x] * 4]) >= 128000) ? 255 : 0; } @@ -1022,7 +1022,7 @@ p2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { static void pa2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; - /* FIXME: precalculate greyscale palette? */ + /* FIXME: precalculate grayscale palette? */ for (x = 0; x < xsize; x++, in += 4) { *out++ = (L(&palette->palette[in[0] * 4]) >= 128000) ? 255 : 0; } @@ -1031,7 +1031,7 @@ pa2bit(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { static void p2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; - /* FIXME: precalculate greyscale palette? */ + /* FIXME: precalculate grayscale palette? */ for (x = 0; x < xsize; x++) { *out++ = L24(&palette->palette[in[x] * 4]) >> 16; } @@ -1040,7 +1040,7 @@ p2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { static void pa2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; - /* FIXME: precalculate greyscale palette? */ + /* FIXME: precalculate grayscale palette? */ for (x = 0; x < xsize; x++, in += 4) { *out++ = L24(&palette->palette[in[0] * 4]) >> 16; } @@ -1070,7 +1070,7 @@ p2pa(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { static void p2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; - /* FIXME: precalculate greyscale palette? */ + /* FIXME: precalculate grayscale palette? */ for (x = 0; x < xsize; x++, out += 4) { const UINT8 *rgba = &palette->palette[*in++ * 4]; out[0] = out[1] = out[2] = L24(rgba) >> 16; @@ -1081,7 +1081,7 @@ p2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { static void pa2la(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) { int x; - /* FIXME: precalculate greyscale palette? */ + /* FIXME: precalculate grayscale palette? */ for (x = 0; x < xsize; x++, in += 4, out += 4) { out[0] = out[1] = out[2] = L24(&palette->palette[in[0] * 4]) >> 16; out[3] = in[3]; @@ -1335,9 +1335,9 @@ topalette( imOut->palette = ImagingPaletteDuplicate(palette); if (imIn->bands == 1) { - /* greyscale image */ + /* grayscale image */ - /* Greyscale palette: copy data as is */ + /* Grayscale palette: copy data as is */ ImagingSectionEnter(&cookie); for (y = 0; y < imIn->ysize; y++) { if (alpha) { diff --git a/contrib/python/Pillow/py3/libImaging/Dib.c b/contrib/python/Pillow/py3/libImaging/Dib.c index f8a2901b8c..1b5bfe1324 100644 --- a/contrib/python/Pillow/py3/libImaging/Dib.c +++ b/contrib/python/Pillow/py3/libImaging/Dib.c @@ -142,9 +142,9 @@ ImagingNewDIB(const char *mode, int xsize, int ysize) { GetSystemPaletteEntries(dib->dc, 0, 256, pal->palPalEntry); if (strcmp(mode, "L") == 0) { - /* Greyscale DIB. Fill all 236 slots with a greyscale ramp + /* Grayscale DIB. Fill all 236 slots with a grayscale ramp * (this is usually overkill on Windows since VGA only offers - * 6 bits greyscale resolution). Ignore the slots already + * 6 bits grayscale resolution). Ignore the slots already * allocated by Windows */ i = 10; @@ -160,7 +160,7 @@ ImagingNewDIB(const char *mode, int xsize, int ysize) { #ifdef CUBE216 /* Colour DIB. Create a 6x6x6 colour cube (216 entries) and - * add 20 extra greylevels for best result with greyscale + * add 20 extra graylevels for best result with grayscale * images. */ i = 10; diff --git a/contrib/python/Pillow/py3/libImaging/Jpeg.h b/contrib/python/Pillow/py3/libImaging/Jpeg.h index 1d75508187..98eaac28dd 100644 --- a/contrib/python/Pillow/py3/libImaging/Jpeg.h +++ b/contrib/python/Pillow/py3/libImaging/Jpeg.h @@ -74,6 +74,9 @@ typedef struct { /* Optimize Huffman tables (slow) */ int optimize; + /* Disable automatic conversion of RGB images to YCbCr if nonzero */ + int keep_rgb; + /* Stream type (0=full, 1=tables only, 2=image only) */ int streamtype; @@ -83,6 +86,10 @@ typedef struct { /* Chroma Subsampling (-1=default, 0=none, 1=medium, 2=high) */ int subsampling; + /* Restart marker interval, in MCU blocks or MCU rows, or 0 for none */ + unsigned int restart_marker_blocks; + unsigned int restart_marker_rows; + /* Converter input mode (input to the shuffler) */ char rawmode[8 + 1]; diff --git a/contrib/python/Pillow/py3/libImaging/JpegEncode.c b/contrib/python/Pillow/py3/libImaging/JpegEncode.c index 2a24eff39c..00f3d5f74d 100644 --- a/contrib/python/Pillow/py3/libImaging/JpegEncode.c +++ b/contrib/python/Pillow/py3/libImaging/JpegEncode.c @@ -137,6 +137,30 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) { /* Compressor configuration */ jpeg_set_defaults(&context->cinfo); + /* Prevent RGB -> YCbCr conversion */ + if (context->keep_rgb) { + switch (context->cinfo.in_color_space) { + case JCS_RGB: +#ifdef JCS_EXTENSIONS + case JCS_EXT_RGBX: +#endif + switch (context->subsampling) { + case -1: /* Default */ + case 0: /* No subsampling */ + break; + default: + /* Would subsample the green and blue + channels, which doesn't make sense */ + state->errcode = IMAGING_CODEC_CONFIG; + return -1; + } + jpeg_set_colorspace(&context->cinfo, JCS_RGB); + break; + default: + break; + } + } + /* Use custom quantization tables */ if (context->qtables) { int i; @@ -210,6 +234,8 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) { } context->cinfo.smoothing_factor = context->smooth; context->cinfo.optimize_coding = (boolean)context->optimize; + context->cinfo.restart_interval = context->restart_marker_blocks; + context->cinfo.restart_in_rows = context->restart_marker_rows; if (context->xdpi > 0 && context->ydpi > 0) { context->cinfo.write_JFIF_header = TRUE; context->cinfo.density_unit = 1; /* dots per inch */ @@ -218,9 +244,9 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) { } switch (context->streamtype) { case 1: - /* tables only -- not yet implemented */ - state->errcode = IMAGING_CODEC_CONFIG; - return -1; + /* tables only */ + jpeg_write_tables(&context->cinfo); + goto cleanup; case 2: /* image only */ jpeg_suppress_tables(&context->cinfo, TRUE); @@ -316,6 +342,7 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) { } jpeg_finish_compress(&context->cinfo); +cleanup: /* Clean up */ if (context->comment) { free(context->comment); diff --git a/contrib/python/Pillow/py3/libImaging/Pack.c b/contrib/python/Pillow/py3/libImaging/Pack.c index 14c8f1461a..d47344245c 100644 --- a/contrib/python/Pillow/py3/libImaging/Pack.c +++ b/contrib/python/Pillow/py3/libImaging/Pack.c @@ -549,16 +549,16 @@ static struct { {"1", "1;IR", 1, pack1IR}, {"1", "L", 8, pack1L}, - /* greyscale */ + /* grayscale */ {"L", "L", 8, copy1}, {"L", "L;16", 16, packL16}, {"L", "L;16B", 16, packL16B}, - /* greyscale w. alpha */ + /* grayscale w. alpha */ {"LA", "LA", 16, packLA}, {"LA", "LA;L", 16, packLAL}, - /* greyscale w. alpha premultiplied */ + /* grayscale w. alpha premultiplied */ {"La", "La", 16, packLA}, /* palette */ diff --git a/contrib/python/Pillow/py3/libImaging/Palette.c b/contrib/python/Pillow/py3/libImaging/Palette.c index 059d7b72ac..78916bca52 100644 --- a/contrib/python/Pillow/py3/libImaging/Palette.c +++ b/contrib/python/Pillow/py3/libImaging/Palette.c @@ -75,7 +75,7 @@ ImagingPaletteNewBrowser(void) { } palette->size = i; - /* FIXME: add 30-level greyscale wedge here? */ + /* FIXME: add 30-level grayscale wedge here? */ return palette; } diff --git a/contrib/python/Pillow/py3/libImaging/Quant.c b/contrib/python/Pillow/py3/libImaging/Quant.c index c84acb9988..398fbf6db5 100644 --- a/contrib/python/Pillow/py3/libImaging/Quant.c +++ b/contrib/python/Pillow/py3/libImaging/Quant.c @@ -1697,7 +1697,7 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans) { image data? */ if (!strcmp(im->mode, "L")) { - /* greyscale */ + /* grayscale */ /* FIXME: converting a "L" image to "P" with 256 colors should be done by a simple copy... */ diff --git a/contrib/python/Pillow/py3/libImaging/Storage.c b/contrib/python/Pillow/py3/libImaging/Storage.c index 128595f654..b1b03c515a 100644 --- a/contrib/python/Pillow/py3/libImaging/Storage.c +++ b/contrib/python/Pillow/py3/libImaging/Storage.c @@ -80,18 +80,18 @@ ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int size) { im->palette = ImagingPaletteNew("RGB"); } else if (strcmp(mode, "L") == 0) { - /* 8-bit greyscale (luminance) images */ + /* 8-bit grayscale (luminance) images */ im->bands = im->pixelsize = 1; im->linesize = xsize; } else if (strcmp(mode, "LA") == 0) { - /* 8-bit greyscale (luminance) with alpha */ + /* 8-bit grayscale (luminance) with alpha */ im->bands = 2; im->pixelsize = 4; /* store in image32 memory */ im->linesize = xsize * 4; } else if (strcmp(mode, "La") == 0) { - /* 8-bit greyscale (luminance) with premultiplied alpha */ + /* 8-bit grayscale (luminance) with premultiplied alpha */ im->bands = 2; im->pixelsize = 4; /* store in image32 memory */ im->linesize = xsize * 4; diff --git a/contrib/python/Pillow/py3/libImaging/TiffDecode.c b/contrib/python/Pillow/py3/libImaging/TiffDecode.c index 35122f1824..e3b81590ec 100644 --- a/contrib/python/Pillow/py3/libImaging/TiffDecode.c +++ b/contrib/python/Pillow/py3/libImaging/TiffDecode.c @@ -14,6 +14,10 @@ #ifdef HAVE_LIBTIFF +#ifdef HAVE_UNISTD_H +#include <unistd.h> /* lseek */ +#endif + #ifndef uint #define uint uint32 #endif diff --git a/contrib/python/Pillow/py3/libImaging/TiffDecode.h b/contrib/python/Pillow/py3/libImaging/TiffDecode.h index c7c7d48ed0..02454ba039 100644 --- a/contrib/python/Pillow/py3/libImaging/TiffDecode.h +++ b/contrib/python/Pillow/py3/libImaging/TiffDecode.h @@ -13,12 +13,6 @@ #include <tiff.h> #endif -/* UNDONE -- what are we using from this? */ -/*#ifndef _UNISTD_H - # include <unistd.h> - # endif -*/ - #ifndef min #define min(x, y) ((x > y) ? y : x) #define max(x, y) ((x < y) ? y : x) diff --git a/contrib/python/Pillow/py3/libImaging/Unpack.c b/contrib/python/Pillow/py3/libImaging/Unpack.c index 279bdcdc8a..6c7d52f58d 100644 --- a/contrib/python/Pillow/py3/libImaging/Unpack.c +++ b/contrib/python/Pillow/py3/libImaging/Unpack.c @@ -819,7 +819,7 @@ ImagingUnpackXBGR(UINT8 *_out, const UINT8 *in, int pixels) { static void unpackRGBALA(UINT8 *_out, const UINT8 *in, int pixels) { int i; - /* greyscale with alpha */ + /* grayscale with alpha */ for (i = 0; i < pixels; i++) { UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[1]); memcpy(_out, &iv, sizeof(iv)); @@ -831,7 +831,7 @@ unpackRGBALA(UINT8 *_out, const UINT8 *in, int pixels) { static void unpackRGBALA16B(UINT8 *_out, const UINT8 *in, int pixels) { int i; - /* 16-bit greyscale with alpha, big-endian */ + /* 16-bit grayscale with alpha, big-endian */ for (i = 0; i < pixels; i++) { UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[2]); memcpy(_out, &iv, sizeof(iv)); @@ -1108,7 +1108,7 @@ unpackCMYKI(UINT8 *_out, const UINT8 *in, int pixels) { /* There are two representations of LAB images for whatever precision: L: Uint (in PS, it's 0-100) A: Int (in ps, -128 .. 128, or elsewhere 0..255, with 128 as middle. - Channels in PS display a 0 value as middle grey, + Channels in PS display a 0 value as middle gray, LCMS appears to use 128 as the 0 value for these channels) B: Int (as above) @@ -1172,7 +1172,7 @@ unpackI16R_I16(UINT8 *out, const UINT8 *in, int pixels) { static void unpackI12_I16(UINT8 *out, const UINT8 *in, int pixels) { - /* Fillorder 1/MSB -> LittleEndian, for 12bit integer greyscale tiffs. + /* Fillorder 1/MSB -> LittleEndian, for 12bit integer grayscale tiffs. According to the TIFF spec: @@ -1527,7 +1527,7 @@ static struct { {"1", "1;IR", 1, unpack1IR}, {"1", "1;8", 8, unpack18}, - /* greyscale */ + /* grayscale */ {"L", "L;2", 2, unpackL2}, {"L", "L;2I", 2, unpackL2I}, {"L", "L;2R", 2, unpackL2R}, @@ -1544,11 +1544,11 @@ static struct { {"L", "L;16", 16, unpackL16}, {"L", "L;16B", 16, unpackL16B}, - /* greyscale w. alpha */ + /* grayscale w. alpha */ {"LA", "LA", 16, unpackLA}, {"LA", "LA;L", 16, unpackLAL}, - /* greyscale w. alpha premultiplied */ + /* grayscale w. alpha premultiplied */ {"La", "La", 16, unpackLA}, /* palette */ |