This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 784ab1558941fa2d0e4774abb9c0ac4a0135f74c Author: marcos ashton <[email protected]> AuthorDate: Tue Mar 31 22:20:55 2026 +0100 Commit: michaelni <[email protected]> CommitDate: Thu Jul 2 13:48:58 2026 +0000 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, write/read-back of rect coordinates, both hint type values, and OOM paths via av_max_alloc. Coverage for libavutil/video_hint.c: 0.00% -> 82.05% The remaining uncovered lines are the nb_rects overflow guard and the av_buffer_create / av_frame_new_side_data_from_buf failure cleanup paths, which av_max_alloc() cannot reach since it forces the first allocation to fail. --- .forgejo/CODEOWNERS | 2 + libavutil/Makefile | 1 + libavutil/tests/.gitignore | 1 + libavutil/tests/video_hint.c | 128 +++++++++++++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 4 ++ tests/ref/fate/video_hint | 21 +++++++ 6 files changed, 157 insertions(+) diff --git a/.forgejo/CODEOWNERS b/.forgejo/CODEOWNERS index e6de0155ea..308ecdfa18 100644 --- a/.forgejo/CODEOWNERS +++ b/.forgejo/CODEOWNERS @@ -240,6 +240,7 @@ libavutil/tests/hdr_dynamic_vivid_metadata.* @MarcosAsh libavutil/tests/mastering_display_metadata.* @MarcosAsh libavutil/tests/tdrdi.* @MarcosAsh libavutil/tests/timestamp.* @MarcosAsh +libavutil/tests/video_hint.* @MarcosAsh tests/ref/.*drawvg.* @ayosec tests/ref/fate/ambient_viewing_environment @MarcosAsh tests/ref/fate/buffer @MarcosAsh @@ -250,6 +251,7 @@ tests/ref/fate/mastering_display_metadata @MarcosAsh tests/ref/fate/sub-mcc.* @programmerjake tests/ref/fate/tdrdi @MarcosAsh tests/ref/fate/timestamp @MarcosAsh +tests/ref/fate/video_hint @MarcosAsh # Forgejo # ======= diff --git a/libavutil/Makefile b/libavutil/Makefile index b7cbe49145..90a42fbb06 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -323,6 +323,7 @@ TESTPROGS = adler32 \ utf8 \ uuid \ video_enc_params \ + video_hint \ xtea \ tea \ diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore index 5562bc3359..04043494ec 100644 --- a/libavutil/tests/.gitignore +++ b/libavutil/tests/.gitignore @@ -68,4 +68,5 @@ /utf8 /uuid /video_enc_params +/video_hint /xtea diff --git a/libavutil/tests/video_hint.c b/libavutil/tests/video_hint.c new file mode 100644 index 0000000000..755bbf1c43 --- /dev/null +++ b/libavutil/tests/video_hint.c @@ -0,0 +1,128 @@ +/* + * 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 <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); + } + + /* OOM paths via av_max_alloc */ + printf("\nTesting OOM paths\n"); + av_max_alloc(1); + hint = av_video_hint_alloc(1, &size); + printf("alloc OOM: %s\n", hint ? "FAIL" : "OK"); + av_free(hint); + av_max_alloc(INT_MAX); + + frame = av_frame_alloc(); + if (frame) { + av_max_alloc(1); + hint = av_video_hint_create_side_data(frame, 1); + printf("side_data OOM: %s\n", hint ? "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 67625445cc..e0014ff26b 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -239,6 +239,10 @@ 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-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..9e3c8c633a --- /dev/null +++ b/tests/ref/fate/video_hint @@ -0,0 +1,21 @@ +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 + +Testing OOM paths +alloc OOM: OK +side_data OOM: OK _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
