FFmpeg
Loading...
Searching...
No Matches
stereo3d.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/frame.h"
22#include "libavutil/macros.h"
23#include "libavutil/mem.h"
24#include "libavutil/stereo3d.h"
25
26int main(void)
27{
28 AVStereo3D *s3d;
30 size_t size;
31 int ret;
32
33 /* av_stereo3d_alloc_size with size output */
34 printf("Testing av_stereo3d_alloc_size()\n");
36 printf("alloc_size: %s, size>0: %s\n",
37 s3d ? "OK" : "FAIL", size > 0 ? "yes" : "no");
38 av_free(s3d);
39
40 /* av_stereo3d_alloc (no size) */
41 s3d = av_stereo3d_alloc();
42 printf("alloc: %s\n", s3d ? "OK" : "FAIL");
43 av_free(s3d);
44
45 /* av_stereo3d_create_side_data */
46 printf("\nTesting av_stereo3d_create_side_data()\n");
49 printf("create_side_data: %s\n", s3d ? "OK" : "FAIL");
51
52 /* av_stereo3d_type_name - all valid types */
53 printf("\nTesting av_stereo3d_type_name()\n");
54 for (int i = 0; i <= AV_STEREO3D_UNSPEC; i++)
55 printf("type %d: %s\n", i, av_stereo3d_type_name(i));
56 printf("out of range: %s\n", av_stereo3d_type_name(100));
57
58 /* av_stereo3d_from_name - all valid names and unknown */
59 printf("\nTesting av_stereo3d_from_name()\n");
60 {
61 static const char * const names[] = {
62 "2D", "side by side", "top and bottom", "frame alternate",
63 "checkerboard", "side by side (quincunx subsampling)",
64 "interleaved lines", "interleaved columns", "unspecified",
65 };
66 for (int i = 0; i < FF_ARRAY_ELEMS(names); i++)
67 printf("%s: %d\n", names[i], av_stereo3d_from_name(names[i]));
68 }
69 ret = av_stereo3d_from_name("nonexistent");
70 printf("nonexistent: %d\n", ret);
71
72 /* av_stereo3d_type_name / av_stereo3d_from_name round-trip */
73 printf("\nTesting type name round-trip\n");
74 for (int i = 0; i <= AV_STEREO3D_UNSPEC; i++) {
75 const char *name = av_stereo3d_type_name(i);
77 printf("type roundtrip %d (%s): %s\n", i, name, rt == i ? "OK" : "FAIL");
78 }
79
80 /* av_stereo3d_view_name - all valid views */
81 printf("\nTesting av_stereo3d_view_name()\n");
82 for (int i = 0; i <= AV_STEREO3D_VIEW_UNSPEC; i++)
83 printf("view %d: %s\n", i, av_stereo3d_view_name(i));
84 printf("out of range: %s\n", av_stereo3d_view_name(100));
85
86 /* av_stereo3d_view_name / av_stereo3d_view_from_name round-trip */
87 printf("\nTesting view name round-trip\n");
88 for (int i = 0; i <= AV_STEREO3D_VIEW_UNSPEC; i++) {
89 const char *name = av_stereo3d_view_name(i);
91 printf("view roundtrip %d (%s): %s\n", i, name, rt == i ? "OK" : "FAIL");
92 }
93
94 /* av_stereo3d_view_from_name */
95 printf("\nTesting av_stereo3d_view_from_name()\n");
96 printf("packed: %d\n", av_stereo3d_view_from_name("packed"));
97 printf("left: %d\n", av_stereo3d_view_from_name("left"));
98 printf("right: %d\n", av_stereo3d_view_from_name("right"));
99 printf("unspecified: %d\n", av_stereo3d_view_from_name("unspecified"));
100 ret = av_stereo3d_view_from_name("nonexistent");
101 printf("nonexistent: %d\n", ret);
102
103 /* av_stereo3d_primary_eye_name - all valid values */
104 printf("\nTesting av_stereo3d_primary_eye_name()\n");
105 for (int i = 0; i <= AV_PRIMARY_EYE_RIGHT; i++)
106 printf("eye %d: %s\n", i, av_stereo3d_primary_eye_name(i));
107 printf("out of range: %s\n", av_stereo3d_primary_eye_name(100));
108
109 /* av_stereo3d_primary_eye_from_name */
110 printf("\nTesting av_stereo3d_primary_eye_from_name()\n");
111 printf("none: %d\n", av_stereo3d_primary_eye_from_name("none"));
112 printf("left: %d\n", av_stereo3d_primary_eye_from_name("left"));
113 printf("right: %d\n", av_stereo3d_primary_eye_from_name("right"));
114 ret = av_stereo3d_primary_eye_from_name("nonexistent");
115 printf("nonexistent: %d\n", ret);
116
117 return 0;
118}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
__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
const char * av_stereo3d_view_name(unsigned int view)
Provide a human-readable name of a given stereo3d view.
Definition stereo3d.c:113
AVStereo3D * av_stereo3d_alloc(void)
Allocate an AVStereo3D structure and set its fields to default values.
Definition stereo3d.c:34
AVStereo3D * av_stereo3d_alloc_size(size_t *size)
Allocate an AVStereo3D structure and set its fields to default values.
Definition stereo3d.c:39
int av_stereo3d_primary_eye_from_name(const char *name)
Get the AVStereo3DPrimaryEye form a human-readable name.
Definition stereo3d.c:141
const char * av_stereo3d_type_name(unsigned int type)
Provide a human-readable name of a given stereo3d type.
Definition stereo3d.c:93
int av_stereo3d_from_name(const char *name)
Get the AVStereo3DType form a human-readable name.
Definition stereo3d.c:101
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
Definition stereo3d.c:54
const char * av_stereo3d_primary_eye_name(unsigned int eye)
Provide a human-readable name of a given stereo3d primary eye.
Definition stereo3d.c:133
int av_stereo3d_view_from_name(const char *name)
Get the AVStereo3DView form a human-readable name.
Definition stereo3d.c:121
@ AV_STEREO3D_UNSPEC
Video is stereoscopic but the packing is unspecified.
Definition stereo3d.h:143
@ AV_PRIMARY_EYE_RIGHT
Right eye.
Definition stereo3d.h:188
@ AV_STEREO3D_VIEW_UNSPEC
Content is unspecified.
Definition stereo3d.h:168
Stereoscopic video.
Utility Preprocessor macros.
Memory handling functions.
const char * name
Definition qsvenc.c:142
#define FF_ARRAY_ELEMS(a)
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition stereo3d.h:203
#define av_free(p)
int main(void)
Definition stereo3d.c:26
int size