mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-11 08:13:06 +00:00
tests/fate/libavutil: add FATE test for hdr_dynamic_vivid_metadata
Test av_dynamic_hdr_vivid_alloc and av_dynamic_hdr_vivid_create_side_data. Verifies zero defaults, write/read-back of system_start_code, num_windows, and color transform params (min/avg/var/max RGB), frame side data attachment, and OOM paths via av_max_alloc. Coverage for libavutil/hdr_dynamic_vivid_metadata.c: 0.00% -> 100.00%
This commit is contained in:
committed by
michaelni
co-authored by
michaelni
parent
2d9c8a9382
commit
215799e369
@@ -233,8 +233,10 @@ doc/.* @GyanD
|
||||
# =====
|
||||
tests/checkasm/riscv/.* @Courmisch
|
||||
libavutil/tests/buffer.* @MarcosAsh
|
||||
libavutil/tests/hdr_dynamic_vivid_metadata.* @MarcosAsh
|
||||
tests/ref/.*drawvg.* @ayosec
|
||||
tests/ref/fate/buffer @MarcosAsh
|
||||
tests/ref/fate/hdr_dynamic_vivid_metadata @MarcosAsh
|
||||
tests/ref/fate/sub-mcc.* @programmerjake
|
||||
|
||||
# Forgejo
|
||||
|
||||
@@ -281,6 +281,7 @@ TESTPROGS = adler32 \
|
||||
fifo \
|
||||
film_grain_params \
|
||||
hash \
|
||||
hdr_dynamic_vivid_metadata \
|
||||
hmac \
|
||||
hwdevice \
|
||||
integer \
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/hdr_dynamic_vivid_metadata.h"
|
||||
#include "libavutil/mem.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
AVDynamicHDRVivid *vivid;
|
||||
AVFrame *frame;
|
||||
size_t size;
|
||||
|
||||
/* av_dynamic_hdr_vivid_alloc */
|
||||
printf("Testing av_dynamic_hdr_vivid_alloc()\n");
|
||||
vivid = av_dynamic_hdr_vivid_alloc(&size);
|
||||
if (vivid) {
|
||||
printf("alloc: OK, size>0=%s\n", size > 0 ? "yes" : "no");
|
||||
printf("defaults: system_start_code=%u, num_windows=%u\n",
|
||||
vivid->system_start_code, vivid->num_windows);
|
||||
|
||||
/* write and read back */
|
||||
vivid->system_start_code = 0x01;
|
||||
vivid->num_windows = 1;
|
||||
vivid->params[0].minimum_maxrgb = (AVRational){ 100, 1 };
|
||||
vivid->params[0].average_maxrgb = (AVRational){ 500, 1 };
|
||||
vivid->params[0].variance_maxrgb = (AVRational){ 200, 1 };
|
||||
vivid->params[0].maximum_maxrgb = (AVRational){ 1000, 1 };
|
||||
printf("write: system_start_code=%u, num_windows=%u\n",
|
||||
vivid->system_start_code, vivid->num_windows);
|
||||
printf("params[0]: min=%d/%d avg=%d/%d var=%d/%d max=%d/%d\n",
|
||||
vivid->params[0].minimum_maxrgb.num,
|
||||
vivid->params[0].minimum_maxrgb.den,
|
||||
vivid->params[0].average_maxrgb.num,
|
||||
vivid->params[0].average_maxrgb.den,
|
||||
vivid->params[0].variance_maxrgb.num,
|
||||
vivid->params[0].variance_maxrgb.den,
|
||||
vivid->params[0].maximum_maxrgb.num,
|
||||
vivid->params[0].maximum_maxrgb.den);
|
||||
av_free(vivid);
|
||||
}
|
||||
|
||||
/* alloc with NULL size */
|
||||
vivid = av_dynamic_hdr_vivid_alloc(NULL);
|
||||
printf("alloc (no size): %s\n", vivid ? "OK" : "FAIL");
|
||||
av_free(vivid);
|
||||
|
||||
/* av_dynamic_hdr_vivid_create_side_data */
|
||||
printf("\nTesting av_dynamic_hdr_vivid_create_side_data()\n");
|
||||
frame = av_frame_alloc();
|
||||
if (frame) {
|
||||
vivid = av_dynamic_hdr_vivid_create_side_data(frame);
|
||||
if (vivid) {
|
||||
printf("side_data: OK\n");
|
||||
vivid->system_start_code = 0x02;
|
||||
printf("side_data write: system_start_code=%u\n",
|
||||
vivid->system_start_code);
|
||||
} 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);
|
||||
vivid = av_dynamic_hdr_vivid_alloc(&size);
|
||||
printf("alloc OOM: %s\n", vivid ? "FAIL" : "OK");
|
||||
av_free(vivid);
|
||||
av_max_alloc(INT_MAX);
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (frame) {
|
||||
av_max_alloc(1);
|
||||
vivid = av_dynamic_hdr_vivid_create_side_data(frame);
|
||||
printf("side_data OOM: %s\n", vivid ? "FAIL" : "OK");
|
||||
av_max_alloc(INT_MAX);
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -103,6 +103,10 @@ FATE_LIBAVUTIL += fate-hash
|
||||
fate-hash: libavutil/tests/hash$(EXESUF)
|
||||
fate-hash: CMD = run libavutil/tests/hash$(EXESUF)
|
||||
|
||||
FATE_LIBAVUTIL += fate-hdr_dynamic_vivid_metadata
|
||||
fate-hdr_dynamic_vivid_metadata: libavutil/tests/hdr_dynamic_vivid_metadata$(EXESUF)
|
||||
fate-hdr_dynamic_vivid_metadata: CMD = run libavutil/tests/hdr_dynamic_vivid_metadata$(EXESUF)
|
||||
|
||||
FATE_LIBAVUTIL += fate-hmac
|
||||
fate-hmac: libavutil/tests/hmac$(EXESUF)
|
||||
fate-hmac: CMD = run libavutil/tests/hmac$(EXESUF)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
Testing av_dynamic_hdr_vivid_alloc()
|
||||
alloc: OK, size>0=yes
|
||||
defaults: system_start_code=0, num_windows=0
|
||||
write: system_start_code=1, num_windows=1
|
||||
params[0]: min=100/1 avg=500/1 var=200/1 max=1000/1
|
||||
alloc (no size): OK
|
||||
|
||||
Testing av_dynamic_hdr_vivid_create_side_data()
|
||||
side_data: OK
|
||||
side_data write: system_start_code=2
|
||||
|
||||
Testing OOM paths
|
||||
alloc OOM: OK
|
||||
side_data OOM: OK
|
||||
Reference in New Issue
Block a user