FFmpeg
Loading...
Searching...
No Matches
spherical.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 <stdio.h>
20
21#include "libavutil/mem.h"
22#include "libavutil/spherical.h"
23
24int main(void)
25{
27 size_t size;
28
29 /* av_spherical_alloc with size output */
30 printf("Testing av_spherical_alloc()\n");
32 if (map) {
33 printf("alloc: OK, size>0=%s, default projection=%d\n",
34 size > 0 ? "yes" : "no", map->projection);
35 av_free(map);
36 } else {
37 printf("alloc: FAIL\n");
38 }
39
40 /* av_spherical_alloc without size */
42 printf("alloc (no size): %s\n", map ? "OK" : "FAIL");
43 av_free(map);
44
45 /* av_spherical_projection_name - all valid projections */
46 printf("\nTesting av_spherical_projection_name()\n");
47 for (int i = 0; i <= AV_SPHERICAL_PARAMETRIC_IMMERSIVE; i++)
48 printf("projection %d: %s\n", i, av_spherical_projection_name(i));
49 printf("out of range: %s\n", av_spherical_projection_name(100));
50
51 /* av_spherical_from_name - all valid names */
52 printf("\nTesting av_spherical_from_name()\n");
53 for (int i = 0; i <= AV_SPHERICAL_PARAMETRIC_IMMERSIVE; i++) {
54 const char *name = av_spherical_projection_name(i);
56 }
57 printf("nonexistent: %d\n", av_spherical_from_name("nonexistent"));
58
59 /* projection name round-trip */
60 printf("\nTesting projection name round-trip\n");
61 for (int i = 0; i <= AV_SPHERICAL_PARAMETRIC_IMMERSIVE; i++) {
62 const char *name = av_spherical_projection_name(i);
64 printf("roundtrip %d (%s): %s\n", i, name, rt == i ? "OK" : "FAIL");
65 }
66
67 /* av_spherical_tile_bounds - no bounds (full frame) */
68 printf("\nTesting av_spherical_tile_bounds()\n");
70 if (map) {
71 size_t left, top, right, bottom;
72
74 printf("projection: %s\n",
76
77 map->bound_left = 0;
78 map->bound_top = 0;
79 map->bound_right = 0;
80 map->bound_bottom = 0;
81 av_spherical_tile_bounds(map, 1920, 1080, &left, &top, &right, &bottom);
82 printf("full frame: left=%zu top=%zu right=%zu bottom=%zu\n",
83 left, top, right, bottom);
84
85 /* quarter tile at top-left (each bound is 0.32 fixed point) */
86 map->bound_left = 0;
87 map->bound_top = 0;
88 map->bound_right = UINT32_MAX / 2;
89 map->bound_bottom = UINT32_MAX / 2;
90 av_spherical_tile_bounds(map, 960, 540, &left, &top, &right, &bottom);
91 printf("quarter top-left: left=%zu top=%zu right=%zu bottom=%zu\n",
92 left, top, right, bottom);
93
94 /* centered tile with equal margins */
95 map->bound_left = UINT32_MAX / 4;
96 map->bound_top = UINT32_MAX / 4;
97 map->bound_right = UINT32_MAX / 4;
98 map->bound_bottom = UINT32_MAX / 4;
99 av_spherical_tile_bounds(map, 960, 540, &left, &top, &right, &bottom);
100 printf("centered: left=%zu top=%zu right=%zu bottom=%zu\n",
101 left, top, right, bottom);
102
103 av_free(map);
104 }
105
106 return 0;
107}
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
AVSphericalMapping * av_spherical_alloc(size_t *size)
Allocate a AVSphericalVideo structure and initialize its fields to default values.
Definition spherical.c:26
int av_spherical_from_name(const char *name)
Get the AVSphericalProjection form a human-readable name.
Definition spherical.c:77
const char * av_spherical_projection_name(enum AVSphericalProjection projection)
Provide a human-readable name of a given AVSphericalProjection.
Definition spherical.c:69
void av_spherical_tile_bounds(const AVSphericalMapping *map, size_t width, size_t height, size_t *left, size_t *top, size_t *right, size_t *bottom)
Convert the bounding fields from an AVSphericalVideo from 0.32 fixed point to pixels.
Definition spherical.c:41
@ AV_SPHERICAL_EQUIRECTANGULAR_TILE
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection.
Definition spherical.h:68
@ AV_SPHERICAL_PARAMETRIC_IMMERSIVE
Parametric Immersive projection (Apple).
Definition spherical.h:90
const VDPAUPixFmtMap * map
Memory handling functions.
const char * name
Definition qsvenc.c:142
Spherical video.
This structure describes how to handle spherical videos, outlining information about projection,...
Definition spherical.h:100
#define av_free(p)
int main(void)
Definition spherical.c:24
int size