1 /*
2  * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
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 module ffmpeg.libavutil.avutil;
22 
23 import core.stdc.stdint;
24 import core.stdc.stdio;
25 
26 import ffmpeg.libavutil.rational;
27 
28 extern (C):
29 import ffmpeg; @nogc nothrow:
30 
31 /**
32  * @file
33  * @ingroup lavu
34  * Convenience header that includes @ref lavu "libavutil"'s core.
35  */
36 
37 /**
38  * @mainpage
39  *
40  * @section ffmpeg_intro Introduction
41  *
42  * This document describes the usage of the different libraries
43  * provided by FFmpeg.
44  *
45  * @li @ref libavc "libavcodec" encoding/decoding library
46  * @li @ref lavfi "libavfilter" graph-based frame editing library
47  * @li @ref libavf "libavformat" I/O and muxing/demuxing library
48  * @li @ref lavd "libavdevice" special devices muxing/demuxing library
49  * @li @ref lavu "libavutil" common utility library
50  * @li @ref lswr "libswresample" audio resampling, format conversion and mixing
51  * @li @ref lpp  "libpostproc" post processing library
52  * @li @ref libsws "libswscale" color conversion and scaling library
53  *
54  * @section ffmpeg_versioning Versioning and compatibility
55  *
56  * Each of the FFmpeg libraries contains a version.h header, which defines a
57  * major, minor and micro version number with the
58  * <em>LIBRARYNAME_VERSION_{MAJOR,MINOR,MICRO}</em> macros. The major version
59  * number is incremented with backward incompatible changes - e.g. removing
60  * parts of the public API, reordering public struct members, etc. The minor
61  * version number is incremented for backward compatible API changes or major
62  * new features - e.g. adding a new public function or a new decoder. The micro
63  * version number is incremented for smaller changes that a calling program
64  * might still want to check for - e.g. changing behavior in a previously
65  * unspecified situation.
66  *
67  * FFmpeg guarantees backward API and ABI compatibility for each library as long
68  * as its major version number is unchanged. This means that no public symbols
69  * will be removed or renamed. Types and names of the public struct members and
70  * values of public macros and enums will remain the same (unless they were
71  * explicitly declared as not part of the public API). Documented behavior will
72  * not change.
73  *
74  * In other words, any correct program that works with a given FFmpeg snapshot
75  * should work just as well without any changes with any later snapshot with the
76  * same major versions. This applies to both rebuilding the program against new
77  * FFmpeg versions or to replacing the dynamic FFmpeg libraries that a program
78  * links against.
79  *
80  * However, new public symbols may be added and new members may be appended to
81  * public structs whose size is not part of public ABI (most public structs in
82  * FFmpeg). New macros and enum values may be added. Behavior in undocumented
83  * situations may change slightly (and be documented). All those are accompanied
84  * by an entry in doc/APIchanges and incrementing either the minor or micro
85  * version number.
86  */
87 
88 /**
89  * @defgroup lavu libavutil
90  * Common code shared across all FFmpeg libraries.
91  *
92  * @note
93  * libavutil is designed to be modular. In most cases, in order to use the
94  * functions provided by one component of libavutil you must explicitly include
95  * the specific header containing that feature. If you are only using
96  * media-related components, you could simply include libavutil/avutil.h, which
97  * brings in most of the "core" components.
98  *
99  * @{
100  *
101  * @defgroup lavu_crypto Crypto and Hashing
102  *
103  * @{
104  * @}
105  *
106  * @defgroup lavu_math Mathematics
107  * @{
108  *
109  * @}
110  *
111  * @defgroup lavu_string String Manipulation
112  *
113  * @{
114  *
115  * @}
116  *
117  * @defgroup lavu_mem Memory Management
118  *
119  * @{
120  *
121  * @}
122  *
123  * @defgroup lavu_data Data Structures
124  * @{
125  *
126  * @}
127  *
128  * @defgroup lavu_video Video related
129  *
130  * @{
131  *
132  * @}
133  *
134  * @defgroup lavu_audio Audio related
135  *
136  * @{
137  *
138  * @}
139  *
140  * @defgroup lavu_error Error Codes
141  *
142  * @{
143  *
144  * @}
145  *
146  * @defgroup lavu_log Logging Facility
147  *
148  * @{
149  *
150  * @}
151  *
152  * @defgroup lavu_misc Other
153  *
154  * @{
155  *
156  * @defgroup preproc_misc Preprocessor String Macros
157  *
158  * @{
159  *
160  * @}
161  *
162  * @defgroup version_utils Library Version Macros
163  *
164  * @{
165  *
166  * @}
167  */
168 
169 /**
170  * @addtogroup lavu_ver
171  * @{
172  */
173 
174 /**
175  * Return the LIBAVUTIL_VERSION_INT constant.
176  */
177 uint avutil_version ();
178 
179 /**
180  * Return an informative version string. This usually is the actual release
181  * version number or a git commit description. This string has no fixed format
182  * and can change any time. It should never be parsed by code.
183  */
184 const(char)* av_version_info ();
185 
186 /**
187  * Return the libavutil build-time configuration.
188  */
189 const(char)* avutil_configuration ();
190 
191 /**
192  * Return the libavutil license.
193  */
194 const(char)* avutil_license ();
195 
196 /**
197  * @}
198  */
199 
200 /**
201  * @addtogroup lavu_media Media Type
202  * @brief Media Type
203  */
204 
205 enum AVMediaType
206 {
207     AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
208     AVMEDIA_TYPE_VIDEO = 0,
209     AVMEDIA_TYPE_AUDIO = 1,
210     AVMEDIA_TYPE_DATA = 2, ///< Opaque data information usually continuous
211     AVMEDIA_TYPE_SUBTITLE = 3,
212     AVMEDIA_TYPE_ATTACHMENT = 4, ///< Opaque data information usually sparse
213     AVMEDIA_TYPE_NB = 5
214 }
215 
216 /**
217  * Return a string describing the media_type enum, NULL if media_type
218  * is unknown.
219  */
220 const(char)* av_get_media_type_string (AVMediaType media_type);
221 
222 /**
223  * @defgroup lavu_const Constants
224  * @{
225  *
226  * @defgroup lavu_enc Encoding specific
227  *
228  * @note those definition should move to avcodec
229  * @{
230  */
231 
232 enum FF_LAMBDA_SHIFT = 7;
233 enum FF_LAMBDA_SCALE = 1 << FF_LAMBDA_SHIFT;
234 enum FF_QP2LAMBDA = 118; ///< factor to convert from H.263 QP to lambda
235 enum FF_LAMBDA_MAX = 256 * 128 - 1;
236 
237 enum FF_QUALITY_SCALE = FF_LAMBDA_SCALE; //FIXME maybe remove
238 
239 /**
240  * @}
241  * @defgroup lavu_time Timestamp specific
242  *
243  * FFmpeg internal timebase and timestamp definitions
244  *
245  * @{
246  */
247 
248 /**
249  * @brief Undefined timestamp value
250  *
251  * Usually reported by demuxer that work on containers that do not provide
252  * either pts or dts.
253  */
254 
255 enum AV_NOPTS_VALUE = cast(long) UINT64_C(0x8000000000000000);
256 
257 /**
258  * Internal time base represented as integer
259  */
260 
261 enum AV_TIME_BASE = 1000000;
262 
263 /**
264  * Internal time base represented as fractional value
265  */
266 
267 /**
268  * @}
269  * @}
270  * @defgroup lavu_picture Image related
271  *
272  * AVPicture types, pixel formats and basic image planes manipulation.
273  *
274  * @{
275  */
276 
277 enum AVPictureType
278 {
279     AV_PICTURE_TYPE_NONE = 0, ///< Undefined
280     AV_PICTURE_TYPE_I = 1, ///< Intra
281     AV_PICTURE_TYPE_P = 2, ///< Predicted
282     AV_PICTURE_TYPE_B = 3, ///< Bi-dir predicted
283     AV_PICTURE_TYPE_S = 4, ///< S(GMC)-VOP MPEG-4
284     AV_PICTURE_TYPE_SI = 5, ///< Switching Intra
285     AV_PICTURE_TYPE_SP = 6, ///< Switching Predicted
286     AV_PICTURE_TYPE_BI = 7 ///< BI type
287 }
288 
289 /**
290  * Return a single letter to describe the given picture type
291  * pict_type.
292  *
293  * @param[in] pict_type the picture type @return a single character
294  * representing the picture type, '?' if pict_type is unknown
295  */
296 char av_get_picture_type_char (AVPictureType pict_type);
297 
298 /**
299  * @}
300  */
301 
302 /**
303  * Return x default pointer in case p is NULL.
304  */
305 void* av_x_if_null (const(void)* p, const(void)* x);
306 
307 /**
308  * Compute the length of an integer list.
309  *
310  * @param elsize  size in bytes of each list element (only 1, 2, 4 or 8)
311  * @param term    list terminator (usually 0 or -1)
312  * @param list    pointer to the list
313  * @return  length of the list, in elements, not counting the terminator
314  */
315 uint av_int_list_length_for_size (uint elsize, const(void)* list, ulong term);
316 
317 /**
318  * Compute the length of an integer list.
319  *
320  * @param term  list terminator (usually 0 or -1)
321  * @param list  pointer to the list
322  * @return  length of the list, in elements, not counting the terminator
323  */
324 extern (D) auto av_int_list_length(T0, T1)(auto ref T0 list, auto ref T1 term)
325 {
326     return av_int_list_length_for_size((*list).sizeof, list, term);
327 }
328 
329 /**
330  * Open a file using a UTF-8 filename.
331  * The API of this function matches POSIX fopen(), errors are returned through
332  * errno.
333  */
334 FILE* av_fopen_utf8 (const(char)* path, const(char)* mode);
335 
336 /**
337  * Return the fractional representation of the internal time base.
338  */
339 AVRational av_get_time_base_q ();
340 
341 enum AV_FOURCC_MAX_STRING_SIZE = 32;
342 
343 /**
344  * Fill the provided buffer with a string containing a FourCC (four-character
345  * code) representation.
346  *
347  * @param buf    a buffer with size in bytes of at least AV_FOURCC_MAX_STRING_SIZE
348  * @param fourcc the fourcc to represent
349  * @return the buffer in input
350  */
351 char* av_fourcc_make_string (char* buf, uint fourcc);
352 
353 /**
354  * @}
355  * @}
356  */
357 
358 /* AVUTIL_AVUTIL_H */