From 8cf24ba99ed76697b2ddae3dc5b2647948b96ac1 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 20 Feb 2024 10:06:53 -0800
Subject: [PATCH] Only set the maxCLL/macFALL properties if they're in the
image metadata
---
src/IMG_avif.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/IMG_avif.c b/src/IMG_avif.c
index 60fd2a33..331842b4 100644
--- a/src/IMG_avif.c
+++ b/src/IMG_avif.c
@@ -441,8 +441,10 @@ SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src)
SDL_MATRIX_COEFFICIENTS_IDENTITY,
SDL_CHROMA_LOCATION_NONE);
SDL_SetNumberProperty(props, SDL_PROP_SURFACE_COLORSPACE_NUMBER, colorspace);
- SDL_SetNumberProperty(props, SDL_PROP_SURFACE_MAXCLL_NUMBER, image->clli.maxCLL);
- SDL_SetNumberProperty(props, SDL_PROP_SURFACE_MAXFALL_NUMBER, image->clli.maxPALL);
+ if (image->clli.maxCLL > 0 || image->clli.maxPALL > 0) {
+ SDL_SetNumberProperty(props, SDL_PROP_SURFACE_MAXCLL_NUMBER, image->clli.maxCLL);
+ SDL_SetNumberProperty(props, SDL_PROP_SURFACE_MAXFALL_NUMBER, image->clli.maxPALL);
+ }
// A good approximation to compress HDR content to SDR
// More complex tone mapping algorithms can be added and set by the caller in the future.