PR #22622 opened by MarcosAsh
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22622
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22622.patch

1. spherical (libavutil)
Unit test covering all 4 public API functions: av_spherical_alloc, 
av_spherical_projection_name, av_spherical_from_name, and 
av_spherical_tile_bounds. Tests all 7 projection type name lookups with 
round-trip verification, and tile bounds computation for full-frame, 
quarter-tile, and centered-tile configurations.

Coverage for libavutil/spherical.c: 0.00% -> 100.00%

2. detection_bbox (libavutil)
Unit test covering av_detection_bbox_alloc, av_get_detection_bbox, and 
av_detection_bbox_create_side_data. Tests allocation with 0, 1, and 4 bounding 
boxes, bbox getter indexing with coordinate/label/confidence read-back, 
classify fields, and side data creation with frame attachment.

Coverage for libavutil/detection_bbox.c: 0.00% -> 86.67% (remaining uncovered 
lines are OOM error paths)

3. video_enc_params (libavutil)
Unit test covering av_video_enc_params_alloc, av_video_enc_params_block, and 
av_video_enc_params_create_side_data. Tests allocation for all three codec 
types (VP9, H264, MPEG2) and NONE, block getter indexing with 
coordinate/delta_qp read-back, and side data creation with frame attachment.

Coverage for libavutil/video_enc_params.c: 0.00% -> 86.21% (remaining uncovered 
lines are OOM error paths)


