PR #22687 opened by Marcos Ashton (MarcosAsh)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22687
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22687.patch

## Summary                                          
  - dovi_meta: exercises av_dovi_alloc, av_dovi_metadata_alloc, and 
av_dovi_find_level; verifies the four inline offset-based accessors return 
consistent pointers and that find_level handles missing levels correctly.  
Coverage: 0% -> 100%.

  - mastering_display_metadata: exercises all 5 public functions including both 
alloc and create_side_data variants for mastering display and content light 
metadata; verifies rational defaults and field read-back.  Coverage: 0% -> 100%.
  
  - video_hint: exercises av_video_hint_alloc with 0, 1, and 4 rects plus 
create_side_data; verifies pointer consistency via 
av_video_hint_rects/av_video_hint_get_rect, rect coordinate read-back, and both 
hint type values. Coverage: 0% -> 86.21% (remaining uncovered lines are OOM 
error paths).


>From e9b5617a2d3a33007815c01e6d980d60fc6bc8e5 Mon Sep 17 00:00:00 2001
From: marcos ashton <[email protected]>
Date: Tue, 31 Mar 2026 22:20:04 +0100
Subject: [PATCH 1/3] tests/fate/libavutil: add FATE test for dovi_meta

Test av_dovi_alloc, av_dovi_metadata_alloc, and av_dovi_find_level.
Verifies that the four inline offset-based accessors (get_header,
get_mapping, get_color, get_ext) return pointers consistent with
the offset fields, and that find_level returns the first matching
ext block or NULL for a missing level.

Coverage for libavutil/dovi_meta.c: 0.00% -> 100.00%
---
 libavutil/Makefile          |   1 +
 libavutil/tests/dovi_meta.c | 130 ++++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak    |   4 ++
 tests/ref/fate/dovi_meta    |  18 +++++
 4 files changed, 153 insertions(+)
 create mode 100644 libavutil/tests/dovi_meta.c
 create mode 100644 tests/ref/fate/dovi_meta

diff --git a/libavutil/Makefile b/libavutil/Makefile
index ff166cc81a..06bc12601c 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -271,6 +271,7 @@ TESTPROGS = adler32                                         
            \
             crc                                                         \
             des                                                         \
             dict                                                        \
+            dovi_meta                                                   \
             display                                                     \
             encryption_info                                             \
             error                                                       \
