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

Git pushed a commit to branch master
in repository ffmpeg.

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

    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 | 130 +++++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak           |   4 ++
 tests/ref/fate/video_enc_params    |  19 ++++++
 4 files changed, 154 insertions(+)

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..ecbc96c689
--- /dev/null
+++ b/libavutil/tests/video_enc_params.c
@@ -0,0 +1,130 @@
+/*
+ * 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 <stdint.h>
+#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);
+            if ((uint8_t *)block != (uint8_t *)par + par->blocks_offset +
+                                    (size_t)i * par->block_size)
+                printf("block %d: pointer inconsistent with 
blocks_offset/block_size\n", 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 0471e94bbc..e25f1e2b9c 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-file
 fate-file: libavutil/tests/file$(EXESUF)
 fate-file: CMD = run libavutil/tests/file$(EXESUF) 
$(SRC_PATH)/libavutil/tests/file.c
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

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

Reply via email to