FFmpeg
Loading...
Searching...
No Matches
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
27{
28 printf("illuminance=%d/%d, light_x=%d/%d, light_y=%d/%d\n",
32}
33
34int main(void)
35{
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}
AVAmbientViewingEnvironment * av_ambient_viewing_environment_alloc(size_t *size)
Allocate an AVAmbientViewingEnvironment structure.
AVAmbientViewingEnvironment * av_ambient_viewing_environment_create_side_data(AVFrame *frame)
Allocate and add an AVAmbientViewingEnvironment structure to an existing AVFrame as side data.
#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
Memory handling functions.
Ambient viewing environment metadata as defined by H.274.
AVRational ambient_illuminance
Environmental illuminance of the ambient viewing environment in lux.
AVRational ambient_light_x
Normalized x chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
AVRational ambient_light_y
Normalized y chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
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)
static void print_env(const AVAmbientViewingEnvironment *env)
int main(void)
int size