diff --git a/libavutil/tests/dovi_meta.c b/libavutil/tests/dovi_meta.c
new file mode 100644
index 0000000000..d5553bec4f
--- /dev/null
+++ b/libavutil/tests/dovi_meta.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/dovi_meta.h"
+#include "libavutil/mem.h"
+
+int main(void)
+{
+    AVDOVIDecoderConfigurationRecord *cfg;
+    AVDOVIMetadata *md;
+    size_t size;
+
+    /* av_dovi_alloc */
+    printf("Testing av_dovi_alloc()\n");
+    cfg = av_dovi_alloc(&size);
+    if (cfg) {
+        printf("alloc: OK, size>0=%s, dv_profile=%d\n",
+               size > 0 ? "yes" : "no", cfg->dv_profile);
+        av_free(cfg);
+    } else {
+        printf("alloc: FAIL\n");
+    }
+
+    cfg = av_dovi_alloc(NULL);
+    printf("alloc (no size): %s\n", cfg ? "OK" : "FAIL");
+    av_free(cfg);
+
+    /* av_dovi_metadata_alloc */
+    printf("\nTesting av_dovi_metadata_alloc()\n");
+    md = av_dovi_metadata_alloc(&size);
+    if (md) {
+        AVDOVIRpuDataHeader *header;
+        AVDOVIDataMapping *mapping;
+        AVDOVIColorMetadata *color;
+
+        printf("alloc: OK, size>0=%s\n", size > 0 ? "yes" : "no");
+        printf("num_ext_blocks=%d\n", md->num_ext_blocks);
+
+        /* pointer consistency checks for inline accessors */
+        header = av_dovi_get_header(md);
+        if ((uint8_t *)header != (uint8_t *)md + md->header_offset)
+            printf("header: pointer inconsistent with header_offset\n");
+        printf("header_offset>0=%s, rpu_type=%d\n",
+               md->header_offset > 0 ? "yes" : "no",
+               header->rpu_type);
+
+        mapping = av_dovi_get_mapping(md);
+        if ((uint8_t *)mapping != (uint8_t *)md + md->mapping_offset)
+            printf("mapping: pointer inconsistent with mapping_offset\n");
+        printf("mapping_offset>0=%s, nlq_method_idc=%d\n",
+               md->mapping_offset > 0 ? "yes" : "no",
+               mapping->nlq_method_idc);
+
+        color = av_dovi_get_color(md);
+        if ((uint8_t *)color != (uint8_t *)md + md->color_offset)
+            printf("color: pointer inconsistent with color_offset\n");
+        printf("color_offset>0=%s, dm_metadata_id=%d\n",
+               md->color_offset > 0 ? "yes" : "no",
+               color->dm_metadata_id);
+
+        /* ext block accessor with pointer check */
+        if (md->ext_block_size > 0) {
+            AVDOVIDmData *ext = av_dovi_get_ext(md, 0);
+            if ((uint8_t *)ext != (uint8_t *)md + md->ext_block_offset)
+                printf("ext[0]: pointer inconsistent with ext_block_offset\n");
+            printf("ext_block_size>0=%s\n",
+                   md->ext_block_size > 0 ? "yes" : "no");
+        }
+
+        av_free(md);
+    } else {
+        printf("alloc: FAIL\n");
+    }
+
+    md = av_dovi_metadata_alloc(NULL);
+    printf("alloc (no size): %s\n", md ? "OK" : "FAIL");
+    av_free(md);
+
+    /* av_dovi_find_level */
+    printf("\nTesting av_dovi_find_level()\n");
+    md = av_dovi_metadata_alloc(NULL);
+    if (md) {
+        AVDOVIDmData *ext, *found;
+
+        /* set up 3 ext blocks with different levels */
+        md->num_ext_blocks = 3;
+        ext = av_dovi_get_ext(md, 0);
+        ext->level = 1;
+        ext = av_dovi_get_ext(md, 1);
+        ext->level = 5;
+        ext = av_dovi_get_ext(md, 2);
+        ext->level = 1;
+
+        found = av_dovi_find_level(md, 1);
+        printf("find level 1: %s\n", found && found->level == 1 ? "OK" : 
"FAIL");
+
+        found = av_dovi_find_level(md, 5);
+        printf("find level 5: %s\n", found && found->level == 5 ? "OK" : 
"FAIL");
+
+        /* first match -- should return ext[0], not ext[2] */
+        found = av_dovi_find_level(md, 1);
+        printf("find level 1 first match: %s\n",
+               found == av_dovi_get_ext(md, 0) ? "OK" : "FAIL");
+
+        found = av_dovi_find_level(md, 99);
+        printf("find level 99 (missing): %s\n", found == NULL ? "OK" : "FAIL");
+
+        av_free(md);
+    }
+
+    return 0;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index d69a4de863..78f4e17b85 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -74,6 +74,10 @@ FATE_LIBAVUTIL += fate-dict
 fate-dict: libavutil/tests/dict$(EXESUF)
 fate-dict: CMD = run libavutil/tests/dict$(EXESUF)
 
+FATE_LIBAVUTIL += fate-dovi_meta
+fate-dovi_meta: libavutil/tests/dovi_meta$(EXESUF)
+fate-dovi_meta: CMD = run libavutil/tests/dovi_meta$(EXESUF)
+
 FATE_LIBAVUTIL += fate-encryption-info
 fate-encryption-info: libavutil/tests/encryption_info$(EXESUF)
 fate-encryption-info: CMD = run libavutil/tests/encryption_info$(EXESUF)
diff --git a/tests/ref/fate/dovi_meta b/tests/ref/fate/dovi_meta
new file mode 100644
index 0000000000..51407e66c0
--- /dev/null
+++ b/tests/ref/fate/dovi_meta
@@ -0,0 +1,18 @@
+Testing av_dovi_alloc()
+alloc: OK, size>0=yes, dv_profile=0
+alloc (no size): OK
+
+Testing av_dovi_metadata_alloc()
+alloc: OK, size>0=yes
+num_ext_blocks=0
+header_offset>0=yes, rpu_type=0
+mapping_offset>0=yes, nlq_method_idc=0
+color_offset>0=yes, dm_metadata_id=0
+ext_block_size>0=yes
+alloc (no size): OK
+
+Testing av_dovi_find_level()
+find level 1: OK
+find level 5: OK
+find level 1 first match: OK
+find level 99 (missing): OK
-- 
2.52.0


>From 9cb9a8e658952e89c1cd45afb51658757ae5fe46 Mon Sep 17 00:00:00 2001
From: marcos ashton <[email protected]>
Date: Tue, 31 Mar 2026 22:20:33 +0100
Subject: [PATCH 2/3] tests/fate/libavutil: add FATE test for
 mastering_display_metadata

Test all 5 public functions: av_mastering_display_metadata_alloc,
av_mastering_display_metadata_alloc_size, the create_side_data
variant, av_content_light_metadata_alloc, and its create_side_data
variant. Verifies the {0,1} rational defaults set by get_defaults(),
write/read-back of HDR metadata fields, and frame side data
attachment for both mastering display and content light metadata.

Coverage for libavutil/mastering_display_metadata.c: 0.00% -> 100.00%
---
 libavutil/Makefile                           |   1 +
 libavutil/tests/mastering_display_metadata.c | 134 +++++++++++++++++++
 tests/fate/libavutil.mak                     |   4 +
 tests/ref/fate/mastering_display_metadata    |  24 ++++
 4 files changed, 163 insertions(+)
 create mode 100644 libavutil/tests/mastering_display_metadata.c
 create mode 100644 tests/ref/fate/mastering_display_metadata

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 06bc12601c..41fbf8230f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -287,6 +287,7 @@ TESTPROGS = adler32                                         
            \
             lfg                                                         \
             lls                                                         \
             log                                                         \
+            mastering_display_metadata                                  \
             md5                                                         \
             murmur3                                                     \
             opt                                                         \
diff --git a/libavutil/tests/mastering_display_metadata.c 
b/libavutil/tests/mastering_display_metadata.c
new file mode 100644
index 0000000000..3b67256f3c
--- /dev/null
+++ b/libavutil/tests/mastering_display_metadata.c
@@ -0,0 +1,134 @@
+/*
+ * 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/mastering_display_metadata.h"
+#include "libavutil/mem.h"
+
+int main(void)
+{
+    AVMasteringDisplayMetadata *mdm;
+    AVContentLightMetadata *clm;
+    AVFrame *frame;
+    size_t size;
+
+    /* av_mastering_display_metadata_alloc */
+    printf("Testing av_mastering_display_metadata_alloc()\n");
+    mdm = av_mastering_display_metadata_alloc();
+    if (mdm) {
+        /* verify defaults: all rationals should be {0, 1} */
+        printf("alloc: OK\n");
+        printf("defaults: primaries[0][0]=%d/%d, white_point[0]=%d/%d\n",
+               mdm->display_primaries[0][0].num,
+               mdm->display_primaries[0][0].den,
+               mdm->white_point[0].num, mdm->white_point[0].den);
+        printf("defaults: min_lum=%d/%d, max_lum=%d/%d\n",
+               mdm->min_luminance.num, mdm->min_luminance.den,
+               mdm->max_luminance.num, mdm->max_luminance.den);
+        printf("defaults: has_primaries=%d, has_luminance=%d\n",
+               mdm->has_primaries, mdm->has_luminance);
+        av_free(mdm);
+    } else {
+        printf("alloc: FAIL\n");
+    }
+
+    /* av_mastering_display_metadata_alloc_size */
+    printf("\nTesting av_mastering_display_metadata_alloc_size()\n");
+    mdm = av_mastering_display_metadata_alloc_size(&size);
+    if (mdm) {
+        printf("alloc_size: OK, size>0=%s\n", size > 0 ? "yes" : "no");
+        printf("defaults: primaries[0][0]=%d/%d\n",
+               mdm->display_primaries[0][0].num,
+               mdm->display_primaries[0][0].den);
+        av_free(mdm);
+    } else {
+        printf("alloc_size: FAIL\n");
+    }
+
+    /* write and read back */
+    printf("\nTesting write/read back\n");
+    mdm = av_mastering_display_metadata_alloc();
+    if (mdm) {
+        mdm->display_primaries[0][0] = (AVRational){ 34000, 50000 };
+        mdm->display_primaries[0][1] = (AVRational){ 16000, 50000 };
+        mdm->white_point[0] = (AVRational){ 15635, 50000 };
+        mdm->white_point[1] = (AVRational){ 16450, 50000 };
+        mdm->min_luminance = (AVRational){ 50, 10000 };
+        mdm->max_luminance = (AVRational){ 10000000, 10000 };
+        mdm->has_primaries = 1;
+        mdm->has_luminance = 1;
+        printf("primaries[0]=(%d/%d, %d/%d)\n",
+               mdm->display_primaries[0][0].num,
+               mdm->display_primaries[0][0].den,
+               mdm->display_primaries[0][1].num,
+               mdm->display_primaries[0][1].den);
+        printf("white_point=(%d/%d, %d/%d)\n",
+               mdm->white_point[0].num, mdm->white_point[0].den,
+               mdm->white_point[1].num, mdm->white_point[1].den);
+        printf("luminance: min=%d/%d max=%d/%d\n",
+               mdm->min_luminance.num, mdm->min_luminance.den,
+               mdm->max_luminance.num, mdm->max_luminance.den);
+        av_free(mdm);
+    }
+
+    /* av_mastering_display_metadata_create_side_data */
+    printf("\nTesting av_mastering_display_metadata_create_side_data()\n");
+    frame = av_frame_alloc();
+    if (frame) {
+        mdm = av_mastering_display_metadata_create_side_data(frame);
+        if (mdm) {
+            printf("side_data: OK, defaults: primaries[0][0]=%d/%d\n",
+                   mdm->display_primaries[0][0].num,
+                   mdm->display_primaries[0][0].den);
+        } else {
+            printf("side_data: FAIL\n");
+        }
+        av_frame_free(&frame);
+    }
+
+    /* av_content_light_metadata_alloc */
+    printf("\nTesting av_content_light_metadata_alloc()\n");
+    clm = av_content_light_metadata_alloc(&size);
+    if (clm) {
+        printf("alloc: OK, size>0=%s, MaxCLL=%u, MaxFALL=%u\n",
+               size > 0 ? "yes" : "no", clm->MaxCLL, clm->MaxFALL);
+        clm->MaxCLL = 1000;
+        clm->MaxFALL = 400;
+        printf("write: MaxCLL=%u, MaxFALL=%u\n", clm->MaxCLL, clm->MaxFALL);
+        av_free(clm);
+    } else {
+        printf("alloc: FAIL\n");
+    }
+
+    /* av_content_light_metadata_create_side_data */
+    printf("\nTesting av_content_light_metadata_create_side_data()\n");
+    frame = av_frame_alloc();
+    if (frame) {
+        clm = av_content_light_metadata_create_side_data(frame);
+        if (clm) {
+            printf("side_data: OK, MaxCLL=%u\n", clm->MaxCLL);
+        } 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 78f4e17b85..65f523c442 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -116,6 +116,10 @@ FATE_LIBAVUTIL += fate-lfg
 fate-lfg: libavutil/tests/lfg$(EXESUF)
 fate-lfg: CMD = run libavutil/tests/lfg$(EXESUF)
 
+FATE_LIBAVUTIL += fate-mastering_display_metadata
+fate-mastering_display_metadata: 
libavutil/tests/mastering_display_metadata$(EXESUF)
+fate-mastering_display_metadata: CMD = run 
libavutil/tests/mastering_display_metadata$(EXESUF)
+
 FATE_LIBAVUTIL += fate-md5
 fate-md5: libavutil/tests/md5$(EXESUF)
 fate-md5: CMD = run libavutil/tests/md5$(EXESUF)
diff --git a/tests/ref/fate/mastering_display_metadata 
b/tests/ref/fate/mastering_display_metadata
new file mode 100644
index 0000000000..a752fb6fe5
--- /dev/null
+++ b/tests/ref/fate/mastering_display_metadata
@@ -0,0 +1,24 @@
+Testing av_mastering_display_metadata_alloc()
+alloc: OK
+defaults: primaries[0][0]=0/1, white_point[0]=0/1
+defaults: min_lum=0/1, max_lum=0/1
+defaults: has_primaries=0, has_luminance=0
+
+Testing av_mastering_display_metadata_alloc_size()
+alloc_size: OK, size>0=yes
+defaults: primaries[0][0]=0/1
+
+Testing write/read back
+primaries[0]=(34000/50000, 16000/50000)
+white_point=(15635/50000, 16450/50000)
+luminance: min=50/10000 max=10000000/10000
+
+Testing av_mastering_display_metadata_create_side_data()
+side_data: OK, defaults: primaries[0][0]=0/1
+
+Testing av_content_light_metadata_alloc()
+alloc: OK, size>0=yes, MaxCLL=0, MaxFALL=0
+write: MaxCLL=1000, MaxFALL=400
+
+Testing av_content_light_metadata_create_side_data()
+side_data: OK, MaxCLL=0
-- 
2.52.0


>From 7cde705f7676fdde43ba07661a5bca042574df87 Mon Sep 17 00:00:00 2001
From: marcos ashton <[email protected]>
Date: Tue, 31 Mar 2026 22:20:55 +0100
Subject: [PATCH 3/3] tests/fate/libavutil: add FATE test for video_hint

Test av_video_hint_alloc with 0, 1, and 4 rects, and
av_video_hint_create_side_data. Verifies that av_video_hint_rects
and av_video_hint_get_rect return pointers consistent with
rect_offset and rect_size, tests write/read-back of rect
coordinates, and both hint type values.

Coverage for libavutil/video_hint.c: 0.00% -> 86.21%

Remaining uncovered lines are OOM error paths.
---
 libavutil/Makefile           |   1 +
 libavutil/tests/video_hint.c | 110 +++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak     |   4 ++
 tests/ref/fate/video_hint    |  17 ++++++
 4 files changed, 132 insertions(+)
 create mode 100644 libavutil/tests/video_hint.c
 create mode 100644 tests/ref/fate/video_hint

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 41fbf8230f..f4437e1b2f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -308,6 +308,7 @@ TESTPROGS = adler32                                         
            \
             twofish                                                     \
             utf8                                                        \
             uuid                                                        \
+            video_hint                                                  \
             xtea                                                        \
             tea                                                         \
 
diff --git a/libavutil/tests/video_hint.c b/libavutil/tests/video_hint.c
new file mode 100644
index 0000000000..d47462c858
--- /dev/null
+++ b/libavutil/tests/video_hint.c
@@ -0,0 +1,110 @@
+/*
+ * 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/macros.h"
+#include "libavutil/mem.h"
+#include "libavutil/video_hint.h"
+
+int main(void)
+{
+    AVVideoHint *hint;
+    AVVideoRect *rect;
+    AVFrame *frame;
+    size_t size;
+
+    static const size_t alloc_counts[] = { 0, 1, 4 };
+
+    /* av_video_hint_alloc - various counts */
+    printf("Testing av_video_hint_alloc()\n");
+    for (int i = 0; i < FF_ARRAY_ELEMS(alloc_counts); i++) {
+        size_t nb = alloc_counts[i];
+        hint = av_video_hint_alloc(nb, &size);
+        if (hint) {
+            printf("alloc %zu: OK, nb_rects=%zu, size>0=%s\n",
+                   nb, hint->nb_rects, size > 0 ? "yes" : "no");
+            av_free(hint);
+        } else {
+            printf("alloc %zu: FAIL\n", nb);
+        }
+    }
+
+    /* pointer consistency and write/read back */
+    printf("\nTesting av_video_hint_get_rect()\n");
+    hint = av_video_hint_alloc(3, &size);
+    if (hint) {
+        /* verify av_video_hint_rects points to first rect */
+        rect = av_video_hint_rects(hint);
+        if ((uint8_t *)rect != (uint8_t *)hint + hint->rect_offset)
+            printf("rects: pointer inconsistent with rect_offset\n");
+
+        for (int i = 0; i < 3; i++) {
+            rect = av_video_hint_get_rect(hint, i);
+            if ((uint8_t *)rect != (uint8_t *)hint + hint->rect_offset +
+                                   (size_t)i * hint->rect_size)
+                printf("rect %d: pointer inconsistent with 
rect_offset/rect_size\n", i);
+            rect->x = i * 100;
+            rect->y = i * 200;
+            rect->width = 64 + i;
+            rect->height = 48 + i;
+        }
+        for (int i = 0; i < 3; i++) {
+            rect = av_video_hint_get_rect(hint, i);
+            printf("rect %d: x=%u y=%u w=%u h=%u\n",
+                   i, rect->x, rect->y, rect->width, rect->height);
+        }
+
+        av_free(hint);
+    }
+
+    /* type field */
+    printf("\nTesting type field\n");
+    hint = av_video_hint_alloc(1, &size);
+    if (hint) {
+        hint->type = AV_VIDEO_HINT_TYPE_CONSTANT;
+        printf("constant: type=%d\n", hint->type);
+        hint->type = AV_VIDEO_HINT_TYPE_CHANGED;
+        printf("changed: type=%d\n", hint->type);
+        av_free(hint);
+    }
+
+    /* av_video_hint_create_side_data */
+    printf("\nTesting av_video_hint_create_side_data()\n");
+    frame = av_frame_alloc();
+    if (frame) {
+        hint = av_video_hint_create_side_data(frame, 2);
+        if (hint) {
+            printf("side_data: OK, nb_rects=%zu\n", hint->nb_rects);
+            rect = av_video_hint_get_rect(hint, 0);
+            rect->x = 10;
+            rect->y = 20;
+            rect->width = 320;
+            rect->height = 240;
+            rect = av_video_hint_get_rect(hint, 0);
+            printf("side_data rect 0: x=%u y=%u\n", rect->x, rect->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 65f523c442..96b9f3ecb4 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_hint
+fate-video_hint: libavutil/tests/video_hint$(EXESUF)
+fate-video_hint: CMD = run libavutil/tests/video_hint$(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_hint b/tests/ref/fate/video_hint
new file mode 100644
index 0000000000..f974b5b9b0
--- /dev/null
+++ b/tests/ref/fate/video_hint
@@ -0,0 +1,17 @@
+Testing av_video_hint_alloc()
+alloc 0: OK, nb_rects=0, size>0=yes
+alloc 1: OK, nb_rects=1, size>0=yes
+alloc 4: OK, nb_rects=4, size>0=yes
+
+Testing av_video_hint_get_rect()
+rect 0: x=0 y=0 w=64 h=48
+rect 1: x=100 y=200 w=65 h=49
+rect 2: x=200 y=400 w=66 h=50
+
+Testing type field
+constant: type=0
+changed: type=1
+
+Testing av_video_hint_create_side_data()
+side_data: OK, nb_rects=2
+side_data rect 0: x=10 y=20
-- 
2.52.0

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

Reply via email to