>From 35344a26528e2571066d02383ea315def909fd1b Mon Sep 17 00:00:00 2001
From: marcos ashton <[email protected]>
Date: Wed, 25 Mar 2026 23:10:17 +0000
Subject: [PATCH 1/3] 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 | 103 ++++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak    |   4 ++
 tests/ref/fate/spherical    |  37 +++++++++++++
 4 files changed, 145 insertions(+)
 create mode 100644 libavutil/tests/spherical.c
 create mode 100644 tests/ref/fate/spherical

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..429775b4a8
--- /dev/null
+++ b/libavutil/tests/spherical.c
@@ -0,0 +1,103 @@
+/*
+ * 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->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 a93a83dc21..3cfaac4551 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..7cca2deb32
--- /dev/null
+++ b/tests/ref/fate/spherical
@@ -0,0 +1,37 @@
+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()
+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
-- 
2.52.0


>From 6dfd27bad7110eebd0e74572d65f8894ddd4ed93 Mon Sep 17 00:00:00 2001
From: marcos ashton <[email protected]>
Date: Wed, 25 Mar 2026 23:10:45 +0000
Subject: [PATCH 2/3] tests/fate/libavutil: add FATE test for detection_bbox

Unit test covering av_detection_bbox_alloc, av_get_detection_bbox,
and av_detection_bbox_create_side_data.

Tests allocation with 0, 1, and 4 bounding boxes, with and without
size output. Verifies bbox getter indexing by writing and reading
back coordinates, labels, and confidence values. Tests classify
fields (labels and confidences), the header source field, and
side data creation with frame attachment.

Coverage for libavutil/detection_bbox.c: 0.00% -> 86.67%
(remaining uncovered lines are OOM error paths)

Signed-off-by: marcos ashton <[email protected]>
---
 libavutil/Makefile               |   1 +
 libavutil/tests/detection_bbox.c | 140 +++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak         |   4 +
 tests/ref/fate/detection_bbox    |  22 +++++
 4 files changed, 167 insertions(+)
 create mode 100644 libavutil/tests/detection_bbox.c
 create mode 100644 tests/ref/fate/detection_bbox

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 1095c5cfcf..4630e51bbc 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -270,6 +270,7 @@ TESTPROGS = adler32                                         
            \
             cpu                                                         \
             crc                                                         \
             des                                                         \
+            detection_bbox                                              \
             dict                                                        \
             display                                                     \
             encryption_info                                             \
diff --git a/libavutil/tests/detection_bbox.c b/libavutil/tests/detection_bbox.c
new file mode 100644
index 0000000000..5bfdd04d37
--- /dev/null
+++ b/libavutil/tests/detection_bbox.c
@@ -0,0 +1,140 @@
+/*
+ * 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 <string.h>
+
+#include "libavutil/detection_bbox.h"
+#include "libavutil/frame.h"
+#include "libavutil/mem.h"
+
+int main(void)
+{
+    AVDetectionBBoxHeader *header;
+    AVDetectionBBox *bbox;
+    AVFrame *frame;
+    size_t size;
+
+    /* av_detection_bbox_alloc - single bbox */
+    printf("Testing av_detection_bbox_alloc()\n");
+    header = av_detection_bbox_alloc(1, &size);
+    if (header) {
+        printf("alloc 1: OK, nb=%u, size>0=%s\n",
+               header->nb_bboxes, size > 0 ? "yes" : "no");
+        av_free(header);
+    } else {
+        printf("alloc 1: FAIL\n");
+    }
+
+    /* av_detection_bbox_alloc - zero bboxes */
+    header = av_detection_bbox_alloc(0, &size);
+    if (header) {
+        printf("alloc 0: OK, nb=%u\n", header->nb_bboxes);
+        av_free(header);
+    } else {
+        printf("alloc 0: FAIL\n");
+    }
+
+    /* av_detection_bbox_alloc - multiple bboxes */
+    header = av_detection_bbox_alloc(4, &size);
+    if (header) {
+        printf("alloc 4: OK, nb=%u\n", header->nb_bboxes);
+        av_free(header);
+    } else {
+        printf("alloc 4: FAIL\n");
+    }
+
+    /* av_detection_bbox_alloc without size */
+    header = av_detection_bbox_alloc(1, NULL);
+    printf("alloc (no size): %s\n", header ? "OK" : "FAIL");
+    av_free(header);
+
+    /* av_get_detection_bbox - write and read back */
+    printf("\nTesting av_get_detection_bbox()\n");
+    header = av_detection_bbox_alloc(3, NULL);
+    if (header) {
+        for (int i = 0; i < 3; i++) {
+            bbox = av_get_detection_bbox(header, i);
+            bbox->x = i * 100;
+            bbox->y = i * 200;
+            bbox->w = 50 + i;
+            bbox->h = 60 + i;
+            snprintf(bbox->detect_label, sizeof(bbox->detect_label),
+                     "obj%d", i);
+            bbox->detect_confidence = (AVRational){ 90 + i, 100 };
+        }
+        for (int i = 0; i < 3; i++) {
+            bbox = av_get_detection_bbox(header, i);
+            printf("bbox %d: x=%d y=%d w=%d h=%d label=%s conf=%d/%d\n",
+                   i, bbox->x, bbox->y, bbox->w, bbox->h,
+                   bbox->detect_label,
+                   bbox->detect_confidence.num,
+                   bbox->detect_confidence.den);
+        }
+        av_free(header);
+    }
+
+    /* classify fields */
+    printf("\nTesting classify fields\n");
+    header = av_detection_bbox_alloc(1, NULL);
+    if (header) {
+        bbox = av_get_detection_bbox(header, 0);
+        bbox->classify_count = 2;
+        snprintf(bbox->classify_labels[0], sizeof(bbox->classify_labels[0]),
+                 "cat");
+        bbox->classify_confidences[0] = (AVRational){ 95, 100 };
+        snprintf(bbox->classify_labels[1], sizeof(bbox->classify_labels[1]),
+                 "animal");
+        bbox->classify_confidences[1] = (AVRational){ 80, 100 };
+        printf("classify_count=%u\n", bbox->classify_count);
+        for (int i = 0; i < (int)bbox->classify_count; i++)
+            printf("classify %d: %s %d/%d\n", i,
+                   bbox->classify_labels[i],
+                   bbox->classify_confidences[i].num,
+                   bbox->classify_confidences[i].den);
+        av_free(header);
+    }
+
+    /* header source field */
+    printf("\nTesting source field\n");
+    header = av_detection_bbox_alloc(1, NULL);
+    if (header) {
+        snprintf(header->source, sizeof(header->source), "test_model_v1");
+        printf("source: %s\n", header->source);
+        av_free(header);
+    }
+
+    /* av_detection_bbox_create_side_data */
+    printf("\nTesting av_detection_bbox_create_side_data()\n");
+    frame = av_frame_alloc();
+    if (frame) {
+        header = av_detection_bbox_create_side_data(frame, 2);
+        if (header) {
+            printf("side_data: OK, nb=%u\n", header->nb_bboxes);
+            bbox = av_get_detection_bbox(header, 0);
+            bbox->x = 10;
+            bbox->y = 20;
+            printf("side_data bbox 0: x=%d y=%d\n", bbox->x, bbox->y);
+        } else {
+            printf("side_data: FAIL\n");
+        }
+        av_frame_free(&frame);
+    }
+
+    return 0;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 3cfaac4551..ec042560dc 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -70,6 +70,10 @@ fate-des: libavutil/tests/des$(EXESUF)
 fate-des: CMD = run libavutil/tests/des$(EXESUF)
 fate-des: CMP = null
 
