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

Git pushed a commit to branch master
in repository ffmpeg.

commit be2fa773446c5f4003616f0e01bb52064b9f0389
Author:     marcos ashton <[email protected]>
AuthorDate: Wed Mar 25 23:10:17 2026 +0000
Commit:     marcos ashton <[email protected]>
CommitDate: Tue Mar 31 18:05:51 2026 +0100

    tests/fate/libavutil: add FATE test for spherical
    
    Unit test covering all 4 public API functions in libavutil/spherical.c:
    av_spherical_alloc, av_spherical_projection_name, av_spherical_from_name,
    and av_spherical_tile_bounds.
    
    Tests allocation with and without size output, all 7 projection type
    name lookups, projection name round-trip verification, out-of-range
    handling, and tile bounds computation for full-frame, quarter-tile,
    and centered-tile configurations.
    
    Coverage for libavutil/spherical.c: 0.00% -> 100.00%
    
    Signed-off-by: marcos ashton <[email protected]>
---
 libavutil/Makefile          |   1 +
 libavutil/tests/spherical.c | 107 ++++++++++++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak    |   4 ++
 tests/ref/fate/spherical    |  38 ++++++++++++++++
 4 files changed, 150 insertions(+)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index ff166cc81a..1095c5cfcf 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -301,6 +301,7 @@ TESTPROGS = adler32                                         
            \
             sha512                                                      \
             side_data_array                                             \
             softfloat                                                   \
+            spherical                                                   \
             stereo3d                                                    \
             tree                                                        \
             twofish                                                     \
diff --git a/libavutil/tests/spherical.c b/libavutil/tests/spherical.c
new file mode 100644
index 0000000000..a7e7d12450
--- /dev/null
+++ b/libavutil/tests/spherical.c
@@ -0,0 +1,107 @@
+/*
+ * 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 <stdio.h>
+
+#include "libavutil/mem.h"
+#include "libavutil/spherical.h"
+
+int main(void)
+{
+    AVSphericalMapping *map;
+    size_t size;
+
+    /* av_spherical_alloc with size output */
+    printf("Testing av_spherical_alloc()\n");
+    map = av_spherical_alloc(&size);
+    if (map) {
+        printf("alloc: OK, size>0=%s, default projection=%d\n",
+               size > 0 ? "yes" : "no", map->projection);
+        av_free(map);
+    } else {
+        printf("alloc: FAIL\n");
+    }
+
+    /* av_spherical_alloc without size */
+    map = av_spherical_alloc(NULL);
+    printf("alloc (no size): %s\n", map ? "OK" : "FAIL");
+    av_free(map);
+
+    /* av_spherical_projection_name - all valid projections */
+    printf("\nTesting av_spherical_projection_name()\n");
+    for (int i = 0; i <= AV_SPHERICAL_PARAMETRIC_IMMERSIVE; i++)
+        printf("projection %d: %s\n", i, av_spherical_projection_name(i));
+    printf("out of range: %s\n", av_spherical_projection_name(100));
+
+    /* av_spherical_from_name - all valid names */
+    printf("\nTesting av_spherical_from_name()\n");
+    for (int i = 0; i <= AV_SPHERICAL_PARAMETRIC_IMMERSIVE; i++) {
+        const char *name = av_spherical_projection_name(i);
+        printf("%s: %d\n", name, av_spherical_from_name(name));
+    }
+    printf("nonexistent: %d\n", av_spherical_from_name("nonexistent"));
+
+    /* projection name round-trip */
+    printf("\nTesting projection name round-trip\n");
+    for (int i = 0; i <= AV_SPHERICAL_PARAMETRIC_IMMERSIVE; i++) {
+        const char *name = av_spherical_projection_name(i);
+        int rt = av_spherical_from_name(name);
+        printf("roundtrip %d (%s): %s\n", i, name, rt == i ? "OK" : "FAIL");
+    }
+
+    /* av_spherical_tile_bounds - no bounds (full frame) */
+    printf("\nTesting av_spherical_tile_bounds()\n");
+    map = av_spherical_alloc(NULL);
+    if (map) {
+        size_t left, top, right, bottom;
+
+        map->projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
+        printf("projection: %s\n",
+               av_spherical_projection_name(map->projection));
+
+        map->bound_left   = 0;
+        map->bound_top    = 0;
+        map->bound_right  = 0;
+        map->bound_bottom = 0;
+        av_spherical_tile_bounds(map, 1920, 1080, &left, &top, &right, 
&bottom);
+        printf("full frame: left=%zu top=%zu right=%zu bottom=%zu\n",
+               left, top, right, bottom);
+
+        /* quarter tile at top-left (each bound is 0.32 fixed point) */
+        map->bound_left   = 0;
+        map->bound_top    = 0;
+        map->bound_right  = UINT32_MAX / 2;
+        map->bound_bottom = UINT32_MAX / 2;
+        av_spherical_tile_bounds(map, 960, 540, &left, &top, &right, &bottom);
+        printf("quarter top-left: left=%zu top=%zu right=%zu bottom=%zu\n",
+               left, top, right, bottom);
+
+        /* centered tile with equal margins */
+        map->bound_left   = UINT32_MAX / 4;
+        map->bound_top    = UINT32_MAX / 4;
+        map->bound_right  = UINT32_MAX / 4;
+        map->bound_bottom = UINT32_MAX / 4;
+        av_spherical_tile_bounds(map, 960, 540, &left, &top, &right, &bottom);
+        printf("centered: left=%zu top=%zu right=%zu bottom=%zu\n",
+               left, top, right, bottom);
+
+        av_free(map);
+    }
+
+    return 0;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index d69a4de863..b0df2938e6 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -156,6 +156,10 @@ FATE_LIBAVUTIL += fate-side_data_array
 fate-side_data_array: libavutil/tests/side_data_array$(EXESUF)
 fate-side_data_array: CMD = run libavutil/tests/side_data_array$(EXESUF)
 
