1 /* 2 * copyright (c) 2003 Fabrice Bellard 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 module ffmpeg.libavutil.avutil; 21 22 import std.stdint; 23 import std.format; 24 import std.array; 25 import core.vararg; 26 27 public import ffmpeg.libavutil.common; 28 public import ffmpeg.libavutil.rational; 29 public import ffmpeg.libavutil.samplefmt; 30 public import ffmpeg.libavutil.frame; 31 public import ffmpeg.libavutil.pixfmt; 32 public import ffmpeg.libavutil.log; 33 public import ffmpeg.libavutil.dict; 34 public import ffmpeg.libavutil.error; 35 public import ffmpeg.libavutil.mathematics; 36 public import ffmpeg.libavutil.channel_layout; 37 public import ffmpeg.libavutil.avutil_version; 38 39 40 /** 41 * Fill the provided buffer with a string containing a timestamp time 42 * representation. 43 * 44 * @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE 45 * @param ts the timestamp to represent 46 * @param tb the timebase of the timestamp 47 * @return the buffer in input 48 */ 49 string av_ts_make_time_string(int64_t ts, AVRational tb) 50 { 51 import std.format; 52 import std.array; 53 if (ts == AV_NOPTS_VALUE) { 54 return "No Value"; 55 } else { 56 auto toTs = av_q2d(tb) * ts; 57 auto writer = appender!string(); 58 formattedWrite(writer, "%.6g", toTs); 59 return writer.data; 60 } 61 } 62 63 @nogc nothrow extern(C): 64 65 /* 66 * @mainpage 67 * 68 * @section libav_intro Introduction 69 * 70 * This document describes the usage of the different libraries 71 * provided by FFmpeg. 72 * 73 * @li @ref libavc "libavcodec" encoding/decoding library 74 * @li @subpage libavfilter graph based frame editing library 75 * @li @ref libavf "libavformat" I/O and muxing/demuxing library 76 * @li @ref lavd "libavdevice" special devices muxing/demuxing library 77 * @li @ref lavu "libavutil" common utility library 78 * @li @subpage libpostproc post processing library 79 * @li @subpage libswscale color conversion and scaling library 80 */ 81 82 /** 83 * @defgroup lavu Common utility functions 84 * 85 * @brief 86 * libavutil contains the code shared across all the other FFmpeg 87 * libraries 88 * 89 * @note In order to use the functions provided by avutil you must include 90 * the specific header. 91 * 92 * @{ 93 * 94 * @defgroup lavu_crypto Crypto and Hashing 95 * 96 * @{ 97 * @} 98 * 99 * @defgroup lavu_math Maths 100 * @{ 101 * 102 * @} 103 * 104 * @defgroup lavu_string String Manipulation 105 * 106 * @{ 107 * 108 * @} 109 * 110 * @defgroup lavu_mem Memory Management 111 * 112 * @{ 113 * 114 * @} 115 * 116 * @defgroup lavu_data Data Structures 117 * @{ 118 * 119 * @} 120 * 121 * @defgroup lavu_audio Audio related 122 * 123 * @{ 124 * 125 * @} 126 * 127 * @defgroup lavu_error Error Codes 128 * 129 * @{ 130 * 131 * @} 132 * 133 * @defgroup lavu_misc Other 134 * 135 * @{ 136 * 137 * @defgroup lavu_internal Internal 138 * 139 * Not exported functions, for internal usage only 140 * 141 * @{ 142 * 143 * @} 144 */ 145 146 /** 147 * @addtogroup lavu_ver 148 * @{ 149 */ 150 151 /** 152 * Return the LIBAVUTIL_VERSION_INT constant. 153 */ 154 uint avutil_version(); 155 156 /** 157 * Return the libavutil build-time configuration. 158 */ 159 char *avutil_configuration(); 160 161 /** 162 * Return the libavutil license. 163 */ 164 char *avutil_license(); 165 166 /** 167 * @} 168 */ 169 170 /** 171 * @addtogroup lavu_media Media Type 172 * @brief Media Type 173 */ 174 175 enum AVMediaType { 176 AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA 177 AVMEDIA_TYPE_VIDEO, 178 AVMEDIA_TYPE_AUDIO, 179 AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous 180 AVMEDIA_TYPE_SUBTITLE, 181 AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse 182 AVMEDIA_TYPE_NB 183 } 184 185 /** 186 * Return a string describing the media_type enum, NULL if media_type 187 * is unknown. 188 */ 189 char* av_get_media_type_string(AVMediaType media_type); 190 191 /** 192 * @defgroup lavu_const Constants 193 * @{ 194 * 195 * @defgroup lavu_enc Encoding specific 196 * 197 * @note those definition should move to avcodec 198 * @{ 199 */ 200 201 enum FF_LAMBDA_SHIFT = 7; 202 enum FF_LAMBDA_SCALE = (1<<FF_LAMBDA_SHIFT); 203 enum FF_QP2LAMBDA = 118; ///< factor to convert from H.263 QP to lambda 204 enum FF_LAMBDA_MAX = (256*128-1); 205 206 enum FF_QUALITY_SCALE = FF_LAMBDA_SCALE; //FIXME maybe remove 207 208 /** 209 * @} 210 * @defgroup lavu_time Timestamp specific 211 * 212 * FFmpeg internal timebase and timestamp definitions 213 * 214 * @{ 215 */ 216 217 /** 218 * @brief Undefined timestamp value 219 * 220 * Usually reported by demuxer that work on containers that do not provide 221 * either pts or dts. 222 */ 223 224 enum AV_NOPTS_VALUE = 0x8000000000000000; 225 226 227 /** 228 * Internal time base represented as integer 229 */ 230 231 enum AV_TIME_BASE = 1000000; 232 233 /** 234 * Internal time base represented as fractional value 235 */ 236 237 AVRational AV_TIME_BASE_Q = {num:1, den:AV_TIME_BASE}; 238 239 /** 240 * @} 241 * @} 242 * @defgroup lavu_picture Image related 243 * 244 * AVPicture types, pixel formats and basic image planes manipulation. 245 * 246 * @{ 247 */ 248 enum AVPictureType { 249 AV_PICTURE_TYPE_NONE = 0, 250 AV_PICTURE_TYPE_I, 251 AV_PICTURE_TYPE_P, 252 AV_PICTURE_TYPE_B, 253 AV_PICTURE_TYPE_S, 254 AV_PICTURE_TYPE_SI, 255 AV_PICTURE_TYPE_SP, 256 AV_PICTURE_TYPE_BI 257 } 258 259 /** 260 * Return a single letter to describe the given picture type 261 * pict_type. 262 * 263 * @param[in] pict_type the picture type @return a single character 264 * representing the picture type, '?' if pict_type is unknown 265 */ 266 char av_get_picture_type_char(AVPictureType pict_type); 267 // end avutil.h 268 269 /** 270 * Return x default pointer in case p is NULL. 271 */ 272 //static inline void *av_x_if_null(const void *p, const void *x) 273 //{ 274 // return (void *)(intptr_t)(p ? p : x); 275 //} 276 277 /** 278 * Compute the length of an integer list. 279 * 280 * @param elsize size in bytes of each list element (only 1, 2, 4 or 8) 281 * @param term list terminator (usually 0 or -1) 282 * @param list pointer to the list 283 * @return length of the list, in elements, not counting the terminator 284 */ 285 //unsigned av_int_list_length_for_size(unsigned elsize, 286 // const void *list, uint64_t term) av_pure; 287 288 /** 289 * Compute the length of an integer list. 290 * 291 * @param term list terminator (usually 0 or -1) 292 * @param list pointer to the list 293 * @return length of the list, in elements, not counting the terminator 294 */ 295 //#define av_int_list_length(list, term) \ 296 //av_int_list_length_for_size(sizeof(*(list)), list, term) 297 298 /** 299 * Open a file using a UTF-8 filename. 300 * The API of this function matches POSIX fopen(), errors are returned through 301 * errno. 302 */ 303 //FILE *av_fopen_utf8(const char *path, const char *mode); 304 305 /** 306 * Return the fractional representation of the internal time base. 307 */ 308 //AVRational av_get_time_base_q(void); 309 310 /** 311 * @} 312 * @} 313 */