+FATE_LIBAVUTIL += fate-detection_bbox
+fate-detection_bbox: libavutil/tests/detection_bbox$(EXESUF)
+fate-detection_bbox: CMD = run libavutil/tests/detection_bbox$(EXESUF)
+
 FATE_LIBAVUTIL += fate-dict
 fate-dict: libavutil/tests/dict$(EXESUF)
 fate-dict: CMD = run libavutil/tests/dict$(EXESUF)
diff --git a/tests/ref/fate/detection_bbox b/tests/ref/fate/detection_bbox
new file mode 100644
index 0000000000..3b15682e14
--- /dev/null
+++ b/tests/ref/fate/detection_bbox
@@ -0,0 +1,22 @@
+Testing av_detection_bbox_alloc()
+alloc 1: OK, nb=1, size>0=yes
+alloc 0: OK, nb=0
+alloc 4: OK, nb=4
+alloc (no size): OK
+
+Testing av_get_detection_bbox()
+bbox 0: x=0 y=0 w=50 h=60 label=obj0 conf=90/100
+bbox 1: x=100 y=200 w=51 h=61 label=obj1 conf=91/100
+bbox 2: x=200 y=400 w=52 h=62 label=obj2 conf=92/100
+
+Testing classify fields
+classify_count=2
+classify 0: cat 95/100
+classify 1: animal 80/100
+
+Testing source field
+source: test_model_v1
+
+Testing av_detection_bbox_create_side_data()
+side_data: OK, nb=2
+side_data bbox 0: x=10 y=20
-- 
2.52.0


>From 9366ffd7ac32e4e759b0edf70a50bc535cc4795f Mon Sep 17 00:00:00 2001
From: marcos ashton <[email protected]>
Date: Wed, 25 Mar 2026 23:11:10 +0000
Subject: [PATCH 3/3] tests/fate/libavutil: add FATE test for video_enc_params

Unit test covering av_video_enc_params_alloc,
av_video_enc_params_block, and
av_video_enc_params_create_side_data.

Tests allocation for all three codec types (VP9, H264, MPEG2) and
the NONE type, with 0 and 4 blocks, with and without size output.
Verifies block getter indexing by writing and reading back
coordinates, dimensions, and delta_qp values. Tests frame-level qp
and delta_qp fields, and side data creation with frame attachment.

Coverage for libavutil/video_enc_params.c: 0.00% -> 86.21%
(remaining uncovered lines are OOM error paths)

Signed-off-by: marcos ashton <[email protected]>
---
 libavutil/Makefile                 |   1 +
 libavutil/tests/video_enc_params.c | 126 +++++++++++++++++++++++++++++
 tests/fate/libavutil.mak           |   4 +
 tests/ref/fate/video_enc_params    |  19 +++++
 4 files changed, 150 insertions(+)
 create mode 100644 libavutil/tests/video_enc_params.c
 create mode 100644 tests/ref/fate/video_enc_params

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 4630e51bbc..1647952f8f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -308,6 +308,7 @@ TESTPROGS = adler32                                         
            \
             twofish                                                     \
             utf8                                                        \
             uuid                                                        \
+            video_enc_params                                            \
             xtea                                                        \
             tea                                                         \
 
