FFmpeg
ambient_viewing_environment.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 
23 #include "libavutil/frame.h"
24 #include "libavutil/mem.h"
25 
26 static void print_env(const AVAmbientViewingEnvironment *env)
27 {
28  printf("illuminance=%d/%d, light_x=%d/%d, light_y=%d/%d\n",
32 }
33 
34 int main(void)
35 {
37  AVFrame *frame;
38  size_t size = 0;
39 
40  /* av_ambient_viewing_environment_alloc with size out-param */
41  printf("Testing av_ambient_viewing_environment_alloc(&size)\n");
43  if (env) {
44  printf("alloc: OK, size_set=%s\n", size == sizeof(*env) ? "yes" : "no");
45  print_env(env);
46  av_free(env);
47  } else {
48  printf("alloc: FAIL\n");
49  }
50 
51  /* av_ambient_viewing_environment_alloc with NULL size */
52  printf("\nTesting av_ambient_viewing_environment_alloc(NULL)\n");
54  if (env) {
55  printf("alloc(NULL): OK\n");
56  print_env(env);
57  av_free(env);
58  } else {
59  printf("alloc(NULL): FAIL\n");
60  }
61 
62  /* write and read back */
63  printf("\nTesting write/read back\n");
65  if (env) {
66  env->ambient_illuminance = (AVRational){ 314, 10 };
67  env->ambient_light_x = (AVRational){ 15635, 50000 };
68  env->ambient_light_y = (AVRational){ 16450, 50000 };
69  print_env(env);
70  av_free(env);
71  }
72 
73  /* av_ambient_viewing_environment_create_side_data */
74  printf("\nTesting av_ambient_viewing_environment_create_side_data()\n");
76  if (frame) {
78  if (env) {
79  printf("side_data: OK\n");
80  print_env(env);
81  } else {
82  printf("side_data: FAIL\n");
83  }
85  }
86 
87  /* OOM paths via av_max_alloc */
88  printf("\nTesting OOM paths\n");
89  av_max_alloc(1);
91  printf("alloc OOM: %s\n", env ? "FAIL" : "OK");
92  av_free(env);
94  printf("alloc(NULL) OOM: %s\n", env ? "FAIL" : "OK");
95  av_free(env);
96  av_max_alloc(INT_MAX);
97 
99  if (frame) {
100  av_max_alloc(1);
102  printf("side_data OOM: %s\n", env ? "FAIL" : "OK");
103  av_max_alloc(INT_MAX);
105  }
106 
107  return 0;
108 }
printf
__device__ int printf(const char *,...)
AVAmbientViewingEnvironment
Ambient viewing environment metadata as defined by H.274.
Definition: ambient_viewing_environment.h:36
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:459
AVAmbientViewingEnvironment::ambient_light_x
AVRational ambient_light_x
Normalized x chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
Definition: ambient_viewing_environment.h:47
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
AVAmbientViewingEnvironment::ambient_illuminance
AVRational ambient_illuminance
Environmental illuminance of the ambient viewing environment in lux.
Definition: ambient_viewing_environment.h:40
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_ambient_viewing_environment_alloc
AVAmbientViewingEnvironment * av_ambient_viewing_environment_alloc(size_t *size)
Allocate an AVAmbientViewingEnvironment structure.
Definition: ambient_viewing_environment.c:31
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
limits.h
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
size
int size
Definition: twinvq_data.h:10344
frame.h
print_env
static void print_env(const AVAmbientViewingEnvironment *env)
Definition: ambient_viewing_environment.c:26
av_ambient_viewing_environment_create_side_data
AVAmbientViewingEnvironment * av_ambient_viewing_environment_create_side_data(AVFrame *frame)
Allocate and add an AVAmbientViewingEnvironment structure to an existing AVFrame as side data.
Definition: ambient_viewing_environment.c:46
ambient_viewing_environment.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
AVRational::den
int den
Denominator.
Definition: rational.h:60
main
int main(void)
Definition: ambient_viewing_environment.c:34
mem.h
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVAmbientViewingEnvironment::ambient_light_y
AVRational ambient_light_y
Normalized y chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
Definition: ambient_viewing_environment.h:54