FFmpeg
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 
26 int main(void)
27 {
28  AVDynamicHDRVivid *vivid;
29  AVFrame *frame;
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 }
AVHDRVividColorTransformParams::maximum_maxrgb
AVRational maximum_maxrgb
Indicates the maximum brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:206
main
int main(void)
Definition: hdr_dynamic_vivid_metadata.c:26
printf
__device__ int printf(const char *,...)
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:435
AVHDRVividColorTransformParams::variance_maxrgb
AVRational variance_maxrgb
Indicates the variance brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:199
hdr_dynamic_vivid_metadata.h
av_max_alloc
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
Definition: mem.c:76
av_dynamic_hdr_vivid_alloc
AVDynamicHDRVivid * av_dynamic_hdr_vivid_alloc(size_t *size)
Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
Definition: hdr_dynamic_vivid_metadata.c:24
AVDynamicHDRVivid::num_windows
uint8_t num_windows
The number of processing windows.
Definition: hdr_dynamic_vivid_metadata.h:266
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
av_dynamic_hdr_vivid_create_side_data
AVDynamicHDRVivid * av_dynamic_hdr_vivid_create_side_data(AVFrame *frame)
Allocate a complete AVDynamicHDRVivid and add it to the frame.
Definition: hdr_dynamic_vivid_metadata.c:36
limits.h
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVDynamicHDRVivid
This struct represents dynamic metadata for color volume transform - CUVA 005.1:2021 standard.
Definition: hdr_dynamic_vivid_metadata.h:256
size
int size
Definition: twinvq_data.h:10344
AVHDRVividColorTransformParams::average_maxrgb
AVRational average_maxrgb
Indicates the average brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:192
frame.h
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
AVHDRVividColorTransformParams::minimum_maxrgb
AVRational minimum_maxrgb
Indicates the minimum brightness of the displayed content.
Definition: hdr_dynamic_vivid_metadata.h:185
AVRational::den
int den
Denominator.
Definition: rational.h:60
mem.h
AVDynamicHDRVivid::params
AVHDRVividColorTransformParams params[3]
The color transform parameters for every processing window.
Definition: hdr_dynamic_vivid_metadata.h:271
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDynamicHDRVivid::system_start_code
uint8_t system_start_code
The system start code.
Definition: hdr_dynamic_vivid_metadata.h:260