FFmpeg
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 
26 int main(void)
27 {
28  AVStereo3D *s3d;
29  AVFrame *frame;
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);
76  int rt = av_stereo3d_from_name(name);
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 }
AV_PRIMARY_EYE_RIGHT
@ AV_PRIMARY_EYE_RIGHT
Right eye.
Definition: stereo3d.h:188
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
printf
__device__ int printf(const char *,...)
av_stereo3d_view_from_name
int av_stereo3d_view_from_name(const char *name)
Get the AVStereo3DView form a human-readable name.
Definition: stereo3d.c:121
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:427
AV_STEREO3D_VIEW_UNSPEC
@ AV_STEREO3D_VIEW_UNSPEC
Content is unspecified.
Definition: stereo3d.h:168
AV_STEREO3D_UNSPEC
@ AV_STEREO3D_UNSPEC
Video is stereoscopic but the packing is unspecified.
Definition: stereo3d.h:143
macros.h
av_stereo3d_view_name
const char * av_stereo3d_view_name(unsigned int view)
Provide a human-readable name of a given stereo3d view.
Definition: stereo3d.c:113
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
stereo3d.h
av_stereo3d_primary_eye_from_name
int av_stereo3d_primary_eye_from_name(const char *name)
Get the AVStereo3DPrimaryEye form a human-readable name.
Definition: stereo3d.c:141
av_stereo3d_alloc_size
AVStereo3D * av_stereo3d_alloc_size(size_t *size)
Allocate an AVStereo3D structure and set its fields to default values.
Definition: stereo3d.c:40
main
int main(void)
Definition: stereo3d.c:26
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
av_stereo3d_primary_eye_name
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
size
int size
Definition: twinvq_data.h:10344
frame.h
ret
ret
Definition: filter_design.txt:187
av_stereo3d_alloc
AVStereo3D * av_stereo3d_alloc(void)
Allocate an AVStereo3D structure and set its fields to default values.
Definition: stereo3d.c:35
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
mem.h
av_stereo3d_create_side_data
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
Definition: stereo3d.c:54
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
av_stereo3d_type_name
const char * av_stereo3d_type_name(unsigned int type)
Provide a human-readable name of a given stereo3d type.
Definition: stereo3d.c:93
AVStereo3D
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition: stereo3d.h:203
av_stereo3d_from_name
int av_stereo3d_from_name(const char *name)
Get the AVStereo3DType form a human-readable name.
Definition: stereo3d.c:101