1 /* 2 * copyright (c) 2001 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 21 module ffmpeg.libavcodec.avcodec; 22 23 extern (C): 24 import ffmpeg; @nogc nothrow: 25 26 /** 27 * @file 28 * @ingroup libavc 29 * Libavcodec external API header 30 */ 31 32 /** 33 * @defgroup libavc libavcodec 34 * Encoding/Decoding Library 35 * 36 * @{ 37 * 38 * @defgroup lavc_decoding Decoding 39 * @{ 40 * @} 41 * 42 * @defgroup lavc_encoding Encoding 43 * @{ 44 * @} 45 * 46 * @defgroup lavc_codec Codecs 47 * @{ 48 * @defgroup lavc_codec_native Native Codecs 49 * @{ 50 * @} 51 * @defgroup lavc_codec_wrappers External library wrappers 52 * @{ 53 * @} 54 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge 55 * @{ 56 * @} 57 * @} 58 * @defgroup lavc_internal Internal 59 * @{ 60 * @} 61 * @} 62 */ 63 64 /** 65 * @ingroup libavc 66 * @defgroup lavc_encdec send/receive encoding and decoding API overview 67 * @{ 68 * 69 * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/ 70 * avcodec_receive_packet() functions provide an encode/decode API, which 71 * decouples input and output. 72 * 73 * The API is very similar for encoding/decoding and audio/video, and works as 74 * follows: 75 * - Set up and open the AVCodecContext as usual. 76 * - Send valid input: 77 * - For decoding, call avcodec_send_packet() to give the decoder raw 78 * compressed data in an AVPacket. 79 * - For encoding, call avcodec_send_frame() to give the encoder an AVFrame 80 * containing uncompressed audio or video. 81 * In both cases, it is recommended that AVPackets and AVFrames are 82 * refcounted, or libavcodec might have to copy the input data. (libavformat 83 * always returns refcounted AVPackets, and av_frame_get_buffer() allocates 84 * refcounted AVFrames.) 85 * - Receive output in a loop. Periodically call one of the avcodec_receive_*() 86 * functions and process their output: 87 * - For decoding, call avcodec_receive_frame(). On success, it will return 88 * an AVFrame containing uncompressed audio or video data. 89 * - For encoding, call avcodec_receive_packet(). On success, it will return 90 * an AVPacket with a compressed frame. 91 * Repeat this call until it returns AVERROR(EAGAIN) or an error. The 92 * AVERROR(EAGAIN) return value means that new input data is required to 93 * return new output. In this case, continue with sending input. For each 94 * input frame/packet, the codec will typically return 1 output frame/packet, 95 * but it can also be 0 or more than 1. 96 * 97 * At the beginning of decoding or encoding, the codec might accept multiple 98 * input frames/packets without returning a frame, until its internal buffers 99 * are filled. This situation is handled transparently if you follow the steps 100 * outlined above. 101 * 102 * In theory, sending input can result in EAGAIN - this should happen only if 103 * not all output was received. You can use this to structure alternative decode 104 * or encode loops other than the one suggested above. For example, you could 105 * try sending new input on each iteration, and try to receive output if that 106 * returns EAGAIN. 107 * 108 * End of stream situations. These require "flushing" (aka draining) the codec, 109 * as the codec might buffer multiple frames or packets internally for 110 * performance or out of necessity (consider B-frames). 111 * This is handled as follows: 112 * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding) 113 * or avcodec_send_frame() (encoding) functions. This will enter draining 114 * mode. 115 * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet() 116 * (encoding) in a loop until AVERROR_EOF is returned. The functions will 117 * not return AVERROR(EAGAIN), unless you forgot to enter draining mode. 118 * - Before decoding can be resumed again, the codec has to be reset with 119 * avcodec_flush_buffers(). 120 * 121 * Using the API as outlined above is highly recommended. But it is also 122 * possible to call functions outside of this rigid schema. For example, you can 123 * call avcodec_send_packet() repeatedly without calling 124 * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed 125 * until the codec's internal buffer has been filled up (which is typically of 126 * size 1 per output frame, after initial input), and then reject input with 127 * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to 128 * read at least some output. 129 * 130 * Not all codecs will follow a rigid and predictable dataflow; the only 131 * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on 132 * one end implies that a receive/send call on the other end will succeed, or 133 * at least will not fail with AVERROR(EAGAIN). In general, no codec will 134 * permit unlimited buffering of input or output. 135 * 136 * This API replaces the following legacy functions: 137 * - avcodec_decode_video2() and avcodec_decode_audio4(): 138 * Use avcodec_send_packet() to feed input to the decoder, then use 139 * avcodec_receive_frame() to receive decoded frames after each packet. 140 * Unlike with the old video decoding API, multiple frames might result from 141 * a packet. For audio, splitting the input packet into frames by partially 142 * decoding packets becomes transparent to the API user. You never need to 143 * feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then 144 * no data was read from the packet). 145 * Additionally, sending a flush/draining packet is required only once. 146 * - avcodec_encode_video2()/avcodec_encode_audio2(): 147 * Use avcodec_send_frame() to feed input to the encoder, then use 148 * avcodec_receive_packet() to receive encoded packets. 149 * Providing user-allocated buffers for avcodec_receive_packet() is not 150 * possible. 151 * - The new API does not handle subtitles yet. 152 * 153 * Mixing new and old function calls on the same AVCodecContext is not allowed, 154 * and will result in undefined behavior. 155 * 156 * Some codecs might require using the new API; using the old API will return 157 * an error when calling it. All codecs support the new API. 158 * 159 * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This 160 * would be an invalid state, which could put the codec user into an endless 161 * loop. The API has no concept of time either: it cannot happen that trying to 162 * do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second 163 * later accepts the packet (with no other receive/flush API calls involved). 164 * The API is a strict state machine, and the passage of time is not supposed 165 * to influence it. Some timing-dependent behavior might still be deemed 166 * acceptable in certain cases. But it must never result in both send/receive 167 * returning EAGAIN at the same time at any point. It must also absolutely be 168 * avoided that the current state is "unstable" and can "flip-flop" between 169 * the send/receive APIs allowing progress. For example, it's not allowed that 170 * the codec randomly decides that it actually wants to consume a packet now 171 * instead of returning a frame, after it just returned AVERROR(EAGAIN) on an 172 * avcodec_send_packet() call. 173 * @} 174 */ 175 176 /** 177 * @defgroup lavc_core Core functions/structures. 178 * @ingroup libavc 179 * 180 * Basic definitions, functions for querying libavcodec capabilities, 181 * allocating core structures, etc. 182 * @{ 183 */ 184 185 /** 186 * Identify the syntax and semantics of the bitstream. 187 * The principle is roughly: 188 * Two decoders with the same ID can decode the same streams. 189 * Two encoders with the same ID can encode compatible streams. 190 * There may be slight deviations from the principle due to implementation 191 * details. 192 * 193 * If you add a codec ID to this list, add it so that 194 * 1. no value of an existing codec ID changes (that would break ABI), 195 * 2. it is as close as possible to similar codecs 196 * 197 * After adding new codec IDs, do not forget to add an entry to the codec 198 * descriptor list and bump libavcodec minor version. 199 */ 200 enum AVCodecID 201 { 202 AV_CODEC_ID_NONE = 0, 203 204 /* video codecs */ 205 AV_CODEC_ID_MPEG1VIDEO = 1, 206 AV_CODEC_ID_MPEG2VIDEO = 2, ///< preferred ID for MPEG-1/2 video decoding 207 AV_CODEC_ID_H261 = 3, 208 AV_CODEC_ID_H263 = 4, 209 AV_CODEC_ID_RV10 = 5, 210 AV_CODEC_ID_RV20 = 6, 211 AV_CODEC_ID_MJPEG = 7, 212 AV_CODEC_ID_MJPEGB = 8, 213 AV_CODEC_ID_LJPEG = 9, 214 AV_CODEC_ID_SP5X = 10, 215 AV_CODEC_ID_JPEGLS = 11, 216 AV_CODEC_ID_MPEG4 = 12, 217 AV_CODEC_ID_RAWVIDEO = 13, 218 AV_CODEC_ID_MSMPEG4V1 = 14, 219 AV_CODEC_ID_MSMPEG4V2 = 15, 220 AV_CODEC_ID_MSMPEG4V3 = 16, 221 AV_CODEC_ID_WMV1 = 17, 222 AV_CODEC_ID_WMV2 = 18, 223 AV_CODEC_ID_H263P = 19, 224 AV_CODEC_ID_H263I = 20, 225 AV_CODEC_ID_FLV1 = 21, 226 AV_CODEC_ID_SVQ1 = 22, 227 AV_CODEC_ID_SVQ3 = 23, 228 AV_CODEC_ID_DVVIDEO = 24, 229 AV_CODEC_ID_HUFFYUV = 25, 230 AV_CODEC_ID_CYUV = 26, 231 AV_CODEC_ID_H264 = 27, 232 AV_CODEC_ID_INDEO3 = 28, 233 AV_CODEC_ID_VP3 = 29, 234 AV_CODEC_ID_THEORA = 30, 235 AV_CODEC_ID_ASV1 = 31, 236 AV_CODEC_ID_ASV2 = 32, 237 AV_CODEC_ID_FFV1 = 33, 238 AV_CODEC_ID_4XM = 34, 239 AV_CODEC_ID_VCR1 = 35, 240 AV_CODEC_ID_CLJR = 36, 241 AV_CODEC_ID_MDEC = 37, 242 AV_CODEC_ID_ROQ = 38, 243 AV_CODEC_ID_INTERPLAY_VIDEO = 39, 244 AV_CODEC_ID_XAN_WC3 = 40, 245 AV_CODEC_ID_XAN_WC4 = 41, 246 AV_CODEC_ID_RPZA = 42, 247 AV_CODEC_ID_CINEPAK = 43, 248 AV_CODEC_ID_WS_VQA = 44, 249 AV_CODEC_ID_MSRLE = 45, 250 AV_CODEC_ID_MSVIDEO1 = 46, 251 AV_CODEC_ID_IDCIN = 47, 252 AV_CODEC_ID_8BPS = 48, 253 AV_CODEC_ID_SMC = 49, 254 AV_CODEC_ID_FLIC = 50, 255 AV_CODEC_ID_TRUEMOTION1 = 51, 256 AV_CODEC_ID_VMDVIDEO = 52, 257 AV_CODEC_ID_MSZH = 53, 258 AV_CODEC_ID_ZLIB = 54, 259 AV_CODEC_ID_QTRLE = 55, 260 AV_CODEC_ID_TSCC = 56, 261 AV_CODEC_ID_ULTI = 57, 262 AV_CODEC_ID_QDRAW = 58, 263 AV_CODEC_ID_VIXL = 59, 264 AV_CODEC_ID_QPEG = 60, 265 AV_CODEC_ID_PNG = 61, 266 AV_CODEC_ID_PPM = 62, 267 AV_CODEC_ID_PBM = 63, 268 AV_CODEC_ID_PGM = 64, 269 AV_CODEC_ID_PGMYUV = 65, 270 AV_CODEC_ID_PAM = 66, 271 AV_CODEC_ID_FFVHUFF = 67, 272 AV_CODEC_ID_RV30 = 68, 273 AV_CODEC_ID_RV40 = 69, 274 AV_CODEC_ID_VC1 = 70, 275 AV_CODEC_ID_WMV3 = 71, 276 AV_CODEC_ID_LOCO = 72, 277 AV_CODEC_ID_WNV1 = 73, 278 AV_CODEC_ID_AASC = 74, 279 AV_CODEC_ID_INDEO2 = 75, 280 AV_CODEC_ID_FRAPS = 76, 281 AV_CODEC_ID_TRUEMOTION2 = 77, 282 AV_CODEC_ID_BMP = 78, 283 AV_CODEC_ID_CSCD = 79, 284 AV_CODEC_ID_MMVIDEO = 80, 285 AV_CODEC_ID_ZMBV = 81, 286 AV_CODEC_ID_AVS = 82, 287 AV_CODEC_ID_SMACKVIDEO = 83, 288 AV_CODEC_ID_NUV = 84, 289 AV_CODEC_ID_KMVC = 85, 290 AV_CODEC_ID_FLASHSV = 86, 291 AV_CODEC_ID_CAVS = 87, 292 AV_CODEC_ID_JPEG2000 = 88, 293 AV_CODEC_ID_VMNC = 89, 294 AV_CODEC_ID_VP5 = 90, 295 AV_CODEC_ID_VP6 = 91, 296 AV_CODEC_ID_VP6F = 92, 297 AV_CODEC_ID_TARGA = 93, 298 AV_CODEC_ID_DSICINVIDEO = 94, 299 AV_CODEC_ID_TIERTEXSEQVIDEO = 95, 300 AV_CODEC_ID_TIFF = 96, 301 AV_CODEC_ID_GIF = 97, 302 AV_CODEC_ID_DXA = 98, 303 AV_CODEC_ID_DNXHD = 99, 304 AV_CODEC_ID_THP = 100, 305 AV_CODEC_ID_SGI = 101, 306 AV_CODEC_ID_C93 = 102, 307 AV_CODEC_ID_BETHSOFTVID = 103, 308 AV_CODEC_ID_PTX = 104, 309 AV_CODEC_ID_TXD = 105, 310 AV_CODEC_ID_VP6A = 106, 311 AV_CODEC_ID_AMV = 107, 312 AV_CODEC_ID_VB = 108, 313 AV_CODEC_ID_PCX = 109, 314 AV_CODEC_ID_SUNRAST = 110, 315 AV_CODEC_ID_INDEO4 = 111, 316 AV_CODEC_ID_INDEO5 = 112, 317 AV_CODEC_ID_MIMIC = 113, 318 AV_CODEC_ID_RL2 = 114, 319 AV_CODEC_ID_ESCAPE124 = 115, 320 AV_CODEC_ID_DIRAC = 116, 321 AV_CODEC_ID_BFI = 117, 322 AV_CODEC_ID_CMV = 118, 323 AV_CODEC_ID_MOTIONPIXELS = 119, 324 AV_CODEC_ID_TGV = 120, 325 AV_CODEC_ID_TGQ = 121, 326 AV_CODEC_ID_TQI = 122, 327 AV_CODEC_ID_AURA = 123, 328 AV_CODEC_ID_AURA2 = 124, 329 AV_CODEC_ID_V210X = 125, 330 AV_CODEC_ID_TMV = 126, 331 AV_CODEC_ID_V210 = 127, 332 AV_CODEC_ID_DPX = 128, 333 AV_CODEC_ID_MAD = 129, 334 AV_CODEC_ID_FRWU = 130, 335 AV_CODEC_ID_FLASHSV2 = 131, 336 AV_CODEC_ID_CDGRAPHICS = 132, 337 AV_CODEC_ID_R210 = 133, 338 AV_CODEC_ID_ANM = 134, 339 AV_CODEC_ID_BINKVIDEO = 135, 340 AV_CODEC_ID_IFF_ILBM = 136, 341 342 AV_CODEC_ID_KGV1 = 137, 343 AV_CODEC_ID_YOP = 138, 344 AV_CODEC_ID_VP8 = 139, 345 AV_CODEC_ID_PICTOR = 140, 346 AV_CODEC_ID_ANSI = 141, 347 AV_CODEC_ID_A64_MULTI = 142, 348 AV_CODEC_ID_A64_MULTI5 = 143, 349 AV_CODEC_ID_R10K = 144, 350 AV_CODEC_ID_MXPEG = 145, 351 AV_CODEC_ID_LAGARITH = 146, 352 AV_CODEC_ID_PRORES = 147, 353 AV_CODEC_ID_JV = 148, 354 AV_CODEC_ID_DFA = 149, 355 AV_CODEC_ID_WMV3IMAGE = 150, 356 AV_CODEC_ID_VC1IMAGE = 151, 357 AV_CODEC_ID_UTVIDEO = 152, 358 AV_CODEC_ID_BMV_VIDEO = 153, 359 AV_CODEC_ID_VBLE = 154, 360 AV_CODEC_ID_DXTORY = 155, 361 AV_CODEC_ID_V410 = 156, 362 AV_CODEC_ID_XWD = 157, 363 AV_CODEC_ID_CDXL = 158, 364 AV_CODEC_ID_XBM = 159, 365 AV_CODEC_ID_ZEROCODEC = 160, 366 AV_CODEC_ID_MSS1 = 161, 367 AV_CODEC_ID_MSA1 = 162, 368 AV_CODEC_ID_TSCC2 = 163, 369 AV_CODEC_ID_MTS2 = 164, 370 AV_CODEC_ID_CLLC = 165, 371 AV_CODEC_ID_MSS2 = 166, 372 AV_CODEC_ID_VP9 = 167, 373 AV_CODEC_ID_AIC = 168, 374 AV_CODEC_ID_ESCAPE130 = 169, 375 AV_CODEC_ID_G2M = 170, 376 AV_CODEC_ID_WEBP = 171, 377 AV_CODEC_ID_HNM4_VIDEO = 172, 378 AV_CODEC_ID_HEVC = 173, 379 380 AV_CODEC_ID_FIC = 174, 381 AV_CODEC_ID_ALIAS_PIX = 175, 382 AV_CODEC_ID_BRENDER_PIX = 176, 383 AV_CODEC_ID_PAF_VIDEO = 177, 384 AV_CODEC_ID_EXR = 178, 385 AV_CODEC_ID_VP7 = 179, 386 AV_CODEC_ID_SANM = 180, 387 AV_CODEC_ID_SGIRLE = 181, 388 AV_CODEC_ID_MVC1 = 182, 389 AV_CODEC_ID_MVC2 = 183, 390 AV_CODEC_ID_HQX = 184, 391 AV_CODEC_ID_TDSC = 185, 392 AV_CODEC_ID_HQ_HQA = 186, 393 AV_CODEC_ID_HAP = 187, 394 AV_CODEC_ID_DDS = 188, 395 AV_CODEC_ID_DXV = 189, 396 AV_CODEC_ID_SCREENPRESSO = 190, 397 AV_CODEC_ID_RSCC = 191, 398 AV_CODEC_ID_AVS2 = 192, 399 400 AV_CODEC_ID_Y41P = 0x8000, 401 AV_CODEC_ID_AVRP = 32769, 402 AV_CODEC_ID_012V = 32770, 403 AV_CODEC_ID_AVUI = 32771, 404 AV_CODEC_ID_AYUV = 32772, 405 AV_CODEC_ID_TARGA_Y216 = 32773, 406 AV_CODEC_ID_V308 = 32774, 407 AV_CODEC_ID_V408 = 32775, 408 AV_CODEC_ID_YUV4 = 32776, 409 AV_CODEC_ID_AVRN = 32777, 410 AV_CODEC_ID_CPIA = 32778, 411 AV_CODEC_ID_XFACE = 32779, 412 AV_CODEC_ID_SNOW = 32780, 413 AV_CODEC_ID_SMVJPEG = 32781, 414 AV_CODEC_ID_APNG = 32782, 415 AV_CODEC_ID_DAALA = 32783, 416 AV_CODEC_ID_CFHD = 32784, 417 AV_CODEC_ID_TRUEMOTION2RT = 32785, 418 AV_CODEC_ID_M101 = 32786, 419 AV_CODEC_ID_MAGICYUV = 32787, 420 AV_CODEC_ID_SHEERVIDEO = 32788, 421 AV_CODEC_ID_YLC = 32789, 422 AV_CODEC_ID_PSD = 32790, 423 AV_CODEC_ID_PIXLET = 32791, 424 AV_CODEC_ID_SPEEDHQ = 32792, 425 AV_CODEC_ID_FMVC = 32793, 426 AV_CODEC_ID_SCPR = 32794, 427 AV_CODEC_ID_CLEARVIDEO = 32795, 428 AV_CODEC_ID_XPM = 32796, 429 AV_CODEC_ID_AV1 = 32797, 430 AV_CODEC_ID_BITPACKED = 32798, 431 AV_CODEC_ID_MSCC = 32799, 432 AV_CODEC_ID_SRGC = 32800, 433 AV_CODEC_ID_SVG = 32801, 434 AV_CODEC_ID_GDV = 32802, 435 AV_CODEC_ID_FITS = 32803, 436 AV_CODEC_ID_IMM4 = 32804, 437 AV_CODEC_ID_PROSUMER = 32805, 438 AV_CODEC_ID_MWSC = 32806, 439 AV_CODEC_ID_WCMV = 32807, 440 AV_CODEC_ID_RASC = 32808, 441 442 /* various PCM "codecs" */ 443 AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs 444 AV_CODEC_ID_PCM_S16LE = 0x10000, 445 AV_CODEC_ID_PCM_S16BE = 65537, 446 AV_CODEC_ID_PCM_U16LE = 65538, 447 AV_CODEC_ID_PCM_U16BE = 65539, 448 AV_CODEC_ID_PCM_S8 = 65540, 449 AV_CODEC_ID_PCM_U8 = 65541, 450 AV_CODEC_ID_PCM_MULAW = 65542, 451 AV_CODEC_ID_PCM_ALAW = 65543, 452 AV_CODEC_ID_PCM_S32LE = 65544, 453 AV_CODEC_ID_PCM_S32BE = 65545, 454 AV_CODEC_ID_PCM_U32LE = 65546, 455 AV_CODEC_ID_PCM_U32BE = 65547, 456 AV_CODEC_ID_PCM_S24LE = 65548, 457 AV_CODEC_ID_PCM_S24BE = 65549, 458 AV_CODEC_ID_PCM_U24LE = 65550, 459 AV_CODEC_ID_PCM_U24BE = 65551, 460 AV_CODEC_ID_PCM_S24DAUD = 65552, 461 AV_CODEC_ID_PCM_ZORK = 65553, 462 AV_CODEC_ID_PCM_S16LE_PLANAR = 65554, 463 AV_CODEC_ID_PCM_DVD = 65555, 464 AV_CODEC_ID_PCM_F32BE = 65556, 465 AV_CODEC_ID_PCM_F32LE = 65557, 466 AV_CODEC_ID_PCM_F64BE = 65558, 467 AV_CODEC_ID_PCM_F64LE = 65559, 468 AV_CODEC_ID_PCM_BLURAY = 65560, 469 AV_CODEC_ID_PCM_LXF = 65561, 470 AV_CODEC_ID_S302M = 65562, 471 AV_CODEC_ID_PCM_S8_PLANAR = 65563, 472 AV_CODEC_ID_PCM_S24LE_PLANAR = 65564, 473 AV_CODEC_ID_PCM_S32LE_PLANAR = 65565, 474 AV_CODEC_ID_PCM_S16BE_PLANAR = 65566, 475 476 AV_CODEC_ID_PCM_S64LE = 0x10800, 477 AV_CODEC_ID_PCM_S64BE = 67585, 478 AV_CODEC_ID_PCM_F16LE = 67586, 479 AV_CODEC_ID_PCM_F24LE = 67587, 480 AV_CODEC_ID_PCM_VIDC = 67588, 481 482 /* various ADPCM codecs */ 483 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, 484 AV_CODEC_ID_ADPCM_IMA_WAV = 69633, 485 AV_CODEC_ID_ADPCM_IMA_DK3 = 69634, 486 AV_CODEC_ID_ADPCM_IMA_DK4 = 69635, 487 AV_CODEC_ID_ADPCM_IMA_WS = 69636, 488 AV_CODEC_ID_ADPCM_IMA_SMJPEG = 69637, 489 AV_CODEC_ID_ADPCM_MS = 69638, 490 AV_CODEC_ID_ADPCM_4XM = 69639, 491 AV_CODEC_ID_ADPCM_XA = 69640, 492 AV_CODEC_ID_ADPCM_ADX = 69641, 493 AV_CODEC_ID_ADPCM_EA = 69642, 494 AV_CODEC_ID_ADPCM_G726 = 69643, 495 AV_CODEC_ID_ADPCM_CT = 69644, 496 AV_CODEC_ID_ADPCM_SWF = 69645, 497 AV_CODEC_ID_ADPCM_YAMAHA = 69646, 498 AV_CODEC_ID_ADPCM_SBPRO_4 = 69647, 499 AV_CODEC_ID_ADPCM_SBPRO_3 = 69648, 500 AV_CODEC_ID_ADPCM_SBPRO_2 = 69649, 501 AV_CODEC_ID_ADPCM_THP = 69650, 502 AV_CODEC_ID_ADPCM_IMA_AMV = 69651, 503 AV_CODEC_ID_ADPCM_EA_R1 = 69652, 504 AV_CODEC_ID_ADPCM_EA_R3 = 69653, 505 AV_CODEC_ID_ADPCM_EA_R2 = 69654, 506 AV_CODEC_ID_ADPCM_IMA_EA_SEAD = 69655, 507 AV_CODEC_ID_ADPCM_IMA_EA_EACS = 69656, 508 AV_CODEC_ID_ADPCM_EA_XAS = 69657, 509 AV_CODEC_ID_ADPCM_EA_MAXIS_XA = 69658, 510 AV_CODEC_ID_ADPCM_IMA_ISS = 69659, 511 AV_CODEC_ID_ADPCM_G722 = 69660, 512 AV_CODEC_ID_ADPCM_IMA_APC = 69661, 513 AV_CODEC_ID_ADPCM_VIMA = 69662, 514 515 AV_CODEC_ID_ADPCM_AFC = 0x11800, 516 AV_CODEC_ID_ADPCM_IMA_OKI = 71681, 517 AV_CODEC_ID_ADPCM_DTK = 71682, 518 AV_CODEC_ID_ADPCM_IMA_RAD = 71683, 519 AV_CODEC_ID_ADPCM_G726LE = 71684, 520 AV_CODEC_ID_ADPCM_THP_LE = 71685, 521 AV_CODEC_ID_ADPCM_PSX = 71686, 522 AV_CODEC_ID_ADPCM_AICA = 71687, 523 AV_CODEC_ID_ADPCM_IMA_DAT4 = 71688, 524 AV_CODEC_ID_ADPCM_MTAF = 71689, 525 526 /* AMR */ 527 AV_CODEC_ID_AMR_NB = 0x12000, 528 AV_CODEC_ID_AMR_WB = 73729, 529 530 /* RealAudio codecs*/ 531 AV_CODEC_ID_RA_144 = 0x13000, 532 AV_CODEC_ID_RA_288 = 77825, 533 534 /* various DPCM codecs */ 535 AV_CODEC_ID_ROQ_DPCM = 0x14000, 536 AV_CODEC_ID_INTERPLAY_DPCM = 81921, 537 AV_CODEC_ID_XAN_DPCM = 81922, 538 AV_CODEC_ID_SOL_DPCM = 81923, 539 540 AV_CODEC_ID_SDX2_DPCM = 0x14800, 541 AV_CODEC_ID_GREMLIN_DPCM = 83969, 542 543 /* audio codecs */ 544 AV_CODEC_ID_MP2 = 0x15000, 545 AV_CODEC_ID_MP3 = 86017, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 546 AV_CODEC_ID_AAC = 86018, 547 AV_CODEC_ID_AC3 = 86019, 548 AV_CODEC_ID_DTS = 86020, 549 AV_CODEC_ID_VORBIS = 86021, 550 AV_CODEC_ID_DVAUDIO = 86022, 551 AV_CODEC_ID_WMAV1 = 86023, 552 AV_CODEC_ID_WMAV2 = 86024, 553 AV_CODEC_ID_MACE3 = 86025, 554 AV_CODEC_ID_MACE6 = 86026, 555 AV_CODEC_ID_VMDAUDIO = 86027, 556 AV_CODEC_ID_FLAC = 86028, 557 AV_CODEC_ID_MP3ADU = 86029, 558 AV_CODEC_ID_MP3ON4 = 86030, 559 AV_CODEC_ID_SHORTEN = 86031, 560 AV_CODEC_ID_ALAC = 86032, 561 AV_CODEC_ID_WESTWOOD_SND1 = 86033, 562 AV_CODEC_ID_GSM = 86034, ///< as in Berlin toast format 563 AV_CODEC_ID_QDM2 = 86035, 564 AV_CODEC_ID_COOK = 86036, 565 AV_CODEC_ID_TRUESPEECH = 86037, 566 AV_CODEC_ID_TTA = 86038, 567 AV_CODEC_ID_SMACKAUDIO = 86039, 568 AV_CODEC_ID_QCELP = 86040, 569 AV_CODEC_ID_WAVPACK = 86041, 570 AV_CODEC_ID_DSICINAUDIO = 86042, 571 AV_CODEC_ID_IMC = 86043, 572 AV_CODEC_ID_MUSEPACK7 = 86044, 573 AV_CODEC_ID_MLP = 86045, 574 AV_CODEC_ID_GSM_MS = 86046, /* as found in WAV */ 575 AV_CODEC_ID_ATRAC3 = 86047, 576 AV_CODEC_ID_APE = 86048, 577 AV_CODEC_ID_NELLYMOSER = 86049, 578 AV_CODEC_ID_MUSEPACK8 = 86050, 579 AV_CODEC_ID_SPEEX = 86051, 580 AV_CODEC_ID_WMAVOICE = 86052, 581 AV_CODEC_ID_WMAPRO = 86053, 582 AV_CODEC_ID_WMALOSSLESS = 86054, 583 AV_CODEC_ID_ATRAC3P = 86055, 584 AV_CODEC_ID_EAC3 = 86056, 585 AV_CODEC_ID_SIPR = 86057, 586 AV_CODEC_ID_MP1 = 86058, 587 AV_CODEC_ID_TWINVQ = 86059, 588 AV_CODEC_ID_TRUEHD = 86060, 589 AV_CODEC_ID_MP4ALS = 86061, 590 AV_CODEC_ID_ATRAC1 = 86062, 591 AV_CODEC_ID_BINKAUDIO_RDFT = 86063, 592 AV_CODEC_ID_BINKAUDIO_DCT = 86064, 593 AV_CODEC_ID_AAC_LATM = 86065, 594 AV_CODEC_ID_QDMC = 86066, 595 AV_CODEC_ID_CELT = 86067, 596 AV_CODEC_ID_G723_1 = 86068, 597 AV_CODEC_ID_G729 = 86069, 598 AV_CODEC_ID_8SVX_EXP = 86070, 599 AV_CODEC_ID_8SVX_FIB = 86071, 600 AV_CODEC_ID_BMV_AUDIO = 86072, 601 AV_CODEC_ID_RALF = 86073, 602 AV_CODEC_ID_IAC = 86074, 603 AV_CODEC_ID_ILBC = 86075, 604 AV_CODEC_ID_OPUS = 86076, 605 AV_CODEC_ID_COMFORT_NOISE = 86077, 606 AV_CODEC_ID_TAK = 86078, 607 AV_CODEC_ID_METASOUND = 86079, 608 AV_CODEC_ID_PAF_AUDIO = 86080, 609 AV_CODEC_ID_ON2AVC = 86081, 610 AV_CODEC_ID_DSS_SP = 86082, 611 AV_CODEC_ID_CODEC2 = 86083, 612 613 AV_CODEC_ID_FFWAVESYNTH = 0x15800, 614 AV_CODEC_ID_SONIC = 88065, 615 AV_CODEC_ID_SONIC_LS = 88066, 616 AV_CODEC_ID_EVRC = 88067, 617 AV_CODEC_ID_SMV = 88068, 618 AV_CODEC_ID_DSD_LSBF = 88069, 619 AV_CODEC_ID_DSD_MSBF = 88070, 620 AV_CODEC_ID_DSD_LSBF_PLANAR = 88071, 621 AV_CODEC_ID_DSD_MSBF_PLANAR = 88072, 622 AV_CODEC_ID_4GV = 88073, 623 AV_CODEC_ID_INTERPLAY_ACM = 88074, 624 AV_CODEC_ID_XMA1 = 88075, 625 AV_CODEC_ID_XMA2 = 88076, 626 AV_CODEC_ID_DST = 88077, 627 AV_CODEC_ID_ATRAC3AL = 88078, 628 AV_CODEC_ID_ATRAC3PAL = 88079, 629 AV_CODEC_ID_DOLBY_E = 88080, 630 AV_CODEC_ID_APTX = 88081, 631 AV_CODEC_ID_APTX_HD = 88082, 632 AV_CODEC_ID_SBC = 88083, 633 AV_CODEC_ID_ATRAC9 = 88084, 634 635 /* subtitle codecs */ 636 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. 637 AV_CODEC_ID_DVD_SUBTITLE = 0x17000, 638 AV_CODEC_ID_DVB_SUBTITLE = 94209, 639 AV_CODEC_ID_TEXT = 94210, ///< raw UTF-8 text 640 AV_CODEC_ID_XSUB = 94211, 641 AV_CODEC_ID_SSA = 94212, 642 AV_CODEC_ID_MOV_TEXT = 94213, 643 AV_CODEC_ID_HDMV_PGS_SUBTITLE = 94214, 644 AV_CODEC_ID_DVB_TELETEXT = 94215, 645 AV_CODEC_ID_SRT = 94216, 646 647 AV_CODEC_ID_MICRODVD = 0x17800, 648 AV_CODEC_ID_EIA_608 = 96257, 649 AV_CODEC_ID_JACOSUB = 96258, 650 AV_CODEC_ID_SAMI = 96259, 651 AV_CODEC_ID_REALTEXT = 96260, 652 AV_CODEC_ID_STL = 96261, 653 AV_CODEC_ID_SUBVIEWER1 = 96262, 654 AV_CODEC_ID_SUBVIEWER = 96263, 655 AV_CODEC_ID_SUBRIP = 96264, 656 AV_CODEC_ID_WEBVTT = 96265, 657 AV_CODEC_ID_MPL2 = 96266, 658 AV_CODEC_ID_VPLAYER = 96267, 659 AV_CODEC_ID_PJS = 96268, 660 AV_CODEC_ID_ASS = 96269, 661 AV_CODEC_ID_HDMV_TEXT_SUBTITLE = 96270, 662 AV_CODEC_ID_TTML = 96271, 663 664 /* other specific kind of codecs (generally used for attachments) */ 665 AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. 666 AV_CODEC_ID_TTF = 0x18000, 667 668 AV_CODEC_ID_SCTE_35 = 98305, ///< Contain timestamp estimated through PCR of program stream. 669 AV_CODEC_ID_BINTEXT = 0x18800, 670 AV_CODEC_ID_XBIN = 100353, 671 AV_CODEC_ID_IDF = 100354, 672 AV_CODEC_ID_OTF = 100355, 673 AV_CODEC_ID_SMPTE_KLV = 100356, 674 AV_CODEC_ID_DVD_NAV = 100357, 675 AV_CODEC_ID_TIMED_ID3 = 100358, 676 AV_CODEC_ID_BIN_DATA = 100359, 677 678 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it 679 680 AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS 681 * stream (only used by libavformat) */ 682 AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems 683 * stream (only used by libavformat) */ 684 AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. 685 AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001 ///< Passthrough codec, AVFrames wrapped in AVPacket 686 } 687 688 enum AV_CODEC_ID_IFF_BYTERUN1 = AVCodecID.AV_CODEC_ID_IFF_ILBM; 689 enum AV_CODEC_ID_H265 = AVCodecID.AV_CODEC_ID_HEVC; 690 691 /** 692 * This struct describes the properties of a single codec described by an 693 * AVCodecID. 694 * @see avcodec_descriptor_get() 695 */ 696 struct AVCodecDescriptor 697 { 698 AVCodecID id; 699 AVMediaType type; 700 /** 701 * Name of the codec described by this descriptor. It is non-empty and 702 * unique for each codec descriptor. It should contain alphanumeric 703 * characters and '_' only. 704 */ 705 const(char)* name; 706 /** 707 * A more descriptive name for this codec. May be NULL. 708 */ 709 const(char)* long_name; 710 /** 711 * Codec properties, a combination of AV_CODEC_PROP_* flags. 712 */ 713 int props; 714 /** 715 * MIME type(s) associated with the codec. 716 * May be NULL; if not, a NULL-terminated array of MIME types. 717 * The first item is always non-NULL and is the preferred MIME type. 718 */ 719 const(char*)* mime_types; 720 /** 721 * If non-NULL, an array of profiles recognized for this codec. 722 * Terminated with FF_PROFILE_UNKNOWN. 723 */ 724 const(AVProfile)* profiles; 725 } 726 727 /** 728 * Codec uses only intra compression. 729 * Video and audio codecs only. 730 */ 731 enum AV_CODEC_PROP_INTRA_ONLY = 1 << 0; 732 /** 733 * Codec supports lossy compression. Audio and video codecs only. 734 * @note a codec may support both lossy and lossless 735 * compression modes 736 */ 737 enum AV_CODEC_PROP_LOSSY = 1 << 1; 738 /** 739 * Codec supports lossless compression. Audio and video codecs only. 740 */ 741 enum AV_CODEC_PROP_LOSSLESS = 1 << 2; 742 /** 743 * Codec supports frame reordering. That is, the coded order (the order in which 744 * the encoded packets are output by the encoders / stored / input to the 745 * decoders) may be different from the presentation order of the corresponding 746 * frames. 747 * 748 * For codecs that do not have this property set, PTS and DTS should always be 749 * equal. 750 */ 751 enum AV_CODEC_PROP_REORDER = 1 << 3; 752 /** 753 * Subtitle codec is bitmap based 754 * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field. 755 */ 756 enum AV_CODEC_PROP_BITMAP_SUB = 1 << 16; 757 /** 758 * Subtitle codec is text based. 759 * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field. 760 */ 761 enum AV_CODEC_PROP_TEXT_SUB = 1 << 17; 762 763 /** 764 * @ingroup lavc_decoding 765 * Required number of additionally allocated bytes at the end of the input bitstream for decoding. 766 * This is mainly needed because some optimized bitstream readers read 767 * 32 or 64 bit at once and could read over the end.<br> 768 * Note: If the first 23 bits of the additional bytes are not 0, then damaged 769 * MPEG bitstreams could cause overread and segfault. 770 */ 771 enum AV_INPUT_BUFFER_PADDING_SIZE = 64; 772 773 /** 774 * @ingroup lavc_encoding 775 * minimum encoding buffer size 776 * Used to avoid some checks during header writing. 777 */ 778 enum AV_INPUT_BUFFER_MIN_SIZE = 16384; 779 780 /** 781 * @ingroup lavc_decoding 782 */ 783 enum AVDiscard 784 { 785 /* We leave some space between them for extensions (drop some 786 * keyframes for intra-only or drop just some bidir frames). */ 787 AVDISCARD_NONE = -16, ///< discard nothing 788 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi 789 AVDISCARD_NONREF = 8, ///< discard all non reference 790 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames 791 AVDISCARD_NONINTRA = 24, ///< discard all non intra frames 792 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes 793 AVDISCARD_ALL = 48 ///< discard all 794 } 795 796 enum AVAudioServiceType 797 { 798 AV_AUDIO_SERVICE_TYPE_MAIN = 0, 799 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, 800 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2, 801 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3, 802 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4, 803 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5, 804 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6, 805 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7, 806 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8, 807 AV_AUDIO_SERVICE_TYPE_NB = 9 ///< Not part of ABI 808 } 809 810 /** 811 * @ingroup lavc_encoding 812 */ 813 struct RcOverride 814 { 815 int start_frame; 816 int end_frame; 817 int qscale; // If this is 0 then quality_factor will be used instead. 818 float quality_factor; 819 } 820 821 /* encoding support 822 These flags can be passed in AVCodecContext.flags before initialization. 823 Note: Not everything is supported yet. 824 */ 825 826 /** 827 * Allow decoders to produce frames with data planes that are not aligned 828 * to CPU requirements (e.g. due to cropping). 829 */ 830 enum AV_CODEC_FLAG_UNALIGNED = 1 << 0; 831 /** 832 * Use fixed qscale. 833 */ 834 enum AV_CODEC_FLAG_QSCALE = 1 << 1; 835 /** 836 * 4 MV per MB allowed / advanced prediction for H.263. 837 */ 838 enum AV_CODEC_FLAG_4MV = 1 << 2; 839 /** 840 * Output even those frames that might be corrupted. 841 */ 842 enum AV_CODEC_FLAG_OUTPUT_CORRUPT = 1 << 3; 843 /** 844 * Use qpel MC. 845 */ 846 enum AV_CODEC_FLAG_QPEL = 1 << 4; 847 /** 848 * Use internal 2pass ratecontrol in first pass mode. 849 */ 850 enum AV_CODEC_FLAG_PASS1 = 1 << 9; 851 /** 852 * Use internal 2pass ratecontrol in second pass mode. 853 */ 854 enum AV_CODEC_FLAG_PASS2 = 1 << 10; 855 /** 856 * loop filter. 857 */ 858 enum AV_CODEC_FLAG_LOOP_FILTER = 1 << 11; 859 /** 860 * Only decode/encode grayscale. 861 */ 862 enum AV_CODEC_FLAG_GRAY = 1 << 13; 863 /** 864 * error[?] variables will be set during encoding. 865 */ 866 enum AV_CODEC_FLAG_PSNR = 1 << 15; 867 /** 868 * Input bitstream might be truncated at a random location 869 * instead of only at frame boundaries. 870 */ 871 enum AV_CODEC_FLAG_TRUNCATED = 1 << 16; 872 /** 873 * Use interlaced DCT. 874 */ 875 enum AV_CODEC_FLAG_INTERLACED_DCT = 1 << 18; 876 /** 877 * Force low delay. 878 */ 879 enum AV_CODEC_FLAG_LOW_DELAY = 1 << 19; 880 /** 881 * Place global headers in extradata instead of every keyframe. 882 */ 883 enum AV_CODEC_FLAG_GLOBAL_HEADER = 1 << 22; 884 /** 885 * Use only bitexact stuff (except (I)DCT). 886 */ 887 enum AV_CODEC_FLAG_BITEXACT = 1 << 23; 888 /* Fx : Flag for H.263+ extra options */ 889 /** 890 * H.263 advanced intra coding / MPEG-4 AC prediction 891 */ 892 enum AV_CODEC_FLAG_AC_PRED = 1 << 24; 893 /** 894 * interlaced motion estimation 895 */ 896 enum AV_CODEC_FLAG_INTERLACED_ME = 1 << 29; 897 enum AV_CODEC_FLAG_CLOSED_GOP = 1U << 31; 898 899 /** 900 * Allow non spec compliant speedup tricks. 901 */ 902 enum AV_CODEC_FLAG2_FAST = 1 << 0; 903 /** 904 * Skip bitstream encoding. 905 */ 906 enum AV_CODEC_FLAG2_NO_OUTPUT = 1 << 2; 907 /** 908 * Place global headers at every keyframe instead of in extradata. 909 */ 910 enum AV_CODEC_FLAG2_LOCAL_HEADER = 1 << 3; 911 912 /** 913 * timecode is in drop frame format. DEPRECATED!!!! 914 */ 915 enum AV_CODEC_FLAG2_DROP_FRAME_TIMECODE = 1 << 13; 916 917 /** 918 * Input bitstream might be truncated at a packet boundaries 919 * instead of only at frame boundaries. 920 */ 921 enum AV_CODEC_FLAG2_CHUNKS = 1 << 15; 922 /** 923 * Discard cropping information from SPS. 924 */ 925 enum AV_CODEC_FLAG2_IGNORE_CROP = 1 << 16; 926 927 /** 928 * Show all frames before the first keyframe 929 */ 930 enum AV_CODEC_FLAG2_SHOW_ALL = 1 << 22; 931 /** 932 * Export motion vectors through frame side data 933 */ 934 enum AV_CODEC_FLAG2_EXPORT_MVS = 1 << 28; 935 /** 936 * Do not skip samples and export skip information as frame side data 937 */ 938 enum AV_CODEC_FLAG2_SKIP_MANUAL = 1 << 29; 939 /** 940 * Do not reset ASS ReadOrder field on flush (subtitles decoding) 941 */ 942 enum AV_CODEC_FLAG2_RO_FLUSH_NOOP = 1 << 30; 943 944 /* Unsupported options : 945 * Syntax Arithmetic coding (SAC) 946 * Reference Picture Selection 947 * Independent Segment Decoding */ 948 /* /Fx */ 949 /* codec capabilities */ 950 951 /** 952 * Decoder can use draw_horiz_band callback. 953 */ 954 enum AV_CODEC_CAP_DRAW_HORIZ_BAND = 1 << 0; 955 /** 956 * Codec uses get_buffer() for allocating buffers and supports custom allocators. 957 * If not set, it might not use get_buffer() at all or use operations that 958 * assume the buffer was allocated by avcodec_default_get_buffer. 959 */ 960 enum AV_CODEC_CAP_DR1 = 1 << 1; 961 enum AV_CODEC_CAP_TRUNCATED = 1 << 3; 962 /** 963 * Encoder or decoder requires flushing with NULL input at the end in order to 964 * give the complete and correct output. 965 * 966 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with 967 * with NULL data. The user can still send NULL data to the public encode 968 * or decode function, but libavcodec will not pass it along to the codec 969 * unless this flag is set. 970 * 971 * Decoders: 972 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, 973 * avpkt->size=0 at the end to get the delayed data until the decoder no longer 974 * returns frames. 975 * 976 * Encoders: 977 * The encoder needs to be fed with NULL data at the end of encoding until the 978 * encoder no longer returns data. 979 * 980 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this 981 * flag also means that the encoder must set the pts and duration for 982 * each output packet. If this flag is not set, the pts and duration will 983 * be determined by libavcodec from the input frame. 984 */ 985 enum AV_CODEC_CAP_DELAY = 1 << 5; 986 /** 987 * Codec can be fed a final frame with a smaller size. 988 * This can be used to prevent truncation of the last audio samples. 989 */ 990 enum AV_CODEC_CAP_SMALL_LAST_FRAME = 1 << 6; 991 992 /** 993 * Codec can output multiple frames per AVPacket 994 * Normally demuxers return one frame at a time, demuxers which do not do 995 * are connected to a parser to split what they return into proper frames. 996 * This flag is reserved to the very rare category of codecs which have a 997 * bitstream that cannot be split into frames without timeconsuming 998 * operations like full decoding. Demuxers carrying such bitstreams thus 999 * may return multiple frames in a packet. This has many disadvantages like 1000 * prohibiting stream copy in many cases thus it should only be considered 1001 * as a last resort. 1002 */ 1003 enum AV_CODEC_CAP_SUBFRAMES = 1 << 8; 1004 /** 1005 * Codec is experimental and is thus avoided in favor of non experimental 1006 * encoders 1007 */ 1008 enum AV_CODEC_CAP_EXPERIMENTAL = 1 << 9; 1009 /** 1010 * Codec should fill in channel configuration and samplerate instead of container 1011 */ 1012 enum AV_CODEC_CAP_CHANNEL_CONF = 1 << 10; 1013 /** 1014 * Codec supports frame-level multithreading. 1015 */ 1016 enum AV_CODEC_CAP_FRAME_THREADS = 1 << 12; 1017 /** 1018 * Codec supports slice-based (or partition-based) multithreading. 1019 */ 1020 enum AV_CODEC_CAP_SLICE_THREADS = 1 << 13; 1021 /** 1022 * Codec supports changed parameters at any point. 1023 */ 1024 enum AV_CODEC_CAP_PARAM_CHANGE = 1 << 14; 1025 /** 1026 * Codec supports avctx->thread_count == 0 (auto). 1027 */ 1028 enum AV_CODEC_CAP_AUTO_THREADS = 1 << 15; 1029 /** 1030 * Audio encoder supports receiving a different number of samples in each call. 1031 */ 1032 enum AV_CODEC_CAP_VARIABLE_FRAME_SIZE = 1 << 16; 1033 /** 1034 * Decoder is not a preferred choice for probing. 1035 * This indicates that the decoder is not a good choice for probing. 1036 * It could for example be an expensive to spin up hardware decoder, 1037 * or it could simply not provide a lot of useful information about 1038 * the stream. 1039 * A decoder marked with this flag should only be used as last resort 1040 * choice for probing. 1041 */ 1042 enum AV_CODEC_CAP_AVOID_PROBING = 1 << 17; 1043 /** 1044 * Codec is intra only. 1045 */ 1046 enum AV_CODEC_CAP_INTRA_ONLY = 0x40000000; 1047 /** 1048 * Codec is lossless. 1049 */ 1050 enum AV_CODEC_CAP_LOSSLESS = 0x80000000; 1051 1052 /** 1053 * Codec is backed by a hardware implementation. Typically used to 1054 * identify a non-hwaccel hardware decoder. For information about hwaccels, use 1055 * avcodec_get_hw_config() instead. 1056 */ 1057 enum AV_CODEC_CAP_HARDWARE = 1 << 18; 1058 1059 /** 1060 * Codec is potentially backed by a hardware implementation, but not 1061 * necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the 1062 * implementation provides some sort of internal fallback. 1063 */ 1064 enum AV_CODEC_CAP_HYBRID = 1 << 19; 1065 1066 /** 1067 * Pan Scan area. 1068 * This specifies the area which should be displayed. 1069 * Note there may be multiple such areas for one frame. 1070 */ 1071 struct AVPanScan 1072 { 1073 /** 1074 * id 1075 * - encoding: Set by user. 1076 * - decoding: Set by libavcodec. 1077 */ 1078 int id; 1079 1080 /** 1081 * width and height in 1/16 pel 1082 * - encoding: Set by user. 1083 * - decoding: Set by libavcodec. 1084 */ 1085 int width; 1086 int height; 1087 1088 /** 1089 * position of the top left corner in 1/16 pel for up to 3 fields/frames 1090 * - encoding: Set by user. 1091 * - decoding: Set by libavcodec. 1092 */ 1093 short[2][3] position; 1094 } 1095 1096 /** 1097 * This structure describes the bitrate properties of an encoded bitstream. It 1098 * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD 1099 * parameters for H.264/HEVC. 1100 */ 1101 struct AVCPBProperties 1102 { 1103 /** 1104 * Maximum bitrate of the stream, in bits per second. 1105 * Zero if unknown or unspecified. 1106 */ 1107 int max_bitrate; 1108 /** 1109 * Minimum bitrate of the stream, in bits per second. 1110 * Zero if unknown or unspecified. 1111 */ 1112 int min_bitrate; 1113 /** 1114 * Average bitrate of the stream, in bits per second. 1115 * Zero if unknown or unspecified. 1116 */ 1117 int avg_bitrate; 1118 1119 /** 1120 * The size of the buffer to which the ratecontrol is applied, in bits. 1121 * Zero if unknown or unspecified. 1122 */ 1123 int buffer_size; 1124 1125 /** 1126 * The delay between the time the packet this structure is associated with 1127 * is received and the time when it should be decoded, in periods of a 27MHz 1128 * clock. 1129 * 1130 * UINT64_MAX when unknown or unspecified. 1131 */ 1132 ulong vbv_delay; 1133 } 1134 1135 /** 1136 * The decoder will keep a reference to the frame and may reuse it later. 1137 */ 1138 enum AV_GET_BUFFER_FLAG_REF = 1 << 0; 1139 1140 /** 1141 * @defgroup lavc_packet AVPacket 1142 * 1143 * Types and functions for working with AVPacket. 1144 * @{ 1145 */ 1146 enum AVPacketSideDataType 1147 { 1148 /** 1149 * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE 1150 * bytes worth of palette. This side data signals that a new palette is 1151 * present. 1152 */ 1153 AV_PKT_DATA_PALETTE = 0, 1154 1155 /** 1156 * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format 1157 * that the extradata buffer was changed and the receiving side should 1158 * act upon it appropriately. The new extradata is embedded in the side 1159 * data buffer and should be immediately used for processing the current 1160 * frame or packet. 1161 */ 1162 AV_PKT_DATA_NEW_EXTRADATA = 1, 1163 1164 /** 1165 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: 1166 * @code 1167 * u32le param_flags 1168 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) 1169 * s32le channel_count 1170 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) 1171 * u64le channel_layout 1172 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) 1173 * s32le sample_rate 1174 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) 1175 * s32le width 1176 * s32le height 1177 * @endcode 1178 */ 1179 AV_PKT_DATA_PARAM_CHANGE = 2, 1180 1181 /** 1182 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of 1183 * structures with info about macroblocks relevant to splitting the 1184 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190). 1185 * That is, it does not necessarily contain info about all macroblocks, 1186 * as long as the distance between macroblocks in the info is smaller 1187 * than the target payload size. 1188 * Each MB info structure is 12 bytes, and is laid out as follows: 1189 * @code 1190 * u32le bit offset from the start of the packet 1191 * u8 current quantizer at the start of the macroblock 1192 * u8 GOB number 1193 * u16le macroblock address within the GOB 1194 * u8 horizontal MV predictor 1195 * u8 vertical MV predictor 1196 * u8 horizontal MV predictor for block number 3 1197 * u8 vertical MV predictor for block number 3 1198 * @endcode 1199 */ 1200 AV_PKT_DATA_H263_MB_INFO = 3, 1201 1202 /** 1203 * This side data should be associated with an audio stream and contains 1204 * ReplayGain information in form of the AVReplayGain struct. 1205 */ 1206 AV_PKT_DATA_REPLAYGAIN = 4, 1207 1208 /** 1209 * This side data contains a 3x3 transformation matrix describing an affine 1210 * transformation that needs to be applied to the decoded video frames for 1211 * correct presentation. 1212 * 1213 * See libavutil/display.h for a detailed description of the data. 1214 */ 1215 AV_PKT_DATA_DISPLAYMATRIX = 5, 1216 1217 /** 1218 * This side data should be associated with a video stream and contains 1219 * Stereoscopic 3D information in form of the AVStereo3D struct. 1220 */ 1221 AV_PKT_DATA_STEREO3D = 6, 1222 1223 /** 1224 * This side data should be associated with an audio stream and corresponds 1225 * to enum AVAudioServiceType. 1226 */ 1227 AV_PKT_DATA_AUDIO_SERVICE_TYPE = 7, 1228 1229 /** 1230 * This side data contains quality related information from the encoder. 1231 * @code 1232 * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad). 1233 * u8 picture type 1234 * u8 error count 1235 * u16 reserved 1236 * u64le[error count] sum of squared differences between encoder in and output 1237 * @endcode 1238 */ 1239 AV_PKT_DATA_QUALITY_STATS = 8, 1240 1241 /** 1242 * This side data contains an integer value representing the stream index 1243 * of a "fallback" track. A fallback track indicates an alternate 1244 * track to use when the current track can not be decoded for some reason. 1245 * e.g. no decoder available for codec. 1246 */ 1247 AV_PKT_DATA_FALLBACK_TRACK = 9, 1248 1249 /** 1250 * This side data corresponds to the AVCPBProperties struct. 1251 */ 1252 AV_PKT_DATA_CPB_PROPERTIES = 10, 1253 1254 /** 1255 * Recommmends skipping the specified number of samples 1256 * @code 1257 * u32le number of samples to skip from start of this packet 1258 * u32le number of samples to skip from end of this packet 1259 * u8 reason for start skip 1260 * u8 reason for end skip (0=padding silence, 1=convergence) 1261 * @endcode 1262 */ 1263 AV_PKT_DATA_SKIP_SAMPLES = 11, 1264 1265 /** 1266 * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that 1267 * the packet may contain "dual mono" audio specific to Japanese DTV 1268 * and if it is true, recommends only the selected channel to be used. 1269 * @code 1270 * u8 selected channels (0=mail/left, 1=sub/right, 2=both) 1271 * @endcode 1272 */ 1273 AV_PKT_DATA_JP_DUALMONO = 12, 1274 1275 /** 1276 * A list of zero terminated key/value strings. There is no end marker for 1277 * the list, so it is required to rely on the side data size to stop. 1278 */ 1279 AV_PKT_DATA_STRINGS_METADATA = 13, 1280 1281 /** 1282 * Subtitle event position 1283 * @code 1284 * u32le x1 1285 * u32le y1 1286 * u32le x2 1287 * u32le y2 1288 * @endcode 1289 */ 1290 AV_PKT_DATA_SUBTITLE_POSITION = 14, 1291 1292 /** 1293 * Data found in BlockAdditional element of matroska container. There is 1294 * no end marker for the data, so it is required to rely on the side data 1295 * size to recognize the end. 8 byte id (as found in BlockAddId) followed 1296 * by data. 1297 */ 1298 AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL = 15, 1299 1300 /** 1301 * The optional first identifier line of a WebVTT cue. 1302 */ 1303 AV_PKT_DATA_WEBVTT_IDENTIFIER = 16, 1304 1305 /** 1306 * The optional settings (rendering instructions) that immediately 1307 * follow the timestamp specifier of a WebVTT cue. 1308 */ 1309 AV_PKT_DATA_WEBVTT_SETTINGS = 17, 1310 1311 /** 1312 * A list of zero terminated key/value strings. There is no end marker for 1313 * the list, so it is required to rely on the side data size to stop. This 1314 * side data includes updated metadata which appeared in the stream. 1315 */ 1316 AV_PKT_DATA_METADATA_UPDATE = 18, 1317 1318 /** 1319 * MPEGTS stream ID as uint8_t, this is required to pass the stream ID 1320 * information from the demuxer to the corresponding muxer. 1321 */ 1322 AV_PKT_DATA_MPEGTS_STREAM_ID = 19, 1323 1324 /** 1325 * Mastering display metadata (based on SMPTE-2086:2014). This metadata 1326 * should be associated with a video stream and contains data in the form 1327 * of the AVMasteringDisplayMetadata struct. 1328 */ 1329 AV_PKT_DATA_MASTERING_DISPLAY_METADATA = 20, 1330 1331 /** 1332 * This side data should be associated with a video stream and corresponds 1333 * to the AVSphericalMapping structure. 1334 */ 1335 AV_PKT_DATA_SPHERICAL = 21, 1336 1337 /** 1338 * Content light level (based on CTA-861.3). This metadata should be 1339 * associated with a video stream and contains data in the form of the 1340 * AVContentLightMetadata struct. 1341 */ 1342 AV_PKT_DATA_CONTENT_LIGHT_LEVEL = 22, 1343 1344 /** 1345 * ATSC A53 Part 4 Closed Captions. This metadata should be associated with 1346 * a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data. 1347 * The number of bytes of CC data is AVPacketSideData.size. 1348 */ 1349 AV_PKT_DATA_A53_CC = 23, 1350 1351 /** 1352 * This side data is encryption initialization data. 1353 * The format is not part of ABI, use av_encryption_init_info_* methods to 1354 * access. 1355 */ 1356 AV_PKT_DATA_ENCRYPTION_INIT_INFO = 24, 1357 1358 /** 1359 * This side data contains encryption info for how to decrypt the packet. 1360 * The format is not part of ABI, use av_encryption_info_* methods to access. 1361 */ 1362 AV_PKT_DATA_ENCRYPTION_INFO = 25, 1363 1364 /** 1365 * Active Format Description data consisting of a single byte as specified 1366 * in ETSI TS 101 154 using AVActiveFormatDescription enum. 1367 */ 1368 AV_PKT_DATA_AFD = 26, 1369 1370 /** 1371 * The number of side data types. 1372 * This is not part of the public API/ABI in the sense that it may 1373 * change when new side data types are added. 1374 * This must stay the last enum value. 1375 * If its value becomes huge, some code using it 1376 * needs to be updated as it assumes it to be smaller than other limits. 1377 */ 1378 AV_PKT_DATA_NB = 27 1379 } 1380 1381 enum AV_PKT_DATA_QUALITY_FACTOR = AVPacketSideDataType.AV_PKT_DATA_QUALITY_STATS; //DEPRECATED 1382 1383 struct AVPacketSideData 1384 { 1385 ubyte* data; 1386 int size; 1387 AVPacketSideDataType type; 1388 } 1389 1390 /** 1391 * This structure stores compressed data. It is typically exported by demuxers 1392 * and then passed as input to decoders, or received as output from encoders and 1393 * then passed to muxers. 1394 * 1395 * For video, it should typically contain one compressed frame. For audio it may 1396 * contain several compressed frames. Encoders are allowed to output empty 1397 * packets, with no compressed data, containing only side data 1398 * (e.g. to update some stream parameters at the end of encoding). 1399 * 1400 * AVPacket is one of the few structs in FFmpeg, whose size is a part of public 1401 * ABI. Thus it may be allocated on stack and no new fields can be added to it 1402 * without libavcodec and libavformat major bump. 1403 * 1404 * The semantics of data ownership depends on the buf field. 1405 * If it is set, the packet data is dynamically allocated and is 1406 * valid indefinitely until a call to av_packet_unref() reduces the 1407 * reference count to 0. 1408 * 1409 * If the buf field is not set av_packet_ref() would make a copy instead 1410 * of increasing the reference count. 1411 * 1412 * The side data is always allocated with av_malloc(), copied by 1413 * av_packet_ref() and freed by av_packet_unref(). 1414 * 1415 * @see av_packet_ref 1416 * @see av_packet_unref 1417 */ 1418 struct AVPacket 1419 { 1420 /** 1421 * A reference to the reference-counted buffer where the packet data is 1422 * stored. 1423 * May be NULL, then the packet data is not reference-counted. 1424 */ 1425 AVBufferRef* buf; 1426 /** 1427 * Presentation timestamp in AVStream->time_base units; the time at which 1428 * the decompressed packet will be presented to the user. 1429 * Can be AV_NOPTS_VALUE if it is not stored in the file. 1430 * pts MUST be larger or equal to dts as presentation cannot happen before 1431 * decompression, unless one wants to view hex dumps. Some formats misuse 1432 * the terms dts and pts/cts to mean something different. Such timestamps 1433 * must be converted to true pts/dts before they are stored in AVPacket. 1434 */ 1435 long pts; 1436 /** 1437 * Decompression timestamp in AVStream->time_base units; the time at which 1438 * the packet is decompressed. 1439 * Can be AV_NOPTS_VALUE if it is not stored in the file. 1440 */ 1441 long dts; 1442 ubyte* data; 1443 int size; 1444 int stream_index; 1445 /** 1446 * A combination of AV_PKT_FLAG values 1447 */ 1448 int flags; 1449 /** 1450 * Additional packet data that can be provided by the container. 1451 * Packet can contain several types of side information. 1452 */ 1453 AVPacketSideData* side_data; 1454 int side_data_elems; 1455 1456 /** 1457 * Duration of this packet in AVStream->time_base units, 0 if unknown. 1458 * Equals next_pts - this_pts in presentation order. 1459 */ 1460 long duration; 1461 1462 long pos; ///< byte position in stream, -1 if unknown 1463 1464 /** 1465 * @deprecated Same as the duration field, but as int64_t. This was required 1466 * for Matroska subtitles, whose duration values could overflow when the 1467 * duration field was still an int. 1468 */ 1469 long convergence_duration; 1470 } 1471 1472 enum AV_PKT_FLAG_KEY = 0x0001; ///< The packet contains a keyframe 1473 enum AV_PKT_FLAG_CORRUPT = 0x0002; ///< The packet content is corrupted 1474 /** 1475 * Flag is used to discard packets which are required to maintain valid 1476 * decoder state but are not required for output and should be dropped 1477 * after decoding. 1478 **/ 1479 enum AV_PKT_FLAG_DISCARD = 0x0004; 1480 /** 1481 * The packet comes from a trusted source. 1482 * 1483 * Otherwise-unsafe constructs such as arbitrary pointers to data 1484 * outside the packet may be followed. 1485 */ 1486 enum AV_PKT_FLAG_TRUSTED = 0x0008; 1487 /** 1488 * Flag is used to indicate packets that contain frames that can 1489 * be discarded by the decoder. I.e. Non-reference frames. 1490 */ 1491 enum AV_PKT_FLAG_DISPOSABLE = 0x0010; 1492 1493 enum AVSideDataParamChangeFlags 1494 { 1495 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, 1496 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, 1497 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, 1498 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008 1499 } 1500 1501 /** 1502 * @} 1503 */ 1504 1505 struct AVCodecInternal; 1506 1507 enum AVFieldOrder 1508 { 1509 AV_FIELD_UNKNOWN = 0, 1510 AV_FIELD_PROGRESSIVE = 1, 1511 AV_FIELD_TT = 2, //< Top coded_first, top displayed first 1512 AV_FIELD_BB = 3, //< Bottom coded first, bottom displayed first 1513 AV_FIELD_TB = 4, //< Top coded first, bottom displayed first 1514 AV_FIELD_BT = 5 //< Bottom coded first, top displayed first 1515 } 1516 1517 /** 1518 * main external API structure. 1519 * New fields can be added to the end with minor version bumps. 1520 * Removal, reordering and changes to existing fields require a major 1521 * version bump. 1522 * You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user 1523 * applications. 1524 * The name string for AVOptions options matches the associated command line 1525 * parameter name and can be found in libavcodec/options_table.h 1526 * The AVOption/command line parameter names differ in some cases from the C 1527 * structure field names for historic reasons or brevity. 1528 * sizeof(AVCodecContext) must not be used outside libav*. 1529 */ 1530 struct AVCodecContext 1531 { 1532 /** 1533 * information on struct for av_log 1534 * - set by avcodec_alloc_context3 1535 */ 1536 const(AVClass)* av_class; 1537 int log_level_offset; 1538 1539 AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ 1540 const(AVCodec)* codec; 1541 AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ 1542 1543 /** 1544 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). 1545 * This is used to work around some encoder bugs. 1546 * A demuxer should set this to what is stored in the field used to identify the codec. 1547 * If there are multiple such fields in a container then the demuxer should choose the one 1548 * which maximizes the information about the used codec. 1549 * If the codec tag field in a container is larger than 32 bits then the demuxer should 1550 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new 1551 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated 1552 * first. 1553 * - encoding: Set by user, if not then the default based on codec_id will be used. 1554 * - decoding: Set by user, will be converted to uppercase by libavcodec during init. 1555 */ 1556 uint codec_tag; 1557 1558 void* priv_data; 1559 1560 /** 1561 * Private context used for internal data. 1562 * 1563 * Unlike priv_data, this is not codec-specific. It is used in general 1564 * libavcodec functions. 1565 */ 1566 AVCodecInternal* internal; 1567 1568 /** 1569 * Private data of the user, can be used to carry app specific stuff. 1570 * - encoding: Set by user. 1571 * - decoding: Set by user. 1572 */ 1573 void* opaque; 1574 1575 /** 1576 * the average bitrate 1577 * - encoding: Set by user; unused for constant quantizer encoding. 1578 * - decoding: Set by user, may be overwritten by libavcodec 1579 * if this info is available in the stream 1580 */ 1581 long bit_rate; 1582 1583 /** 1584 * number of bits the bitstream is allowed to diverge from the reference. 1585 * the reference can be CBR (for CBR pass1) or VBR (for pass2) 1586 * - encoding: Set by user; unused for constant quantizer encoding. 1587 * - decoding: unused 1588 */ 1589 int bit_rate_tolerance; 1590 1591 /** 1592 * Global quality for codecs which cannot change it per frame. 1593 * This should be proportional to MPEG-1/2/4 qscale. 1594 * - encoding: Set by user. 1595 * - decoding: unused 1596 */ 1597 int global_quality; 1598 1599 /** 1600 * - encoding: Set by user. 1601 * - decoding: unused 1602 */ 1603 int compression_level; 1604 1605 /** 1606 * AV_CODEC_FLAG_*. 1607 * - encoding: Set by user. 1608 * - decoding: Set by user. 1609 */ 1610 int flags; 1611 1612 /** 1613 * AV_CODEC_FLAG2_* 1614 * - encoding: Set by user. 1615 * - decoding: Set by user. 1616 */ 1617 int flags2; 1618 1619 /** 1620 * some codecs need / can use extradata like Huffman tables. 1621 * MJPEG: Huffman tables 1622 * rv10: additional flags 1623 * MPEG-4: global headers (they can be in the bitstream or here) 1624 * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger 1625 * than extradata_size to avoid problems if it is read with the bitstream reader. 1626 * The bytewise contents of extradata must not depend on the architecture or CPU endianness. 1627 * Must be allocated with the av_malloc() family of functions. 1628 * - encoding: Set/allocated/freed by libavcodec. 1629 * - decoding: Set/allocated/freed by user. 1630 */ 1631 ubyte* extradata; 1632 int extradata_size; 1633 1634 /** 1635 * This is the fundamental unit of time (in seconds) in terms 1636 * of which frame timestamps are represented. For fixed-fps content, 1637 * timebase should be 1/framerate and timestamp increments should be 1638 * identically 1. 1639 * This often, but not always is the inverse of the frame rate or field rate 1640 * for video. 1/time_base is not the average frame rate if the frame rate is not 1641 * constant. 1642 * 1643 * Like containers, elementary streams also can store timestamps, 1/time_base 1644 * is the unit in which these timestamps are specified. 1645 * As example of such codec time base see ISO/IEC 14496-2:2001(E) 1646 * vop_time_increment_resolution and fixed_vop_rate 1647 * (fixed_vop_rate == 0 implies that it is different from the framerate) 1648 * 1649 * - encoding: MUST be set by user. 1650 * - decoding: the use of this field for decoding is deprecated. 1651 * Use framerate instead. 1652 */ 1653 AVRational time_base; 1654 1655 /** 1656 * For some codecs, the time base is closer to the field rate than the frame rate. 1657 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration 1658 * if no telecine is used ... 1659 * 1660 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. 1661 */ 1662 int ticks_per_frame; 1663 1664 /** 1665 * Codec delay. 1666 * 1667 * Encoding: Number of frames delay there will be from the encoder input to 1668 * the decoder output. (we assume the decoder matches the spec) 1669 * Decoding: Number of frames delay in addition to what a standard decoder 1670 * as specified in the spec would produce. 1671 * 1672 * Video: 1673 * Number of frames the decoded output will be delayed relative to the 1674 * encoded input. 1675 * 1676 * Audio: 1677 * For encoding, this field is unused (see initial_padding). 1678 * 1679 * For decoding, this is the number of samples the decoder needs to 1680 * output before the decoder's output is valid. When seeking, you should 1681 * start decoding this many samples prior to your desired seek point. 1682 * 1683 * - encoding: Set by libavcodec. 1684 * - decoding: Set by libavcodec. 1685 */ 1686 int delay; 1687 1688 /* video only */ 1689 /** 1690 * picture width / height. 1691 * 1692 * @note Those fields may not match the values of the last 1693 * AVFrame output by avcodec_decode_video2 due frame 1694 * reordering. 1695 * 1696 * - encoding: MUST be set by user. 1697 * - decoding: May be set by the user before opening the decoder if known e.g. 1698 * from the container. Some decoders will require the dimensions 1699 * to be set by the caller. During decoding, the decoder may 1700 * overwrite those values as required while parsing the data. 1701 */ 1702 int width; 1703 int height; 1704 1705 /** 1706 * Bitstream width / height, may be different from width/height e.g. when 1707 * the decoded frame is cropped before being output or lowres is enabled. 1708 * 1709 * @note Those field may not match the value of the last 1710 * AVFrame output by avcodec_receive_frame() due frame 1711 * reordering. 1712 * 1713 * - encoding: unused 1714 * - decoding: May be set by the user before opening the decoder if known 1715 * e.g. from the container. During decoding, the decoder may 1716 * overwrite those values as required while parsing the data. 1717 */ 1718 int coded_width; 1719 int coded_height; 1720 1721 /** 1722 * the number of pictures in a group of pictures, or 0 for intra_only 1723 * - encoding: Set by user. 1724 * - decoding: unused 1725 */ 1726 int gop_size; 1727 1728 /** 1729 * Pixel format, see AV_PIX_FMT_xxx. 1730 * May be set by the demuxer if known from headers. 1731 * May be overridden by the decoder if it knows better. 1732 * 1733 * @note This field may not match the value of the last 1734 * AVFrame output by avcodec_receive_frame() due frame 1735 * reordering. 1736 * 1737 * - encoding: Set by user. 1738 * - decoding: Set by user if known, overridden by libavcodec while 1739 * parsing the data. 1740 */ 1741 AVPixelFormat pix_fmt; 1742 1743 /** 1744 * If non NULL, 'draw_horiz_band' is called by the libavcodec 1745 * decoder to draw a horizontal band. It improves cache usage. Not 1746 * all codecs can do that. You must check the codec capabilities 1747 * beforehand. 1748 * When multithreading is used, it may be called from multiple threads 1749 * at the same time; threads might draw different parts of the same AVFrame, 1750 * or multiple AVFrames, and there is no guarantee that slices will be drawn 1751 * in order. 1752 * The function is also used by hardware acceleration APIs. 1753 * It is called at least once during frame decoding to pass 1754 * the data needed for hardware render. 1755 * In that mode instead of pixel data, AVFrame points to 1756 * a structure specific to the acceleration API. The application 1757 * reads the structure and can change some fields to indicate progress 1758 * or mark state. 1759 * - encoding: unused 1760 * - decoding: Set by user. 1761 * @param height the height of the slice 1762 * @param y the y position of the slice 1763 * @param type 1->top field, 2->bottom field, 3->frame 1764 * @param offset offset into the AVFrame.data from which the slice should be read 1765 */ 1766 void function ( 1767 AVCodecContext* s, 1768 const(AVFrame)* src, 1769 int[AV_NUM_DATA_POINTERS] offset, 1770 int y, 1771 int type, 1772 int height) draw_horiz_band; 1773 1774 /** 1775 * callback to negotiate the pixelFormat 1776 * @param fmt is the list of formats which are supported by the codec, 1777 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. 1778 * The first is always the native one. 1779 * @note The callback may be called again immediately if initialization for 1780 * the selected (hardware-accelerated) pixel format failed. 1781 * @warning Behavior is undefined if the callback returns a value not 1782 * in the fmt list of formats. 1783 * @return the chosen format 1784 * - encoding: unused 1785 * - decoding: Set by user, if not set the native format will be chosen. 1786 */ 1787 AVPixelFormat function (AVCodecContext* s, const(AVPixelFormat)* fmt) get_format; 1788 1789 /** 1790 * maximum number of B-frames between non-B-frames 1791 * Note: The output will be delayed by max_b_frames+1 relative to the input. 1792 * - encoding: Set by user. 1793 * - decoding: unused 1794 */ 1795 int max_b_frames; 1796 1797 /** 1798 * qscale factor between IP and B-frames 1799 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). 1800 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). 1801 * - encoding: Set by user. 1802 * - decoding: unused 1803 */ 1804 float b_quant_factor; 1805 1806 /** @deprecated use encoder private options instead */ 1807 int b_frame_strategy; 1808 1809 /** 1810 * qscale offset between IP and B-frames 1811 * - encoding: Set by user. 1812 * - decoding: unused 1813 */ 1814 float b_quant_offset; 1815 1816 /** 1817 * Size of the frame reordering buffer in the decoder. 1818 * For MPEG-2 it is 1 IPB or 0 low delay IP. 1819 * - encoding: Set by libavcodec. 1820 * - decoding: Set by libavcodec. 1821 */ 1822 int has_b_frames; 1823 1824 /** @deprecated use encoder private options instead */ 1825 int mpeg_quant; 1826 1827 /** 1828 * qscale factor between P- and I-frames 1829 * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset). 1830 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). 1831 * - encoding: Set by user. 1832 * - decoding: unused 1833 */ 1834 float i_quant_factor; 1835 1836 /** 1837 * qscale offset between P and I-frames 1838 * - encoding: Set by user. 1839 * - decoding: unused 1840 */ 1841 float i_quant_offset; 1842 1843 /** 1844 * luminance masking (0-> disabled) 1845 * - encoding: Set by user. 1846 * - decoding: unused 1847 */ 1848 float lumi_masking; 1849 1850 /** 1851 * temporary complexity masking (0-> disabled) 1852 * - encoding: Set by user. 1853 * - decoding: unused 1854 */ 1855 float temporal_cplx_masking; 1856 1857 /** 1858 * spatial complexity masking (0-> disabled) 1859 * - encoding: Set by user. 1860 * - decoding: unused 1861 */ 1862 float spatial_cplx_masking; 1863 1864 /** 1865 * p block masking (0-> disabled) 1866 * - encoding: Set by user. 1867 * - decoding: unused 1868 */ 1869 float p_masking; 1870 1871 /** 1872 * darkness masking (0-> disabled) 1873 * - encoding: Set by user. 1874 * - decoding: unused 1875 */ 1876 float dark_masking; 1877 1878 /** 1879 * slice count 1880 * - encoding: Set by libavcodec. 1881 * - decoding: Set by user (or 0). 1882 */ 1883 int slice_count; 1884 1885 /** @deprecated use encoder private options instead */ 1886 int prediction_method; 1887 1888 /** 1889 * slice offsets in the frame in bytes 1890 * - encoding: Set/allocated by libavcodec. 1891 * - decoding: Set/allocated by user (or NULL). 1892 */ 1893 int* slice_offset; 1894 1895 /** 1896 * sample aspect ratio (0 if unknown) 1897 * That is the width of a pixel divided by the height of the pixel. 1898 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. 1899 * - encoding: Set by user. 1900 * - decoding: Set by libavcodec. 1901 */ 1902 AVRational sample_aspect_ratio; 1903 1904 /** 1905 * motion estimation comparison function 1906 * - encoding: Set by user. 1907 * - decoding: unused 1908 */ 1909 int me_cmp; 1910 /** 1911 * subpixel motion estimation comparison function 1912 * - encoding: Set by user. 1913 * - decoding: unused 1914 */ 1915 int me_sub_cmp; 1916 /** 1917 * macroblock comparison function (not supported yet) 1918 * - encoding: Set by user. 1919 * - decoding: unused 1920 */ 1921 int mb_cmp; 1922 /** 1923 * interlaced DCT comparison function 1924 * - encoding: Set by user. 1925 * - decoding: unused 1926 */ 1927 int ildct_cmp; 1928 1929 /** 1930 * ME diamond size & shape 1931 * - encoding: Set by user. 1932 * - decoding: unused 1933 */ 1934 int dia_size; 1935 1936 /** 1937 * amount of previous MV predictors (2a+1 x 2a+1 square) 1938 * - encoding: Set by user. 1939 * - decoding: unused 1940 */ 1941 int last_predictor_count; 1942 1943 /** @deprecated use encoder private options instead */ 1944 int pre_me; 1945 1946 /** 1947 * motion estimation prepass comparison function 1948 * - encoding: Set by user. 1949 * - decoding: unused 1950 */ 1951 int me_pre_cmp; 1952 1953 /** 1954 * ME prepass diamond size & shape 1955 * - encoding: Set by user. 1956 * - decoding: unused 1957 */ 1958 int pre_dia_size; 1959 1960 /** 1961 * subpel ME quality 1962 * - encoding: Set by user. 1963 * - decoding: unused 1964 */ 1965 int me_subpel_quality; 1966 1967 /** 1968 * maximum motion estimation search range in subpel units 1969 * If 0 then no limit. 1970 * 1971 * - encoding: Set by user. 1972 * - decoding: unused 1973 */ 1974 int me_range; 1975 1976 /** 1977 * slice flags 1978 * - encoding: unused 1979 * - decoding: Set by user. 1980 */ 1981 int slice_flags; 1982 ///< draw_horiz_band() is called in coded order instead of display 1983 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics) 1984 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) 1985 1986 /** 1987 * macroblock decision mode 1988 * - encoding: Set by user. 1989 * - decoding: unused 1990 */ 1991 int mb_decision; 1992 ///< uses mb_cmp 1993 ///< chooses the one which needs the fewest bits 1994 ///< rate distortion 1995 1996 /** 1997 * custom intra quantization matrix 1998 * - encoding: Set by user, can be NULL. 1999 * - decoding: Set by libavcodec. 2000 */ 2001 ushort* intra_matrix; 2002 2003 /** 2004 * custom inter quantization matrix 2005 * - encoding: Set by user, can be NULL. 2006 * - decoding: Set by libavcodec. 2007 */ 2008 ushort* inter_matrix; 2009 2010 /** @deprecated use encoder private options instead */ 2011 int scenechange_threshold; 2012 2013 /** @deprecated use encoder private options instead */ 2014 int noise_reduction; 2015 2016 /** 2017 * precision of the intra DC coefficient - 8 2018 * - encoding: Set by user. 2019 * - decoding: Set by libavcodec 2020 */ 2021 int intra_dc_precision; 2022 2023 /** 2024 * Number of macroblock rows at the top which are skipped. 2025 * - encoding: unused 2026 * - decoding: Set by user. 2027 */ 2028 int skip_top; 2029 2030 /** 2031 * Number of macroblock rows at the bottom which are skipped. 2032 * - encoding: unused 2033 * - decoding: Set by user. 2034 */ 2035 int skip_bottom; 2036 2037 /** 2038 * minimum MB Lagrange multiplier 2039 * - encoding: Set by user. 2040 * - decoding: unused 2041 */ 2042 int mb_lmin; 2043 2044 /** 2045 * maximum MB Lagrange multiplier 2046 * - encoding: Set by user. 2047 * - decoding: unused 2048 */ 2049 int mb_lmax; 2050 2051 /** 2052 * @deprecated use encoder private options instead 2053 */ 2054 int me_penalty_compensation; 2055 2056 /** 2057 * - encoding: Set by user. 2058 * - decoding: unused 2059 */ 2060 int bidir_refine; 2061 2062 /** @deprecated use encoder private options instead */ 2063 int brd_scale; 2064 2065 /** 2066 * minimum GOP size 2067 * - encoding: Set by user. 2068 * - decoding: unused 2069 */ 2070 int keyint_min; 2071 2072 /** 2073 * number of reference frames 2074 * - encoding: Set by user. 2075 * - decoding: Set by lavc. 2076 */ 2077 int refs; 2078 2079 /** @deprecated use encoder private options instead */ 2080 int chromaoffset; 2081 2082 /** 2083 * Note: Value depends upon the compare function used for fullpel ME. 2084 * - encoding: Set by user. 2085 * - decoding: unused 2086 */ 2087 int mv0_threshold; 2088 2089 /** @deprecated use encoder private options instead */ 2090 int b_sensitivity; 2091 2092 /** 2093 * Chromaticity coordinates of the source primaries. 2094 * - encoding: Set by user 2095 * - decoding: Set by libavcodec 2096 */ 2097 AVColorPrimaries color_primaries; 2098 2099 /** 2100 * Color Transfer Characteristic. 2101 * - encoding: Set by user 2102 * - decoding: Set by libavcodec 2103 */ 2104 AVColorTransferCharacteristic color_trc; 2105 2106 /** 2107 * YUV colorspace type. 2108 * - encoding: Set by user 2109 * - decoding: Set by libavcodec 2110 */ 2111 AVColorSpace colorspace; 2112 2113 /** 2114 * MPEG vs JPEG YUV range. 2115 * - encoding: Set by user 2116 * - decoding: Set by libavcodec 2117 */ 2118 AVColorRange color_range; 2119 2120 /** 2121 * This defines the location of chroma samples. 2122 * - encoding: Set by user 2123 * - decoding: Set by libavcodec 2124 */ 2125 AVChromaLocation chroma_sample_location; 2126 2127 /** 2128 * Number of slices. 2129 * Indicates number of picture subdivisions. Used for parallelized 2130 * decoding. 2131 * - encoding: Set by user 2132 * - decoding: unused 2133 */ 2134 int slices; 2135 2136 /** Field order 2137 * - encoding: set by libavcodec 2138 * - decoding: Set by user. 2139 */ 2140 AVFieldOrder field_order; 2141 2142 /* audio only */ 2143 int sample_rate; ///< samples per second 2144 int channels; ///< number of audio channels 2145 2146 /** 2147 * audio sample format 2148 * - encoding: Set by user. 2149 * - decoding: Set by libavcodec. 2150 */ 2151 AVSampleFormat sample_fmt; ///< sample format 2152 2153 /* The following data should not be initialized. */ 2154 /** 2155 * Number of samples per channel in an audio frame. 2156 * 2157 * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame 2158 * except the last must contain exactly frame_size samples per channel. 2159 * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the 2160 * frame size is not restricted. 2161 * - decoding: may be set by some decoders to indicate constant frame size 2162 */ 2163 int frame_size; 2164 2165 /** 2166 * Frame counter, set by libavcodec. 2167 * 2168 * - decoding: total number of frames returned from the decoder so far. 2169 * - encoding: total number of frames passed to the encoder so far. 2170 * 2171 * @note the counter is not incremented if encoding/decoding resulted in 2172 * an error. 2173 */ 2174 int frame_number; 2175 2176 /** 2177 * number of bytes per packet if constant and known or 0 2178 * Used by some WAV based audio codecs. 2179 */ 2180 int block_align; 2181 2182 /** 2183 * Audio cutoff bandwidth (0 means "automatic") 2184 * - encoding: Set by user. 2185 * - decoding: unused 2186 */ 2187 int cutoff; 2188 2189 /** 2190 * Audio channel layout. 2191 * - encoding: set by user. 2192 * - decoding: set by user, may be overwritten by libavcodec. 2193 */ 2194 ulong channel_layout; 2195 2196 /** 2197 * Request decoder to use this channel layout if it can (0 for default) 2198 * - encoding: unused 2199 * - decoding: Set by user. 2200 */ 2201 ulong request_channel_layout; 2202 2203 /** 2204 * Type of service that the audio stream conveys. 2205 * - encoding: Set by user. 2206 * - decoding: Set by libavcodec. 2207 */ 2208 AVAudioServiceType audio_service_type; 2209 2210 /** 2211 * desired sample format 2212 * - encoding: Not used. 2213 * - decoding: Set by user. 2214 * Decoder will decode to this format if it can. 2215 */ 2216 AVSampleFormat request_sample_fmt; 2217 2218 /** 2219 * This callback is called at the beginning of each frame to get data 2220 * buffer(s) for it. There may be one contiguous buffer for all the data or 2221 * there may be a buffer per each data plane or anything in between. What 2222 * this means is, you may set however many entries in buf[] you feel necessary. 2223 * Each buffer must be reference-counted using the AVBuffer API (see description 2224 * of buf[] below). 2225 * 2226 * The following fields will be set in the frame before this callback is 2227 * called: 2228 * - format 2229 * - width, height (video only) 2230 * - sample_rate, channel_layout, nb_samples (audio only) 2231 * Their values may differ from the corresponding values in 2232 * AVCodecContext. This callback must use the frame values, not the codec 2233 * context values, to calculate the required buffer size. 2234 * 2235 * This callback must fill the following fields in the frame: 2236 * - data[] 2237 * - linesize[] 2238 * - extended_data: 2239 * * if the data is planar audio with more than 8 channels, then this 2240 * callback must allocate and fill extended_data to contain all pointers 2241 * to all data planes. data[] must hold as many pointers as it can. 2242 * extended_data must be allocated with av_malloc() and will be freed in 2243 * av_frame_unref(). 2244 * * otherwise extended_data must point to data 2245 * - buf[] must contain one or more pointers to AVBufferRef structures. Each of 2246 * the frame's data and extended_data pointers must be contained in these. That 2247 * is, one AVBufferRef for each allocated chunk of memory, not necessarily one 2248 * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(), 2249 * and av_buffer_ref(). 2250 * - extended_buf and nb_extended_buf must be allocated with av_malloc() by 2251 * this callback and filled with the extra buffers if there are more 2252 * buffers than buf[] can hold. extended_buf will be freed in 2253 * av_frame_unref(). 2254 * 2255 * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call 2256 * avcodec_default_get_buffer2() instead of providing buffers allocated by 2257 * some other means. 2258 * 2259 * Each data plane must be aligned to the maximum required by the target 2260 * CPU. 2261 * 2262 * @see avcodec_default_get_buffer2() 2263 * 2264 * Video: 2265 * 2266 * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused 2267 * (read and/or written to if it is writable) later by libavcodec. 2268 * 2269 * avcodec_align_dimensions2() should be used to find the required width and 2270 * height, as they normally need to be rounded up to the next multiple of 16. 2271 * 2272 * Some decoders do not support linesizes changing between frames. 2273 * 2274 * If frame multithreading is used and thread_safe_callbacks is set, 2275 * this callback may be called from a different thread, but not from more 2276 * than one at once. Does not need to be reentrant. 2277 * 2278 * @see avcodec_align_dimensions2() 2279 * 2280 * Audio: 2281 * 2282 * Decoders request a buffer of a particular size by setting 2283 * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may, 2284 * however, utilize only part of the buffer by setting AVFrame.nb_samples 2285 * to a smaller value in the output frame. 2286 * 2287 * As a convenience, av_samples_get_buffer_size() and 2288 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2() 2289 * functions to find the required data size and to fill data pointers and 2290 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio 2291 * since all planes must be the same size. 2292 * 2293 * @see av_samples_get_buffer_size(), av_samples_fill_arrays() 2294 * 2295 * - encoding: unused 2296 * - decoding: Set by libavcodec, user can override. 2297 */ 2298 int function (AVCodecContext* s, AVFrame* frame, int flags) get_buffer2; 2299 2300 /** 2301 * If non-zero, the decoded audio and video frames returned from 2302 * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted 2303 * and are valid indefinitely. The caller must free them with 2304 * av_frame_unref() when they are not needed anymore. 2305 * Otherwise, the decoded frames must not be freed by the caller and are 2306 * only valid until the next decode call. 2307 * 2308 * This is always automatically enabled if avcodec_receive_frame() is used. 2309 * 2310 * - encoding: unused 2311 * - decoding: set by the caller before avcodec_open2(). 2312 */ 2313 int refcounted_frames; 2314 2315 /* - encoding parameters */ 2316 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) 2317 float qblur; ///< amount of qscale smoothing over time (0.0-1.0) 2318 2319 /** 2320 * minimum quantizer 2321 * - encoding: Set by user. 2322 * - decoding: unused 2323 */ 2324 int qmin; 2325 2326 /** 2327 * maximum quantizer 2328 * - encoding: Set by user. 2329 * - decoding: unused 2330 */ 2331 int qmax; 2332 2333 /** 2334 * maximum quantizer difference between frames 2335 * - encoding: Set by user. 2336 * - decoding: unused 2337 */ 2338 int max_qdiff; 2339 2340 /** 2341 * decoder bitstream buffer size 2342 * - encoding: Set by user. 2343 * - decoding: unused 2344 */ 2345 int rc_buffer_size; 2346 2347 /** 2348 * ratecontrol override, see RcOverride 2349 * - encoding: Allocated/set/freed by user. 2350 * - decoding: unused 2351 */ 2352 int rc_override_count; 2353 RcOverride* rc_override; 2354 2355 /** 2356 * maximum bitrate 2357 * - encoding: Set by user. 2358 * - decoding: Set by user, may be overwritten by libavcodec. 2359 */ 2360 long rc_max_rate; 2361 2362 /** 2363 * minimum bitrate 2364 * - encoding: Set by user. 2365 * - decoding: unused 2366 */ 2367 long rc_min_rate; 2368 2369 /** 2370 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow. 2371 * - encoding: Set by user. 2372 * - decoding: unused. 2373 */ 2374 float rc_max_available_vbv_use; 2375 2376 /** 2377 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow. 2378 * - encoding: Set by user. 2379 * - decoding: unused. 2380 */ 2381 float rc_min_vbv_overflow_use; 2382 2383 /** 2384 * Number of bits which should be loaded into the rc buffer before decoding starts. 2385 * - encoding: Set by user. 2386 * - decoding: unused 2387 */ 2388 int rc_initial_buffer_occupancy; 2389 2390 /** 2391 * @deprecated use encoder private options instead 2392 */ 2393 int coder_type; 2394 /* FF_API_CODER_TYPE */ 2395 2396 /** @deprecated use encoder private options instead */ 2397 int context_model; 2398 2399 /** @deprecated use encoder private options instead */ 2400 int frame_skip_threshold; 2401 2402 /** @deprecated use encoder private options instead */ 2403 int frame_skip_factor; 2404 2405 /** @deprecated use encoder private options instead */ 2406 int frame_skip_exp; 2407 2408 /** @deprecated use encoder private options instead */ 2409 int frame_skip_cmp; 2410 /* FF_API_PRIVATE_OPT */ 2411 2412 /** 2413 * trellis RD quantization 2414 * - encoding: Set by user. 2415 * - decoding: unused 2416 */ 2417 int trellis; 2418 2419 /** @deprecated use encoder private options instead */ 2420 int min_prediction_order; 2421 2422 /** @deprecated use encoder private options instead */ 2423 int max_prediction_order; 2424 2425 /** @deprecated use encoder private options instead */ 2426 long timecode_frame_start; 2427 2428 /** 2429 * @deprecated unused 2430 */ 2431 /* The RTP callback: This function is called */ 2432 /* every time the encoder has a packet to send. */ 2433 /* It depends on the encoder if the data starts */ 2434 /* with a Start Code (it should). H.263 does. */ 2435 /* mb_nb contains the number of macroblocks */ 2436 /* encoded in the RTP payload. */ 2437 void function ( 2438 AVCodecContext* avctx, 2439 void* data, 2440 int size, 2441 int mb_nb) rtp_callback; 2442 2443 /** @deprecated use encoder private options instead */ 2444 int rtp_payload_size; /* The size of the RTP payload: the coder will */ 2445 /* do its best to deliver a chunk with size */ 2446 /* below rtp_payload_size, the chunk will start */ 2447 /* with a start code on some codecs like H.263. */ 2448 /* This doesn't take account of any particular */ 2449 /* headers inside the transmitted RTP payload. */ 2450 2451 /* statistics, used for 2-pass encoding */ 2452 int mv_bits; 2453 int header_bits; 2454 int i_tex_bits; 2455 int p_tex_bits; 2456 int i_count; 2457 int p_count; 2458 int skip_count; 2459 int misc_bits; 2460 2461 /** @deprecated this field is unused */ 2462 int frame_bits; 2463 2464 /** 2465 * pass1 encoding statistics output buffer 2466 * - encoding: Set by libavcodec. 2467 * - decoding: unused 2468 */ 2469 char* stats_out; 2470 2471 /** 2472 * pass2 encoding statistics input buffer 2473 * Concatenated stuff from stats_out of pass1 should be placed here. 2474 * - encoding: Allocated/set/freed by user. 2475 * - decoding: unused 2476 */ 2477 char* stats_in; 2478 2479 /** 2480 * Work around bugs in encoders which sometimes cannot be detected automatically. 2481 * - encoding: Set by user 2482 * - decoding: Set by user 2483 */ 2484 int workaround_bugs; 2485 ///< autodetection 2486 2487 ///< Work around various bugs in Microsoft's broken decoders. 2488 2489 /** 2490 * strictly follow the standard (MPEG-4, ...). 2491 * - encoding: Set by user. 2492 * - decoding: Set by user. 2493 * Setting this to STRICT or higher means the encoder and decoder will 2494 * generally do stupid things, whereas setting it to unofficial or lower 2495 * will mean the encoder might produce output that is not supported by all 2496 * spec-compliant decoders. Decoders don't differentiate between normal, 2497 * unofficial and experimental (that is, they always try to decode things 2498 * when they can) unless they are explicitly asked to behave stupidly 2499 * (=strictly conform to the specs) 2500 */ 2501 int strict_std_compliance; 2502 ///< Strictly conform to an older more strict version of the spec or reference software. 2503 ///< Strictly conform to all the things in the spec no matter what consequences. 2504 2505 ///< Allow unofficial extensions 2506 ///< Allow nonstandardized experimental things. 2507 2508 /** 2509 * error concealment flags 2510 * - encoding: unused 2511 * - decoding: Set by user. 2512 */ 2513 int error_concealment; 2514 2515 /** 2516 * debug 2517 * - encoding: Set by user. 2518 * - decoding: Set by user. 2519 */ 2520 int debug_; 2521 2522 /** 2523 * @deprecated this option does nothing 2524 */ 2525 2526 /** 2527 * debug 2528 * - encoding: Set by user. 2529 * - decoding: Set by user. 2530 */ 2531 2532 // visualize forward predicted MVs of P-frames 2533 // visualize forward predicted MVs of B-frames 2534 // visualize backward predicted MVs of B-frames 2535 2536 /** 2537 * Error recognition; may misdetect some more or less valid parts as errors. 2538 * - encoding: unused 2539 * - decoding: Set by user. 2540 */ 2541 int err_recognition; 2542 2543 /** 2544 * Verify checksums embedded in the bitstream (could be of either encoded or 2545 * decoded data, depending on the codec) and print an error message on mismatch. 2546 * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the 2547 * decoder returning an error. 2548 */ 2549 2550 ///< detect bitstream specification deviations 2551 ///< detect improper bitstream length 2552 ///< abort decoding on minor error detection 2553 2554 ///< ignore errors and continue 2555 ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors 2556 ///< consider all spec non compliances as errors 2557 ///< consider things that a sane encoder should not do as an error 2558 2559 /** 2560 * opaque 64-bit number (generally a PTS) that will be reordered and 2561 * output in AVFrame.reordered_opaque 2562 * - encoding: unused 2563 * - decoding: Set by user. 2564 */ 2565 long reordered_opaque; 2566 2567 /** 2568 * Hardware accelerator in use 2569 * - encoding: unused. 2570 * - decoding: Set by libavcodec 2571 */ 2572 const(AVHWAccel)* hwaccel; 2573 2574 /** 2575 * Hardware accelerator context. 2576 * For some hardware accelerators, a global context needs to be 2577 * provided by the user. In that case, this holds display-dependent 2578 * data FFmpeg cannot instantiate itself. Please refer to the 2579 * FFmpeg HW accelerator documentation to know how to fill this 2580 * is. e.g. for VA API, this is a struct vaapi_context. 2581 * - encoding: unused 2582 * - decoding: Set by user 2583 */ 2584 void* hwaccel_context; 2585 2586 /** 2587 * error 2588 * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR. 2589 * - decoding: unused 2590 */ 2591 ulong[AV_NUM_DATA_POINTERS] error; 2592 2593 /** 2594 * DCT algorithm, see FF_DCT_* below 2595 * - encoding: Set by user. 2596 * - decoding: unused 2597 */ 2598 int dct_algo; 2599 2600 /** 2601 * IDCT algorithm, see FF_IDCT_* below. 2602 * - encoding: Set by user. 2603 * - decoding: Set by user. 2604 */ 2605 int idct_algo; 2606 2607 /* Used by XvMC to extract IDCT coefficients with FF_IDCT_PERM_NONE */ 2608 2609 /** 2610 * bits per sample/pixel from the demuxer (needed for huffyuv). 2611 * - encoding: Set by libavcodec. 2612 * - decoding: Set by user. 2613 */ 2614 int bits_per_coded_sample; 2615 2616 /** 2617 * Bits per sample/pixel of internal libavcodec pixel/sample format. 2618 * - encoding: set by user. 2619 * - decoding: set by libavcodec. 2620 */ 2621 int bits_per_raw_sample; 2622 2623 /** 2624 * low resolution decoding, 1-> 1/2 size, 2->1/4 size 2625 * - encoding: unused 2626 * - decoding: Set by user. 2627 */ 2628 int lowres; 2629 2630 /** 2631 * the picture in the bitstream 2632 * - encoding: Set by libavcodec. 2633 * - decoding: unused 2634 * 2635 * @deprecated use the quality factor packet side data instead 2636 */ 2637 AVFrame* coded_frame; 2638 2639 /** 2640 * thread count 2641 * is used to decide how many independent tasks should be passed to execute() 2642 * - encoding: Set by user. 2643 * - decoding: Set by user. 2644 */ 2645 int thread_count; 2646 2647 /** 2648 * Which multithreading methods to use. 2649 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread, 2650 * so clients which cannot provide future frames should not use it. 2651 * 2652 * - encoding: Set by user, otherwise the default is used. 2653 * - decoding: Set by user, otherwise the default is used. 2654 */ 2655 int thread_type; 2656 ///< Decode more than one frame at once 2657 ///< Decode more than one part of a single frame at once 2658 2659 /** 2660 * Which multithreading methods are in use by the codec. 2661 * - encoding: Set by libavcodec. 2662 * - decoding: Set by libavcodec. 2663 */ 2664 int active_thread_type; 2665 2666 /** 2667 * Set by the client if its custom get_buffer() callback can be called 2668 * synchronously from another thread, which allows faster multithreaded decoding. 2669 * draw_horiz_band() will be called from other threads regardless of this setting. 2670 * Ignored if the default get_buffer() is used. 2671 * - encoding: Set by user. 2672 * - decoding: Set by user. 2673 */ 2674 int thread_safe_callbacks; 2675 2676 /** 2677 * The codec may call this to execute several independent things. 2678 * It will return only after finishing all tasks. 2679 * The user may replace this with some multithreaded implementation, 2680 * the default implementation will execute the parts serially. 2681 * @param count the number of things to execute 2682 * - encoding: Set by libavcodec, user can override. 2683 * - decoding: Set by libavcodec, user can override. 2684 */ 2685 int function (AVCodecContext* c, int function (AVCodecContext* c2, void* arg) func, void* arg2, int* ret, int count, int size) execute; 2686 2687 /** 2688 * The codec may call this to execute several independent things. 2689 * It will return only after finishing all tasks. 2690 * The user may replace this with some multithreaded implementation, 2691 * the default implementation will execute the parts serially. 2692 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. 2693 * @param c context passed also to func 2694 * @param count the number of things to execute 2695 * @param arg2 argument passed unchanged to func 2696 * @param ret return values of executed functions, must have space for "count" values. May be NULL. 2697 * @param func function that will be called count times, with jobnr from 0 to count-1. 2698 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no 2699 * two instances of func executing at the same time will have the same threadnr. 2700 * @return always 0 currently, but code should handle a future improvement where when any call to func 2701 * returns < 0 no further calls to func may be done and < 0 is returned. 2702 * - encoding: Set by libavcodec, user can override. 2703 * - decoding: Set by libavcodec, user can override. 2704 */ 2705 int function (AVCodecContext* c, int function (AVCodecContext* c2, void* arg, int jobnr, int threadnr) func, void* arg2, int* ret, int count) execute2; 2706 2707 /** 2708 * noise vs. sse weight for the nsse comparison function 2709 * - encoding: Set by user. 2710 * - decoding: unused 2711 */ 2712 int nsse_weight; 2713 2714 /** 2715 * profile 2716 * - encoding: Set by user. 2717 * - decoding: Set by libavcodec. 2718 */ 2719 int profile; 2720 2721 // 8+1; constraint_set1_flag 2722 // 8+3; constraint_set3_flag 2723 2724 /** 2725 * level 2726 * - encoding: Set by user. 2727 * - decoding: Set by libavcodec. 2728 */ 2729 int level; 2730 2731 /** 2732 * Skip loop filtering for selected frames. 2733 * - encoding: unused 2734 * - decoding: Set by user. 2735 */ 2736 AVDiscard skip_loop_filter; 2737 2738 /** 2739 * Skip IDCT/dequantization for selected frames. 2740 * - encoding: unused 2741 * - decoding: Set by user. 2742 */ 2743 AVDiscard skip_idct; 2744 2745 /** 2746 * Skip decoding for selected frames. 2747 * - encoding: unused 2748 * - decoding: Set by user. 2749 */ 2750 AVDiscard skip_frame; 2751 2752 /** 2753 * Header containing style information for text subtitles. 2754 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS 2755 * [Script Info] and [V4+ Styles] section, plus the [Events] line and 2756 * the Format line following. It shouldn't include any Dialogue line. 2757 * - encoding: Set/allocated/freed by user (before avcodec_open2()) 2758 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) 2759 */ 2760 ubyte* subtitle_header; 2761 int subtitle_header_size; 2762 2763 /** 2764 * VBV delay coded in the last frame (in periods of a 27 MHz clock). 2765 * Used for compliant TS muxing. 2766 * - encoding: Set by libavcodec. 2767 * - decoding: unused. 2768 * @deprecated this value is now exported as a part of 2769 * AV_PKT_DATA_CPB_PROPERTIES packet side data 2770 */ 2771 ulong vbv_delay; 2772 2773 /** 2774 * Encoding only and set by default. Allow encoders to output packets 2775 * that do not contain any encoded data, only side data. 2776 * 2777 * Some encoders need to output such packets, e.g. to update some stream 2778 * parameters at the end of encoding. 2779 * 2780 * @deprecated this field disables the default behaviour and 2781 * it is kept only for compatibility. 2782 */ 2783 int side_data_only_packets; 2784 2785 /** 2786 * Audio only. The number of "priming" samples (padding) inserted by the 2787 * encoder at the beginning of the audio. I.e. this number of leading 2788 * decoded samples must be discarded by the caller to get the original audio 2789 * without leading padding. 2790 * 2791 * - decoding: unused 2792 * - encoding: Set by libavcodec. The timestamps on the output packets are 2793 * adjusted by the encoder so that they always refer to the 2794 * first sample of the data actually contained in the packet, 2795 * including any added padding. E.g. if the timebase is 2796 * 1/samplerate and the timestamp of the first input sample is 2797 * 0, the timestamp of the first output packet will be 2798 * -initial_padding. 2799 */ 2800 int initial_padding; 2801 2802 /** 2803 * - decoding: For codecs that store a framerate value in the compressed 2804 * bitstream, the decoder may export it here. { 0, 1} when 2805 * unknown. 2806 * - encoding: May be used to signal the framerate of CFR content to an 2807 * encoder. 2808 */ 2809 AVRational framerate; 2810 2811 /** 2812 * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx. 2813 * - encoding: unused. 2814 * - decoding: Set by libavcodec before calling get_format() 2815 */ 2816 AVPixelFormat sw_pix_fmt; 2817 2818 /** 2819 * Timebase in which pkt_dts/pts and AVPacket.dts/pts are. 2820 * - encoding unused. 2821 * - decoding set by user. 2822 */ 2823 AVRational pkt_timebase; 2824 2825 /** 2826 * AVCodecDescriptor 2827 * - encoding: unused. 2828 * - decoding: set by libavcodec. 2829 */ 2830 const(AVCodecDescriptor)* codec_descriptor; 2831 2832 /** 2833 * low resolution decoding, 1-> 1/2 size, 2->1/4 size 2834 * - encoding: unused 2835 * - decoding: Set by user. 2836 */ 2837 2838 /** 2839 * Current statistics for PTS correction. 2840 * - decoding: maintained and used by libavcodec, not intended to be used by user apps 2841 * - encoding: unused 2842 */ 2843 long pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far 2844 long pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far 2845 long pts_correction_last_pts; /// PTS of the last frame 2846 long pts_correction_last_dts; /// DTS of the last frame 2847 2848 /** 2849 * Character encoding of the input subtitles file. 2850 * - decoding: set by user 2851 * - encoding: unused 2852 */ 2853 char* sub_charenc; 2854 2855 /** 2856 * Subtitles character encoding mode. Formats or codecs might be adjusting 2857 * this setting (if they are doing the conversion themselves for instance). 2858 * - decoding: set by libavcodec 2859 * - encoding: unused 2860 */ 2861 int sub_charenc_mode; 2862 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance) 2863 ///< libavcodec will select the mode itself 2864 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv 2865 ///< neither convert the subtitles, nor check them for valid UTF-8 2866 2867 /** 2868 * Skip processing alpha if supported by codec. 2869 * Note that if the format uses pre-multiplied alpha (common with VP6, 2870 * and recommended due to better video quality/compression) 2871 * the image will look as if alpha-blended onto a black background. 2872 * However for formats that do not use pre-multiplied alpha 2873 * there might be serious artefacts (though e.g. libswscale currently 2874 * assumes pre-multiplied alpha anyway). 2875 * 2876 * - decoding: set by user 2877 * - encoding: unused 2878 */ 2879 int skip_alpha; 2880 2881 /** 2882 * Number of samples to skip after a discontinuity 2883 * - decoding: unused 2884 * - encoding: set by libavcodec 2885 */ 2886 int seek_preroll; 2887 2888 /** 2889 * debug motion vectors 2890 * - encoding: Set by user. 2891 * - decoding: Set by user. 2892 */ 2893 int debug_mv; 2894 //visualize forward predicted MVs of P frames 2895 //visualize forward predicted MVs of B frames 2896 //visualize backward predicted MVs of B frames 2897 2898 /** 2899 * custom intra quantization matrix 2900 * - encoding: Set by user, can be NULL. 2901 * - decoding: unused. 2902 */ 2903 ushort* chroma_intra_matrix; 2904 2905 /** 2906 * dump format separator. 2907 * can be ", " or "\n " or anything else 2908 * - encoding: Set by user. 2909 * - decoding: Set by user. 2910 */ 2911 ubyte* dump_separator; 2912 2913 /** 2914 * ',' separated list of allowed decoders. 2915 * If NULL then all are allowed 2916 * - encoding: unused 2917 * - decoding: set by user 2918 */ 2919 char* codec_whitelist; 2920 2921 /** 2922 * Properties of the stream that gets decoded 2923 * - encoding: unused 2924 * - decoding: set by libavcodec 2925 */ 2926 uint properties; 2927 2928 /** 2929 * Additional data associated with the entire coded stream. 2930 * 2931 * - decoding: unused 2932 * - encoding: may be set by libavcodec after avcodec_open2(). 2933 */ 2934 AVPacketSideData* coded_side_data; 2935 int nb_coded_side_data; 2936 2937 /** 2938 * A reference to the AVHWFramesContext describing the input (for encoding) 2939 * or output (decoding) frames. The reference is set by the caller and 2940 * afterwards owned (and freed) by libavcodec - it should never be read by 2941 * the caller after being set. 2942 * 2943 * - decoding: This field should be set by the caller from the get_format() 2944 * callback. The previous reference (if any) will always be 2945 * unreffed by libavcodec before the get_format() call. 2946 * 2947 * If the default get_buffer2() is used with a hwaccel pixel 2948 * format, then this AVHWFramesContext will be used for 2949 * allocating the frame buffers. 2950 * 2951 * - encoding: For hardware encoders configured to use a hwaccel pixel 2952 * format, this field should be set by the caller to a reference 2953 * to the AVHWFramesContext describing input frames. 2954 * AVHWFramesContext.format must be equal to 2955 * AVCodecContext.pix_fmt. 2956 * 2957 * This field should be set before avcodec_open2() is called. 2958 */ 2959 AVBufferRef* hw_frames_ctx; 2960 2961 /** 2962 * Control the form of AVSubtitle.rects[N]->ass 2963 * - decoding: set by user 2964 * - encoding: unused 2965 */ 2966 int sub_text_format; 2967 2968 /** 2969 * Audio only. The amount of padding (in samples) appended by the encoder to 2970 * the end of the audio. I.e. this number of decoded samples must be 2971 * discarded by the caller from the end of the stream to get the original 2972 * audio without any trailing padding. 2973 * 2974 * - decoding: unused 2975 * - encoding: unused 2976 */ 2977 int trailing_padding; 2978 2979 /** 2980 * The number of pixels per image to maximally accept. 2981 * 2982 * - decoding: set by user 2983 * - encoding: set by user 2984 */ 2985 long max_pixels; 2986 2987 /** 2988 * A reference to the AVHWDeviceContext describing the device which will 2989 * be used by a hardware encoder/decoder. The reference is set by the 2990 * caller and afterwards owned (and freed) by libavcodec. 2991 * 2992 * This should be used if either the codec device does not require 2993 * hardware frames or any that are used are to be allocated internally by 2994 * libavcodec. If the user wishes to supply any of the frames used as 2995 * encoder input or decoder output then hw_frames_ctx should be used 2996 * instead. When hw_frames_ctx is set in get_format() for a decoder, this 2997 * field will be ignored while decoding the associated stream segment, but 2998 * may again be used on a following one after another get_format() call. 2999 * 3000 * For both encoders and decoders this field should be set before 3001 * avcodec_open2() is called and must not be written to thereafter. 3002 * 3003 * Note that some decoders may require this field to be set initially in 3004 * order to support hw_frames_ctx at all - in that case, all frames 3005 * contexts used must be created on the same device. 3006 */ 3007 AVBufferRef* hw_device_ctx; 3008 3009 /** 3010 * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated 3011 * decoding (if active). 3012 * - encoding: unused 3013 * - decoding: Set by user (either before avcodec_open2(), or in the 3014 * AVCodecContext.get_format callback) 3015 */ 3016 int hwaccel_flags; 3017 3018 /** 3019 * Video decoding only. Certain video codecs support cropping, meaning that 3020 * only a sub-rectangle of the decoded frame is intended for display. This 3021 * option controls how cropping is handled by libavcodec. 3022 * 3023 * When set to 1 (the default), libavcodec will apply cropping internally. 3024 * I.e. it will modify the output frame width/height fields and offset the 3025 * data pointers (only by as much as possible while preserving alignment, or 3026 * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that 3027 * the frames output by the decoder refer only to the cropped area. The 3028 * crop_* fields of the output frames will be zero. 3029 * 3030 * When set to 0, the width/height fields of the output frames will be set 3031 * to the coded dimensions and the crop_* fields will describe the cropping 3032 * rectangle. Applying the cropping is left to the caller. 3033 * 3034 * @warning When hardware acceleration with opaque output frames is used, 3035 * libavcodec is unable to apply cropping from the top/left border. 3036 * 3037 * @note when this option is set to zero, the width/height fields of the 3038 * AVCodecContext and output AVFrames have different meanings. The codec 3039 * context fields store display dimensions (with the coded dimensions in 3040 * coded_width/height), while the frame fields store the coded dimensions 3041 * (with the display dimensions being determined by the crop_* fields). 3042 */ 3043 int apply_cropping; 3044 3045 /* 3046 * Video decoding only. Sets the number of extra hardware frames which 3047 * the decoder will allocate for use by the caller. This must be set 3048 * before avcodec_open2() is called. 3049 * 3050 * Some hardware decoders require all frames that they will use for 3051 * output to be defined in advance before decoding starts. For such 3052 * decoders, the hardware frame pool must therefore be of a fixed size. 3053 * The extra frames set here are on top of any number that the decoder 3054 * needs internally in order to operate normally (for example, frames 3055 * used as reference pictures). 3056 */ 3057 int extra_hw_frames; 3058 } 3059 3060 enum FF_COMPRESSION_DEFAULT = -1; 3061 enum FF_PRED_LEFT = 0; 3062 enum FF_PRED_PLANE = 1; 3063 enum FF_PRED_MEDIAN = 2; 3064 enum FF_CMP_SAD = 0; 3065 enum FF_CMP_SSE = 1; 3066 enum FF_CMP_SATD = 2; 3067 enum FF_CMP_DCT = 3; 3068 enum FF_CMP_PSNR = 4; 3069 enum FF_CMP_BIT = 5; 3070 enum FF_CMP_RD = 6; 3071 enum FF_CMP_ZERO = 7; 3072 enum FF_CMP_VSAD = 8; 3073 enum FF_CMP_VSSE = 9; 3074 enum FF_CMP_NSSE = 10; 3075 enum FF_CMP_W53 = 11; 3076 enum FF_CMP_W97 = 12; 3077 enum FF_CMP_DCTMAX = 13; 3078 enum FF_CMP_DCT264 = 14; 3079 enum FF_CMP_MEDIAN_SAD = 15; 3080 enum FF_CMP_CHROMA = 256; 3081 enum SLICE_FLAG_CODED_ORDER = 0x0001; 3082 enum SLICE_FLAG_ALLOW_FIELD = 0x0002; 3083 enum SLICE_FLAG_ALLOW_PLANE = 0x0004; 3084 enum FF_MB_DECISION_SIMPLE = 0; 3085 enum FF_MB_DECISION_BITS = 1; 3086 enum FF_MB_DECISION_RD = 2; 3087 enum FF_CODER_TYPE_VLC = 0; 3088 enum FF_CODER_TYPE_AC = 1; 3089 enum FF_CODER_TYPE_RAW = 2; 3090 enum FF_CODER_TYPE_RLE = 3; 3091 enum FF_BUG_AUTODETECT = 1; 3092 enum FF_BUG_XVID_ILACE = 4; 3093 enum FF_BUG_UMP4 = 8; 3094 enum FF_BUG_NO_PADDING = 16; 3095 enum FF_BUG_AMV = 32; 3096 enum FF_BUG_QPEL_CHROMA = 64; 3097 enum FF_BUG_STD_QPEL = 128; 3098 enum FF_BUG_QPEL_CHROMA2 = 256; 3099 enum FF_BUG_DIRECT_BLOCKSIZE = 512; 3100 enum FF_BUG_EDGE = 1024; 3101 enum FF_BUG_HPEL_CHROMA = 2048; 3102 enum FF_BUG_DC_CLIP = 4096; 3103 enum FF_BUG_MS = 8192; 3104 enum FF_BUG_TRUNCATED = 16384; 3105 enum FF_BUG_IEDGE = 32768; 3106 enum FF_COMPLIANCE_VERY_STRICT = 2; 3107 enum FF_COMPLIANCE_STRICT = 1; 3108 enum FF_COMPLIANCE_NORMAL = 0; 3109 enum FF_COMPLIANCE_UNOFFICIAL = -1; 3110 enum FF_COMPLIANCE_EXPERIMENTAL = -2; 3111 enum FF_EC_GUESS_MVS = 1; 3112 enum FF_EC_DEBLOCK = 2; 3113 enum FF_EC_FAVOR_INTER = 256; 3114 enum FF_DEBUG_PICT_INFO = 1; 3115 enum FF_DEBUG_RC = 2; 3116 enum FF_DEBUG_BITSTREAM = 4; 3117 enum FF_DEBUG_MB_TYPE = 8; 3118 enum FF_DEBUG_QP = 16; 3119 enum FF_DEBUG_DCT_COEFF = 0x00000040; 3120 enum FF_DEBUG_SKIP = 0x00000080; 3121 enum FF_DEBUG_STARTCODE = 0x00000100; 3122 enum FF_DEBUG_ER = 0x00000400; 3123 enum FF_DEBUG_MMCO = 0x00000800; 3124 enum FF_DEBUG_BUGS = 0x00001000; 3125 enum FF_DEBUG_BUFFERS = 0x00008000; 3126 enum FF_DEBUG_THREADS = 0x00010000; 3127 enum FF_DEBUG_GREEN_MD = 0x00800000; 3128 enum FF_DEBUG_NOMC = 0x01000000; 3129 enum AV_EF_CRCCHECK = 1 << 0; 3130 enum AV_EF_BITSTREAM = 1 << 1; 3131 enum AV_EF_BUFFER = 1 << 2; 3132 enum AV_EF_EXPLODE = 1 << 3; 3133 enum AV_EF_IGNORE_ERR = 1 << 15; 3134 enum AV_EF_CAREFUL = 1 << 16; 3135 enum AV_EF_COMPLIANT = 1 << 17; 3136 enum AV_EF_AGGRESSIVE = 1 << 18; 3137 enum FF_DCT_AUTO = 0; 3138 enum FF_DCT_FASTINT = 1; 3139 enum FF_DCT_INT = 2; 3140 enum FF_DCT_MMX = 3; 3141 enum FF_DCT_ALTIVEC = 5; 3142 enum FF_DCT_FAAN = 6; 3143 enum FF_IDCT_AUTO = 0; 3144 enum FF_IDCT_INT = 1; 3145 enum FF_IDCT_SIMPLE = 2; 3146 enum FF_IDCT_SIMPLEMMX = 3; 3147 enum FF_IDCT_ARM = 7; 3148 enum FF_IDCT_ALTIVEC = 8; 3149 enum FF_IDCT_SIMPLEARM = 10; 3150 enum FF_IDCT_XVID = 14; 3151 enum FF_IDCT_SIMPLEARMV5TE = 16; 3152 enum FF_IDCT_SIMPLEARMV6 = 17; 3153 enum FF_IDCT_FAAN = 20; 3154 enum FF_IDCT_SIMPLENEON = 22; 3155 enum FF_IDCT_NONE = 24; 3156 enum FF_IDCT_SIMPLEAUTO = 128; 3157 enum FF_THREAD_FRAME = 1; 3158 enum FF_THREAD_SLICE = 2; 3159 enum FF_PROFILE_UNKNOWN = -99; 3160 enum FF_PROFILE_RESERVED = -100; 3161 enum FF_PROFILE_AAC_MAIN = 0; 3162 enum FF_PROFILE_AAC_LOW = 1; 3163 enum FF_PROFILE_AAC_SSR = 2; 3164 enum FF_PROFILE_AAC_LTP = 3; 3165 enum FF_PROFILE_AAC_HE = 4; 3166 enum FF_PROFILE_AAC_HE_V2 = 28; 3167 enum FF_PROFILE_AAC_LD = 22; 3168 enum FF_PROFILE_AAC_ELD = 38; 3169 enum FF_PROFILE_MPEG2_AAC_LOW = 128; 3170 enum FF_PROFILE_MPEG2_AAC_HE = 131; 3171 enum FF_PROFILE_DNXHD = 0; 3172 enum FF_PROFILE_DNXHR_LB = 1; 3173 enum FF_PROFILE_DNXHR_SQ = 2; 3174 enum FF_PROFILE_DNXHR_HQ = 3; 3175 enum FF_PROFILE_DNXHR_HQX = 4; 3176 enum FF_PROFILE_DNXHR_444 = 5; 3177 enum FF_PROFILE_DTS = 20; 3178 enum FF_PROFILE_DTS_ES = 30; 3179 enum FF_PROFILE_DTS_96_24 = 40; 3180 enum FF_PROFILE_DTS_HD_HRA = 50; 3181 enum FF_PROFILE_DTS_HD_MA = 60; 3182 enum FF_PROFILE_DTS_EXPRESS = 70; 3183 enum FF_PROFILE_MPEG2_422 = 0; 3184 enum FF_PROFILE_MPEG2_HIGH = 1; 3185 enum FF_PROFILE_MPEG2_SS = 2; 3186 enum FF_PROFILE_MPEG2_SNR_SCALABLE = 3; 3187 enum FF_PROFILE_MPEG2_MAIN = 4; 3188 enum FF_PROFILE_MPEG2_SIMPLE = 5; 3189 enum FF_PROFILE_H264_CONSTRAINED = 1 << 9; 3190 enum FF_PROFILE_H264_INTRA = 1 << 11; 3191 enum FF_PROFILE_H264_BASELINE = 66; 3192 enum FF_PROFILE_H264_CONSTRAINED_BASELINE = 66 | FF_PROFILE_H264_CONSTRAINED; 3193 enum FF_PROFILE_H264_MAIN = 77; 3194 enum FF_PROFILE_H264_EXTENDED = 88; 3195 enum FF_PROFILE_H264_HIGH = 100; 3196 enum FF_PROFILE_H264_HIGH_10 = 110; 3197 enum FF_PROFILE_H264_HIGH_10_INTRA = 110 | FF_PROFILE_H264_INTRA; 3198 enum FF_PROFILE_H264_MULTIVIEW_HIGH = 118; 3199 enum FF_PROFILE_H264_HIGH_422 = 122; 3200 enum FF_PROFILE_H264_HIGH_422_INTRA = 122 | FF_PROFILE_H264_INTRA; 3201 enum FF_PROFILE_H264_STEREO_HIGH = 128; 3202 enum FF_PROFILE_H264_HIGH_444 = 144; 3203 enum FF_PROFILE_H264_HIGH_444_PREDICTIVE = 244; 3204 enum FF_PROFILE_H264_HIGH_444_INTRA = 244 | FF_PROFILE_H264_INTRA; 3205 enum FF_PROFILE_H264_CAVLC_444 = 44; 3206 enum FF_PROFILE_VC1_SIMPLE = 0; 3207 enum FF_PROFILE_VC1_MAIN = 1; 3208 enum FF_PROFILE_VC1_COMPLEX = 2; 3209 enum FF_PROFILE_VC1_ADVANCED = 3; 3210 enum FF_PROFILE_MPEG4_SIMPLE = 0; 3211 enum FF_PROFILE_MPEG4_SIMPLE_SCALABLE = 1; 3212 enum FF_PROFILE_MPEG4_CORE = 2; 3213 enum FF_PROFILE_MPEG4_MAIN = 3; 3214 enum FF_PROFILE_MPEG4_N_BIT = 4; 3215 enum FF_PROFILE_MPEG4_SCALABLE_TEXTURE = 5; 3216 enum FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION = 6; 3217 enum FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE = 7; 3218 enum FF_PROFILE_MPEG4_HYBRID = 8; 3219 enum FF_PROFILE_MPEG4_ADVANCED_REAL_TIME = 9; 3220 enum FF_PROFILE_MPEG4_CORE_SCALABLE = 10; 3221 enum FF_PROFILE_MPEG4_ADVANCED_CODING = 11; 3222 enum FF_PROFILE_MPEG4_ADVANCED_CORE = 12; 3223 enum FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE = 13; 3224 enum FF_PROFILE_MPEG4_SIMPLE_STUDIO = 14; 3225 enum FF_PROFILE_MPEG4_ADVANCED_SIMPLE = 15; 3226 enum FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 = 1; 3227 enum FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 = 2; 3228 enum FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION = 32768; 3229 enum FF_PROFILE_JPEG2000_DCINEMA_2K = 3; 3230 enum FF_PROFILE_JPEG2000_DCINEMA_4K = 4; 3231 enum FF_PROFILE_VP9_0 = 0; 3232 enum FF_PROFILE_VP9_1 = 1; 3233 enum FF_PROFILE_VP9_2 = 2; 3234 enum FF_PROFILE_VP9_3 = 3; 3235 enum FF_PROFILE_HEVC_MAIN = 1; 3236 enum FF_PROFILE_HEVC_MAIN_10 = 2; 3237 enum FF_PROFILE_HEVC_MAIN_STILL_PICTURE = 3; 3238 enum FF_PROFILE_HEVC_REXT = 4; 3239 enum FF_PROFILE_AV1_MAIN = 0; 3240 enum FF_PROFILE_AV1_HIGH = 1; 3241 enum FF_PROFILE_AV1_PROFESSIONAL = 2; 3242 enum FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT = 0xc0; 3243 enum FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT = 0xc1; 3244 enum FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT = 0xc2; 3245 enum FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS = 0xc3; 3246 enum FF_PROFILE_MJPEG_JPEG_LS = 0xf7; 3247 enum FF_PROFILE_SBC_MSBC = 1; 3248 enum FF_LEVEL_UNKNOWN = -99; 3249 enum FF_SUB_CHARENC_MODE_DO_NOTHING = -1; 3250 enum FF_SUB_CHARENC_MODE_AUTOMATIC = 0; 3251 enum FF_SUB_CHARENC_MODE_PRE_DECODER = 1; 3252 enum FF_SUB_CHARENC_MODE_IGNORE = 2; 3253 enum FF_DEBUG_VIS_MV_P_FOR = 0x00000001; 3254 enum FF_DEBUG_VIS_MV_B_FOR = 0x00000002; 3255 enum FF_DEBUG_VIS_MV_B_BACK = 0x00000004; 3256 enum FF_CODEC_PROPERTY_LOSSLESS = 0x00000001; 3257 enum FF_CODEC_PROPERTY_CLOSED_CAPTIONS = 0x00000002; 3258 enum FF_SUB_TEXT_FMT_ASS = 0; 3259 enum FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS = 1; 3260 3261 /** 3262 * Accessors for some AVCodecContext fields. These used to be provided for ABI 3263 * compatibility, and do not need to be used anymore. 3264 */ 3265 AVRational av_codec_get_pkt_timebase (const(AVCodecContext)* avctx); 3266 void av_codec_set_pkt_timebase (AVCodecContext* avctx, AVRational val); 3267 3268 const(AVCodecDescriptor)* av_codec_get_codec_descriptor ( 3269 const(AVCodecContext)* avctx); 3270 void av_codec_set_codec_descriptor ( 3271 AVCodecContext* avctx, 3272 const(AVCodecDescriptor)* desc); 3273 3274 uint av_codec_get_codec_properties (const(AVCodecContext)* avctx); 3275 3276 int av_codec_get_lowres (const(AVCodecContext)* avctx); 3277 void av_codec_set_lowres (AVCodecContext* avctx, int val); 3278 3279 int av_codec_get_seek_preroll (const(AVCodecContext)* avctx); 3280 void av_codec_set_seek_preroll (AVCodecContext* avctx, int val); 3281 3282 ushort* av_codec_get_chroma_intra_matrix (const(AVCodecContext)* avctx); 3283 void av_codec_set_chroma_intra_matrix (AVCodecContext* avctx, ushort* val); 3284 3285 /** 3286 * AVProfile. 3287 */ 3288 struct AVProfile 3289 { 3290 int profile; 3291 const(char)* name; ///< short name for the profile 3292 } 3293 3294 enum 3295 { 3296 /** 3297 * The codec supports this format via the hw_device_ctx interface. 3298 * 3299 * When selecting this format, AVCodecContext.hw_device_ctx should 3300 * have been set to a device of the specified type before calling 3301 * avcodec_open2(). 3302 */ 3303 AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01, 3304 /** 3305 * The codec supports this format via the hw_frames_ctx interface. 3306 * 3307 * When selecting this format for a decoder, 3308 * AVCodecContext.hw_frames_ctx should be set to a suitable frames 3309 * context inside the get_format() callback. The frames context 3310 * must have been created on a device of the specified type. 3311 */ 3312 AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02, 3313 /** 3314 * The codec supports this format by some internal method. 3315 * 3316 * This format can be selected without any additional configuration - 3317 * no device or frames context is required. 3318 */ 3319 AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04, 3320 /** 3321 * The codec supports this format by some ad-hoc method. 3322 * 3323 * Additional settings and/or function calls are required. See the 3324 * codec-specific documentation for details. (Methods requiring 3325 * this sort of configuration are deprecated and others should be 3326 * used in preference.) 3327 */ 3328 AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08 3329 } 3330 3331 struct AVCodecHWConfig 3332 { 3333 /** 3334 * A hardware pixel format which the codec can use. 3335 */ 3336 AVPixelFormat pix_fmt; 3337 /** 3338 * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible 3339 * setup methods which can be used with this configuration. 3340 */ 3341 int methods; 3342 /** 3343 * The device type associated with the configuration. 3344 * 3345 * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and 3346 * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused. 3347 */ 3348 AVHWDeviceType device_type; 3349 } 3350 3351 struct AVCodecDefault; 3352 3353 /** 3354 * AVCodec. 3355 */ 3356 struct AVCodec 3357 { 3358 /** 3359 * Name of the codec implementation. 3360 * The name is globally unique among encoders and among decoders (but an 3361 * encoder and a decoder can share the same name). 3362 * This is the primary way to find a codec from the user perspective. 3363 */ 3364 const(char)* name; 3365 /** 3366 * Descriptive name for the codec, meant to be more human readable than name. 3367 * You should use the NULL_IF_CONFIG_SMALL() macro to define it. 3368 */ 3369 const(char)* long_name; 3370 AVMediaType type; 3371 AVCodecID id; 3372 /** 3373 * Codec capabilities. 3374 * see AV_CODEC_CAP_* 3375 */ 3376 int capabilities; 3377 const(AVRational)* supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} 3378 const(AVPixelFormat)* pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 3379 const(int)* supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 3380 const(AVSampleFormat)* sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 3381 const(ulong)* channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 3382 ubyte max_lowres; ///< maximum value for lowres supported by the decoder 3383 const(AVClass)* priv_class; ///< AVClass for the private context 3384 const(AVProfile)* profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} 3385 3386 /** 3387 * Group name of the codec implementation. 3388 * This is a short symbolic name of the wrapper backing this codec. A 3389 * wrapper uses some kind of external implementation for the codec, such 3390 * as an external library, or a codec implementation provided by the OS or 3391 * the hardware. 3392 * If this field is NULL, this is a builtin, libavcodec native codec. 3393 * If non-NULL, this will be the suffix in AVCodec.name in most cases 3394 * (usually AVCodec.name will be of the form "<codec_name>_<wrapper_name>"). 3395 */ 3396 const(char)* wrapper_name; 3397 3398 /***************************************************************** 3399 * No fields below this line are part of the public API. They 3400 * may not be used outside of libavcodec and can be changed and 3401 * removed at will. 3402 * New public fields should be added right above. 3403 ***************************************************************** 3404 */ 3405 int priv_data_size; 3406 AVCodec* next; 3407 /** 3408 * @name Frame-level threading support functions 3409 * @{ 3410 */ 3411 /** 3412 * If defined, called on thread contexts when they are created. 3413 * If the codec allocates writable tables in init(), re-allocate them here. 3414 * priv_data will be set to a copy of the original. 3415 */ 3416 int function (AVCodecContext*) init_thread_copy; 3417 /** 3418 * Copy necessary context variables from a previous thread context to the current one. 3419 * If not defined, the next thread will start automatically; otherwise, the codec 3420 * must call ff_thread_finish_setup(). 3421 * 3422 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. 3423 */ 3424 int function (AVCodecContext* dst, const(AVCodecContext)* src) update_thread_context; 3425 /** @} */ 3426 3427 /** 3428 * Private codec-specific defaults. 3429 */ 3430 const(AVCodecDefault)* defaults; 3431 3432 /** 3433 * Initialize codec static data, called from avcodec_register(). 3434 * 3435 * This is not intended for time consuming operations as it is 3436 * run for every codec regardless of that codec being used. 3437 */ 3438 void function (AVCodec* codec) init_static_data; 3439 3440 int function (AVCodecContext*) init; 3441 int function ( 3442 AVCodecContext*, 3443 ubyte* buf, 3444 int buf_size, 3445 const(AVSubtitle)* sub) encode_sub; 3446 /** 3447 * Encode data to an AVPacket. 3448 * 3449 * @param avctx codec context 3450 * @param avpkt output AVPacket (may contain a user-provided buffer) 3451 * @param[in] frame AVFrame containing the raw data to be encoded 3452 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a 3453 * non-empty packet was returned in avpkt. 3454 * @return 0 on success, negative error code on failure 3455 */ 3456 int function ( 3457 AVCodecContext* avctx, 3458 AVPacket* avpkt, 3459 const(AVFrame)* frame, 3460 int* got_packet_ptr) encode2; 3461 int function (AVCodecContext*, void* outdata, int* outdata_size, AVPacket* avpkt) decode; 3462 int function (AVCodecContext*) close; 3463 /** 3464 * Encode API with decoupled packet/frame dataflow. The API is the 3465 * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except 3466 * that: 3467 * - never called if the codec is closed or the wrong type, 3468 * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent, 3469 * - only one drain frame is ever passed down, 3470 */ 3471 int function (AVCodecContext* avctx, const(AVFrame)* frame) send_frame; 3472 int function (AVCodecContext* avctx, AVPacket* avpkt) receive_packet; 3473 3474 /** 3475 * Decode API with decoupled packet/frame dataflow. This function is called 3476 * to get one output frame. It should call ff_decode_get_packet() to obtain 3477 * input data. 3478 */ 3479 int function (AVCodecContext* avctx, AVFrame* frame) receive_frame; 3480 /** 3481 * Flush buffers. 3482 * Will be called when seeking 3483 */ 3484 void function (AVCodecContext*) flush; 3485 /** 3486 * Internal codec capabilities. 3487 * See FF_CODEC_CAP_* in internal.h 3488 */ 3489 int caps_internal; 3490 3491 /** 3492 * Decoding only, a comma-separated list of bitstream filters to apply to 3493 * packets before decoding. 3494 */ 3495 const(char)* bsfs; 3496 3497 /** 3498 * Array of pointers to hardware configurations supported by the codec, 3499 * or NULL if no hardware supported. The array is terminated by a NULL 3500 * pointer. 3501 * 3502 * The user can only access this field via avcodec_get_hw_config(). 3503 */ 3504 struct AVCodecHWConfigInternal; 3505 const(AVCodecHWConfigInternal*)* hw_configs; 3506 } 3507 3508 int av_codec_get_max_lowres (const(AVCodec)* codec); 3509 3510 struct MpegEncContext; 3511 3512 /** 3513 * Retrieve supported hardware configurations for a codec. 3514 * 3515 * Values of index from zero to some maximum return the indexed configuration 3516 * descriptor; all other values return NULL. If the codec does not support 3517 * any hardware configurations then it will always return NULL. 3518 */ 3519 const(AVCodecHWConfig)* avcodec_get_hw_config (const(AVCodec)* codec, int index); 3520 3521 /** 3522 * @defgroup lavc_hwaccel AVHWAccel 3523 * 3524 * @note Nothing in this structure should be accessed by the user. At some 3525 * point in future it will not be externally visible at all. 3526 * 3527 * @{ 3528 */ 3529 struct AVHWAccel 3530 { 3531 /** 3532 * Name of the hardware accelerated codec. 3533 * The name is globally unique among encoders and among decoders (but an 3534 * encoder and a decoder can share the same name). 3535 */ 3536 const(char)* name; 3537 3538 /** 3539 * Type of codec implemented by the hardware accelerator. 3540 * 3541 * See AVMEDIA_TYPE_xxx 3542 */ 3543 AVMediaType type; 3544 3545 /** 3546 * Codec implemented by the hardware accelerator. 3547 * 3548 * See AV_CODEC_ID_xxx 3549 */ 3550 AVCodecID id; 3551 3552 /** 3553 * Supported pixel format. 3554 * 3555 * Only hardware accelerated formats are supported here. 3556 */ 3557 AVPixelFormat pix_fmt; 3558 3559 /** 3560 * Hardware accelerated codec capabilities. 3561 * see AV_HWACCEL_CODEC_CAP_* 3562 */ 3563 int capabilities; 3564 3565 /***************************************************************** 3566 * No fields below this line are part of the public API. They 3567 * may not be used outside of libavcodec and can be changed and 3568 * removed at will. 3569 * New public fields should be added right above. 3570 ***************************************************************** 3571 */ 3572 3573 /** 3574 * Allocate a custom buffer 3575 */ 3576 int function (AVCodecContext* avctx, AVFrame* frame) alloc_frame; 3577 3578 /** 3579 * Called at the beginning of each frame or field picture. 3580 * 3581 * Meaningful frame information (codec specific) is guaranteed to 3582 * be parsed at this point. This function is mandatory. 3583 * 3584 * Note that buf can be NULL along with buf_size set to 0. 3585 * Otherwise, this means the whole frame is available at this point. 3586 * 3587 * @param avctx the codec context 3588 * @param buf the frame data buffer base 3589 * @param buf_size the size of the frame in bytes 3590 * @return zero if successful, a negative value otherwise 3591 */ 3592 int function (AVCodecContext* avctx, const(ubyte)* buf, uint buf_size) start_frame; 3593 3594 /** 3595 * Callback for parameter data (SPS/PPS/VPS etc). 3596 * 3597 * Useful for hardware decoders which keep persistent state about the 3598 * video parameters, and need to receive any changes to update that state. 3599 * 3600 * @param avctx the codec context 3601 * @param type the nal unit type 3602 * @param buf the nal unit data buffer 3603 * @param buf_size the size of the nal unit in bytes 3604 * @return zero if successful, a negative value otherwise 3605 */ 3606 int function (AVCodecContext* avctx, int type, const(ubyte)* buf, uint buf_size) decode_params; 3607 3608 /** 3609 * Callback for each slice. 3610 * 3611 * Meaningful slice information (codec specific) is guaranteed to 3612 * be parsed at this point. This function is mandatory. 3613 * The only exception is XvMC, that works on MB level. 3614 * 3615 * @param avctx the codec context 3616 * @param buf the slice data buffer base 3617 * @param buf_size the size of the slice in bytes 3618 * @return zero if successful, a negative value otherwise 3619 */ 3620 int function (AVCodecContext* avctx, const(ubyte)* buf, uint buf_size) decode_slice; 3621 3622 /** 3623 * Called at the end of each frame or field picture. 3624 * 3625 * The whole picture is parsed at this point and can now be sent 3626 * to the hardware accelerator. This function is mandatory. 3627 * 3628 * @param avctx the codec context 3629 * @return zero if successful, a negative value otherwise 3630 */ 3631 int function (AVCodecContext* avctx) end_frame; 3632 3633 /** 3634 * Size of per-frame hardware accelerator private data. 3635 * 3636 * Private data is allocated with av_mallocz() before 3637 * AVCodecContext.get_buffer() and deallocated after 3638 * AVCodecContext.release_buffer(). 3639 */ 3640 int frame_priv_data_size; 3641 3642 /** 3643 * Called for every Macroblock in a slice. 3644 * 3645 * XvMC uses it to replace the ff_mpv_reconstruct_mb(). 3646 * Instead of decoding to raw picture, MB parameters are 3647 * stored in an array provided by the video driver. 3648 * 3649 * @param s the mpeg context 3650 */ 3651 void function (MpegEncContext* s) decode_mb; 3652 3653 /** 3654 * Initialize the hwaccel private data. 3655 * 3656 * This will be called from ff_get_format(), after hwaccel and 3657 * hwaccel_context are set and the hwaccel private data in AVCodecInternal 3658 * is allocated. 3659 */ 3660 int function (AVCodecContext* avctx) init; 3661 3662 /** 3663 * Uninitialize the hwaccel private data. 3664 * 3665 * This will be called from get_format() or avcodec_close(), after hwaccel 3666 * and hwaccel_context are already uninitialized. 3667 */ 3668 int function (AVCodecContext* avctx) uninit; 3669 3670 /** 3671 * Size of the private data to allocate in 3672 * AVCodecInternal.hwaccel_priv_data. 3673 */ 3674 int priv_data_size; 3675 3676 /** 3677 * Internal hwaccel capabilities. 3678 */ 3679 int caps_internal; 3680 3681 /** 3682 * Fill the given hw_frames context with current codec parameters. Called 3683 * from get_format. Refer to avcodec_get_hw_frames_parameters() for 3684 * details. 3685 * 3686 * This CAN be called before AVHWAccel.init is called, and you must assume 3687 * that avctx->hwaccel_priv_data is invalid. 3688 */ 3689 int function (AVCodecContext* avctx, AVBufferRef* hw_frames_ctx) frame_params; 3690 } 3691 3692 /** 3693 * HWAccel is experimental and is thus avoided in favor of non experimental 3694 * codecs 3695 */ 3696 enum AV_HWACCEL_CODEC_CAP_EXPERIMENTAL = 0x0200; 3697 3698 /** 3699 * Hardware acceleration should be used for decoding even if the codec level 3700 * used is unknown or higher than the maximum supported level reported by the 3701 * hardware driver. 3702 * 3703 * It's generally a good idea to pass this flag unless you have a specific 3704 * reason not to, as hardware tends to under-report supported levels. 3705 */ 3706 enum AV_HWACCEL_FLAG_IGNORE_LEVEL = 1 << 0; 3707 3708 /** 3709 * Hardware acceleration can output YUV pixel formats with a different chroma 3710 * sampling than 4:2:0 and/or other than 8 bits per component. 3711 */ 3712 enum AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH = 1 << 1; 3713 3714 /** 3715 * Hardware acceleration should still be attempted for decoding when the 3716 * codec profile does not match the reported capabilities of the hardware. 3717 * 3718 * For example, this can be used to try to decode baseline profile H.264 3719 * streams in hardware - it will often succeed, because many streams marked 3720 * as baseline profile actually conform to constrained baseline profile. 3721 * 3722 * @warning If the stream is actually not supported then the behaviour is 3723 * undefined, and may include returning entirely incorrect output 3724 * while indicating success. 3725 */ 3726 enum AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH = 1 << 2; 3727 3728 /** 3729 * @} 3730 */ 3731 3732 /** 3733 * @defgroup lavc_picture AVPicture 3734 * 3735 * Functions for working with AVPicture 3736 * @{ 3737 */ 3738 3739 /** 3740 * Picture data structure. 3741 * 3742 * Up to four components can be stored into it, the last component is 3743 * alpha. 3744 * @deprecated use AVFrame or imgutils functions instead 3745 */ 3746 struct AVPicture 3747 { 3748 ubyte*[AV_NUM_DATA_POINTERS] data; ///< pointers to the image data planes 3749 int[AV_NUM_DATA_POINTERS] linesize; ///< number of bytes per line 3750 } 3751 3752 /** 3753 * @} 3754 */ 3755 3756 enum AVSubtitleType 3757 { 3758 SUBTITLE_NONE = 0, 3759 3760 SUBTITLE_BITMAP = 1, ///< A bitmap, pict will be set 3761 3762 /** 3763 * Plain text, the text field must be set by the decoder and is 3764 * authoritative. ass and pict fields may contain approximations. 3765 */ 3766 SUBTITLE_TEXT = 2, 3767 3768 /** 3769 * Formatted text, the ass field must be set by the decoder and is 3770 * authoritative. pict and text fields may contain approximations. 3771 */ 3772 SUBTITLE_ASS = 3 3773 } 3774 3775 enum AV_SUBTITLE_FLAG_FORCED = 0x00000001; 3776 3777 struct AVSubtitleRect 3778 { 3779 int x; ///< top left corner of pict, undefined when pict is not set 3780 int y; ///< top left corner of pict, undefined when pict is not set 3781 int w; ///< width of pict, undefined when pict is not set 3782 int h; ///< height of pict, undefined when pict is not set 3783 int nb_colors; ///< number of colors in pict, undefined when pict is not set 3784 3785 /** 3786 * @deprecated unused 3787 */ 3788 AVPicture pict; 3789 3790 /** 3791 * data+linesize for the bitmap of this subtitle. 3792 * Can be set for text/ass as well once they are rendered. 3793 */ 3794 ubyte*[4] data; 3795 int[4] linesize; 3796 3797 AVSubtitleType type; 3798 3799 char* text; ///< 0 terminated plain UTF-8 text 3800 3801 /** 3802 * 0 terminated ASS/SSA compatible event line. 3803 * The presentation of this is unaffected by the other values in this 3804 * struct. 3805 */ 3806 char* ass; 3807 3808 int flags; 3809 } 3810 3811 struct AVSubtitle 3812 { 3813 ushort format; /* 0 = graphics */ 3814 uint start_display_time; /* relative to packet pts, in ms */ 3815 uint end_display_time; /* relative to packet pts, in ms */ 3816 uint num_rects; 3817 AVSubtitleRect** rects; 3818 long pts; ///< Same as packet pts, in AV_TIME_BASE 3819 } 3820 3821 /** 3822 * This struct describes the properties of an encoded stream. 3823 * 3824 * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must 3825 * be allocated with avcodec_parameters_alloc() and freed with 3826 * avcodec_parameters_free(). 3827 */ 3828 struct AVCodecParameters 3829 { 3830 /** 3831 * General type of the encoded data. 3832 */ 3833 AVMediaType codec_type; 3834 /** 3835 * Specific type of the encoded data (the codec used). 3836 */ 3837 AVCodecID codec_id; 3838 /** 3839 * Additional information about the codec (corresponds to the AVI FOURCC). 3840 */ 3841 uint codec_tag; 3842 3843 /** 3844 * Extra binary data needed for initializing the decoder, codec-dependent. 3845 * 3846 * Must be allocated with av_malloc() and will be freed by 3847 * avcodec_parameters_free(). The allocated size of extradata must be at 3848 * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding 3849 * bytes zeroed. 3850 */ 3851 ubyte* extradata; 3852 /** 3853 * Size of the extradata content in bytes. 3854 */ 3855 int extradata_size; 3856 3857 /** 3858 * - video: the pixel format, the value corresponds to enum AVPixelFormat. 3859 * - audio: the sample format, the value corresponds to enum AVSampleFormat. 3860 */ 3861 int format; 3862 3863 /** 3864 * The average bitrate of the encoded data (in bits per second). 3865 */ 3866 long bit_rate; 3867 3868 /** 3869 * The number of bits per sample in the codedwords. 3870 * 3871 * This is basically the bitrate per sample. It is mandatory for a bunch of 3872 * formats to actually decode them. It's the number of bits for one sample in 3873 * the actual coded bitstream. 3874 * 3875 * This could be for example 4 for ADPCM 3876 * For PCM formats this matches bits_per_raw_sample 3877 * Can be 0 3878 */ 3879 int bits_per_coded_sample; 3880 3881 /** 3882 * This is the number of valid bits in each output sample. If the 3883 * sample format has more bits, the least significant bits are additional 3884 * padding bits, which are always 0. Use right shifts to reduce the sample 3885 * to its actual size. For example, audio formats with 24 bit samples will 3886 * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32. 3887 * To get the original sample use "(int32_t)sample >> 8"." 3888 * 3889 * For ADPCM this might be 12 or 16 or similar 3890 * Can be 0 3891 */ 3892 int bits_per_raw_sample; 3893 3894 /** 3895 * Codec-specific bitstream restrictions that the stream conforms to. 3896 */ 3897 int profile; 3898 int level; 3899 3900 /** 3901 * Video only. The dimensions of the video frame in pixels. 3902 */ 3903 int width; 3904 int height; 3905 3906 /** 3907 * Video only. The aspect ratio (width / height) which a single pixel 3908 * should have when displayed. 3909 * 3910 * When the aspect ratio is unknown / undefined, the numerator should be 3911 * set to 0 (the denominator may have any value). 3912 */ 3913 AVRational sample_aspect_ratio; 3914 3915 /** 3916 * Video only. The order of the fields in interlaced video. 3917 */ 3918 AVFieldOrder field_order; 3919 3920 /** 3921 * Video only. Additional colorspace characteristics. 3922 */ 3923 AVColorRange color_range; 3924 AVColorPrimaries color_primaries; 3925 AVColorTransferCharacteristic color_trc; 3926 AVColorSpace color_space; 3927 AVChromaLocation chroma_location; 3928 3929 /** 3930 * Video only. Number of delayed frames. 3931 */ 3932 int video_delay; 3933 3934 /** 3935 * Audio only. The channel layout bitmask. May be 0 if the channel layout is 3936 * unknown or unspecified, otherwise the number of bits set must be equal to 3937 * the channels field. 3938 */ 3939 ulong channel_layout; 3940 /** 3941 * Audio only. The number of audio channels. 3942 */ 3943 int channels; 3944 /** 3945 * Audio only. The number of audio samples per second. 3946 */ 3947 int sample_rate; 3948 /** 3949 * Audio only. The number of bytes per coded audio frame, required by some 3950 * formats. 3951 * 3952 * Corresponds to nBlockAlign in WAVEFORMATEX. 3953 */ 3954 int block_align; 3955 /** 3956 * Audio only. Audio frame size, if known. Required by some formats to be static. 3957 */ 3958 int frame_size; 3959 3960 /** 3961 * Audio only. The amount of padding (in samples) inserted by the encoder at 3962 * the beginning of the audio. I.e. this number of leading decoded samples 3963 * must be discarded by the caller to get the original audio without leading 3964 * padding. 3965 */ 3966 int initial_padding; 3967 /** 3968 * Audio only. The amount of padding (in samples) appended by the encoder to 3969 * the end of the audio. I.e. this number of decoded samples must be 3970 * discarded by the caller from the end of the stream to get the original 3971 * audio without any trailing padding. 3972 */ 3973 int trailing_padding; 3974 /** 3975 * Audio only. Number of samples to skip after a discontinuity. 3976 */ 3977 int seek_preroll; 3978 } 3979 3980 /** 3981 * Iterate over all registered codecs. 3982 * 3983 * @param opaque a pointer where libavcodec will store the iteration state. Must 3984 * point to NULL to start the iteration. 3985 * 3986 * @return the next registered codec or NULL when the iteration is 3987 * finished 3988 */ 3989 const(AVCodec)* av_codec_iterate (void** opaque); 3990 3991 /** 3992 * If c is NULL, returns the first registered codec, 3993 * if c is non-NULL, returns the next registered codec after c, 3994 * or NULL if c is the last one. 3995 */ 3996 AVCodec* av_codec_next (const(AVCodec)* c); 3997 3998 /** 3999 * Return the LIBAVCODEC_VERSION_INT constant. 4000 */ 4001 uint avcodec_version (); 4002 4003 /** 4004 * Return the libavcodec build-time configuration. 4005 */ 4006 const(char)* avcodec_configuration (); 4007 4008 /** 4009 * Return the libavcodec license. 4010 */ 4011 const(char)* avcodec_license (); 4012 4013 /** 4014 * Register the codec codec and initialize libavcodec. 4015 * 4016 * @warning either this function or avcodec_register_all() must be called 4017 * before any other libavcodec functions. 4018 * 4019 * @see avcodec_register_all() 4020 */ 4021 void avcodec_register (AVCodec* codec); 4022 4023 /** 4024 * Register all the codecs, parsers and bitstream filters which were enabled at 4025 * configuration time. If you do not call this function you can select exactly 4026 * which formats you want to support, by using the individual registration 4027 * functions. 4028 * 4029 * @see avcodec_register 4030 * @see av_register_codec_parser 4031 * @see av_register_bitstream_filter 4032 */ 4033 void avcodec_register_all (); 4034 4035 /** 4036 * Allocate an AVCodecContext and set its fields to default values. The 4037 * resulting struct should be freed with avcodec_free_context(). 4038 * 4039 * @param codec if non-NULL, allocate private data and initialize defaults 4040 * for the given codec. It is illegal to then call avcodec_open2() 4041 * with a different codec. 4042 * If NULL, then the codec-specific defaults won't be initialized, 4043 * which may result in suboptimal default settings (this is 4044 * important mainly for encoders, e.g. libx264). 4045 * 4046 * @return An AVCodecContext filled with default values or NULL on failure. 4047 */ 4048 AVCodecContext* avcodec_alloc_context3 (const(AVCodec)* codec); 4049 4050 /** 4051 * Free the codec context and everything associated with it and write NULL to 4052 * the provided pointer. 4053 */ 4054 void avcodec_free_context (AVCodecContext** avctx); 4055 4056 /** 4057 * @deprecated This function should not be used, as closing and opening a codec 4058 * context multiple time is not supported. A new codec context should be 4059 * allocated for each new use. 4060 */ 4061 int avcodec_get_context_defaults3 (AVCodecContext* s, const(AVCodec)* codec); 4062 4063 /** 4064 * Get the AVClass for AVCodecContext. It can be used in combination with 4065 * AV_OPT_SEARCH_FAKE_OBJ for examining options. 4066 * 4067 * @see av_opt_find(). 4068 */ 4069 const(AVClass)* avcodec_get_class (); 4070 4071 /** 4072 * Get the AVClass for AVFrame. It can be used in combination with 4073 * AV_OPT_SEARCH_FAKE_OBJ for examining options. 4074 * 4075 * @see av_opt_find(). 4076 */ 4077 const(AVClass)* avcodec_get_frame_class (); 4078 4079 /** 4080 * Get the AVClass for AVSubtitleRect. It can be used in combination with 4081 * AV_OPT_SEARCH_FAKE_OBJ for examining options. 4082 * 4083 * @see av_opt_find(). 4084 */ 4085 const(AVClass)* avcodec_get_subtitle_rect_class (); 4086 4087 /** 4088 * Copy the settings of the source AVCodecContext into the destination 4089 * AVCodecContext. The resulting destination codec context will be 4090 * unopened, i.e. you are required to call avcodec_open2() before you 4091 * can use this AVCodecContext to decode/encode video/audio data. 4092 * 4093 * @param dest target codec context, should be initialized with 4094 * avcodec_alloc_context3(NULL), but otherwise uninitialized 4095 * @param src source codec context 4096 * @return AVERROR() on error (e.g. memory allocation error), 0 on success 4097 * 4098 * @deprecated The semantics of this function are ill-defined and it should not 4099 * be used. If you need to transfer the stream parameters from one codec context 4100 * to another, use an intermediate AVCodecParameters instance and the 4101 * avcodec_parameters_from_context() / avcodec_parameters_to_context() 4102 * functions. 4103 */ 4104 int avcodec_copy_context (AVCodecContext* dest, const(AVCodecContext)* src); 4105 4106 /** 4107 * Allocate a new AVCodecParameters and set its fields to default values 4108 * (unknown/invalid/0). The returned struct must be freed with 4109 * avcodec_parameters_free(). 4110 */ 4111 AVCodecParameters* avcodec_parameters_alloc (); 4112 4113 /** 4114 * Free an AVCodecParameters instance and everything associated with it and 4115 * write NULL to the supplied pointer. 4116 */ 4117 void avcodec_parameters_free (AVCodecParameters** par); 4118 4119 /** 4120 * Copy the contents of src to dst. Any allocated fields in dst are freed and 4121 * replaced with newly allocated duplicates of the corresponding fields in src. 4122 * 4123 * @return >= 0 on success, a negative AVERROR code on failure. 4124 */ 4125 int avcodec_parameters_copy (AVCodecParameters* dst, const(AVCodecParameters)* src); 4126 4127 /** 4128 * Fill the parameters struct based on the values from the supplied codec 4129 * context. Any allocated fields in par are freed and replaced with duplicates 4130 * of the corresponding fields in codec. 4131 * 4132 * @return >= 0 on success, a negative AVERROR code on failure 4133 */ 4134 int avcodec_parameters_from_context ( 4135 AVCodecParameters* par, 4136 const(AVCodecContext)* codec); 4137 4138 /** 4139 * Fill the codec context based on the values from the supplied codec 4140 * parameters. Any allocated fields in codec that have a corresponding field in 4141 * par are freed and replaced with duplicates of the corresponding field in par. 4142 * Fields in codec that do not have a counterpart in par are not touched. 4143 * 4144 * @return >= 0 on success, a negative AVERROR code on failure. 4145 */ 4146 int avcodec_parameters_to_context ( 4147 AVCodecContext* codec, 4148 const(AVCodecParameters)* par); 4149 4150 /** 4151 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this 4152 * function the context has to be allocated with avcodec_alloc_context3(). 4153 * 4154 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), 4155 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for 4156 * retrieving a codec. 4157 * 4158 * @warning This function is not thread safe! 4159 * 4160 * @note Always call this function before using decoding routines (such as 4161 * @ref avcodec_receive_frame()). 4162 * 4163 * @code 4164 * avcodec_register_all(); 4165 * av_dict_set(&opts, "b", "2.5M", 0); 4166 * codec = avcodec_find_decoder(AV_CODEC_ID_H264); 4167 * if (!codec) 4168 * exit(1); 4169 * 4170 * context = avcodec_alloc_context3(codec); 4171 * 4172 * if (avcodec_open2(context, codec, opts) < 0) 4173 * exit(1); 4174 * @endcode 4175 * 4176 * @param avctx The context to initialize. 4177 * @param codec The codec to open this context for. If a non-NULL codec has been 4178 * previously passed to avcodec_alloc_context3() or 4179 * for this context, then this parameter MUST be either NULL or 4180 * equal to the previously passed codec. 4181 * @param options A dictionary filled with AVCodecContext and codec-private options. 4182 * On return this object will be filled with options that were not found. 4183 * 4184 * @return zero on success, a negative value on error 4185 * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), 4186 * av_dict_set(), av_opt_find(). 4187 */ 4188 int avcodec_open2 (AVCodecContext* avctx, const(AVCodec)* codec, AVDictionary** options); 4189 4190 /** 4191 * Close a given AVCodecContext and free all the data associated with it 4192 * (but not the AVCodecContext itself). 4193 * 4194 * Calling this function on an AVCodecContext that hasn't been opened will free 4195 * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL 4196 * codec. Subsequent calls will do nothing. 4197 * 4198 * @note Do not use this function. Use avcodec_free_context() to destroy a 4199 * codec context (either open or closed). Opening and closing a codec context 4200 * multiple times is not supported anymore -- use multiple codec contexts 4201 * instead. 4202 */ 4203 int avcodec_close (AVCodecContext* avctx); 4204 4205 /** 4206 * Free all allocated data in the given subtitle struct. 4207 * 4208 * @param sub AVSubtitle to free. 4209 */ 4210 void avsubtitle_free (AVSubtitle* sub); 4211 4212 /** 4213 * @} 4214 */ 4215 4216 /** 4217 * @addtogroup lavc_packet 4218 * @{ 4219 */ 4220 4221 /** 4222 * Allocate an AVPacket and set its fields to default values. The resulting 4223 * struct must be freed using av_packet_free(). 4224 * 4225 * @return An AVPacket filled with default values or NULL on failure. 4226 * 4227 * @note this only allocates the AVPacket itself, not the data buffers. Those 4228 * must be allocated through other means such as av_new_packet. 4229 * 4230 * @see av_new_packet 4231 */ 4232 AVPacket* av_packet_alloc (); 4233 4234 /** 4235 * Create a new packet that references the same data as src. 4236 * 4237 * This is a shortcut for av_packet_alloc()+av_packet_ref(). 4238 * 4239 * @return newly created AVPacket on success, NULL on error. 4240 * 4241 * @see av_packet_alloc 4242 * @see av_packet_ref 4243 */ 4244 AVPacket* av_packet_clone (const(AVPacket)* src); 4245 4246 /** 4247 * Free the packet, if the packet is reference counted, it will be 4248 * unreferenced first. 4249 * 4250 * @param pkt packet to be freed. The pointer will be set to NULL. 4251 * @note passing NULL is a no-op. 4252 */ 4253 void av_packet_free (AVPacket** pkt); 4254 4255 /** 4256 * Initialize optional fields of a packet with default values. 4257 * 4258 * Note, this does not touch the data and size members, which have to be 4259 * initialized separately. 4260 * 4261 * @param pkt packet 4262 */ 4263 void av_init_packet (AVPacket* pkt); 4264 4265 /** 4266 * Allocate the payload of a packet and initialize its fields with 4267 * default values. 4268 * 4269 * @param pkt packet 4270 * @param size wanted payload size 4271 * @return 0 if OK, AVERROR_xxx otherwise 4272 */ 4273 int av_new_packet (AVPacket* pkt, int size); 4274 4275 /** 4276 * Reduce packet size, correctly zeroing padding 4277 * 4278 * @param pkt packet 4279 * @param size new size 4280 */ 4281 void av_shrink_packet (AVPacket* pkt, int size); 4282 4283 /** 4284 * Increase packet size, correctly zeroing padding 4285 * 4286 * @param pkt packet 4287 * @param grow_by number of bytes by which to increase the size of the packet 4288 */ 4289 int av_grow_packet (AVPacket* pkt, int grow_by); 4290 4291 /** 4292 * Initialize a reference-counted packet from av_malloc()ed data. 4293 * 4294 * @param pkt packet to be initialized. This function will set the data, size, 4295 * buf and destruct fields, all others are left untouched. 4296 * @param data Data allocated by av_malloc() to be used as packet data. If this 4297 * function returns successfully, the data is owned by the underlying AVBuffer. 4298 * The caller may not access the data through other means. 4299 * @param size size of data in bytes, without the padding. I.e. the full buffer 4300 * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. 4301 * 4302 * @return 0 on success, a negative AVERROR on error 4303 */ 4304 int av_packet_from_data (AVPacket* pkt, ubyte* data, int size); 4305 4306 /** 4307 * @warning This is a hack - the packet memory allocation stuff is broken. The 4308 * packet is allocated if it was not really allocated. 4309 * 4310 * @deprecated Use av_packet_ref or av_packet_make_refcounted 4311 */ 4312 int av_dup_packet (AVPacket* pkt); 4313 /** 4314 * Copy packet, including contents 4315 * 4316 * @return 0 on success, negative AVERROR on fail 4317 * 4318 * @deprecated Use av_packet_ref 4319 */ 4320 int av_copy_packet (AVPacket* dst, const(AVPacket)* src); 4321 4322 /** 4323 * Copy packet side data 4324 * 4325 * @return 0 on success, negative AVERROR on fail 4326 * 4327 * @deprecated Use av_packet_copy_props 4328 */ 4329 int av_copy_packet_side_data (AVPacket* dst, const(AVPacket)* src); 4330 4331 /** 4332 * Free a packet. 4333 * 4334 * @deprecated Use av_packet_unref 4335 * 4336 * @param pkt packet to free 4337 */ 4338 void av_free_packet (AVPacket* pkt); 4339 4340 /** 4341 * Allocate new information of a packet. 4342 * 4343 * @param pkt packet 4344 * @param type side information type 4345 * @param size side information size 4346 * @return pointer to fresh allocated data or NULL otherwise 4347 */ 4348 ubyte* av_packet_new_side_data ( 4349 AVPacket* pkt, 4350 AVPacketSideDataType type, 4351 int size); 4352 4353 /** 4354 * Wrap an existing array as a packet side data. 4355 * 4356 * @param pkt packet 4357 * @param type side information type 4358 * @param data the side data array. It must be allocated with the av_malloc() 4359 * family of functions. The ownership of the data is transferred to 4360 * pkt. 4361 * @param size side information size 4362 * @return a non-negative number on success, a negative AVERROR code on 4363 * failure. On failure, the packet is unchanged and the data remains 4364 * owned by the caller. 4365 */ 4366 int av_packet_add_side_data ( 4367 AVPacket* pkt, 4368 AVPacketSideDataType type, 4369 ubyte* data, 4370 size_t size); 4371 4372 /** 4373 * Shrink the already allocated side data buffer 4374 * 4375 * @param pkt packet 4376 * @param type side information type 4377 * @param size new side information size 4378 * @return 0 on success, < 0 on failure 4379 */ 4380 int av_packet_shrink_side_data ( 4381 AVPacket* pkt, 4382 AVPacketSideDataType type, 4383 int size); 4384 4385 /** 4386 * Get side information from packet. 4387 * 4388 * @param pkt packet 4389 * @param type desired side information type 4390 * @param size pointer for side information size to store (optional) 4391 * @return pointer to data if present or NULL otherwise 4392 */ 4393 ubyte* av_packet_get_side_data ( 4394 const(AVPacket)* pkt, 4395 AVPacketSideDataType type, 4396 int* size); 4397 4398 int av_packet_merge_side_data (AVPacket* pkt); 4399 4400 int av_packet_split_side_data (AVPacket* pkt); 4401 4402 const(char)* av_packet_side_data_name (AVPacketSideDataType type); 4403 4404 /** 4405 * Pack a dictionary for use in side_data. 4406 * 4407 * @param dict The dictionary to pack. 4408 * @param size pointer to store the size of the returned data 4409 * @return pointer to data if successful, NULL otherwise 4410 */ 4411 ubyte* av_packet_pack_dictionary (AVDictionary* dict, int* size); 4412 /** 4413 * Unpack a dictionary from side_data. 4414 * 4415 * @param data data from side_data 4416 * @param size size of the data 4417 * @param dict the metadata storage dictionary 4418 * @return 0 on success, < 0 on failure 4419 */ 4420 int av_packet_unpack_dictionary (const(ubyte)* data, int size, AVDictionary** dict); 4421 4422 /** 4423 * Convenience function to free all the side data stored. 4424 * All the other fields stay untouched. 4425 * 4426 * @param pkt packet 4427 */ 4428 void av_packet_free_side_data (AVPacket* pkt); 4429 4430 /** 4431 * Setup a new reference to the data described by a given packet 4432 * 4433 * If src is reference-counted, setup dst as a new reference to the 4434 * buffer in src. Otherwise allocate a new buffer in dst and copy the 4435 * data from src into it. 4436 * 4437 * All the other fields are copied from src. 4438 * 4439 * @see av_packet_unref 4440 * 4441 * @param dst Destination packet 4442 * @param src Source packet 4443 * 4444 * @return 0 on success, a negative AVERROR on error. 4445 */ 4446 int av_packet_ref (AVPacket* dst, const(AVPacket)* src); 4447 4448 /** 4449 * Wipe the packet. 4450 * 4451 * Unreference the buffer referenced by the packet and reset the 4452 * remaining packet fields to their default values. 4453 * 4454 * @param pkt The packet to be unreferenced. 4455 */ 4456 void av_packet_unref (AVPacket* pkt); 4457 4458 /** 4459 * Move every field in src to dst and reset src. 4460 * 4461 * @see av_packet_unref 4462 * 4463 * @param src Source packet, will be reset 4464 * @param dst Destination packet 4465 */ 4466 void av_packet_move_ref (AVPacket* dst, AVPacket* src); 4467 4468 /** 4469 * Copy only "properties" fields from src to dst. 4470 * 4471 * Properties for the purpose of this function are all the fields 4472 * beside those related to the packet data (buf, data, size) 4473 * 4474 * @param dst Destination packet 4475 * @param src Source packet 4476 * 4477 * @return 0 on success AVERROR on failure. 4478 */ 4479 int av_packet_copy_props (AVPacket* dst, const(AVPacket)* src); 4480 4481 /** 4482 * Ensure the data described by a given packet is reference counted. 4483 * 4484 * @note This function does not ensure that the reference will be writable. 4485 * Use av_packet_make_writable instead for that purpose. 4486 * 4487 * @see av_packet_ref 4488 * @see av_packet_make_writable 4489 * 4490 * @param pkt packet whose data should be made reference counted. 4491 * 4492 * @return 0 on success, a negative AVERROR on error. On failure, the 4493 * packet is unchanged. 4494 */ 4495 int av_packet_make_refcounted (AVPacket* pkt); 4496 4497 /** 4498 * Create a writable reference for the data described by a given packet, 4499 * avoiding data copy if possible. 4500 * 4501 * @param pkt Packet whose data should be made writable. 4502 * 4503 * @return 0 on success, a negative AVERROR on failure. On failure, the 4504 * packet is unchanged. 4505 */ 4506 int av_packet_make_writable (AVPacket* pkt); 4507 4508 /** 4509 * Convert valid timing fields (timestamps / durations) in a packet from one 4510 * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be 4511 * ignored. 4512 * 4513 * @param pkt packet on which the conversion will be performed 4514 * @param tb_src source timebase, in which the timing fields in pkt are 4515 * expressed 4516 * @param tb_dst destination timebase, to which the timing fields will be 4517 * converted 4518 */ 4519 void av_packet_rescale_ts (AVPacket* pkt, AVRational tb_src, AVRational tb_dst); 4520 4521 /** 4522 * @} 4523 */ 4524 4525 /** 4526 * @addtogroup lavc_decoding 4527 * @{ 4528 */ 4529 4530 /** 4531 * Find a registered decoder with a matching codec ID. 4532 * 4533 * @param id AVCodecID of the requested decoder 4534 * @return A decoder if one was found, NULL otherwise. 4535 */ 4536 AVCodec* avcodec_find_decoder (AVCodecID id); 4537 4538 /** 4539 * Find a registered decoder with the specified name. 4540 * 4541 * @param name name of the requested decoder 4542 * @return A decoder if one was found, NULL otherwise. 4543 */ 4544 AVCodec* avcodec_find_decoder_by_name (const(char)* name); 4545 4546 /** 4547 * The default callback for AVCodecContext.get_buffer2(). It is made public so 4548 * it can be called by custom get_buffer2() implementations for decoders without 4549 * AV_CODEC_CAP_DR1 set. 4550 */ 4551 int avcodec_default_get_buffer2 (AVCodecContext* s, AVFrame* frame, int flags); 4552 4553 /** 4554 * Modify width and height values so that they will result in a memory 4555 * buffer that is acceptable for the codec if you do not use any horizontal 4556 * padding. 4557 * 4558 * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened. 4559 */ 4560 void avcodec_align_dimensions (AVCodecContext* s, int* width, int* height); 4561 4562 /** 4563 * Modify width and height values so that they will result in a memory 4564 * buffer that is acceptable for the codec if you also ensure that all 4565 * line sizes are a multiple of the respective linesize_align[i]. 4566 * 4567 * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened. 4568 */ 4569 void avcodec_align_dimensions2 ( 4570 AVCodecContext* s, 4571 int* width, 4572 int* height, 4573 ref int[AV_NUM_DATA_POINTERS] linesize_align); 4574 4575 /** 4576 * Converts AVChromaLocation to swscale x/y chroma position. 4577 * 4578 * The positions represent the chroma (0,0) position in a coordinates system 4579 * with luma (0,0) representing the origin and luma(1,1) representing 256,256 4580 * 4581 * @param xpos horizontal chroma sample position 4582 * @param ypos vertical chroma sample position 4583 */ 4584 int avcodec_enum_to_chroma_pos (int* xpos, int* ypos, AVChromaLocation pos); 4585 4586 /** 4587 * Converts swscale x/y chroma position to AVChromaLocation. 4588 * 4589 * The positions represent the chroma (0,0) position in a coordinates system 4590 * with luma (0,0) representing the origin and luma(1,1) representing 256,256 4591 * 4592 * @param xpos horizontal chroma sample position 4593 * @param ypos vertical chroma sample position 4594 */ 4595 AVChromaLocation avcodec_chroma_pos_to_enum (int xpos, int ypos); 4596 4597 /** 4598 * Decode the audio frame of size avpkt->size from avpkt->data into frame. 4599 * 4600 * Some decoders may support multiple frames in a single AVPacket. Such 4601 * decoders would then just decode the first frame and the return value would be 4602 * less than the packet size. In this case, avcodec_decode_audio4 has to be 4603 * called again with an AVPacket containing the remaining data in order to 4604 * decode the second frame, etc... Even if no frames are returned, the packet 4605 * needs to be fed to the decoder with remaining data until it is completely 4606 * consumed or an error occurs. 4607 * 4608 * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input 4609 * and output. This means that for some packets they will not immediately 4610 * produce decoded output and need to be flushed at the end of decoding to get 4611 * all the decoded data. Flushing is done by calling this function with packets 4612 * with avpkt->data set to NULL and avpkt->size set to 0 until it stops 4613 * returning samples. It is safe to flush even those decoders that are not 4614 * marked with AV_CODEC_CAP_DELAY, then no samples will be returned. 4615 * 4616 * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE 4617 * larger than the actual read bytes because some optimized bitstream 4618 * readers read 32 or 64 bits at once and could read over the end. 4619 * 4620 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() 4621 * before packets may be fed to the decoder. 4622 * 4623 * @param avctx the codec context 4624 * @param[out] frame The AVFrame in which to store decoded audio samples. 4625 * The decoder will allocate a buffer for the decoded frame by 4626 * calling the AVCodecContext.get_buffer2() callback. 4627 * When AVCodecContext.refcounted_frames is set to 1, the frame is 4628 * reference counted and the returned reference belongs to the 4629 * caller. The caller must release the frame using av_frame_unref() 4630 * when the frame is no longer needed. The caller may safely write 4631 * to the frame if av_frame_is_writable() returns 1. 4632 * When AVCodecContext.refcounted_frames is set to 0, the returned 4633 * reference belongs to the decoder and is valid only until the 4634 * next call to this function or until closing or flushing the 4635 * decoder. The caller may not write to it. 4636 * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is 4637 * non-zero. Note that this field being set to zero 4638 * does not mean that an error has occurred. For 4639 * decoders with AV_CODEC_CAP_DELAY set, no given decode 4640 * call is guaranteed to produce a frame. 4641 * @param[in] avpkt The input AVPacket containing the input buffer. 4642 * At least avpkt->data and avpkt->size should be set. Some 4643 * decoders might also require additional fields to be set. 4644 * @return A negative error code is returned if an error occurred during 4645 * decoding, otherwise the number of bytes consumed from the input 4646 * AVPacket is returned. 4647 * 4648 * @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). 4649 */ 4650 int avcodec_decode_audio4 ( 4651 AVCodecContext* avctx, 4652 AVFrame* frame, 4653 int* got_frame_ptr, 4654 const(AVPacket)* avpkt); 4655 4656 /** 4657 * Decode the video frame of size avpkt->size from avpkt->data into picture. 4658 * Some decoders may support multiple frames in a single AVPacket, such 4659 * decoders would then just decode the first frame. 4660 * 4661 * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than 4662 * the actual read bytes because some optimized bitstream readers read 32 or 64 4663 * bits at once and could read over the end. 4664 * 4665 * @warning The end of the input buffer buf should be set to 0 to ensure that 4666 * no overreading happens for damaged MPEG streams. 4667 * 4668 * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay 4669 * between input and output, these need to be fed with avpkt->data=NULL, 4670 * avpkt->size=0 at the end to return the remaining frames. 4671 * 4672 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() 4673 * before packets may be fed to the decoder. 4674 * 4675 * @param avctx the codec context 4676 * @param[out] picture The AVFrame in which the decoded video frame will be stored. 4677 * Use av_frame_alloc() to get an AVFrame. The codec will 4678 * allocate memory for the actual bitmap by calling the 4679 * AVCodecContext.get_buffer2() callback. 4680 * When AVCodecContext.refcounted_frames is set to 1, the frame is 4681 * reference counted and the returned reference belongs to the 4682 * caller. The caller must release the frame using av_frame_unref() 4683 * when the frame is no longer needed. The caller may safely write 4684 * to the frame if av_frame_is_writable() returns 1. 4685 * When AVCodecContext.refcounted_frames is set to 0, the returned 4686 * reference belongs to the decoder and is valid only until the 4687 * next call to this function or until closing or flushing the 4688 * decoder. The caller may not write to it. 4689 * 4690 * @param[in] avpkt The input AVPacket containing the input buffer. 4691 * You can create such packet with av_init_packet() and by then setting 4692 * data and size, some decoders might in addition need other fields like 4693 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least 4694 * fields possible. 4695 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. 4696 * @return On error a negative value is returned, otherwise the number of bytes 4697 * used or zero if no frame could be decompressed. 4698 * 4699 * @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). 4700 */ 4701 int avcodec_decode_video2 ( 4702 AVCodecContext* avctx, 4703 AVFrame* picture, 4704 int* got_picture_ptr, 4705 const(AVPacket)* avpkt); 4706 4707 /** 4708 * Decode a subtitle message. 4709 * Return a negative value on error, otherwise return the number of bytes used. 4710 * If no subtitle could be decompressed, got_sub_ptr is zero. 4711 * Otherwise, the subtitle is stored in *sub. 4712 * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for 4713 * simplicity, because the performance difference is expect to be negligible 4714 * and reusing a get_buffer written for video codecs would probably perform badly 4715 * due to a potentially very different allocation pattern. 4716 * 4717 * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input 4718 * and output. This means that for some packets they will not immediately 4719 * produce decoded output and need to be flushed at the end of decoding to get 4720 * all the decoded data. Flushing is done by calling this function with packets 4721 * with avpkt->data set to NULL and avpkt->size set to 0 until it stops 4722 * returning subtitles. It is safe to flush even those decoders that are not 4723 * marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned. 4724 * 4725 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() 4726 * before packets may be fed to the decoder. 4727 * 4728 * @param avctx the codec context 4729 * @param[out] sub The Preallocated AVSubtitle in which the decoded subtitle will be stored, 4730 * must be freed with avsubtitle_free if *got_sub_ptr is set. 4731 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. 4732 * @param[in] avpkt The input AVPacket containing the input buffer. 4733 */ 4734 int avcodec_decode_subtitle2 ( 4735 AVCodecContext* avctx, 4736 AVSubtitle* sub, 4737 int* got_sub_ptr, 4738 AVPacket* avpkt); 4739 4740 /** 4741 * Supply raw packet data as input to a decoder. 4742 * 4743 * Internally, this call will copy relevant AVCodecContext fields, which can 4744 * influence decoding per-packet, and apply them when the packet is actually 4745 * decoded. (For example AVCodecContext.skip_frame, which might direct the 4746 * decoder to drop the frame contained by the packet sent with this function.) 4747 * 4748 * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE 4749 * larger than the actual read bytes because some optimized bitstream 4750 * readers read 32 or 64 bits at once and could read over the end. 4751 * 4752 * @warning Do not mix this API with the legacy API (like avcodec_decode_video2()) 4753 * on the same AVCodecContext. It will return unexpected results now 4754 * or in future libavcodec versions. 4755 * 4756 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() 4757 * before packets may be fed to the decoder. 4758 * 4759 * @param avctx codec context 4760 * @param[in] avpkt The input AVPacket. Usually, this will be a single video 4761 * frame, or several complete audio frames. 4762 * Ownership of the packet remains with the caller, and the 4763 * decoder will not write to the packet. The decoder may create 4764 * a reference to the packet data (or copy it if the packet is 4765 * not reference-counted). 4766 * Unlike with older APIs, the packet is always fully consumed, 4767 * and if it contains multiple frames (e.g. some audio codecs), 4768 * will require you to call avcodec_receive_frame() multiple 4769 * times afterwards before you can send a new packet. 4770 * It can be NULL (or an AVPacket with data set to NULL and 4771 * size set to 0); in this case, it is considered a flush 4772 * packet, which signals the end of the stream. Sending the 4773 * first flush packet will return success. Subsequent ones are 4774 * unnecessary and will return AVERROR_EOF. If the decoder 4775 * still has frames buffered, it will return them after sending 4776 * a flush packet. 4777 * 4778 * @return 0 on success, otherwise negative error code: 4779 * AVERROR(EAGAIN): input is not accepted in the current state - user 4780 * must read output with avcodec_receive_frame() (once 4781 * all output is read, the packet should be resent, and 4782 * the call will not fail with EAGAIN). 4783 * AVERROR_EOF: the decoder has been flushed, and no new packets can 4784 * be sent to it (also returned if more than 1 flush 4785 * packet is sent) 4786 * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush 4787 * AVERROR(ENOMEM): failed to add packet to internal queue, or similar 4788 * other errors: legitimate decoding errors 4789 */ 4790 int avcodec_send_packet (AVCodecContext* avctx, const(AVPacket)* avpkt); 4791 4792 /** 4793 * Return decoded output data from a decoder. 4794 * 4795 * @param avctx codec context 4796 * @param frame This will be set to a reference-counted video or audio 4797 * frame (depending on the decoder type) allocated by the 4798 * decoder. Note that the function will always call 4799 * av_frame_unref(frame) before doing anything else. 4800 * 4801 * @return 4802 * 0: success, a frame was returned 4803 * AVERROR(EAGAIN): output is not available in this state - user must try 4804 * to send new input 4805 * AVERROR_EOF: the decoder has been fully flushed, and there will be 4806 * no more output frames 4807 * AVERROR(EINVAL): codec not opened, or it is an encoder 4808 * other negative values: legitimate decoding errors 4809 */ 4810 int avcodec_receive_frame (AVCodecContext* avctx, AVFrame* frame); 4811 4812 /** 4813 * Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet() 4814 * to retrieve buffered output packets. 4815 * 4816 * @param avctx codec context 4817 * @param[in] frame AVFrame containing the raw audio or video frame to be encoded. 4818 * Ownership of the frame remains with the caller, and the 4819 * encoder will not write to the frame. The encoder may create 4820 * a reference to the frame data (or copy it if the frame is 4821 * not reference-counted). 4822 * It can be NULL, in which case it is considered a flush 4823 * packet. This signals the end of the stream. If the encoder 4824 * still has packets buffered, it will return them after this 4825 * call. Once flushing mode has been entered, additional flush 4826 * packets are ignored, and sending frames will return 4827 * AVERROR_EOF. 4828 * 4829 * For audio: 4830 * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame 4831 * can have any number of samples. 4832 * If it is not set, frame->nb_samples must be equal to 4833 * avctx->frame_size for all frames except the last. 4834 * The final frame may be smaller than avctx->frame_size. 4835 * @return 0 on success, otherwise negative error code: 4836 * AVERROR(EAGAIN): input is not accepted in the current state - user 4837 * must read output with avcodec_receive_packet() (once 4838 * all output is read, the packet should be resent, and 4839 * the call will not fail with EAGAIN). 4840 * AVERROR_EOF: the encoder has been flushed, and no new frames can 4841 * be sent to it 4842 * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a 4843 * decoder, or requires flush 4844 * AVERROR(ENOMEM): failed to add packet to internal queue, or similar 4845 * other errors: legitimate decoding errors 4846 */ 4847 int avcodec_send_frame (AVCodecContext* avctx, const(AVFrame)* frame); 4848 4849 /** 4850 * Read encoded data from the encoder. 4851 * 4852 * @param avctx codec context 4853 * @param avpkt This will be set to a reference-counted packet allocated by the 4854 * encoder. Note that the function will always call 4855 * av_frame_unref(frame) before doing anything else. 4856 * @return 0 on success, otherwise negative error code: 4857 * AVERROR(EAGAIN): output is not available in the current state - user 4858 * must try to send input 4859 * AVERROR_EOF: the encoder has been fully flushed, and there will be 4860 * no more output packets 4861 * AVERROR(EINVAL): codec not opened, or it is an encoder 4862 * other errors: legitimate decoding errors 4863 */ 4864 int avcodec_receive_packet (AVCodecContext* avctx, AVPacket* avpkt); 4865 4866 /** 4867 * Create and return a AVHWFramesContext with values adequate for hardware 4868 * decoding. This is meant to get called from the get_format callback, and is 4869 * a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx. 4870 * This API is for decoding with certain hardware acceleration modes/APIs only. 4871 * 4872 * The returned AVHWFramesContext is not initialized. The caller must do this 4873 * with av_hwframe_ctx_init(). 4874 * 4875 * Calling this function is not a requirement, but makes it simpler to avoid 4876 * codec or hardware API specific details when manually allocating frames. 4877 * 4878 * Alternatively to this, an API user can set AVCodecContext.hw_device_ctx, 4879 * which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes 4880 * it unnecessary to call this function or having to care about 4881 * AVHWFramesContext initialization at all. 4882 * 4883 * There are a number of requirements for calling this function: 4884 * 4885 * - It must be called from get_format with the same avctx parameter that was 4886 * passed to get_format. Calling it outside of get_format is not allowed, and 4887 * can trigger undefined behavior. 4888 * - The function is not always supported (see description of return values). 4889 * Even if this function returns successfully, hwaccel initialization could 4890 * fail later. (The degree to which implementations check whether the stream 4891 * is actually supported varies. Some do this check only after the user's 4892 * get_format callback returns.) 4893 * - The hw_pix_fmt must be one of the choices suggested by get_format. If the 4894 * user decides to use a AVHWFramesContext prepared with this API function, 4895 * the user must return the same hw_pix_fmt from get_format. 4896 * - The device_ref passed to this function must support the given hw_pix_fmt. 4897 * - After calling this API function, it is the user's responsibility to 4898 * initialize the AVHWFramesContext (returned by the out_frames_ref parameter), 4899 * and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done 4900 * before returning from get_format (this is implied by the normal 4901 * AVCodecContext.hw_frames_ctx API rules). 4902 * - The AVHWFramesContext parameters may change every time time get_format is 4903 * called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So 4904 * you are inherently required to go through this process again on every 4905 * get_format call. 4906 * - It is perfectly possible to call this function without actually using 4907 * the resulting AVHWFramesContext. One use-case might be trying to reuse a 4908 * previously initialized AVHWFramesContext, and calling this API function 4909 * only to test whether the required frame parameters have changed. 4910 * - Fields that use dynamically allocated values of any kind must not be set 4911 * by the user unless setting them is explicitly allowed by the documentation. 4912 * If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque, 4913 * the new free callback must call the potentially set previous free callback. 4914 * This API call may set any dynamically allocated fields, including the free 4915 * callback. 4916 * 4917 * The function will set at least the following fields on AVHWFramesContext 4918 * (potentially more, depending on hwaccel API): 4919 * 4920 * - All fields set by av_hwframe_ctx_alloc(). 4921 * - Set the format field to hw_pix_fmt. 4922 * - Set the sw_format field to the most suited and most versatile format. (An 4923 * implication is that this will prefer generic formats over opaque formats 4924 * with arbitrary restrictions, if possible.) 4925 * - Set the width/height fields to the coded frame size, rounded up to the 4926 * API-specific minimum alignment. 4927 * - Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size 4928 * field to the number of maximum reference surfaces possible with the codec, 4929 * plus 1 surface for the user to work (meaning the user can safely reference 4930 * at most 1 decoded surface at a time), plus additional buffering introduced 4931 * by frame threading. If the hwaccel does not require pre-allocation, the 4932 * field is left to 0, and the decoder will allocate new surfaces on demand 4933 * during decoding. 4934 * - Possibly AVHWFramesContext.hwctx fields, depending on the underlying 4935 * hardware API. 4936 * 4937 * Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but 4938 * with basic frame parameters set. 4939 * 4940 * The function is stateless, and does not change the AVCodecContext or the 4941 * device_ref AVHWDeviceContext. 4942 * 4943 * @param avctx The context which is currently calling get_format, and which 4944 * implicitly contains all state needed for filling the returned 4945 * AVHWFramesContext properly. 4946 * @param device_ref A reference to the AVHWDeviceContext describing the device 4947 * which will be used by the hardware decoder. 4948 * @param hw_pix_fmt The hwaccel format you are going to return from get_format. 4949 * @param out_frames_ref On success, set to a reference to an _uninitialized_ 4950 * AVHWFramesContext, created from the given device_ref. 4951 * Fields will be set to values required for decoding. 4952 * Not changed if an error is returned. 4953 * @return zero on success, a negative value on error. The following error codes 4954 * have special semantics: 4955 * AVERROR(ENOENT): the decoder does not support this functionality. Setup 4956 * is always manual, or it is a decoder which does not 4957 * support setting AVCodecContext.hw_frames_ctx at all, 4958 * or it is a software format. 4959 * AVERROR(EINVAL): it is known that hardware decoding is not supported for 4960 * this configuration, or the device_ref is not supported 4961 * for the hwaccel referenced by hw_pix_fmt. 4962 */ 4963 int avcodec_get_hw_frames_parameters ( 4964 AVCodecContext* avctx, 4965 AVBufferRef* device_ref, 4966 AVPixelFormat hw_pix_fmt, 4967 AVBufferRef** out_frames_ref); 4968 4969 /** 4970 * @defgroup lavc_parsing Frame parsing 4971 * @{ 4972 */ 4973 4974 enum AVPictureStructure 4975 { 4976 AV_PICTURE_STRUCTURE_UNKNOWN = 0, //< unknown 4977 AV_PICTURE_STRUCTURE_TOP_FIELD = 1, //< coded as top field 4978 AV_PICTURE_STRUCTURE_BOTTOM_FIELD = 2, //< coded as bottom field 4979 AV_PICTURE_STRUCTURE_FRAME = 3 //< coded as frame 4980 } 4981 4982 struct AVCodecParserContext 4983 { 4984 void* priv_data; 4985 AVCodecParser* parser; 4986 long frame_offset; /* offset of the current frame */ 4987 long cur_offset; /* current offset 4988 (incremented by each av_parser_parse()) */ 4989 long next_frame_offset; /* offset of the next frame */ 4990 /* video info */ 4991 int pict_type; /* XXX: Put it back in AVCodecContext. */ 4992 /** 4993 * This field is used for proper frame duration computation in lavf. 4994 * It signals, how much longer the frame duration of the current frame 4995 * is compared to normal frame duration. 4996 * 4997 * frame_duration = (1 + repeat_pict) * time_base 4998 * 4999 * It is used by codecs like H.264 to display telecined material. 5000 */ 5001 int repeat_pict; /* XXX: Put it back in AVCodecContext. */ 5002 long pts; /* pts of the current frame */ 5003 long dts; /* dts of the current frame */ 5004 5005 /* private data */ 5006 long last_pts; 5007 long last_dts; 5008 int fetch_timestamp; 5009 5010 int cur_frame_start_index; 5011 long[AV_PARSER_PTS_NB] cur_frame_offset; 5012 long[AV_PARSER_PTS_NB] cur_frame_pts; 5013 long[AV_PARSER_PTS_NB] cur_frame_dts; 5014 5015 int flags; 5016 5017 /// Set if the parser has a valid file offset 5018 5019 long offset; ///< byte offset from starting packet start 5020 long[AV_PARSER_PTS_NB] cur_frame_end; 5021 5022 /** 5023 * Set by parser to 1 for key frames and 0 for non-key frames. 5024 * It is initialized to -1, so if the parser doesn't set this flag, 5025 * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames 5026 * will be used. 5027 */ 5028 int key_frame; 5029 5030 /** 5031 * @deprecated unused 5032 */ 5033 long convergence_duration; 5034 5035 // Timestamp generation support: 5036 /** 5037 * Synchronization point for start of timestamp generation. 5038 * 5039 * Set to >0 for sync point, 0 for no sync point and <0 for undefined 5040 * (default). 5041 * 5042 * For example, this corresponds to presence of H.264 buffering period 5043 * SEI message. 5044 */ 5045 int dts_sync_point; 5046 5047 /** 5048 * Offset of the current timestamp against last timestamp sync point in 5049 * units of AVCodecContext.time_base. 5050 * 5051 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must 5052 * contain a valid timestamp offset. 5053 * 5054 * Note that the timestamp of sync point has usually a nonzero 5055 * dts_ref_dts_delta, which refers to the previous sync point. Offset of 5056 * the next frame after timestamp sync point will be usually 1. 5057 * 5058 * For example, this corresponds to H.264 cpb_removal_delay. 5059 */ 5060 int dts_ref_dts_delta; 5061 5062 /** 5063 * Presentation delay of current frame in units of AVCodecContext.time_base. 5064 * 5065 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must 5066 * contain valid non-negative timestamp delta (presentation time of a frame 5067 * must not lie in the past). 5068 * 5069 * This delay represents the difference between decoding and presentation 5070 * time of the frame. 5071 * 5072 * For example, this corresponds to H.264 dpb_output_delay. 5073 */ 5074 int pts_dts_delta; 5075 5076 /** 5077 * Position of the packet in file. 5078 * 5079 * Analogous to cur_frame_pts/dts 5080 */ 5081 long[AV_PARSER_PTS_NB] cur_frame_pos; 5082 5083 /** 5084 * Byte position of currently parsed frame in stream. 5085 */ 5086 long pos; 5087 5088 /** 5089 * Previous frame byte position. 5090 */ 5091 long last_pos; 5092 5093 /** 5094 * Duration of the current frame. 5095 * For audio, this is in units of 1 / AVCodecContext.sample_rate. 5096 * For all other types, this is in units of AVCodecContext.time_base. 5097 */ 5098 int duration; 5099 5100 AVFieldOrder field_order; 5101 5102 /** 5103 * Indicate whether a picture is coded as a frame, top field or bottom field. 5104 * 5105 * For example, H.264 field_pic_flag equal to 0 corresponds to 5106 * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag 5107 * equal to 1 and bottom_field_flag equal to 0 corresponds to 5108 * AV_PICTURE_STRUCTURE_TOP_FIELD. 5109 */ 5110 AVPictureStructure picture_structure; 5111 5112 /** 5113 * Picture number incremented in presentation or output order. 5114 * This field may be reinitialized at the first picture of a new sequence. 5115 * 5116 * For example, this corresponds to H.264 PicOrderCnt. 5117 */ 5118 int output_picture_number; 5119 5120 /** 5121 * Dimensions of the decoded video intended for presentation. 5122 */ 5123 int width; 5124 int height; 5125 5126 /** 5127 * Dimensions of the coded video. 5128 */ 5129 int coded_width; 5130 int coded_height; 5131 5132 /** 5133 * The format of the coded data, corresponds to enum AVPixelFormat for video 5134 * and for enum AVSampleFormat for audio. 5135 * 5136 * Note that a decoder can have considerable freedom in how exactly it 5137 * decodes the data, so the format reported here might be different from the 5138 * one returned by a decoder. 5139 */ 5140 int format; 5141 } 5142 5143 enum AV_PARSER_PTS_NB = 4; 5144 enum PARSER_FLAG_COMPLETE_FRAMES = 0x0001; 5145 enum PARSER_FLAG_ONCE = 0x0002; 5146 enum PARSER_FLAG_FETCHED_OFFSET = 0x0004; 5147 enum PARSER_FLAG_USE_CODEC_TS = 0x1000; 5148 5149 struct AVCodecParser 5150 { 5151 int[5] codec_ids; /* several codec IDs are permitted */ 5152 int priv_data_size; 5153 int function (AVCodecParserContext* s) parser_init; 5154 /* This callback never returns an error, a negative value means that 5155 * the frame start was in a previous packet. */ 5156 int function ( 5157 AVCodecParserContext* s, 5158 AVCodecContext* avctx, 5159 const(ubyte*)* poutbuf, 5160 int* poutbuf_size, 5161 const(ubyte)* buf, 5162 int buf_size) parser_parse; 5163 void function (AVCodecParserContext* s) parser_close; 5164 int function (AVCodecContext* avctx, const(ubyte)* buf, int buf_size) split; 5165 AVCodecParser* next; 5166 } 5167 5168 /** 5169 * Iterate over all registered codec parsers. 5170 * 5171 * @param opaque a pointer where libavcodec will store the iteration state. Must 5172 * point to NULL to start the iteration. 5173 * 5174 * @return the next registered codec parser or NULL when the iteration is 5175 * finished 5176 */ 5177 const(AVCodecParser)* av_parser_iterate (void** opaque); 5178 5179 AVCodecParser* av_parser_next (const(AVCodecParser)* c); 5180 5181 void av_register_codec_parser (AVCodecParser* parser); 5182 AVCodecParserContext* av_parser_init (int codec_id); 5183 5184 /** 5185 * Parse a packet. 5186 * 5187 * @param s parser context. 5188 * @param avctx codec context. 5189 * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. 5190 * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. 5191 * @param buf input buffer. 5192 * @param buf_size buffer size in bytes without the padding. I.e. the full buffer 5193 size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE. 5194 To signal EOF, this should be 0 (so that the last frame 5195 can be output). 5196 * @param pts input presentation timestamp. 5197 * @param dts input decoding timestamp. 5198 * @param pos input byte position in stream. 5199 * @return the number of bytes of the input bitstream used. 5200 * 5201 * Example: 5202 * @code 5203 * while(in_len){ 5204 * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, 5205 * in_data, in_len, 5206 * pts, dts, pos); 5207 * in_data += len; 5208 * in_len -= len; 5209 * 5210 * if(size) 5211 * decode_frame(data, size); 5212 * } 5213 * @endcode 5214 */ 5215 int av_parser_parse2 ( 5216 AVCodecParserContext* s, 5217 AVCodecContext* avctx, 5218 ubyte** poutbuf, 5219 int* poutbuf_size, 5220 const(ubyte)* buf, 5221 int buf_size, 5222 long pts, 5223 long dts, 5224 long pos); 5225 5226 /** 5227 * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed 5228 * @deprecated use AVBitStreamFilter 5229 */ 5230 int av_parser_change ( 5231 AVCodecParserContext* s, 5232 AVCodecContext* avctx, 5233 ubyte** poutbuf, 5234 int* poutbuf_size, 5235 const(ubyte)* buf, 5236 int buf_size, 5237 int keyframe); 5238 void av_parser_close (AVCodecParserContext* s); 5239 5240 /** 5241 * @} 5242 * @} 5243 */ 5244 5245 /** 5246 * @addtogroup lavc_encoding 5247 * @{ 5248 */ 5249 5250 /** 5251 * Find a registered encoder with a matching codec ID. 5252 * 5253 * @param id AVCodecID of the requested encoder 5254 * @return An encoder if one was found, NULL otherwise. 5255 */ 5256 AVCodec* avcodec_find_encoder (AVCodecID id); 5257 5258 /** 5259 * Find a registered encoder with the specified name. 5260 * 5261 * @param name name of the requested encoder 5262 * @return An encoder if one was found, NULL otherwise. 5263 */ 5264 AVCodec* avcodec_find_encoder_by_name (const(char)* name); 5265 5266 /** 5267 * Encode a frame of audio. 5268 * 5269 * Takes input samples from frame and writes the next output packet, if 5270 * available, to avpkt. The output packet does not necessarily contain data for 5271 * the most recent frame, as encoders can delay, split, and combine input frames 5272 * internally as needed. 5273 * 5274 * @param avctx codec context 5275 * @param avpkt output AVPacket. 5276 * The user can supply an output buffer by setting 5277 * avpkt->data and avpkt->size prior to calling the 5278 * function, but if the size of the user-provided data is not 5279 * large enough, encoding will fail. If avpkt->data and 5280 * avpkt->size are set, avpkt->destruct must also be set. All 5281 * other AVPacket fields will be reset by the encoder using 5282 * av_init_packet(). If avpkt->data is NULL, the encoder will 5283 * allocate it. The encoder will set avpkt->size to the size 5284 * of the output packet. 5285 * 5286 * If this function fails or produces no output, avpkt will be 5287 * freed using av_packet_unref(). 5288 * @param[in] frame AVFrame containing the raw audio data to be encoded. 5289 * May be NULL when flushing an encoder that has the 5290 * AV_CODEC_CAP_DELAY capability set. 5291 * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame 5292 * can have any number of samples. 5293 * If it is not set, frame->nb_samples must be equal to 5294 * avctx->frame_size for all frames except the last. 5295 * The final frame may be smaller than avctx->frame_size. 5296 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the 5297 * output packet is non-empty, and to 0 if it is 5298 * empty. If the function returns an error, the 5299 * packet can be assumed to be invalid, and the 5300 * value of got_packet_ptr is undefined and should 5301 * not be used. 5302 * @return 0 on success, negative error code on failure 5303 * 5304 * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead 5305 */ 5306 int avcodec_encode_audio2 ( 5307 AVCodecContext* avctx, 5308 AVPacket* avpkt, 5309 const(AVFrame)* frame, 5310 int* got_packet_ptr); 5311 5312 /** 5313 * Encode a frame of video. 5314 * 5315 * Takes input raw video data from frame and writes the next output packet, if 5316 * available, to avpkt. The output packet does not necessarily contain data for 5317 * the most recent frame, as encoders can delay and reorder input frames 5318 * internally as needed. 5319 * 5320 * @param avctx codec context 5321 * @param avpkt output AVPacket. 5322 * The user can supply an output buffer by setting 5323 * avpkt->data and avpkt->size prior to calling the 5324 * function, but if the size of the user-provided data is not 5325 * large enough, encoding will fail. All other AVPacket fields 5326 * will be reset by the encoder using av_init_packet(). If 5327 * avpkt->data is NULL, the encoder will allocate it. 5328 * The encoder will set avpkt->size to the size of the 5329 * output packet. The returned data (if any) belongs to the 5330 * caller, he is responsible for freeing it. 5331 * 5332 * If this function fails or produces no output, avpkt will be 5333 * freed using av_packet_unref(). 5334 * @param[in] frame AVFrame containing the raw video data to be encoded. 5335 * May be NULL when flushing an encoder that has the 5336 * AV_CODEC_CAP_DELAY capability set. 5337 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the 5338 * output packet is non-empty, and to 0 if it is 5339 * empty. If the function returns an error, the 5340 * packet can be assumed to be invalid, and the 5341 * value of got_packet_ptr is undefined and should 5342 * not be used. 5343 * @return 0 on success, negative error code on failure 5344 * 5345 * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead 5346 */ 5347 int avcodec_encode_video2 ( 5348 AVCodecContext* avctx, 5349 AVPacket* avpkt, 5350 const(AVFrame)* frame, 5351 int* got_packet_ptr); 5352 5353 int avcodec_encode_subtitle ( 5354 AVCodecContext* avctx, 5355 ubyte* buf, 5356 int buf_size, 5357 const(AVSubtitle)* sub); 5358 5359 /** 5360 * @} 5361 */ 5362 5363 /** 5364 * @addtogroup lavc_picture 5365 * @{ 5366 */ 5367 5368 /** 5369 * @deprecated unused 5370 */ 5371 int avpicture_alloc ( 5372 AVPicture* picture, 5373 AVPixelFormat pix_fmt, 5374 int width, 5375 int height); 5376 5377 /** 5378 * @deprecated unused 5379 */ 5380 void avpicture_free (AVPicture* picture); 5381 5382 /** 5383 * @deprecated use av_image_fill_arrays() instead. 5384 */ 5385 int avpicture_fill ( 5386 AVPicture* picture, 5387 const(ubyte)* ptr, 5388 AVPixelFormat pix_fmt, 5389 int width, 5390 int height); 5391 5392 /** 5393 * @deprecated use av_image_copy_to_buffer() instead. 5394 */ 5395 int avpicture_layout ( 5396 const(AVPicture)* src, 5397 AVPixelFormat pix_fmt, 5398 int width, 5399 int height, 5400 ubyte* dest, 5401 int dest_size); 5402 5403 /** 5404 * @deprecated use av_image_get_buffer_size() instead. 5405 */ 5406 int avpicture_get_size (AVPixelFormat pix_fmt, int width, int height); 5407 5408 /** 5409 * @deprecated av_image_copy() instead. 5410 */ 5411 void av_picture_copy ( 5412 AVPicture* dst, 5413 const(AVPicture)* src, 5414 AVPixelFormat pix_fmt, 5415 int width, 5416 int height); 5417 5418 /** 5419 * @deprecated unused 5420 */ 5421 int av_picture_crop ( 5422 AVPicture* dst, 5423 const(AVPicture)* src, 5424 AVPixelFormat pix_fmt, 5425 int top_band, 5426 int left_band); 5427 5428 /** 5429 * @deprecated unused 5430 */ 5431 int av_picture_pad ( 5432 AVPicture* dst, 5433 const(AVPicture)* src, 5434 int height, 5435 int width, 5436 AVPixelFormat pix_fmt, 5437 int padtop, 5438 int padbottom, 5439 int padleft, 5440 int padright, 5441 int* color); 5442 5443 /** 5444 * @} 5445 */ 5446 5447 /** 5448 * @defgroup lavc_misc Utility functions 5449 * @ingroup libavc 5450 * 5451 * Miscellaneous utility functions related to both encoding and decoding 5452 * (or neither). 5453 * @{ 5454 */ 5455 5456 /** 5457 * @defgroup lavc_misc_pixfmt Pixel formats 5458 * 5459 * Functions for working with pixel formats. 5460 * @{ 5461 */ 5462 5463 /** 5464 * @deprecated Use av_pix_fmt_get_chroma_sub_sample 5465 */ 5466 5467 void avcodec_get_chroma_sub_sample ( 5468 AVPixelFormat pix_fmt, 5469 int* h_shift, 5470 int* v_shift); 5471 5472 /** 5473 * Return a value representing the fourCC code associated to the 5474 * pixel format pix_fmt, or 0 if no associated fourCC code can be 5475 * found. 5476 */ 5477 uint avcodec_pix_fmt_to_codec_tag (AVPixelFormat pix_fmt); 5478 5479 /** 5480 * @deprecated see av_get_pix_fmt_loss() 5481 */ 5482 int avcodec_get_pix_fmt_loss ( 5483 AVPixelFormat dst_pix_fmt, 5484 AVPixelFormat src_pix_fmt, 5485 int has_alpha); 5486 5487 /** 5488 * Find the best pixel format to convert to given a certain source pixel 5489 * format. When converting from one pixel format to another, information loss 5490 * may occur. For example, when converting from RGB24 to GRAY, the color 5491 * information will be lost. Similarly, other losses occur when converting from 5492 * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of 5493 * the given pixel formats should be used to suffer the least amount of loss. 5494 * The pixel formats from which it chooses one, are determined by the 5495 * pix_fmt_list parameter. 5496 * 5497 * 5498 * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from 5499 * @param[in] src_pix_fmt source pixel format 5500 * @param[in] has_alpha Whether the source pixel format alpha channel is used. 5501 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. 5502 * @return The best pixel format to convert to or -1 if none was found. 5503 */ 5504 AVPixelFormat avcodec_find_best_pix_fmt_of_list ( 5505 const(AVPixelFormat)* pix_fmt_list, 5506 AVPixelFormat src_pix_fmt, 5507 int has_alpha, 5508 int* loss_ptr); 5509 5510 /** 5511 * @deprecated see av_find_best_pix_fmt_of_2() 5512 */ 5513 AVPixelFormat avcodec_find_best_pix_fmt_of_2 ( 5514 AVPixelFormat dst_pix_fmt1, 5515 AVPixelFormat dst_pix_fmt2, 5516 AVPixelFormat src_pix_fmt, 5517 int has_alpha, 5518 int* loss_ptr); 5519 5520 AVPixelFormat avcodec_find_best_pix_fmt2 ( 5521 AVPixelFormat dst_pix_fmt1, 5522 AVPixelFormat dst_pix_fmt2, 5523 AVPixelFormat src_pix_fmt, 5524 int has_alpha, 5525 int* loss_ptr); 5526 5527 AVPixelFormat avcodec_default_get_format (AVCodecContext* s, const(AVPixelFormat)* fmt); 5528 5529 /** 5530 * @} 5531 */ 5532 5533 /** 5534 * Put a string representing the codec tag codec_tag in buf. 5535 * 5536 * @param buf buffer to place codec tag in 5537 * @param buf_size size in bytes of buf 5538 * @param codec_tag codec tag to assign 5539 * @return the length of the string that would have been generated if 5540 * enough space had been available, excluding the trailing null 5541 * 5542 * @deprecated see av_fourcc_make_string() and av_fourcc2str(). 5543 */ 5544 size_t av_get_codec_tag_string (char* buf, size_t buf_size, uint codec_tag); 5545 5546 void avcodec_string (char* buf, int buf_size, AVCodecContext* enc, int encode); 5547 5548 /** 5549 * Return a name for the specified profile, if available. 5550 * 5551 * @param codec the codec that is searched for the given profile 5552 * @param profile the profile value for which a name is requested 5553 * @return A name for the profile if found, NULL otherwise. 5554 */ 5555 const(char)* av_get_profile_name (const(AVCodec)* codec, int profile); 5556 5557 /** 5558 * Return a name for the specified profile, if available. 5559 * 5560 * @param codec_id the ID of the codec to which the requested profile belongs 5561 * @param profile the profile value for which a name is requested 5562 * @return A name for the profile if found, NULL otherwise. 5563 * 5564 * @note unlike av_get_profile_name(), which searches a list of profiles 5565 * supported by a specific decoder or encoder implementation, this 5566 * function searches the list of profiles from the AVCodecDescriptor 5567 */ 5568 const(char)* avcodec_profile_name (AVCodecID codec_id, int profile); 5569 5570 int avcodec_default_execute (AVCodecContext* c, int function (AVCodecContext* c2, void* arg2) func, void* arg, int* ret, int count, int size); 5571 int avcodec_default_execute2 (AVCodecContext* c, int function (AVCodecContext* c2, void* arg2, int, int) func, void* arg, int* ret, int count); 5572 //FIXME func typedef 5573 5574 /** 5575 * Fill AVFrame audio data and linesize pointers. 5576 * 5577 * The buffer buf must be a preallocated buffer with a size big enough 5578 * to contain the specified samples amount. The filled AVFrame data 5579 * pointers will point to this buffer. 5580 * 5581 * AVFrame extended_data channel pointers are allocated if necessary for 5582 * planar audio. 5583 * 5584 * @param frame the AVFrame 5585 * frame->nb_samples must be set prior to calling the 5586 * function. This function fills in frame->data, 5587 * frame->extended_data, frame->linesize[0]. 5588 * @param nb_channels channel count 5589 * @param sample_fmt sample format 5590 * @param buf buffer to use for frame data 5591 * @param buf_size size of buffer 5592 * @param align plane size sample alignment (0 = default) 5593 * @return >=0 on success, negative error code on failure 5594 * @todo return the size in bytes required to store the samples in 5595 * case of success, at the next libavutil bump 5596 */ 5597 int avcodec_fill_audio_frame ( 5598 AVFrame* frame, 5599 int nb_channels, 5600 AVSampleFormat sample_fmt, 5601 const(ubyte)* buf, 5602 int buf_size, 5603 int align_); 5604 5605 /** 5606 * Reset the internal decoder state / flush internal buffers. Should be called 5607 * e.g. when seeking or when switching to a different stream. 5608 * 5609 * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0), 5610 * this invalidates the frames previously returned from the decoder. When 5611 * refcounted frames are used, the decoder just releases any references it might 5612 * keep internally, but the caller's reference remains valid. 5613 */ 5614 void avcodec_flush_buffers (AVCodecContext* avctx); 5615 5616 /** 5617 * Return codec bits per sample. 5618 * 5619 * @param[in] codec_id the codec 5620 * @return Number of bits per sample or zero if unknown for the given codec. 5621 */ 5622 int av_get_bits_per_sample (AVCodecID codec_id); 5623 5624 /** 5625 * Return the PCM codec associated with a sample format. 5626 * @param be endianness, 0 for little, 1 for big, 5627 * -1 (or anything else) for native 5628 * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE 5629 */ 5630 AVCodecID av_get_pcm_codec (AVSampleFormat fmt, int be); 5631 5632 /** 5633 * Return codec bits per sample. 5634 * Only return non-zero if the bits per sample is exactly correct, not an 5635 * approximation. 5636 * 5637 * @param[in] codec_id the codec 5638 * @return Number of bits per sample or zero if unknown for the given codec. 5639 */ 5640 int av_get_exact_bits_per_sample (AVCodecID codec_id); 5641 5642 /** 5643 * Return audio frame duration. 5644 * 5645 * @param avctx codec context 5646 * @param frame_bytes size of the frame, or 0 if unknown 5647 * @return frame duration, in samples, if known. 0 if not able to 5648 * determine. 5649 */ 5650 int av_get_audio_frame_duration (AVCodecContext* avctx, int frame_bytes); 5651 5652 /** 5653 * This function is the same as av_get_audio_frame_duration(), except it works 5654 * with AVCodecParameters instead of an AVCodecContext. 5655 */ 5656 int av_get_audio_frame_duration2 (AVCodecParameters* par, int frame_bytes); 5657 5658 struct AVBitStreamFilterContext 5659 { 5660 void* priv_data; 5661 const(AVBitStreamFilter)* filter; 5662 AVCodecParserContext* parser; 5663 AVBitStreamFilterContext* next; 5664 /** 5665 * Internal default arguments, used if NULL is passed to av_bitstream_filter_filter(). 5666 * Not for access by library users. 5667 */ 5668 char* args; 5669 } 5670 5671 struct AVBSFInternal; 5672 5673 /** 5674 * The bitstream filter state. 5675 * 5676 * This struct must be allocated with av_bsf_alloc() and freed with 5677 * av_bsf_free(). 5678 * 5679 * The fields in the struct will only be changed (by the caller or by the 5680 * filter) as described in their documentation, and are to be considered 5681 * immutable otherwise. 5682 */ 5683 struct AVBSFContext 5684 { 5685 /** 5686 * A class for logging and AVOptions 5687 */ 5688 const(AVClass)* av_class; 5689 5690 /** 5691 * The bitstream filter this context is an instance of. 5692 */ 5693 const(AVBitStreamFilter)* filter; 5694 5695 /** 5696 * Opaque libavcodec internal data. Must not be touched by the caller in any 5697 * way. 5698 */ 5699 AVBSFInternal* internal; 5700 5701 /** 5702 * Opaque filter-specific private data. If filter->priv_class is non-NULL, 5703 * this is an AVOptions-enabled struct. 5704 */ 5705 void* priv_data; 5706 5707 /** 5708 * Parameters of the input stream. This field is allocated in 5709 * av_bsf_alloc(), it needs to be filled by the caller before 5710 * av_bsf_init(). 5711 */ 5712 AVCodecParameters* par_in; 5713 5714 /** 5715 * Parameters of the output stream. This field is allocated in 5716 * av_bsf_alloc(), it is set by the filter in av_bsf_init(). 5717 */ 5718 AVCodecParameters* par_out; 5719 5720 /** 5721 * The timebase used for the timestamps of the input packets. Set by the 5722 * caller before av_bsf_init(). 5723 */ 5724 AVRational time_base_in; 5725 5726 /** 5727 * The timebase used for the timestamps of the output packets. Set by the 5728 * filter in av_bsf_init(). 5729 */ 5730 AVRational time_base_out; 5731 } 5732 5733 struct AVBitStreamFilter 5734 { 5735 const(char)* name; 5736 5737 /** 5738 * A list of codec ids supported by the filter, terminated by 5739 * AV_CODEC_ID_NONE. 5740 * May be NULL, in that case the bitstream filter works with any codec id. 5741 */ 5742 const(AVCodecID)* codec_ids; 5743 5744 /** 5745 * A class for the private data, used to declare bitstream filter private 5746 * AVOptions. This field is NULL for bitstream filters that do not declare 5747 * any options. 5748 * 5749 * If this field is non-NULL, the first member of the filter private data 5750 * must be a pointer to AVClass, which will be set by libavcodec generic 5751 * code to this class. 5752 */ 5753 const(AVClass)* priv_class; 5754 5755 /***************************************************************** 5756 * No fields below this line are part of the public API. They 5757 * may not be used outside of libavcodec and can be changed and 5758 * removed at will. 5759 * New public fields should be added right above. 5760 ***************************************************************** 5761 */ 5762 5763 int priv_data_size; 5764 int function (AVBSFContext* ctx) init; 5765 int function (AVBSFContext* ctx, AVPacket* pkt) filter; 5766 void function (AVBSFContext* ctx) close; 5767 void function (AVBSFContext* ctx) flush; 5768 } 5769 5770 /** 5771 * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) 5772 * is deprecated. Use the new bitstream filtering API (using AVBSFContext). 5773 */ 5774 void av_register_bitstream_filter (AVBitStreamFilter* bsf); 5775 /** 5776 * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) 5777 * is deprecated. Use av_bsf_get_by_name(), av_bsf_alloc(), and av_bsf_init() 5778 * from the new bitstream filtering API (using AVBSFContext). 5779 */ 5780 AVBitStreamFilterContext* av_bitstream_filter_init (const(char)* name); 5781 /** 5782 * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) 5783 * is deprecated. Use av_bsf_send_packet() and av_bsf_receive_packet() from the 5784 * new bitstream filtering API (using AVBSFContext). 5785 */ 5786 int av_bitstream_filter_filter ( 5787 AVBitStreamFilterContext* bsfc, 5788 AVCodecContext* avctx, 5789 const(char)* args, 5790 ubyte** poutbuf, 5791 int* poutbuf_size, 5792 const(ubyte)* buf, 5793 int buf_size, 5794 int keyframe); 5795 /** 5796 * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) 5797 * is deprecated. Use av_bsf_free() from the new bitstream filtering API (using 5798 * AVBSFContext). 5799 */ 5800 void av_bitstream_filter_close (AVBitStreamFilterContext* bsf); 5801 /** 5802 * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) 5803 * is deprecated. Use av_bsf_iterate() from the new bitstream filtering API (using 5804 * AVBSFContext). 5805 */ 5806 const(AVBitStreamFilter)* av_bitstream_filter_next ( 5807 const(AVBitStreamFilter)* f); 5808 5809 /** 5810 * @return a bitstream filter with the specified name or NULL if no such 5811 * bitstream filter exists. 5812 */ 5813 const(AVBitStreamFilter)* av_bsf_get_by_name (const(char)* name); 5814 5815 /** 5816 * Iterate over all registered bitstream filters. 5817 * 5818 * @param opaque a pointer where libavcodec will store the iteration state. Must 5819 * point to NULL to start the iteration. 5820 * 5821 * @return the next registered bitstream filter or NULL when the iteration is 5822 * finished 5823 */ 5824 const(AVBitStreamFilter)* av_bsf_iterate (void** opaque); 5825 const(AVBitStreamFilter)* av_bsf_next (void** opaque); 5826 5827 /** 5828 * Allocate a context for a given bitstream filter. The caller must fill in the 5829 * context parameters as described in the documentation and then call 5830 * av_bsf_init() before sending any data to the filter. 5831 * 5832 * @param filter the filter for which to allocate an instance. 5833 * @param ctx a pointer into which the pointer to the newly-allocated context 5834 * will be written. It must be freed with av_bsf_free() after the 5835 * filtering is done. 5836 * 5837 * @return 0 on success, a negative AVERROR code on failure 5838 */ 5839 int av_bsf_alloc (const(AVBitStreamFilter)* filter, AVBSFContext** ctx); 5840 5841 /** 5842 * Prepare the filter for use, after all the parameters and options have been 5843 * set. 5844 */ 5845 int av_bsf_init (AVBSFContext* ctx); 5846 5847 /** 5848 * Submit a packet for filtering. 5849 * 5850 * After sending each packet, the filter must be completely drained by calling 5851 * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or 5852 * AVERROR_EOF. 5853 * 5854 * @param pkt the packet to filter. The bitstream filter will take ownership of 5855 * the packet and reset the contents of pkt. pkt is not touched if an error occurs. 5856 * This parameter may be NULL, which signals the end of the stream (i.e. no more 5857 * packets will be sent). That will cause the filter to output any packets it 5858 * may have buffered internally. 5859 * 5860 * @return 0 on success, a negative AVERROR on error. 5861 */ 5862 int av_bsf_send_packet (AVBSFContext* ctx, AVPacket* pkt); 5863 5864 /** 5865 * Retrieve a filtered packet. 5866 * 5867 * @param[out] pkt this struct will be filled with the contents of the filtered 5868 * packet. It is owned by the caller and must be freed using 5869 * av_packet_unref() when it is no longer needed. 5870 * This parameter should be "clean" (i.e. freshly allocated 5871 * with av_packet_alloc() or unreffed with av_packet_unref()) 5872 * when this function is called. If this function returns 5873 * successfully, the contents of pkt will be completely 5874 * overwritten by the returned data. On failure, pkt is not 5875 * touched. 5876 * 5877 * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the 5878 * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there 5879 * will be no further output from the filter. Another negative AVERROR value if 5880 * an error occurs. 5881 * 5882 * @note one input packet may result in several output packets, so after sending 5883 * a packet with av_bsf_send_packet(), this function needs to be called 5884 * repeatedly until it stops returning 0. It is also possible for a filter to 5885 * output fewer packets than were sent to it, so this function may return 5886 * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call. 5887 */ 5888 int av_bsf_receive_packet (AVBSFContext* ctx, AVPacket* pkt); 5889 5890 /** 5891 * Reset the internal bitstream filter state / flush internal buffers. 5892 */ 5893 void av_bsf_flush (AVBSFContext* ctx); 5894 5895 /** 5896 * Free a bitstream filter context and everything associated with it; write NULL 5897 * into the supplied pointer. 5898 */ 5899 void av_bsf_free (AVBSFContext** ctx); 5900 5901 /** 5902 * Get the AVClass for AVBSFContext. It can be used in combination with 5903 * AV_OPT_SEARCH_FAKE_OBJ for examining options. 5904 * 5905 * @see av_opt_find(). 5906 */ 5907 const(AVClass)* av_bsf_get_class (); 5908 5909 /** 5910 * Structure for chain/list of bitstream filters. 5911 * Empty list can be allocated by av_bsf_list_alloc(). 5912 */ 5913 struct AVBSFList; 5914 5915 /** 5916 * Allocate empty list of bitstream filters. 5917 * The list must be later freed by av_bsf_list_free() 5918 * or finalized by av_bsf_list_finalize(). 5919 * 5920 * @return Pointer to @ref AVBSFList on success, NULL in case of failure 5921 */ 5922 AVBSFList* av_bsf_list_alloc (); 5923 5924 /** 5925 * Free list of bitstream filters. 5926 * 5927 * @param lst Pointer to pointer returned by av_bsf_list_alloc() 5928 */ 5929 void av_bsf_list_free (AVBSFList** lst); 5930 5931 /** 5932 * Append bitstream filter to the list of bitstream filters. 5933 * 5934 * @param lst List to append to 5935 * @param bsf Filter context to be appended 5936 * 5937 * @return >=0 on success, negative AVERROR in case of failure 5938 */ 5939 int av_bsf_list_append (AVBSFList* lst, AVBSFContext* bsf); 5940 5941 /** 5942 * Construct new bitstream filter context given it's name and options 5943 * and append it to the list of bitstream filters. 5944 * 5945 * @param lst List to append to 5946 * @param bsf_name Name of the bitstream filter 5947 * @param options Options for the bitstream filter, can be set to NULL 5948 * 5949 * @return >=0 on success, negative AVERROR in case of failure 5950 */ 5951 int av_bsf_list_append2 (AVBSFList* lst, const(char)* bsf_name, AVDictionary** options); 5952 /** 5953 * Finalize list of bitstream filters. 5954 * 5955 * This function will transform @ref AVBSFList to single @ref AVBSFContext, 5956 * so the whole chain of bitstream filters can be treated as single filter 5957 * freshly allocated by av_bsf_alloc(). 5958 * If the call is successful, @ref AVBSFList structure is freed and lst 5959 * will be set to NULL. In case of failure, caller is responsible for 5960 * freeing the structure by av_bsf_list_free() 5961 * 5962 * @param lst Filter list structure to be transformed 5963 * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure 5964 * representing the chain of bitstream filters 5965 * 5966 * @return >=0 on success, negative AVERROR in case of failure 5967 */ 5968 int av_bsf_list_finalize (AVBSFList** lst, AVBSFContext** bsf); 5969 5970 /** 5971 * Parse string describing list of bitstream filters and create single 5972 * @ref AVBSFContext describing the whole chain of bitstream filters. 5973 * Resulting @ref AVBSFContext can be treated as any other @ref AVBSFContext freshly 5974 * allocated by av_bsf_alloc(). 5975 * 5976 * @param str String describing chain of bitstream filters in format 5977 * `bsf1[=opt1=val1:opt2=val2][,bsf2]` 5978 * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure 5979 * representing the chain of bitstream filters 5980 * 5981 * @return >=0 on success, negative AVERROR in case of failure 5982 */ 5983 int av_bsf_list_parse_str (const(char)* str, AVBSFContext** bsf); 5984 5985 /** 5986 * Get null/pass-through bitstream filter. 5987 * 5988 * @param[out] bsf Pointer to be set to new instance of pass-through bitstream filter 5989 * 5990 * @return 5991 */ 5992 int av_bsf_get_null_filter (AVBSFContext** bsf); 5993 5994 /* memory */ 5995 5996 /** 5997 * Same behaviour av_fast_malloc but the buffer has additional 5998 * AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. 5999 * 6000 * In addition the whole buffer will initially and after resizes 6001 * be 0-initialized so that no uninitialized data will ever appear. 6002 */ 6003 void av_fast_padded_malloc (void* ptr, uint* size, size_t min_size); 6004 6005 /** 6006 * Same behaviour av_fast_padded_malloc except that buffer will always 6007 * be 0-initialized after call. 6008 */ 6009 void av_fast_padded_mallocz (void* ptr, uint* size, size_t min_size); 6010 6011 /** 6012 * Encode extradata length to a buffer. Used by xiph codecs. 6013 * 6014 * @param s buffer to write to; must be at least (v/255+1) bytes long 6015 * @param v size of extradata in bytes 6016 * @return number of bytes written to the buffer. 6017 */ 6018 uint av_xiphlacing (ubyte* s, uint v); 6019 6020 /** 6021 * Register the hardware accelerator hwaccel. 6022 * 6023 * @deprecated This function doesn't do anything. 6024 */ 6025 void av_register_hwaccel (AVHWAccel* hwaccel); 6026 6027 /** 6028 * If hwaccel is NULL, returns the first registered hardware accelerator, 6029 * if hwaccel is non-NULL, returns the next registered hardware accelerator 6030 * after hwaccel, or NULL if hwaccel is the last one. 6031 * 6032 * @deprecated AVHWaccel structures contain no user-serviceable parts, so 6033 * this function should not be used. 6034 */ 6035 AVHWAccel* av_hwaccel_next (const(AVHWAccel)* hwaccel); 6036 6037 /** 6038 * Lock operation used by lockmgr 6039 * 6040 * @deprecated Deprecated together with av_lockmgr_register(). 6041 */ 6042 enum AVLockOp 6043 { 6044 AV_LOCK_CREATE = 0, ///< Create a mutex 6045 AV_LOCK_OBTAIN = 1, ///< Lock the mutex 6046 AV_LOCK_RELEASE = 2, ///< Unlock the mutex 6047 AV_LOCK_DESTROY = 3 ///< Free mutex resources 6048 } 6049 6050 /** 6051 * Register a user provided lock manager supporting the operations 6052 * specified by AVLockOp. The "mutex" argument to the function points 6053 * to a (void *) where the lockmgr should store/get a pointer to a user 6054 * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the 6055 * value left by the last call for all other ops. If the lock manager is 6056 * unable to perform the op then it should leave the mutex in the same 6057 * state as when it was called and return a non-zero value. However, 6058 * when called with AV_LOCK_DESTROY the mutex will always be assumed to 6059 * have been successfully destroyed. If av_lockmgr_register succeeds 6060 * it will return a non-negative value, if it fails it will return a 6061 * negative value and destroy all mutex and unregister all callbacks. 6062 * av_lockmgr_register is not thread-safe, it must be called from a 6063 * single thread before any calls which make use of locking are used. 6064 * 6065 * @param cb User defined callback. av_lockmgr_register invokes calls 6066 * to this callback and the previously registered callback. 6067 * The callback will be used to create more than one mutex 6068 * each of which must be backed by its own underlying locking 6069 * mechanism (i.e. do not use a single static object to 6070 * implement your lock manager). If cb is set to NULL the 6071 * lockmgr will be unregistered. 6072 * 6073 * @deprecated This function does nothing, and always returns 0. Be sure to 6074 * build with thread support to get basic thread safety. 6075 */ 6076 int av_lockmgr_register (int function (void** mutex, AVLockOp op) cb); 6077 6078 /** 6079 * Get the type of the given codec. 6080 */ 6081 AVMediaType avcodec_get_type (AVCodecID codec_id); 6082 6083 /** 6084 * Get the name of a codec. 6085 * @return a static string identifying the codec; never NULL 6086 */ 6087 const(char)* avcodec_get_name (AVCodecID id); 6088 6089 /** 6090 * @return a positive value if s is open (i.e. avcodec_open2() was called on it 6091 * with no corresponding avcodec_close()), 0 otherwise. 6092 */ 6093 int avcodec_is_open (AVCodecContext* s); 6094 6095 /** 6096 * @return a non-zero number if codec is an encoder, zero otherwise 6097 */ 6098 int av_codec_is_encoder (const(AVCodec)* codec); 6099 6100 /** 6101 * @return a non-zero number if codec is a decoder, zero otherwise 6102 */ 6103 int av_codec_is_decoder (const(AVCodec)* codec); 6104 6105 /** 6106 * @return descriptor for given codec ID or NULL if no descriptor exists. 6107 */ 6108 const(AVCodecDescriptor)* avcodec_descriptor_get (AVCodecID id); 6109 6110 /** 6111 * Iterate over all codec descriptors known to libavcodec. 6112 * 6113 * @param prev previous descriptor. NULL to get the first descriptor. 6114 * 6115 * @return next descriptor or NULL after the last descriptor 6116 */ 6117 const(AVCodecDescriptor)* avcodec_descriptor_next (const(AVCodecDescriptor)* prev); 6118 6119 /** 6120 * @return codec descriptor with the given name or NULL if no such descriptor 6121 * exists. 6122 */ 6123 const(AVCodecDescriptor)* avcodec_descriptor_get_by_name (const(char)* name); 6124 6125 /** 6126 * Allocate a CPB properties structure and initialize its fields to default 6127 * values. 6128 * 6129 * @param size if non-NULL, the size of the allocated struct will be written 6130 * here. This is useful for embedding it in side data. 6131 * 6132 * @return the newly allocated struct or NULL on failure 6133 */ 6134 AVCPBProperties* av_cpb_properties_alloc (size_t* size); 6135 6136 /** 6137 * @} 6138 */ 6139 6140 /* AVCODEC_AVCODEC_H */