From 5889a4a48c6ea69bca118042d07c473e7b2d5bfd Mon Sep 17 00:00:00 2001 From: Ben Morss Date: Fri, 16 Jul 2021 17:29:27 -0400 Subject: [PATCH 1/4] Disable strict pixi requirement for libavif >= 0.9.1 Some AVIF image generators didn't include the PixelInformationProperty (pixi), even though strictly speaking they should. In v0.9.2, libavif began requiring this. Let's disable it so we can read those images too. --- ext/gd/libgd/gd_avif.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/gd/libgd/gd_avif.c b/ext/gd/libgd/gd_avif.c index 01bcbf14abdb8..83f11b5ad77a0 100644 --- a/ext/gd/libgd/gd_avif.c +++ b/ext/gd/libgd/gd_avif.c @@ -342,6 +342,14 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx) decoder = avifDecoderCreate(); + // Check if libavif version is >= 0.9.1 +#if AVIF_VERSION_MAJOR > 0 || (AVIF_VERSION_MAJOR == 0 && AVIF_VERSION_MINOR > 9) || (AVIF_VERSION_MAJOR == 0 && AVIF_VERSION_MINOR == 9 && AVIF_VERSION_PATCH >= 1) + // If so, allow the PixelInformationProperty ('pixi') to be missing in AV1 image + // items. libheif v1.11.0 or older does not add the 'pixi' item property to + // AV1 image items. (This issue has been corrected in libheif v1.12.0.) + decoder->strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED; +#endif + io = createAvifIOFromCtx(ctx); if (!io) { gd_error("avif error - Could not allocate memory"); From 36698d24de69ec7688ee9c65c21414f0a42743a6 Mon Sep 17 00:00:00 2001 From: Ben Morss Date: Mon, 19 Jul 2021 21:30:33 -0400 Subject: [PATCH 2/4] Remove xfail from test on FreeBSD --- ext/gd/tests/imagecreatefromstring_avif.phpt | 3 --- 1 file changed, 3 deletions(-) diff --git a/ext/gd/tests/imagecreatefromstring_avif.phpt b/ext/gd/tests/imagecreatefromstring_avif.phpt index 98ba5acaaa9dc..987b538c5fbcb 100644 --- a/ext/gd/tests/imagecreatefromstring_avif.phpt +++ b/ext/gd/tests/imagecreatefromstring_avif.phpt @@ -7,9 +7,6 @@ gd if (!(imagetypes() & IMG_AVIF)) { die('skip AVIF support required'); } -if (str_contains(PHP_OS, "FreeBSD")) { - die("xfail Currently failing on FreeBSD CI"); -} ?> --FILE-- Date: Mon, 26 Jul 2021 19:11:34 -0400 Subject: [PATCH 3/4] Use more compact AVIF_VERSION This keeps us in sync with libgd. See https://github.com/libgd/libgd/pull/723 . --- ext/gd/libgd/gd_avif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/gd/libgd/gd_avif.c b/ext/gd/libgd/gd_avif.c index 83f11b5ad77a0..c526dde1dc25f 100644 --- a/ext/gd/libgd/gd_avif.c +++ b/ext/gd/libgd/gd_avif.c @@ -343,7 +343,7 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx) decoder = avifDecoderCreate(); // Check if libavif version is >= 0.9.1 -#if AVIF_VERSION_MAJOR > 0 || (AVIF_VERSION_MAJOR == 0 && AVIF_VERSION_MINOR > 9) || (AVIF_VERSION_MAJOR == 0 && AVIF_VERSION_MINOR == 9 && AVIF_VERSION_PATCH >= 1) +#if AVIF_VERSION >= 90100 // If so, allow the PixelInformationProperty ('pixi') to be missing in AV1 image // items. libheif v1.11.0 or older does not add the 'pixi' item property to // AV1 image items. (This issue has been corrected in libheif v1.12.0.) From d6226daca6185a9f5b330229a491b44cd87b601b Mon Sep 17 00:00:00 2001 From: Ben Morss Date: Fri, 6 Aug 2021 13:40:45 -0400 Subject: [PATCH 4/4] concatenate comment --- .vscode/launch.json | 68 ++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 3 ++ ext/gd/libgd/gd_avif.c | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000000..6691742698ba8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,68 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "PHP aviftest", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/sapi/cli/php", + "args": ["../play/php/aviftest.php"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, + { + "name": "getimagesize", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/sapi/cli/php", + "args": ["../play/php/getimagesize.php"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, + { + "name": "imagecreatefromstring_avif", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/sapi/cli/php", + "args": ["ext/gd/tests/imagecreatefromstring_avif.phpt"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, + { + "name": "Web-Pee", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/sapi/cli/php", + "args": ["ext/gd/tests/imagecreatefromstring_webp.phpt"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, + { + "name": "avif_decode_encode", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/sapi/cli/php", + "args": ["ext/gd/tests/avif_decode_encode.phpt"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000..b3fb208794105 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.dimInactiveRegions": false +} \ No newline at end of file diff --git a/ext/gd/libgd/gd_avif.c b/ext/gd/libgd/gd_avif.c index c526dde1dc25f..c0819283a7edf 100644 --- a/ext/gd/libgd/gd_avif.c +++ b/ext/gd/libgd/gd_avif.c @@ -343,10 +343,10 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx) decoder = avifDecoderCreate(); // Check if libavif version is >= 0.9.1 -#if AVIF_VERSION >= 90100 // If so, allow the PixelInformationProperty ('pixi') to be missing in AV1 image // items. libheif v1.11.0 or older does not add the 'pixi' item property to // AV1 image items. (This issue has been corrected in libheif v1.12.0.) +#if AVIF_VERSION >= 90100 decoder->strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED; #endif