FFmpeg
Loading...
Searching...
No Matches
hdr_dynamic_vivid_metadata.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <limits.h>
20#include <stdio.h>
21
22#include "libavutil/frame.h"
24#include "libavutil/mem.h"
25
26int main(void)
27{
28 AVDynamicHDRVivid *vivid;
30 size_t size;
31
32 /* av_dynamic_hdr_vivid_alloc */
33 printf("Testing av_dynamic_hdr_vivid_alloc()\n");
35 if (vivid) {
36 printf("alloc: OK, size>0=%s\n", size > 0 ? "yes" : "no");
37 printf("defaults: system_start_code=%u, num_windows=%u\n",
38 vivid->system_start_code, vivid->num_windows);
39
40 /* write and read back */
41 vivid->system_start_code = 0x01;
42 vivid->num_windows = 1;
43 vivid->params[0].minimum_maxrgb = (AVRational){ 100, 1 };
44 vivid->params[0].average_maxrgb = (AVRational){ 500, 1 };
45 vivid->params[0].variance_maxrgb = (AVRational){ 200, 1 };
46 vivid->params[0].maximum_maxrgb = (AVRational){ 1000, 1 };
47 printf("write: system_start_code=%u, num_windows=%u\n",
48 vivid->system_start_code, vivid->num_windows);
49 printf("params[0]: min=%d/%d avg=%d/%d var=%d/%d max=%d/%d\n",
50 vivid->params[0].minimum_maxrgb.num,
51 vivid->params[0].minimum_maxrgb.den,
52 vivid->params[0].average_maxrgb.num,
53 vivid->params[0].average_maxrgb.den,
54 vivid->params[0].variance_maxrgb.num,
55 vivid->params[0].variance_maxrgb.den,
56 vivid->params[0].maximum_maxrgb.num,
57 vivid->params[0].maximum_maxrgb.den);
58 av_free(vivid);
59 }
60
61 /* alloc with NULL size */
63 printf("alloc (no size): %s\n", vivid ? "OK" : "FAIL");
64 av_free(vivid);
65
66 /* av_dynamic_hdr_vivid_create_side_data */
67 printf("\nTesting av_dynamic_hdr_vivid_create_side_data()\n");
69 if (frame) {
71 if (vivid) {
72 printf("side_data: OK\n");
73 vivid->system_start_code = 0x02;
74 printf("side_data write: system_start_code=%u\n",
75 vivid->system_start_code);
76 } else {
77 printf("side_data: FAIL\n");
78 }
80 }
81
82 /* OOM paths via av_max_alloc */
83 printf("\nTesting OOM paths\n");
84 av_max_alloc(1);
86 printf("alloc OOM: %s\n", vivid ? "FAIL" : "OK");
87 av_free(vivid);
88 av_max_alloc(INT_MAX);
89
91 if (frame) {
92 av_max_alloc(1);
94 printf("side_data OOM: %s\n", vivid ? "FAIL" : "OK");
95 av_max_alloc(INT_MAX);
97 }
98
99 return 0;
100}
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
static AVFrame * frame
reference-counted frame API
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
Definition mem.c:76
AVDynamicHDRVivid * av_dynamic_hdr_vivid_create_side_data(AVFrame *frame)
Allocate a complete AVDynamicHDRVivid and add it to the frame.
AVDynamicHDRVivid * av_dynamic_hdr_vivid_alloc(size_t *size)
Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
Memory handling functions.
This struct represents dynamic metadata for color volume transform - CUVA 005.1:2021 standard.
uint8_t num_windows
The number of processing windows.
uint8_t system_start_code
The system start code.
AVHDRVividColorTransformParams params[3]
The color transform parameters for every processing window.
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVRational variance_maxrgb
Indicates the variance brightness of the displayed content.
AVRational average_maxrgb
Indicates the average brightness of the displayed content.
AVRational minimum_maxrgb
Indicates the minimum brightness of the displayed content.
AVRational maximum_maxrgb
Indicates the maximum brightness of the displayed content.
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
#define av_free(p)
int main(void)
int size