1 /*
2  * Copyright (c) 2013 Vittorio Giovara <vittorio.giovara@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * Stereoscopic video
24  */
25 
26 module ffmpeg.libavutil.stereo3d;
27 
28 import ffmpeg.libavutil.frame;
29 
30 extern (C):
31 import ffmpeg; @nogc nothrow:
32 
33 /**
34  * @addtogroup lavu_video
35  * @{
36  *
37  * @defgroup lavu_video_stereo3d Stereo3D types and functions
38  * @{
39  */
40 
41 /**
42  * @addtogroup lavu_video_stereo3d
43  * A stereoscopic video file consists in multiple views embedded in a single
44  * frame, usually describing two views of a scene. This file describes all
45  * possible codec-independent view arrangements.
46  * */
47 
48 /**
49  * List of possible 3D Types
50  */
51 enum AVStereo3DType
52 {
53     /**
54      * Video is not stereoscopic (and metadata has to be there).
55      */
56     AV_STEREO3D_2D = 0,
57 
58     /**
59      * Views are next to each other.
60      *
61      * @code{.unparsed}
62      *    LLLLRRRR
63      *    LLLLRRRR
64      *    LLLLRRRR
65      *    ...
66      * @endcode
67      */
68     AV_STEREO3D_SIDEBYSIDE = 1,
69 
70     /**
71      * Views are on top of each other.
72      *
73      * @code{.unparsed}
74      *    LLLLLLLL
75      *    LLLLLLLL
76      *    RRRRRRRR
77      *    RRRRRRRR
78      * @endcode
79      */
80     AV_STEREO3D_TOPBOTTOM = 2,
81 
82     /**
83      * Views are alternated temporally.
84      *
85      * @code{.unparsed}
86      *     frame0   frame1   frame2   ...
87      *    LLLLLLLL RRRRRRRR LLLLLLLL
88      *    LLLLLLLL RRRRRRRR LLLLLLLL
89      *    LLLLLLLL RRRRRRRR LLLLLLLL
90      *    ...      ...      ...
91      * @endcode
92      */
93     AV_STEREO3D_FRAMESEQUENCE = 3,
94 
95     /**
96      * Views are packed in a checkerboard-like structure per pixel.
97      *
98      * @code{.unparsed}
99      *    LRLRLRLR
100      *    RLRLRLRL
101      *    LRLRLRLR
102      *    ...
103      * @endcode
104      */
105     AV_STEREO3D_CHECKERBOARD = 4,
106 
107     /**
108      * Views are next to each other, but when upscaling
109      * apply a checkerboard pattern.
110      *
111      * @code{.unparsed}
112      *     LLLLRRRR          L L L L    R R R R
113      *     LLLLRRRR    =>     L L L L  R R R R
114      *     LLLLRRRR          L L L L    R R R R
115      *     LLLLRRRR           L L L L  R R R R
116      * @endcode
117      */
118     AV_STEREO3D_SIDEBYSIDE_QUINCUNX = 5,
119 
120     /**
121      * Views are packed per line, as if interlaced.
122      *
123      * @code{.unparsed}
124      *    LLLLLLLL
125      *    RRRRRRRR
126      *    LLLLLLLL
127      *    ...
128      * @endcode
129      */
130     AV_STEREO3D_LINES = 6,
131 
132     /**
133      * Views are packed per column.
134      *
135      * @code{.unparsed}
136      *    LRLRLRLR
137      *    LRLRLRLR
138      *    LRLRLRLR
139      *    ...
140      * @endcode
141      */
142     AV_STEREO3D_COLUMNS = 7
143 }
144 
145 /**
146  * List of possible view types.
147  */
148 enum AVStereo3DView
149 {
150     /**
151      * Frame contains two packed views.
152      */
153     AV_STEREO3D_VIEW_PACKED = 0,
154 
155     /**
156      * Frame contains only the left view.
157      */
158     AV_STEREO3D_VIEW_LEFT = 1,
159 
160     /**
161      * Frame contains only the right view.
162      */
163     AV_STEREO3D_VIEW_RIGHT = 2
164 }
165 
166 /**
167  * Inverted views, Right/Bottom represents the left view.
168  */
169 enum AV_STEREO3D_FLAG_INVERT = 1 << 0;
170 
171 /**
172  * Stereo 3D type: this structure describes how two videos are packed
173  * within a single video surface, with additional information as needed.
174  *
175  * @note The struct must be allocated with av_stereo3d_alloc() and
176  *       its size is not a part of the public ABI.
177  */
178 struct AVStereo3D
179 {
180     /**
181      * How views are packed within the video.
182      */
183     AVStereo3DType type;
184 
185     /**
186      * Additional information about the frame packing.
187      */
188     int flags;
189 
190     /**
191      * Determines which views are packed.
192      */
193     AVStereo3DView view;
194 }
195 
196 /**
197  * Allocate an AVStereo3D structure and set its fields to default values.
198  * The resulting struct can be freed using av_freep().
199  *
200  * @return An AVStereo3D filled with default values or NULL on failure.
201  */
202 AVStereo3D* av_stereo3d_alloc ();
203 
204 /**
205  * Allocate a complete AVFrameSideData and add it to the frame.
206  *
207  * @param frame The frame which side data is added to.
208  *
209  * @return The AVStereo3D structure to be filled by caller.
210  */
211 AVStereo3D* av_stereo3d_create_side_data (AVFrame* frame);
212 
213 /**
214  * Provide a human-readable name of a given stereo3d type.
215  *
216  * @param type The input stereo3d type value.
217  *
218  * @return The name of the stereo3d value, or "unknown".
219  */
220 const(char)* av_stereo3d_type_name (uint type);
221 
222 /**
223  * Get the AVStereo3DType form a human-readable name.
224  *
225  * @param name The input string.
226  *
227  * @return The AVStereo3DType value, or -1 if not found.
228  */
229 int av_stereo3d_from_name (const(char)* name);
230 
231 /**
232  * @}
233  * @}
234  */
235 
236 /* AVUTIL_STEREO3D_H */