This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 907b7389952c4e2e98c40a58177ebf5166732d55
Author:     marcos ashton <[email protected]>
AuthorDate: Mon May 18 00:23:05 2026 +0100
Commit:     michaelni <[email protected]>
CommitDate: Mon May 25 21:18:34 2026 +0000

    tests/fate/libavutil: add FATE test for ambient_viewing_environment
    
    Test av_ambient_viewing_environment_alloc with and without the size
    out-parameter, and av_ambient_viewing_environment_create_side_data.
    Verifies the {0, 1} rational defaults set by get_defaults(),
    write/read-back of the three AVRational fields, frame side data
    attachment, and OOM paths via av_max_alloc.
    
    Coverage for libavutil/ambient_viewing_environment.c: 60.00% -> 100.00%
---
 .forgejo/CODEOWNERS                           |   2 +
 libavutil/Makefile                            |   1 +
 libavutil/tests/.gitignore                    |   1 +
 libavutil/tests/ambient_viewing_environment.c | 108 ++++++++++++++++++++++++++
 tests/fate/libavutil.mak                      |   4 +
 tests/ref/fate/ambient_viewing_environment    |  19 +++++
 6 files changed, 135 insertions(+)

diff --git a/.forgejo/CODEOWNERS b/.forgejo/CODEOWNERS
index d3bfa07145..fa0c62218c 100644
--- a/.forgejo/CODEOWNERS
+++ b/.forgejo/CODEOWNERS
@@ -232,11 +232,13 @@ doc/.* @GyanD
 # tests
 # =====
 tests/checkasm/riscv/.* @Courmisch
+libavutil/tests/ambient_viewing_environment.* @MarcosAsh
 libavutil/tests/buffer.* @MarcosAsh
 libavutil/tests/hdr_dynamic_vivid_metadata.* @MarcosAsh
 libavutil/tests/tdrdi.* @MarcosAsh
 libavutil/tests/timestamp.* @MarcosAsh
 tests/ref/.*drawvg.* @ayosec
+tests/ref/fate/ambient_viewing_environment @MarcosAsh
 tests/ref/fate/buffer @MarcosAsh
 tests/ref/fate/hdr_dynamic_vivid_metadata @MarcosAsh
 tests/ref/fate/sub-mcc.* @programmerjake
diff --git a/libavutil/Makefile b/libavutil/Makefile
index b7d6e4906f..3fe02936ef 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -258,6 +258,7 @@ SKIPHEADERS-$(CONFIG_SHADER_COMPRESSION) += zlib_utils.h
 TESTPROGS = adler32                                                     \
             aes                                                         \
             aes_ctr                                                     \
+            ambient_viewing_environment                                 \
             audio_fifo                                                  \
             avstring                                                    \
             base64                                                      \
diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
index b43c1e395b..47b319bb89 100644
--- a/libavutil/tests/.gitignore
+++ b/libavutil/tests/.gitignore
@@ -1,6 +1,7 @@
 /adler32
 /aes
 /aes_ctr
+/ambient_viewing_environment
 /atomic
 /audio_fifo
 /avstring
