mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-16427: Unchecked libavif return values
This commit is contained in:
commit
055b15f08c
1
NEWS
1
NEWS
@ -33,6 +33,7 @@ PHP NEWS
|
||||
- GD:
|
||||
. Fixed bug GH-16334 (imageaffine overflow on matrix elements).
|
||||
(David Carlier)
|
||||
. Fixed bug GH-16427 (Unchecked libavif return values). (cmb)
|
||||
|
||||
- GMP:
|
||||
. Fixed floating point exception bug with gmp_pow when using
|
||||
|
@ -393,7 +393,13 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx)
|
||||
// (While AVIF image pixel depth can be 8, 10, or 12 bits, GD truecolor images are 8-bit.)
|
||||
avifRGBImageSetDefaults(&rgb, decoder->image);
|
||||
rgb.depth = 8;
|
||||
#if AVIF_VERSION >= 1000000
|
||||
result = avifRGBImageAllocatePixels(&rgb);
|
||||
if (isAvifError(result, "Allocating RGB pixels failed"))
|
||||
goto cleanup;
|
||||
#else
|
||||
avifRGBImageAllocatePixels(&rgb);
|
||||
#endif
|
||||
|
||||
result = avifImageYUVToRGB(decoder->image, &rgb);
|
||||
if (isAvifError(result, "Conversion from YUV to RGB failed"))
|
||||
@ -522,14 +528,25 @@ void gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
|
||||
// Note that MATRIX_COEFFICIENTS_IDENTITY enables lossless conversion from RGB to YUV.
|
||||
|
||||
avifImage *avifIm = avifImageCreate(gdImageSX(im), gdImageSY(im), 8, subsampling);
|
||||
|
||||
#if AVIF_VERSION >= 1000000
|
||||
if (avifIm == NULL) {
|
||||
gd_error("avif error - Creating image failed\n");
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
avifIm->colorPrimaries = AVIF_COLOR_PRIMARIES_BT709;
|
||||
avifIm->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_SRGB;
|
||||
avifIm->matrixCoefficients = lossless ? AVIF_MATRIX_COEFFICIENTS_IDENTITY : AVIF_MATRIX_COEFFICIENTS_BT709;
|
||||
|
||||
avifRGBImageSetDefaults(&rgb, avifIm);
|
||||
// this allocates memory, and sets rgb.rowBytes and rgb.pixels.
|
||||
#if AVIF_VERSION >= 1000000
|
||||
result = avifRGBImageAllocatePixels(&rgb);
|
||||
if (isAvifError(result, "Allocating RGB pixels failed"))
|
||||
goto cleanup;
|
||||
#else
|
||||
avifRGBImageAllocatePixels(&rgb);
|
||||
#endif
|
||||
|
||||
// Parse RGB data from the GD image, and copy it into the AVIF RGB image.
|
||||
// Convert 7-bit GD alpha channel values to 8-bit AVIF values.
|
||||
@ -555,6 +572,12 @@ void gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
|
||||
// Encode the image in AVIF format.
|
||||
|
||||
encoder = avifEncoderCreate();
|
||||
#if AVIF_VERSION >= 1000000
|
||||
if (encoder == NULL) {
|
||||
gd_error("avif error - Creating encoder failed\n");
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
int quantizerQuality = quality == QUALITY_DEFAULT ?
|
||||
QUANTIZER_DEFAULT : quality2Quantizer(quality);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user