+FATE_LIBAVUTIL += fate-spherical
+fate-spherical: libavutil/tests/spherical$(EXESUF)
+fate-spherical: CMD = run libavutil/tests/spherical$(EXESUF)
+
 FATE_LIBAVUTIL += fate-stereo3d
 fate-stereo3d: libavutil/tests/stereo3d$(EXESUF)
 fate-stereo3d: CMD = run libavutil/tests/stereo3d$(EXESUF)
diff --git a/tests/ref/fate/spherical b/tests/ref/fate/spherical
new file mode 100644
index 0000000000..2629c4f2fd
--- /dev/null
+++ b/tests/ref/fate/spherical
@@ -0,0 +1,38 @@
+Testing av_spherical_alloc()
+alloc: OK, size>0=yes, default projection=4
+alloc (no size): OK
+
+Testing av_spherical_projection_name()
+projection 0: equirectangular
+projection 1: cubemap
+projection 2: tiled equirectangular
+projection 3: half equirectangular
+projection 4: rectilinear
+projection 5: fisheye
+projection 6: parametric immersive
+out of range: unknown
+
+Testing av_spherical_from_name()
+equirectangular: 0
+cubemap: 1
+tiled equirectangular: 2
+half equirectangular: 3
+rectilinear: 4
+fisheye: 5
+parametric immersive: 6
+nonexistent: -1
+
+Testing projection name round-trip
+roundtrip 0 (equirectangular): OK
+roundtrip 1 (cubemap): OK
+roundtrip 2 (tiled equirectangular): OK
+roundtrip 3 (half equirectangular): OK
+roundtrip 4 (rectilinear): OK
+roundtrip 5 (fisheye): OK
+roundtrip 6 (parametric immersive): OK
+
+Testing av_spherical_tile_bounds()
+projection: tiled equirectangular
+full frame: left=0 top=0 right=0 bottom=0
+quarter top-left: left=0 top=0 right=959 bottom=539
+centered: left=480 top=270 right=479 bottom=269

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

Reply via email to