From d5f53fc18158b7f944b1bb834be95b294011ad39 Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Sun, 7 Jul 2024 14:29:10 -0400 Subject: [PATCH] fix: disable decoder strictness for clap and pixi properties fixes #28 --- src/pillow_avif/_avif.c | 8 ++++++++ tests/images/chimera-missing-pixi.avif | Bin 0 -> 9717 bytes tests/test_file_avif.py | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 tests/images/chimera-missing-pixi.avif diff --git a/src/pillow_avif/_avif.c b/src/pillow_avif/_avif.c index 0fece9e..6669d45 100644 --- a/src/pillow_avif/_avif.c +++ b/src/pillow_avif/_avif.c @@ -790,6 +790,14 @@ AvifDecoderNew(PyObject *self_, PyObject *args) { max_threads = default_max_threads; } self->decoder->maxThreads = max_threads; +#endif +#if AVIF_VERSION >= 90200 + // Turn off libavif's 'clap' (clean aperture) property validation. + self->decoder->strictFlags &= ~AVIF_STRICT_CLAP_VALID; + // Allow the PixelInformationProperty ('pixi') to be missing in AV1 image + // items. libheif v1.11.0 and older does not add the 'pixi' item property to + // AV1 image items. + self->decoder->strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED; #endif self->decoder->codecChoice = codec; diff --git a/tests/images/chimera-missing-pixi.avif b/tests/images/chimera-missing-pixi.avif new file mode 100644 index 0000000000000000000000000000000000000000..4039547d57413457c9b3c6573e9a42b378e00a41 GIT binary patch literal 9717 zcmY*z5jy5J?9Q9zQY@n>D>&s%lugNZFKm6%T44rc({*KjsdM0& z{0h)@^SZvRq$4Jtn-D~Ml(-0pu7HB1y=|26iCyu1hB)Ak!a3^@Kz+4B6a-&zyB#PA z1LflX%aik8I}sxP@me@z72ALlE_7?T#v3+jXW>yYZ1+zAygxkJZ0QmrPEpmgLR0m0 zKR#Rk6z_#9?7;(ljyzh_pD$Zc#}ceS-;pd&!-)kybC0DjZ z3CRqox%NnyJTOn^mIo1wQdBl8tU~&}MMa7sqD0wv!r3+Nweu>gWwlh)Bf>eTTl!V@ zCqs<4Q`IR|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B1X%*osM8%HZ5^PIylDz2&xI?&jrubyCZCvARJ?hReDH&DT>EY`& znSQdD)>}AybSEM?7$?;CvN~q9K9s*1(y+i}wfn@Fz28vsUV%WNAl}cg%wkGV1pUN1 zwCWfQ+PW2559B1iZ103JG8c%DQ@2?&9bcPWnsfW0lf-m`LVsyXy7_2NM1nS0n-eN< z{OYXP+;)?#;P!rw(%7uhyKwyXPuIZJ8l&w1m)Mezn^*o)W;M7n=7>4P+If&HZoMKa zc{gY(;dJ{<+|%Kp%XcTz-!^xSRv2iPS-e%`5=%`Vt@7lHno_Xeo8P;?{YXCp$>q%L zoeM|cOSlHldgRDf1S(BRYYn^?Z9rm5xteyw61(ww_8Kr!NrpmYVk%ulPCv}Pn}SF&ZTyfKkiIAARm&Sdhsr>4_668wD1vHB5{HOqH8D^`_HV8R(I_)@Bx zvFD#poN8i$%w7nWtJs7Zh^{9#;@YcU$sk!u5%KLXuQPf!MQ?FdZ%G)y{^;Z_tRs9K z;SKVGEr)qbRG>S$sj>0~Es0<}!^b zk-m+gle3BAS4FS~8xv>4{{~-RG6!1!ulb*_w=n*Hy-)w?|1JHWNho1x3$*?}tC8$2 zoNfNgf`NYpzJ;}&@qYqJ;7kAKfPvBc$D{#YBMJ)(+pn&wFZ`Fm`4T1&|5q8hGB8To z7@C>A(1C=*lP@04DSQ YcWHekFfHtD48Qn4e7zDRI7HC@03D=sOaK4? literal 0 HcmV?d00001 diff --git a/tests/test_file_avif.py b/tests/test_file_avif.py index 771b08a..a6ef23e 100644 --- a/tests/test_file_avif.py +++ b/tests/test_file_avif.py @@ -579,6 +579,11 @@ def test_p_mode_transparency(self): assert_image_similar(im_png.convert("RGBA"), Image.open(buf_out), 1) + def test_decoder_strict_flags(self): + # This would fail if full avif strictFlags were enabled + with Image.open("%s/tests/images/chimera-missing-pixi.avif" % CURR_DIR) as im: + assert im.size == (480, 270) + class TestAvifAnimation: @contextmanager