diff --git a/libavutil/tests/ambient_viewing_environment.c 
b/libavutil/tests/ambient_viewing_environment.c
new file mode 100644
index 0000000000..f15b76b0c2
--- /dev/null
+++ b/libavutil/tests/ambient_viewing_environment.c
@@ -0,0 +1,108 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <limits.h>
+#include <stdio.h>
+
+#include "libavutil/ambient_viewing_environment.h"
+#include "libavutil/frame.h"
+#include "libavutil/mem.h"
+
+static void print_env(const AVAmbientViewingEnvironment *env)
+{
+    printf("illuminance=%d/%d, light_x=%d/%d, light_y=%d/%d\n",
+           env->ambient_illuminance.num, env->ambient_illuminance.den,
+           env->ambient_light_x.num,     env->ambient_light_x.den,
+           env->ambient_light_y.num,     env->ambient_light_y.den);
+}
+
+int main(void)
+{
+    AVAmbientViewingEnvironment *env;
+    AVFrame *frame;
+    size_t size = 0;
+
+    /* av_ambient_viewing_environment_alloc with size out-param */
+    printf("Testing av_ambient_viewing_environment_alloc(&size)\n");
+    env = av_ambient_viewing_environment_alloc(&size);
+    if (env) {
+        printf("alloc: OK, size_set=%s\n", size == sizeof(*env) ? "yes" : 
"no");
+        print_env(env);
+        av_free(env);
+    } else {
+        printf("alloc: FAIL\n");
+    }
+
+    /* av_ambient_viewing_environment_alloc with NULL size */
+    printf("\nTesting av_ambient_viewing_environment_alloc(NULL)\n");
+    env = av_ambient_viewing_environment_alloc(NULL);
+    if (env) {
+        printf("alloc(NULL): OK\n");
+        print_env(env);
+        av_free(env);
+    } else {
+        printf("alloc(NULL): FAIL\n");
+    }
+
+    /* write and read back */
+    printf("\nTesting write/read back\n");
+    env = av_ambient_viewing_environment_alloc(NULL);
+    if (env) {
+        env->ambient_illuminance = (AVRational){ 314, 10 };
+        env->ambient_light_x     = (AVRational){ 15635, 50000 };
+        env->ambient_light_y     = (AVRational){ 16450, 50000 };
+        print_env(env);
+        av_free(env);
+    }
+
+    /* av_ambient_viewing_environment_create_side_data */
+    printf("\nTesting av_ambient_viewing_environment_create_side_data()\n");
+    frame = av_frame_alloc();
+    if (frame) {
+        env = av_ambient_viewing_environment_create_side_data(frame);
+        if (env) {
+            printf("side_data: OK\n");
+            print_env(env);
+        } else {
+            printf("side_data: FAIL\n");
+        }
+        av_frame_free(&frame);
+    }
+
+    /* OOM paths via av_max_alloc */
+    printf("\nTesting OOM paths\n");
+    av_max_alloc(1);
+    env = av_ambient_viewing_environment_alloc(&size);
+    printf("alloc OOM: %s\n", env ? "FAIL" : "OK");
+    av_free(env);
+    env = av_ambient_viewing_environment_alloc(NULL);
+    printf("alloc(NULL) OOM: %s\n", env ? "FAIL" : "OK");
+    av_free(env);
+    av_max_alloc(INT_MAX);
+
+    frame = av_frame_alloc();
+    if (frame) {
+        av_max_alloc(1);
+        env = av_ambient_viewing_environment_create_side_data(frame);
+        printf("side_data OOM: %s\n", env ? "FAIL" : "OK");
+        av_max_alloc(INT_MAX);
+        av_frame_free(&frame);
+    }
+
+    return 0;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index e814ee884c..166c0d8c64 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -13,6 +13,10 @@ fate-aes_ctr: libavutil/tests/aes_ctr$(EXESUF)
 fate-aes_ctr: CMD = run libavutil/tests/aes_ctr$(EXESUF)
 fate-aes_ctr: CMP = null
 
+FATE_LIBAVUTIL += fate-ambient_viewing_environment
+fate-ambient_viewing_environment: 
libavutil/tests/ambient_viewing_environment$(EXESUF)
+fate-ambient_viewing_environment: CMD = run 
libavutil/tests/ambient_viewing_environment$(EXESUF)
+
 FATE_LIBAVUTIL += fate-camellia
 fate-camellia: libavutil/tests/camellia$(EXESUF)
 fate-camellia: CMD = run libavutil/tests/camellia$(EXESUF)
diff --git a/tests/ref/fate/ambient_viewing_environment 
b/tests/ref/fate/ambient_viewing_environment
new file mode 100644
index 0000000000..ef66095c5e
--- /dev/null
+++ b/tests/ref/fate/ambient_viewing_environment
@@ -0,0 +1,19 @@
+Testing av_ambient_viewing_environment_alloc(&size)
+alloc: OK, size_set=yes
+illuminance=0/1, light_x=0/1, light_y=0/1
+
+Testing av_ambient_viewing_environment_alloc(NULL)
+alloc(NULL): OK
+illuminance=0/1, light_x=0/1, light_y=0/1
+
+Testing write/read back
+illuminance=314/10, light_x=15635/50000, light_y=16450/50000
+
+Testing av_ambient_viewing_environment_create_side_data()
+side_data: OK
+illuminance=0/1, light_x=0/1, light_y=0/1
+
+Testing OOM paths
+alloc OOM: OK
+alloc(NULL) OOM: OK
+side_data OOM: OK

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to