diff --git a/libavutil/tests/video_enc_params.c 
b/libavutil/tests/video_enc_params.c
new file mode 100644
index 0000000000..5bdcc63e14
--- /dev/null
+++ b/libavutil/tests/video_enc_params.c
@@ -0,0 +1,126 @@
+/*
+ * 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/frame.h"
+#include "libavutil/mem.h"
+#include "libavutil/video_enc_params.h"
+
+int main(void)
+{
+    AVVideoEncParams *par;
+    AVVideoBlockParams *block;
+    AVFrame *frame;
+    size_t size;
+
+    static const struct {
+        enum AVVideoEncParamsType type;
+        const char *name;
+    } types[] = {
+        { AV_VIDEO_ENC_PARAMS_VP9,   "VP9"   },
+        { AV_VIDEO_ENC_PARAMS_H264,  "H264"  },
+        { AV_VIDEO_ENC_PARAMS_MPEG2, "MPEG2" },
+    };
+
+    /* av_video_enc_params_alloc - each type with blocks */
+    printf("Testing av_video_enc_params_alloc()\n");
+    for (int i = 0; i < 3; i++) {
+        par = av_video_enc_params_alloc(types[i].type, 4, &size);
+        if (par) {
+            printf("%s: OK, type=%d, nb_blocks=%u, size>0=%s\n",
+                   types[i].name, par->type, par->nb_blocks,
+                   size > 0 ? "yes" : "no");
+            av_free(par);
+        } else {
+            printf("%s: FAIL\n", types[i].name);
+        }
+    }
+
+    /* zero blocks */
+    par = av_video_enc_params_alloc(AV_VIDEO_ENC_PARAMS_VP9, 0, &size);
+    if (par) {
+        printf("zero blocks: OK, nb_blocks=%u\n", par->nb_blocks);
+        av_free(par);
+    } else {
+        printf("zero blocks: FAIL\n");
+    }
+
+    /* alloc without size */
+    par = av_video_enc_params_alloc(AV_VIDEO_ENC_PARAMS_H264, 1, NULL);
+    printf("alloc (no size): %s\n", par ? "OK" : "FAIL");
+    av_free(par);
+
+    /* av_video_enc_params_block - write and read back */
+    printf("\nTesting av_video_enc_params_block()\n");
+    par = av_video_enc_params_alloc(AV_VIDEO_ENC_PARAMS_H264, 3, NULL);
+    if (par) {
+        par->qp = 26;
+        par->delta_qp[0][0] = -2;
+        par->delta_qp[0][1] = -1;
+        printf("frame qp=%d, delta_qp[0]={%d,%d}\n",
+               par->qp, par->delta_qp[0][0], par->delta_qp[0][1]);
+
+        for (int i = 0; i < 3; i++) {
+            block = av_video_enc_params_block(par, i);
+            block->src_x = i * 16;
+            block->src_y = i * 16;
+            block->w = 16;
+            block->h = 16;
+            block->delta_qp = i - 1;
+        }
+        for (int i = 0; i < 3; i++) {
+            block = av_video_enc_params_block(par, i);
+            printf("block %d: src=(%d,%d) size=%dx%d delta_qp=%d\n",
+                   i, block->src_x, block->src_y,
+                   block->w, block->h, block->delta_qp);
+        }
+        av_free(par);
+    }
+
+    /* av_video_enc_params_create_side_data */
+    printf("\nTesting av_video_enc_params_create_side_data()\n");
+    frame = av_frame_alloc();
+    if (frame) {
+        par = av_video_enc_params_create_side_data(frame,
+                  AV_VIDEO_ENC_PARAMS_VP9, 2);
+        if (par) {
+            printf("side_data: OK, type=%d, nb_blocks=%u\n",
+                   par->type, par->nb_blocks);
+            block = av_video_enc_params_block(par, 0);
+            block->delta_qp = 5;
+            block = av_video_enc_params_block(par, 0);
+            printf("side_data block 0: delta_qp=%d\n", block->delta_qp);
+        } else {
+            printf("side_data: FAIL\n");
+        }
+        av_frame_free(&frame);
+    }
+
+    /* NONE type */
+    printf("\nTesting NONE type\n");
+    par = av_video_enc_params_alloc(AV_VIDEO_ENC_PARAMS_NONE, 0, &size);
+    if (par) {
+        printf("NONE: OK, type=%d\n", par->type);
+        av_free(par);
+    } else {
+        printf("NONE: FAIL\n");
+    }
+
+    return 0;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index ec042560dc..d608ed745b 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -195,6 +195,10 @@ fate-uuid: libavutil/tests/uuid$(EXESUF)
 fate-uuid: CMD = run libavutil/tests/uuid$(EXESUF)
 fate-uuid: CMP = null
 
+FATE_LIBAVUTIL += fate-video_enc_params
+fate-video_enc_params: libavutil/tests/video_enc_params$(EXESUF)
+fate-video_enc_params: CMD = run libavutil/tests/video_enc_params$(EXESUF)
+
 FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
 FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
 fate-libavutil: $(FATE_LIBAVUTIL)
diff --git a/tests/ref/fate/video_enc_params b/tests/ref/fate/video_enc_params
new file mode 100644
index 0000000000..8c0fa898af
--- /dev/null
+++ b/tests/ref/fate/video_enc_params
@@ -0,0 +1,19 @@
+Testing av_video_enc_params_alloc()
+VP9: OK, type=0, nb_blocks=4, size>0=yes
+H264: OK, type=1, nb_blocks=4, size>0=yes
+MPEG2: OK, type=2, nb_blocks=4, size>0=yes
+zero blocks: OK, nb_blocks=0
+alloc (no size): OK
+
+Testing av_video_enc_params_block()
+frame qp=26, delta_qp[0]={-2,-1}
+block 0: src=(0,0) size=16x16 delta_qp=-1
+block 1: src=(16,16) size=16x16 delta_qp=0
+block 2: src=(32,32) size=16x16 delta_qp=1
+
+Testing av_video_enc_params_create_side_data()
+side_data: OK, type=0, nb_blocks=2
+side_data block 0: delta_qp=5
+
+Testing NONE type
+NONE: OK, type=-1
-- 
2.52.0

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

Reply via email to