From 678cc132f942ff4d84a803550eedf96acc543bca Mon Sep 17 00:00:00 2001 From: tobigun Date: Sun, 23 May 2010 09:07:15 +0000 Subject: update to trunk rev. 2391 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2401 b956fd51-792f-4845-bead-9b4dfca2ff2c --- cmake/src/lib/ffmpeg/avcodec.pas | 730 ++++++++++++++++----- cmake/src/lib/ffmpeg/avformat.pas | 315 +++++++-- cmake/src/lib/ffmpeg/avio.pas | 204 +++++- cmake/src/lib/ffmpeg/avutil.pas | 140 +++- cmake/src/lib/ffmpeg/error.pas | 113 ++++ cmake/src/lib/ffmpeg/mathematics.pas | 30 +- cmake/src/lib/ffmpeg/opt.pas | 59 +- cmake/src/lib/ffmpeg/rational.pas | 4 +- cmake/src/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt | 24 - cmake/src/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh | 6 - .../lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh | 23 - cmake/src/lib/ffmpeg/swscale.pas | 92 ++- 12 files changed, 1408 insertions(+), 332 deletions(-) create mode 100644 cmake/src/lib/ffmpeg/error.pas delete mode 100644 cmake/src/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt delete mode 100755 cmake/src/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh delete mode 100755 cmake/src/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh (limited to 'cmake/src/lib/ffmpeg') diff --git a/cmake/src/lib/ffmpeg/avcodec.pas b/cmake/src/lib/ffmpeg/avcodec.pas index ceb1b7f0..7e55e13a 100644 --- a/cmake/src/lib/ffmpeg/avcodec.pas +++ b/cmake/src/lib/ffmpeg/avcodec.pas @@ -27,13 +27,9 @@ (* * Conversion of libavcodec/avcodec.h * Min. version: 51.16.0, revision 6577, Sat Oct 7 15:30:46 2006 UTC - * Max. version: 52.11.0, revision 16912, Sun Feb 1 02:00:19 2009 UTC + * Max. version: 52.67.2, revision 23191, Wed May 19 19:30 2010 CET + * *) -{ - * update to - * Max. version: 52.31.2, Sar Jun 13 22:05:00 2009 UTC - * MiSchi -} unit avcodec; @@ -63,9 +59,34 @@ uses UConfig; const + (* + * IMPORTANT: The official FFmpeg C headers change very quickly. Often some + * of the data structures are changed so that they become incompatible with + * older header files. The Pascal headers have to be adjusted to those changes, + * otherwise the application might crash randomly or strange bugs (not + * necessarily related to video or audio due to buffer overflows etc.) might + * occur. + * + * In the past users reported problems with USDX that took hours to fix and + * the problem was an unsupported version of FFmpeg. So we decided to disable + * support for future versions of FFmpeg until the headers are revised by us + * for that version as they otherwise most probably will break USDX. + * + * If the headers do not yet support your FFmpeg version you may want to + * adjust the max. version numbers manually but please note: it may work but + * in many cases it does not. The USDX team does NOT PROVIDE ANY SUPPORT + * for the game if the MAX. VERSION WAS CHANGED. + * + * The only safe way to support new versions of FFmpeg is to add the changes + * of the FFmpeg git repository C headers to the Pascal headers. + * You can accelerate this process by posting a patch with the git changes + * translated to Pascal to our bug tracker (please join our IRC chat before + * you start working on it). Simply adjusting the max. versions is NOT a valid + * fix. + *) (* Max. supported version by this header *) LIBAVCODEC_MAX_VERSION_MAJOR = 52; - LIBAVCODEC_MAX_VERSION_MINOR = 31; + LIBAVCODEC_MAX_VERSION_MINOR = 67; LIBAVCODEC_MAX_VERSION_RELEASE = 2; LIBAVCODEC_MAX_VERSION = (LIBAVCODEC_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBAVCODEC_MAX_VERSION_MINOR * VERSION_MINOR) + @@ -173,7 +194,9 @@ type CODEC_ID_QDRAW, CODEC_ID_VIXL, CODEC_ID_QPEG, +{$IF LIBAVCODEC_VERSION_MAJOR < 53} CODEC_ID_XVID, +{$IFEND} CODEC_ID_PNG, CODEC_ID_PPM, CODEC_ID_PBM, @@ -260,6 +283,33 @@ type {$IF LIBAVCODEC_VERSION >= 52031002} // >= 52.31.2 CODEC_ID_MAD, {$IFEND} +{$IF LIBAVCODEC_VERSION >= 52037000} // >= 52.37.0 + CODEC_ID_FRWU, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52041000} // >= 52.41.0 + CODEC_ID_FLASHSV2, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52043000} // >= 52.43.0 + CODEC_ID_CDGRAPHICS, + CODEC_ID_R210, +{$IFEND} + CODEC_ID_ANM, +{$IF LIBAVCODEC_VERSION >= 52049000} // >= 52.49.0 + CODEC_ID_BINKVIDEO, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52052000} // >= 52.52.0 + CODEC_ID_IFF_ILBM, + CODEC_ID_IFF_BYTERUN1, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52058000} // >= 52.58.0 + CODEC_ID_KGV1, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52062000} // >= 52.62.0 + CODEC_ID_YOP, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52067002} // >= 52.67.2 + CODEC_ID_VP8, +{$IFEND} //* various PCM "codecs" */ CODEC_ID_PCM_S16LE= $10000, @@ -286,6 +336,9 @@ type CODEC_ID_PCM_F32LE, CODEC_ID_PCM_F64BE, CODEC_ID_PCM_F64LE, +{$IF LIBAVCODEC_VERSION >= 52034000} // >= 52.34.0 + CODEC_ID_PCM_BLURAY, +{$IFEND} //* various ADPCM codecs */ CODEC_ID_ADPCM_IMA_QT= $11000, @@ -390,6 +443,13 @@ type {$IF LIBAVCODEC_VERSION >= 52026000} // >= 52.26.0 CODEC_ID_MP4ALS, {$IFEND} +{$IF LIBAVCODEC_VERSION >= 52035000} // >= 52.35.0 + CODEC_ID_ATRAC1, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52049000} // >= 52.49.0 + CODEC_ID_BINKAUDIO_RDFT, + CODEC_ID_BINKAUDIO_DCT, +{$IFEND} //* subtitle codecs */ CODEC_ID_DVD_SUBTITLE= $17000, @@ -398,6 +458,12 @@ type CODEC_ID_XSUB, CODEC_ID_SSA, CODEC_ID_MOV_TEXT, +{$IF LIBAVCODEC_VERSION >= 52033000} // >= 52.33.0 + CODEC_ID_HDMV_PGS_SUBTITLE, +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52037001} // >= 52.37.1 + CODEC_ID_DVB_TELETEXT, +{$IFEND} (* other specific kind of codecs (generally used for attachments) *) CODEC_ID_TTF= $18000, @@ -416,6 +482,7 @@ const CODEC_ID_MPEG4AAC = CODEC_ID_AAC; {$IFEND} +{$IF LIBAVCODEC_VERSION_MAJOR < 53} // < 53.0.0 type TCodecType = ( CODEC_TYPE_UNKNOWN = -1, @@ -426,6 +493,25 @@ type CODEC_TYPE_ATTACHMENT, CODEC_TYPE_NB ); +{$IFEND} + +{ + TAVMediaType moved to avutil in LIBAVUTIL_VERSION 50.14.0 + but moving it in the pascal headers was not really necessary + but caused problems. So, I (KMS) left it here. +} +{$IF LIBAVCODEC_VERSION >= 52064000} // >= 52.64.0 +type + TAVMediaType = ( + AVMEDIA_TYPE_UNKNOWN = -1, + AVMEDIA_TYPE_VIDEO, + AVMEDIA_TYPE_AUDIO, + AVMEDIA_TYPE_DATA, + AVMEDIA_TYPE_SUBTITLE, + AVMEDIA_TYPE_ATTACHMENT, + AVMEDIA_TYPE_NB + ); +{$IFEND} {** * all in native endian @@ -465,6 +551,13 @@ const CH_TOP_BACK_RIGHT = $00020000; CH_STEREO_LEFT = $20000000; ///< Stereo downmix. CH_STEREO_RIGHT = $40000000; ///< See CH_STEREO_LEFT. +{** Channel mask value used for AVCodecContext.request_channel_layout + * to indicate that the user requests the channel order of the decoder output + * to be the native codec channel order. + *} +{$IF LIBAVCODEC_VERSION >= 52038001} // >= 52.38.1 + CH_LAYOUT_NATIVE = $8000000000000000; +{$IFEND} {* Audio channel convenience macros *} CH_LAYOUT_MONO = (CH_FRONT_CENTER); @@ -482,6 +575,9 @@ const CH_LAYOUT_5POINT0_BACK = (CH_LAYOUT_SURROUND or CH_BACK_LEFT or CH_BACK_RIGHT); CH_LAYOUT_5POINT1_BACK = (CH_LAYOUT_5POINT0_BACK or CH_LOW_FREQUENCY); +{$IFEND} +{$IF LIBAVCODEC_VERSION >= 52034000} // >= 52.34.0 + CH_LAYOUT_7POINT0 = (CH_LAYOUT_5POINT0 or CH_BACK_LEFT or CH_BACK_RIGHT); {$IFEND} CH_LAYOUT_7POINT1 = (CH_LAYOUT_5POINT1 or CH_BACK_LEFT or CH_BACK_RIGHT); {$IF LIBAVCODEC_VERSION < 52025000} // < 52.25.0 @@ -494,11 +590,30 @@ const CH_FRONT_RIGHT_OF_CENTER); CH_LAYOUT_STEREO_DOWNMIX = (CH_STEREO_LEFT or CH_STEREO_RIGHT); - -const - {* in bytes *} +{* in bytes *} AVCODEC_MAX_AUDIO_FRAME_SIZE = 192000; // 1 second of 48khz 32bit audio +{$IF LIBAVCODEC_VERSION <= 52056000} // <= 52.56.0 +{** + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.
+ * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + *} + FF_INPUT_BUFFER_PADDING_SIZE = 8; +{$ELSEIF LIBAVCODEC_VERSION < 52058000} // < 52.58.0 +{** + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * The first 8 bytes are needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end. The remainder is to give + * decoders a reasonable amount of distance to work with before checking for + * buffer overreads.
+ * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + *} + FF_INPUT_BUFFER_PADDING_SIZE = 64; +{$ELSE} // >= 52.58.0} {** * Required number of additionally allocated bytes at the end of the input bitstream for decoding. * This is mainly needed because some optimized bitstream readers read @@ -507,6 +622,7 @@ const * MPEG bitstreams could cause overread and segfault. *} FF_INPUT_BUFFER_PADDING_SIZE = 8; +{$IFEND} {** * minimum encoding buffer size. @@ -676,6 +792,16 @@ const CODEC_FLAG2_CHUNKS = $00008000; ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. CODEC_FLAG2_NON_LINEAR_QUANT = $00010000; ///< Use MPEG-2 nonlinear quantizer. CODEC_FLAG2_BIT_RESERVOIR = $00020000; ///< Use a bit reservoir when encoding if possible + {$IF LIBAVCODEC_VERSION >= 52043000} // >= 52.43.0 + CODEC_FLAG2_MBTREE = $00040000; ///< Use macroblock tree ratecontrol (x264 only) + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52061000} // >= 52.61.0 + CODEC_FLAG2_PSY = $00080000; ///< Use psycho visual optimizations. + CODEC_FLAG2_SSIM = $00100000; ///< Compute SSIM during encoding, error[] values are undefined. + {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52067000} // >= 52.67.0 + CODEC_FLAG2_INTRA_REFRESH = $00200000; ///< Use periodic insertion of intra blocks instead of keyframes. + {$IFEND} (* Unsupported options : * Syntax Arithmetic coding (SAC) @@ -684,11 +810,11 @@ const (* /Fx *) (* codec capabilities *) -const CODEC_CAP_DRAW_HORIZ_BAND = $0001; ///< decoder can use draw_horiz_band callback (** - * Codec uses get_buffer() for allocating buffers. - * direct rendering method 1 + * Codec uses get_buffer() for allocating buffers and supports custom allocators. + * If not set, it might not use get_buffer() at all or use operations that + * assume the buffer was allocated by avcodec_default_get_buffer. *) CODEC_CAP_DR1 = $0002; (* if 'parse_only' field is true, then avcodec_parse_frame() can be used *) @@ -712,6 +838,21 @@ const *) CODEC_CAP_HWACCEL_VDPAU = $0080; + {$IF LIBAVCODEC_VERSION >= 52035000} // >= 52.35.0 + (** + * Codec can output multiple frames per AVPacket + * Normally demuxers return one frame at a time, demuxers which do not do + * are connected to a parser to split what they return into proper frames. + * This flag is reserved to the very rare category of codecs which have a + * bitstream that cannot be split into frames without timeconsuming + * operations like full decoding. Demuxers carring such bitstreams thus + * may return multiple frames in a packet. This has many disadvantages like + * prohibiting stream copy in many cases thus it should only be considered + * as a last resort. + *) + CODEC_CAP_SUBFRAMES = $0100; + {$IFEND} + //the following defines may change, don't expect compatibility if you use them MB_TYPE_INTRA4x4 = $001; MB_TYPE_INTRA16x16 = $002; //FIXME h264 specific @@ -765,6 +906,9 @@ const FF_QSCALE_TYPE_MPEG1 = 0; FF_QSCALE_TYPE_MPEG2 = 1; FF_QSCALE_TYPE_H264 = 2; + {$IF LIBAVCODEC_VERSION >= 52049000} // >= 52.49.0 + FF_QSCALE_TYPE_VP56 = 3; + {$IFEND} FF_BUFFER_TYPE_INTERNAL = 1; FF_BUFFER_TYPE_USER = 2; ///< Direct rendering buffers (image is (de)allocated by user) @@ -809,6 +953,9 @@ const FF_BUG_HPEL_CHROMA = 2048; FF_BUG_DC_CLIP = 4096; FF_BUG_MS = 8192; ///< workaround various bugs in microsofts broken decoders + {$IF LIBAVCODEC_VERSION >= 52054000} // >= 52.54.0 + FF_BUG_TRUNCATED = 16384; + {$IFEND} //FF_BUG_FAKE_SCALABILITY = 16 //Autodetection should work 100%. FF_COMPLIANCE_VERY_STRICT = 2; ///< strictly conform to a older more strict version of the spec or reference software @@ -854,6 +1001,9 @@ const FF_IDCT_EA = 21; FF_IDCT_SIMPLENEON = 22; FF_IDCT_SIMPLEALPHA = 23; + {$IF LIBAVCODEC_VERSION >= 52055000} // >= 52.55.0 + FF_IDCT_BINK = 24; + {$IFEND} FF_EC_GUESS_MVS = 1; FF_EC_DEBLOCK = 2; @@ -974,11 +1124,11 @@ const FF_COMPRESSION_DEFAULT = -1; +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} const AVPALETTE_SIZE = 1024; AVPALETTE_COUNT = 256; -{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} type (** * AVPaletteControl @@ -1054,7 +1204,7 @@ type end; const - {$IF LIBAVCODEC_VERSION >= 52030002} // >= 52.30.2 + {$IF LIBAVCODEC_VERSION < 52030002} // < 52.30.2 PKT_FLAG_KEY = $0001; {$ELSE} AV_PKT_FLAG_KEY = $0001; @@ -1079,7 +1229,11 @@ type TQuadIntArray = array[0..3] of cint; // int (*func)(struct AVCodecContext *c2, void *arg) TExecuteFunc = function(c2: PAVCodecContext; arg: Pointer): cint; cdecl; - +{$IF LIBAVCODEC_VERSION >= 52037000} // >= 52.37.0 + // int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr) + TExecute2Func = function(c2: PAVCodecContext; arg: Pointer; jobnr: cint; threadnr: cint): cint; cdecl; +{$IFEND} + TAVClass = record class_name: PAnsiChar; (* actually passing a pointer to an AVCodecContext @@ -1088,6 +1242,23 @@ type of AVIn/OutputFormat *) item_name: function(): PAnsiChar; cdecl; option: PAVOption; + +{$IF LIBAVUTIL_VERSION >= 50015000} // 50.15.0 + (** + * LIBAVUTIL_VERSION with which this structure was created. + * This is used to allow fields to be added without requiring major + * version bumps everywhere. + *) + version: cint; +{$IFEND} + +{$IF LIBAVUTIL_VERSION >= 50015002} // 50.15.2 + (** + * Offset in the structure where log_level_offset is stored. + * 0 means there is no such variable + *) + log_level_offset_offset: cint; +{$IFEND} end; {** @@ -1283,7 +1454,8 @@ type *) dct_coeff: PsmallInt; (** - * motion referece frame index + * motion reference frame index + * the order in which these are stored can depend on the codec. * - encoding: Set by user. * - decoding: Set by libavcodec. *) @@ -1307,118 +1479,11 @@ type *) hwaccel_data_private: pointer; {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52022000} // >= 52.22.0 hwaccel_picture_private: pointer; {$IFEND} - {$IF LIBAVCODEC_VERSION >= 51070000} // >= 51.70.0 - (** - * Bits per sample/pixel of internal libavcodec pixel/sample format. - * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. - * - encoding: set by user. - * - decoding: set by libavcodec. - *) - bits_per_raw_sample: cint; - {$IFEND} - - {$IF LIBAVCODEC_VERSION >= 52002000} // >= 52.2.0 - (** - * Audio channel layout. - * - encoding: set by user. - * - decoding: set by libavcodec. - *) - channel_layout: cint64; - - (** - * Request decoder to use this channel layout if it can (0 for default) - * - encoding: unused - * - decoding: Set by user. - *) - request_channel_layout: cint64; - {$IFEND} - - {$IF LIBAVCODEC_VERSION >= 52004000} // >= 52.4.0 - (** - * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. - * - encoding: Set by user. - * - decoding: unused. - *) - rc_max_available_vbv_use: cfloat; - - (** - * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. - * - encoding: Set by user. - * - decoding: unused. - *) - rc_min_vbv_overflow_use: cfloat; - {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52018000} // >= 52.18.0 - (** - * Hardware accelerator in use - * - encoding: unused. - * - decoding: Set by libavcodec - *) - hwaccel: PAVHWAccel; - {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52020000} // >= 52.20.0 - (** - * For some codecs, the time base is closer to the field rate than the frame rate. - * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration - * if no telecine is used ... - * - * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. - *) - ticks_per_frame: cint; - {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52021000} // >= 52.21.0 - (** - * Hardware accelerator context. - * For some hardware accelerators, a global context needs to be - * provided by the user. In that case, this holds display-dependent - * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this - * is. e.g. for VA API, this is a struct vaapi_context. - * - encoding: unused - * - decoding: Set by user - *) - hwaccel_context: pointer; - {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52028000} // >= 52.28.0 - (** - * Chromaticity coordinates of the source primaries. - * - encoding: Set by user - * - decoding: Set by libavcodec - *) - color_primaries: TAVColorPrimaries; - - (** - * Color Transfer Characteristic. - * - encoding: Set by user - * - decoding: Set by libavcodec - *) - color_trc: TAVColorTransferCharacteristic; - - (** - * YUV colorspace type. - * - encoding: Set by user - * - decoding: Set by libavcodec - *) - colorspace: TAVColorSpace; - - (** - * MPEG vs JPEG YUV range. - * - encoding: Set by user - * - decoding: Set by libavcodec - *) - color_range: TAVColorRange; - - (** - * This defines the location of chroma samples. - * - encoding: Set by user - * - decoding: Set by libavcodec - *) - chroma_sample_location: TAVChromaLocation; - {$IFEND} end; (** @@ -1563,7 +1628,7 @@ type * - encoding: Set by user. * - decoding: Set by libavcodec. *) - sample_fmt: TSampleFormat; ///< sample format, currenly unused + sample_fmt: TSampleFormat; ///< sample format (* The following data should not be initialized. *) (** @@ -1689,7 +1754,11 @@ type opaque: pointer; codec_name: array [0..31] of AnsiChar; +{$IF LIBAVCODEC_VERSION < 52064000} // < 52.64.0 codec_type: TCodecType; (* see CODEC_TYPE_xxx *) +{$ELSE} + codec_type: TAVMediaType; (* see AVMEDIA_TYPE_xxx *) +{$IFEND} codec_id: TCodecID; (* see CODEC_ID_xxx *) (** @@ -1760,7 +1829,7 @@ type (** * Called at the beginning of each frame to get a buffer for it. * If pic.reference is set then the frame will be read later by libavcodec. - * avcodec_align_dimensions() should be used to find the required width and + * avcodec_align_dimensions2() should be used to find the required width and * height, as they normally need to be rounded up to the next multiple of 16. * if CODEC_CAP_DR1 is not set then get_buffer() must call * avcodec_default_get_buffer() instead of providing buffers allocated by @@ -2745,7 +2814,111 @@ type reordered_opaque: cint64; {$IFEND} - {$IF LIBAVCODEC_VERSION >= 52028000} // 52.28.0 + {$IF LIBAVCODEC_VERSION >= 51069000} // 51.69.0 + (** + * Bits per sample/pixel of internal libavcodec pixel/sample format. + * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. + * - encoding: set by user. + * - decoding: set by libavcodec. + *) + bits_per_raw_sample: cint; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52002000} // 52.2.0 + (** + * Audio channel layout. + * - encoding: set by user. + * - decoding: set by libavcodec. + *) + channel_layout: cint64; + + (** + * Request decoder to use this channel layout if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + *) + request_channel_layout: cint64; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52004000} // >= 52.4.0 + (** + * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. + * - encoding: Set by user. + * - decoding: unused. + *) + rc_max_available_vbv_use: cfloat; + + (** + * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. + * - encoding: Set by user. + * - decoding: unused. + *) + rc_min_vbv_overflow_use: cfloat; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52018000} // >= 52.18.0 + (** + * Hardware accelerator in use + * - encoding: unused. + * - decoding: Set by libavcodec + *) + hwaccel: PAVHWAccel; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52020000} // >= 52.20.0 + (** + * For some codecs, the time base is closer to the field rate than the frame rate. + * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration + * if no telecine is used ... + * + * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + *) + ticks_per_frame: cint; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52021000} // >= 52.21.0 + (** + * Hardware accelerator context. + * For some hardware accelerators, a global context needs to be + * provided by the user. In that case, this holds display-dependent + * data FFmpeg cannot instantiate itself. Please refer to the + * FFmpeg HW accelerator documentation to know how to fill this + * is. e.g. for VA API, this is a struct vaapi_context. + * - encoding: unused + * - decoding: Set by user + *) + hwaccel_context: pointer; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52028000} // >= 52.28.0 + (** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + color_primaries: TAVColorPrimaries; + + (** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + color_trc: TAVColorTransferCharacteristic; + + (** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + colorspace: TAVColorSpace; + + (** + * MPEG vs JPEG YUV range. + * - encoding: Set by user + * - decoding: Set by libavcodec + *) + color_range: TAVColorRange; + (** * This defines the location of chroma samples. * - encoding: Set by user @@ -2753,6 +2926,95 @@ type *) chroma_sample_location: TAVChromaLocation; {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52037000} // >= 52.37.0 + (** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. + * @param c context passed also to func + * @param count the number of things to execute + * @param arg2 argument passed unchanged to func + * @param ret return values of executed functions, must have space for "count" values. May be NULL. + * @param func function that will be called count times, with jobnr from 0 to count-1. + * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no + * two instances of func executing at the same time will have the same threadnr. + * @return always 0 currently, but code should handle a future improvement where when any call to func + * returns < 0 no further calls to func may be done and < 0 is returned. + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + *) + execute2: function (c: PAVCodecContext; func: TExecute2Func; arg2: Pointer; ret: Pcint; count: cint): cint; cdecl; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52042000} // >= 52.42.0 + (** + * explicit P-frame weighted prediction analysis method + * 0: off + * 1: fast blind weighting (one reference duplicate with -1 offset) + * 2: smart weighting (full fade detection analysis) + * - encoding: Set by user. + * - decoding: unused + *) + weighted_p_pred: cint; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52061000} // >= 52.61.0 + (** + * AQ mode + * 0: Disabled + * 1: Variance AQ (complexity mask) + * 2: Auto-variance AQ (experimental) + * - encoding: Set by user + * - decoding: unused + *) + aq_mode: cint; + + (** + * AQ strength + * Reduces blocking and blurring in flat and textured areas. + * - encoding: Set by user + * - decoding: unused + *) + aq_strength: cfloat; + + (** + * PSY RD + * Strength of psychovisual optimization + * - encoding: Set by user + * - decoding: unused + *) + psy_rd: cfloat; + + (** + * PSY trellis + * Strength of psychovisual optimization + * - encoding: Set by user + * - decoding: unused + *) + psy_trellis: cfloat; + + (** + * RC lookahead + * Number of frames for frametype and ratecontrol lookahead + * - encoding: Set by user + * - decoding: unused + *) + rc_lookahead: cint; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 52067000} // >= 52.67.0 + (** + * Constant rate factor maximum + * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse + * than crf_max, even if doing so would violate VBV restrictions. + * - encoding: Set by user. + * - decoding: unused + *) + crf_max: cfloat; + {$IFEND} end; (** @@ -2760,7 +3022,11 @@ type *) TAVCodec = record name: PAnsiChar; +{$IF LIBAVCODEC_VERSION < 52064000} // < 52.64.0 type_: TCodecType; +{$ELSE} + type_: TAVMediaType; +{$IFEND} id: TCodecID; priv_data_size: cint; init: function (avctx: PAVCodecContext): cint; cdecl; (* typo corretion by the Creative CAT *) @@ -2815,13 +3081,23 @@ type *) name: PAnsiChar; +{$IF LIBAVCODEC_VERSION < 52064000} // < 52.64.0 (** * Type of codec implemented by the hardware accelerator. * * See CODEC_TYPE_xxx *) type_: TCodecType; +{$ELSE} + (** + * Type of codec implemented by the hardware accelerator. + * + * See AVMediaType_xxx + *) + type_: TAVMediaType; +{$IFEND} + (** * Codec implemented by the hardware accelerator. * @@ -2983,6 +3259,9 @@ type {$ELSE} rects: PPAVSubtitleRect; {$IFEND} + {$IF LIBAVCODEC_VERSION >= 52032000} // >= 52.32.0 + pts: cint64; ///< Same as packet pts, in AV_TIME_BASE + {$IFEND} end; {$IF LIBAVCODEC_VERSION >= 52025000} // 52.25.0 @@ -3005,7 +3284,7 @@ procedure av_destruct_packet(pkt: PAVPacket); * * @param pkt packet *) -procedure av_init_packet(pkt: PAVPacket); +procedure av_init_packet(var pkt: TAVPacket); cdecl; external av__codec; (* @@ -3223,6 +3502,7 @@ function avcodec_get_pix_fmt_name(pix_fmt: TAVPixelFormat): PAnsiChar; procedure avcodec_set_dimensions(s: PAVCodecContext; width: cint; height: cint); cdecl; external av__codec; +{$IF LIBAVCODEC_MAX_VERSION_MAJOR < 53} (** * Returns the pixel format corresponding to the name name. * @@ -3232,12 +3512,22 @@ procedure avcodec_set_dimensions(s: PAVCodecContext; width: cint; height: cint); * For example in a little-endian system, first looks for "gray16", * then for "gray16le". * - * Finally if no pixel format has been found, returns PIX_FMT_NONE. + * Finally if no pixel format has been found, returns PIX_FMT_NONE.* + * @deprecated Deprecated in favor of av_get_pix_fmt(). *) function avcodec_get_pix_fmt(name: {const} PAnsiChar): TAVPixelFormat; cdecl; external av__codec; +{$IF LIBAVCODEC_VERSION >= 52049000} // >= 52.49.0 + deprecated; +{$IFEND} +{$IFEND} -function avcodec_pix_fmt_to_codec_tag(p: TAVPixelFormat): cuint; +(** + * Returns a value representing the fourCC code associated to the + * pixel format pix_fmt, or 0 if no associated fourCC code can be + * found. + *) +function avcodec_pix_fmt_to_codec_tag(pix_fmt: TAVPixelFormat): cuint; cdecl; external av__codec; const @@ -3390,6 +3680,20 @@ function avcodec_build(): cuint; cdecl; external av__codec; deprecated; {$IFEND} +{$IF LIBAVCODEC_VERSION >= 52041000} // 52.41.0 +(** + * Returns the libavcodec build-time configuration. + *) +function avcodec_configuration(): PAnsiChar; + cdecl; external av__codec; + +(** + * Returns the libavcodec license. + *) +function avcodec_license(): PAnsiChar; + cdecl; external av__codec; +{$IFEND} + (** * Initializes libavcodec. * @@ -3463,8 +3767,13 @@ procedure avcodec_get_context_defaults(s: PAVCodecContext); {$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 (** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! * we WILL change its arguments and name a few times! *) +{$IF LIBAVCODEC_VERSION < 52064000} // < 52.64.0 procedure avcodec_get_context_defaults2(s: PAVCodecContext; ctype: TCodecType); cdecl; external av__codec; +{$ELSE} +procedure avcodec_get_context_defaults2(s: PAVCodecContext; ctype: TAVMediaType); + cdecl; external av__codec; +{$IFEND} {$IFEND} (** @@ -3480,8 +3789,29 @@ function avcodec_alloc_context(): PAVCodecContext; {$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 (** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! * we WILL change its arguments and name a few times! *) +{$IF LIBAVCODEC_VERSION < 52064000} // < 52.64.0 function avcodec_alloc_context2(ctype: TCodecType): PAVCodecContext; cdecl; external av__codec; +{$ELSE} +function avcodec_alloc_context2(ctype: TAVMediaType): PAVCodecContext; + cdecl; external av__codec; +{$IFEND} +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52065000} // >= 52.65.0 +(** + * Copy the settings of the source AVCodecContext into the destination + * AVCodecContext. The resulting destination codec context will be + * unopened, i.e. you are required to call avcodec_open() before you + * can use this AVCodecContext to decode/encode video/audio data. + * + * @param dest target codec context, should be initialized with + * avcodec_alloc_context(), but otherwise uninitialized + * @param src source codec context + * @return AVERROR() on error (e.g. memory allocation error), 0 on success + *) +function avcodec_copy_context(dest: PAVCodecContext; src: {const} PAVCodecContext): cint; + cdecl; external av__codec; {$IFEND} (** @@ -3508,9 +3838,38 @@ procedure avcodec_default_release_buffer (s: PAVCodecContext; pic: PAVFrame); cdecl; external av__codec; function avcodec_default_reget_buffer (s: PAVCodecContext; pic: PAVFrame): cint; cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 52066000} // >= 52.66.0 +(** + * Returns the amount of padding in pixels which the get_buffer callback must + * provide around the edge of the image for codecs which do not have the + * CODEC_FLAG_EMU_EDGE flag. + * + * @return Required padding in pixels. + *) +function avcodec_get_edge_width(): cuint; + cdecl; external av__codec; +{$IFEND} + +(** + * Modifies width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you do not use any horizontal + * padding. + *) procedure avcodec_align_dimensions(s: PAVCodecContext; width: PCint; height: PCint); cdecl; external av__codec; +{$IF LIBAVCODEC_VERSION >= 52055000} // >= 52.55.0 +(** + * Modifies width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you also ensure that all + * line sizes are a multiple of the respective linesize_align[i]. + *) +procedure avcodec_align_dimensions2(s: PAVCodecContext; width: PCint; height: PCint; + linesize_align: PQuadIntArray); + cdecl; external av__codec; +{$IFEND} + (** * Checks if the given dimension of a picture is valid, meaning that all * bytes of the picture can be addressed with a signed int. @@ -3529,11 +3888,10 @@ function avcodec_thread_init(s: PAVCodecContext; thread_count: cint): cint; procedure avcodec_thread_free(s: PAVCodecContext); cdecl; external av__codec; - {$IF LIBAVCODEC_VERSION < 52004000} // < 52.4.0 function avcodec_thread_execute(s: PAVCodecContext; func: TExecuteFunc; arg: PPointer; var ret: cint; count: cint): cint; cdecl; external av__codec; -{$ELSE} +{$ELSEIF LIBAVCODEC_VERSION < 52059000} // < 52.59.0 function avcodec_thread_execute(s: PAVCodecContext; func: TExecuteFunc; arg: Pointer; var ret: cint; count: cint; size: cint): cint; cdecl; external av__codec; {$IFEND} @@ -3545,6 +3903,11 @@ function avcodec_default_execute(s: PAVCodecContext; func: TExecuteFunc; arg: PP function avcodec_default_execute(s: PAVCodecContext; func: TExecuteFunc; arg: Pointer; var ret: cint; count: cint; size: cint): cint; cdecl; external av__codec; {$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52037000} // >= 52.37.0 +function avcodec_default_execute2(s: PAVCodecContext; func: TExecuteFunc; arg: Pointer; var ret: cint; count: cint): cint; + cdecl; external av__codec; +{$IFEND} //FIXME func typedef (** @@ -3595,7 +3958,7 @@ function avcodec_decode_audio(avctx: PAVCodecContext; samples: PSmallint; * * @deprecated Use avcodec_decode_audio3 instead. * @param avctx the codec context - * @param[out] samples the output buffer + * @param[out] samples the output buffer, sample type in avctx->sample_fmt * @param[in,out] frame_size_ptr the output buffer size in bytes * @param[in] buf the input buffer * @param[in] buf_size the input buffer size in bytes @@ -3613,9 +3976,11 @@ function avcodec_decode_audio2(avctx: PAVCodecContext; samples: PSmallint; (** * Decodes the audio frame of size avpkt->size from avpkt->data into samples. * Some decoders may support multiple frames in a single AVPacket, such - * decoders would then just decode the first frame. + * decoders would then just decode the first frame. In this case, + * avcodec_decode_audio3 has to be called again with an AVPacket that contains + * the remaining data in order to decode the second frame etc. * If no frame - * could be decompressed, frame_size_ptr is zero. Otherwise, it is the + * could be outputted, frame_size_ptr is zero. Otherwise, it is the * decompressed frame size in bytes. * * @warning You must set frame_size_ptr to the allocated size of the @@ -3638,7 +4003,7 @@ function avcodec_decode_audio2(avctx: PAVCodecContext; samples: PSmallint; * (AltiVec and SSE do). * * @note Some codecs have a delay between input and output, these need to be - * feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. + * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. * * @param avctx the codec context * @param[out] samples the output buffer @@ -3648,7 +4013,7 @@ function avcodec_decode_audio2(avctx: PAVCodecContext; samples: PSmallint; * data and size, some decoders might in addition need other fields. * All decoders are designed to use the least fields possible though. * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. + * used or zero if no frame data was decompressed (used) from the input AVPacket. *) function avcodec_decode_audio3(avctx: PAVCodecContext; samples: PSmallint; var frame_size_ptr: cint; @@ -3664,6 +4029,8 @@ function avcodec_decode_audio3(avctx: PAVCodecContext; samples: PSmallint; * @deprecated Use avcodec_decode_video2 instead. * @param avctx the codec context * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * Use avcodec_alloc_frame to get an AVFrame, the codec will + * allocate memory for the actual bitmap. * @param[in] buf the input buffer * @param[in] buf_size the size of the input buffer in bytes * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. @@ -3701,7 +4068,7 @@ function avcodec_decode_video(avctx: PAVCodecContext; picture: PAVFrame; * @param[in] avpkt The input AVpacket containing the input buffer. * You can create such packet with av_init_packet() and by then setting * data and size, some decoders might in addition need other fields like - * flags&PKT_FLAG_KEY. All decoders are designed to use the least + * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least * fields possible. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. * @return On error a negative value is returned, otherwise the number of bytes @@ -3987,9 +4354,10 @@ type codec_ids: array [0..4] of cint; (* several codec IDs are permitted *) priv_data_size: cint; parser_init: function(s: PAVCodecParserContext): cint; cdecl; - parser_parse: function(s: PAVCodecParserContext; avctx: PAVCodecContext; - poutbuf: {const} PPointer; poutbuf_size: PCint; - buf: {const} PByteArray; buf_size: cint): cint; cdecl; + parser_parse: function(s: PAVCodecParserContext; + avctx: PAVCodecContext; + poutbuf: {const} PPointer; poutbuf_size: PCint; + buf: {const} PByteArray; buf_size: cint): cint; cdecl; parser_close: procedure(s: PAVCodecParserContext); cdecl; split: function(avctx: PAVCodecContext; buf: {const} PByteArray; buf_size: cint): cint; cdecl; @@ -4112,6 +4480,7 @@ function av_bitstream_filter_filter(bsfc: PAVBitStreamFilterContext; poutbuf: PPointer; poutbuf_size: PCint; buf: PByte; buf_size: cint; keyframe: cint): cint; cdecl; external av__codec; + procedure av_bitstream_filter_close(bsf: PAVBitStreamFilterContext); cdecl; external av__codec; @@ -4255,6 +4624,13 @@ function img_pad(dst: PAVPicture; src: {const} PAVPicture; height, width: cint; cdecl; external av__codec; deprecated; {$IFEND} +(** + * Encodes extradata length to a buffer. Used by xiph codecs. + * + * @param s buffer to write to; must be at least (v/255+1) bytes long + * @param v size of extradata in bytes + * @return number of bytes written to the buffer. + *) function av_xiphlacing(s: PByte; v: cuint): cuint; cdecl; external av__codec; @@ -4286,6 +4662,13 @@ function av_parse_video_frame_rate(frame_rate: PAVRational; str: {const} PAnsiCh cdecl; external av__codec; {$IFEND} +{$IF LIBAVCODEC_VERSION < 52059000} // <52.59.0 + +{ + The following error codes are moved to libavutil/error.h on + revision 22501 Mar 13 2010 +} + {* error handling *} const @@ -4313,13 +4696,20 @@ const {$ENDIF} {$ENDIF} +(** + * We need the sign of the error, because some platforms have + * E* and errno already negated. The previous version failed + * with Delphi, because it needed EINVAL defined. + * Warning: This code is platform dependent and assumes constants + * to be 32 bit. + * This version does the following steps: + * 1) shr 30: shifts the sign bit to bit position 2 + * 2) and $00000002: sets all other bits to zero + * positive EINVAL gives 0, negative gives 2 + * 3) - 1: positive EINVAL gives -1, negative 1 + *) const -{$IF EINVAL > 0} - AVERROR_SIGN = -1; -{$ELSE} - {* Some platforms have E* and errno already negated. *} - AVERROR_SIGN = 1; -{$IFEND} + AVERROR_SIGN = (EINVAL shr 30) and $00000002 - 1; (* #if EINVAL > 0 @@ -4347,6 +4737,35 @@ const // Note: function calls as constant-initializers are invalid //AVERROR_PATCHWELCOME = -MKTAG('P','A','W','E'); {**< Not yet implemented in FFmpeg. Patches welcome. *} AVERROR_PATCHWELCOME = -(ord('P') or (ord('A') shl 8) or (ord('W') shl 16) or (ord('E') shl 24)); +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 52032000} // >= 52.32.0 +(** + * Logs a generic warning message about a missing feature. This function is + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] feature string containing the name of the missing feature + * @param[in] want_sample indicates if samples are wanted which exhibit this feature. + * If want_sample is non-zero, additional verbage will be added to the log + * message which tells the user how to report samples to the development + * mailing list. + *) +procedure av_log_missing_feature(avc: Pointer; feature: {const} Pchar; want_sample: cint); + cdecl; external av__codec; + +(** + * Logs a generic warning message asking for a sample. This function is + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] msg string containing an optional message, or NULL if no message + *) +procedure av_log_ask_for_sample(avc: Pointer; msg: {const} Pchar); + cdecl; external av__codec; +{$IFEND} {$IF LIBAVCODEC_VERSION >= 52018000} // 52.18.0 (** @@ -4396,18 +4815,15 @@ type implementation -{$IF (LIBAVCODEC_VERSION >= 52025000) and (LIBAVCODEC_VERSION <= 5202700)} // 52.25.0 +{$IF (LIBAVCODEC_VERSION >= 52025000) and (LIBAVCODEC_VERSION <= 52027000)} // 52.25.0 - 52.27.0 procedure av_free_packet(pkt: PAVPacket);{$IFDEF HASINLINE} inline; {$ENDIF} begin - if (pkt <> nil) then + if assigned(pkt) then begin - if (pkt.destruct <> nil) then - pkt.destruct(pkt) - else - begin - pkt.data = NULL; - pkt.size = 0; - end; + if assigned(pkt^.destruct) then + pkt^.destruct(pkt); + pkt^.data := NIL; + pkt^.size := 0; end; end; {$IFEND} diff --git a/cmake/src/lib/ffmpeg/avformat.pas b/cmake/src/lib/ffmpeg/avformat.pas index 0ec2c118..b745f962 100644 --- a/cmake/src/lib/ffmpeg/avformat.pas +++ b/cmake/src/lib/ffmpeg/avformat.pas @@ -26,14 +26,9 @@ (* * Conversion of libavformat/avformat.h - * Min. version: 50.5.0 , revision 6577, Sat Oct 7 15:30:46 2006 UTC - * Max. version: 52.25.0, revision 16986, Wed Feb 4 05:56:39 2009 UTC + * Min. version: 50.5.0 , revision 6577, Sat Oct 7 15:30:46 2006 UTC + * Max. version: 52.63.0, revision 23179, Wed May 19 19:17:00 2010 CET *) -{ - * update to - * Max. version: 52.34.0, Sat Jun 13 00:37:00 2009 UTC - * MiSchi -} unit avformat; @@ -63,9 +58,34 @@ uses UConfig; const + (* + * IMPORTANT: The official FFmpeg C headers change very quickly. Often some + * of the data structures are changed so that they become incompatible with + * older header files. The Pascal headers have to be adjusted to those changes, + * otherwise the application might crash randomly or strange bugs (not + * necessarily related to video or audio due to buffer overflows etc.) might + * occur. + * + * In the past users reported problems with USDX that took hours to fix and + * the problem was an unsupported version of FFmpeg. So we decided to disable + * support for future versions of FFmpeg until the headers are revised by us + * for that version as they otherwise most probably will break USDX. + * + * If the headers do not yet support your FFmpeg version you may want to + * adjust the max. version numbers manually but please note: it may work but + * in many cases it does not. The USDX team does NOT PROVIDE ANY SUPPORT + * for the game if the MAX. VERSION WAS CHANGED. + * + * The only safe way to support new versions of FFmpeg is to add the changes + * of the FFmpeg git repository C headers to the Pascal headers. + * You can accelerate this process by posting a patch with the git changes + * translated to Pascal to our bug tracker (please join our IRC chat before + * you start working on it). Simply adjusting the max. versions is NOT a valid + * fix. + *) (* Max. supported version by this header *) LIBAVFORMAT_MAX_VERSION_MAJOR = 52; - LIBAVFORMAT_MAX_VERSION_MINOR = 34; + LIBAVFORMAT_MAX_VERSION_MINOR = 63; LIBAVFORMAT_MAX_VERSION_RELEASE = 0; LIBAVFORMAT_MAX_VERSION = (LIBAVFORMAT_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBAVFORMAT_MAX_VERSION_MINOR * VERSION_MINOR) + @@ -91,19 +111,36 @@ const {$IF LIBAVFORMAT_VERSION >= 52020000} // 52.20.0 (** - * Returns the LIBAVFORMAT_VERSION_INT constant. + * I return the LIBAVFORMAT_VERSION_INT constant. You got + * a fucking problem with that, douchebag? *) function avformat_version(): cuint; cdecl; external av__format; {$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52039002} // 52.39.2 +(** + * Returns the libavformat build-time configuration. + *) +function avformat_configuration(): {const} PansiChar; + cdecl; external av__format; + +(** + * Returns the libavformat license. + *) +function avformat_license(): {const} PansiChar; + cdecl; external av__format; +{$IFEND} + type PAVFile = Pointer; (* * Public Metadata API. * The metadata API allows libavformat to export metadata tags to a client - * application using a sequence of key/value pairs. + * application using a sequence of key/value pairs. Like all strings in FFmpeg, + * metadata must be stored as UTF-8 encoded Unicode. Note that metadata + * exported by demuxers isn't checked to be valid UTF-8 in most cases. * Important concepts to keep in mind: * 1. Keys are unique; there can never be 2 tags with the same key. This is * also meant semantically, i.e., a demuxer should not knowingly produce @@ -122,6 +159,13 @@ type const AV_METADATA_MATCH_CASE = 1; AV_METADATA_IGNORE_SUFFIX = 2; +{$IF LIBAVFORMAT_VERSION >= 52043000} // >= 52.43.0 + AV_METADATA_DONT_STRDUP_KEY = 4; + AV_METADATA_DONT_STRDUP_VAL = 8; +{$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52061000} // >= 52.61.0 + AV_METADATA_DONT_OVERWRITE = 16; +{$IFEND} type PAVMetadataTag = ^TAVMetadataTag; @@ -133,9 +177,11 @@ type PAVMetadata = Pointer; {$IF LIBAVFORMAT_VERSION > 52024001} // > 52.24.1 +{$IF LIBAVFORMAT_VERSION_MAJOR = 52} (** * Gets a metadata element with matching key. * @param prev Set to the previous matching element to find the next. + * If set to NULL the first matching element is returned. * @param flags Allows case as well as suffix-insensitive comparisons. * @return Found tag or NULL, changing key or value leads to undefined behavior. *) @@ -148,9 +194,25 @@ function av_metadata_get(m: PAVMetadata; key: {const} PAnsiChar; * @param key tag key to add to m (will be av_strduped) * @param value tag value to add to m (will be av_strduped) * @return >= 0 on success otherwise an error code <0 + * @deprecated Use av_metadata_set2() instead. *) function av_metadata_set(var pm: PAVMetadata; key: {const} PAnsiChar; value: {const} PAnsiChar): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52061000} // >= 52.61.0 + deprecated; +{$IFEND} +{$IFEND} + +{$IF LIBAVFORMAT_VERSION >= 52043000} // >= 52.43.0 +(** + * Sets the given tag in m, overwriting an existing tag. + * @param key tag key to add to m (will be av_strduped depending on flags) + * @param value tag value to add to m (will be av_strduped depending on flags) + * @return >= 0 on success otherwise an error code <0 + *) +function av_metadata_set2(var pm: PAVMetadata; key: {const} PAnsiChar; value: {const} PAnsiChar; flags: cint): cint; + cdecl; external av__format; +{$IFEND} (** * Frees all the memory allocated for an AVMetadata struct. @@ -161,7 +223,7 @@ procedure av_metadata_free(var m: PAVMetadata); (* packet functions *) -{$IF LIBAVCODEC_VERSION < 52032000} // < 52.32.0 +{$IF LIBAVFORMAT_VERSION < 52032000} // < 52.32.0 type PAVPacket = ^TAVPacket; TAVPacket = record @@ -259,7 +321,7 @@ function av_new_packet(var pkt: TAVPacket; size: cint): cint; function av_get_packet(s: PByteIOContext; var pkt: TAVPacket; size: cint): cint; cdecl; external av__format; -{$IF LIBAVCODEC_VERSION < 52032000} // < 52.32.0 +{$IF LIBAVFORMAT_VERSION < 52032000} // < 52.32.0 (** * @warning This is a hack - the packet memory allocation stuff is broken. The * packet is allocated if it was not really allocated. @@ -295,8 +357,8 @@ type (** This structure contains the data a format has to probe a file. *) TAVProbeData = record filename: PAnsiChar; - buf: PByteArray; - buf_size: cint; + buf: PByteArray; (**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. *) + buf_size: cint; (**< Size of buf except extra allocated bytes *) end; const @@ -316,19 +378,36 @@ const {$IF LIBAVFORMAT_VERSION >= 52029002} // 52.29.2 AVFMT_VARIABLE_FPS = $0400; (**< Format allows variable fps. *) {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52052000} // 52.52.0 + AVFMT_NODIMENSIONS = $0800; (**< Format does not need width/height *) + {$IFEND} // used by AVIndexEntry AVINDEX_KEYFRAME = $0001; AVFMTCTX_NOHEADER = $0001; (**< signal that no header is present (streams are added dynamically) *) +{$IF LIBAVFORMAT_VERSION_MAJOR < 53} MAX_STREAMS = 20; +{$ELSE} + MAX_STREAMS = 100; +{$IFEND} AVFMT_NOOUTPUTLOOP = -1; AVFMT_INFINITEOUTPUTLOOP = 0; AVFMT_FLAG_GENPTS = $0001; ///< Generate missing pts even if it requires parsing future frames. AVFMT_FLAG_IGNIDX = $0002; ///< Ignore index. AVFMT_FLAG_NONBLOCK = $0004; ///< Do not block when reading packets from input. +{$IF LIBAVFORMAT_VERSION >= 52048000} // >= 52.48.0 + AVFMT_FLAG_IGNDTS = $0008; ///< Ignore DTS on frames that contain both DTS & PTS +{$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52060000} // >= 52.60.0 + AVFMT_FLAG_NOFILLIN = $0010; ///< Do not infer any values from other values, just return what is stored in the container + AVFMT_FLAG_NOPARSE = $0020; ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled +{$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52063000} // >= 52.63.0 + AVFMT_FLAG_RTP_HINT = $0040; ///< Add RTP hinting to the output file +{$IFEND} // used by AVStream MAX_REORDER_DELAY = 16; @@ -347,8 +426,20 @@ const // used by TAVFormatContext.debug FF_FDEBUG_TS = 0001; - {$IF LIBAVFORMAT_VERSION >= 52034000} // > 52.34.0 + {$IF LIBAVFORMAT_VERSION >= 52034000} // >= 52.34.0 + {$IF LIBAVFORMAT_VERSION < 52039000} // < 52.39.0 MAX_PROBE_PACKETS = 100; + {$ELSE} + MAX_PROBE_PACKETS = 2500; + {$IFEND} + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52035000} // >= 52.35.0 + {$IF LIBAVFORMAT_VERSION < 52039000} // < 52.39.0 + RAW_PACKET_BUFFER_SIZE = 32000; + {$ELSE} + RAW_PACKET_BUFFER_SIZE = 2500000; + {$IFEND} {$IFEND} type @@ -543,11 +634,11 @@ type (** General purpose read-only value that the format can use. *) value: cint; - (** Start/resume playing - only meaningful if using a network-based format + (** Starts/resumes playing - only meaningful if using a network-based format (RTSP). *) read_play: function (c: PAVFormatContext): cint; cdecl; - (** Pause playing - only meaningful if using a network-based format + (** Pauses playing - only meaningful if using a network-based format (RTSP). *) read_pause: function (c: PAVFormatContext): cint; cdecl; @@ -557,7 +648,7 @@ type {$IF LIBAVFORMAT_VERSION >= 52030000} // 52.30.0 (** - * Seek to timestamp ts. + * Seeks to timestamp ts. * Seeking will be done so that the point from which all active streams * can be presented successfully will be closest to ts and within min/max_ts. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. @@ -724,13 +815,32 @@ type *) reference_dts: cint64; {$IFEND} - {$IF LIBAVFORMAT_VERSION >= 52034000} // > 52.34.0 + {$IF LIBAVFORMAT_VERSION >= 52034000} // >= 52.34.0 (** * Number of packets to buffer for codec probing * NOT PART OF PUBLIC API *) probe_packets: cint; {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52038000} // >= 52.38.0 + (** + * last packet in packet_buffer for this stream when muxing. + * used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav* + *) + last_in_packet_buffer: PAVPacketList; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52041000} // >= 52.41.0 + (** + * Average framerate + *) + avg_frame_rate: TAVRational; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52054000} // >= 52.54.0 + (** + * Number of frames that have been demuxed during av_find_stream_info() + *) + codec_info_nb_frames: cint; + {$IFEND} end; (** @@ -781,8 +891,9 @@ type It is deduced from the AVStream values. *) start_time: cint64; (** Decoding: duration of the stream, in AV_TIME_BASE fractional - seconds. NEVER set this value directly: it is deduced from the - AVStream values. *) + seconds. Only set this value if you know none of the individual stream + durations and also dont set any of them. This is deduced from the + AVStream values if not set. *) duration: cint64; (** decoding: total file size, 0 if unknown *) file_size: cint64; @@ -804,7 +915,11 @@ type index_built: cint; mux_rate: cint; + {$IF LIBAVFORMAT_VERSION < 52034001} // < 52.34.1 packet_size: cint; + {$ELSE} + packet_size: cuint; + {$IFEND} preload: cint; max_delay: cint; @@ -903,6 +1018,26 @@ type {$IF LIBAVFORMAT_VERSION >= 52024001} // 52.24.1 metadata: PAVMetadata; {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52035000} // 52.35.0 + (** + * Remaining size available for raw_packet_buffer, in bytes. + * NOT PART OF PUBLIC API + *) + raw_packet_buffer_remaining_size: cint; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52056000} // 52.56.0 + (** + * Start time of the stream in real world time, in microseconds + * since the unix epoch (00:00 1st January 1970). That is, pts=0 + * in the stream was captured at this real world time. + * - encoding: Set by user. + * - decoding: Unused. + *) + start_time_realtime: cint64; + {$IFEND} + end; (** @@ -1019,15 +1154,39 @@ procedure av_register_input_format(format: PAVInputFormat); procedure av_register_output_format(format: PAVOutputFormat); cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION_MAJOR < 53} // < 53 function guess_stream_format(short_name: PAnsiChar; filename: PAnsiChar; mime_type: PAnsiChar): PAVOutputFormat; - cdecl; external av__format; + cdecl; external av__format; deprecated; +{$IFEND} +(** + * Returns the output format in the list of registered output formats + * which best matches the provided parameters, or returns NULL if + * there is no match. + * + * @param short_name if non-NULL checks if short_name matches with the + * names of the registered formats + * @param filename if non-NULL checks if filename terminates with the + * extensions of the registered formats + * @param mime_type if non-NULL checks if mime_type matches with the + * MIME type of the registered formats + *) +(** + * @deprecated Use av_guess_format() instead. + *) function guess_format(short_name: PAnsiChar; filename: PAnsiChar; mime_type: PAnsiChar): PAVOutputFormat; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52045000} // >= 52.45.0 + deprecated; +function av_guess_format(short_name: PAnsiChar; + filename: PAnsiChar; + mime_type: PAnsiChar): PAVOutputFormat; + cdecl; external av__format; +{$IFEND} (** * Guesses the codec ID based upon muxer and filename. @@ -1038,7 +1197,7 @@ function av_guess_codec(fmt: PAVOutputFormat; short_name: PAnsiChar; cdecl; external av__format; (** - * Send a nice hexadecimal dump of a buffer to the specified file stream. + * Sends a nice hexadecimal dump of a buffer to the specified file stream. * * @param f The file stream pointer where the dump should be sent to. * @param buf buffer @@ -1051,7 +1210,7 @@ procedure av_hex_dump(f: PAVFile; buf: PByteArray; size: cint); {$IF LIBAVFORMAT_VERSION >= 51011000} // 51.11.0 (** - * Send a nice hexadecimal dump of a buffer to the log. + * Sends a nice hexadecimal dump of a buffer to the log. * * @param avcl A pointer to an arbitrary struct of which the first field is a * pointer to an AVClass struct. @@ -1067,7 +1226,7 @@ procedure av_hex_dump_log(avcl: Pointer; level: cint; buf: PByteArray; size: cin {$IFEND} (** - * Send a nice dump of a packet to the specified file stream. + * Sends a nice dump of a packet to the specified file stream. * * @param f The file stream pointer where the dump should be sent to. * @param pkt packet to dump @@ -1078,7 +1237,7 @@ procedure av_pkt_dump(f: PAVFile; pkt: PAVPacket; dump_payload: cint); {$IF LIBAVFORMAT_VERSION >= 51011000} // 51.11.0 (** - * Send a nice dump of a packet to the log. + * Sends a nice dump of a packet to the log. * * @param avcl A pointer to an arbitrary struct of which the first field is a * pointer to an AVClass struct. @@ -1092,7 +1251,7 @@ procedure av_pkt_dump_log(avcl: Pointer; level: cint; pkt: PAVPacket; dump_paylo {$IFEND} (** - * Initialize libavformat and register all the muxers, demuxers and + * Initializes libavformat and registers all the muxers, demuxers and * protocols. If you do not call this function, then you can select * exactly which formats you want to support. * @@ -1104,9 +1263,23 @@ procedure av_register_all(); cdecl; external av__format; {$IF LIBAVFORMAT_VERSION >= 51008000} // 51.8.0 -(** codec tag <-> codec id *) +(** + * Gets the CodecID for the given codec tag tag. + * If no codec id is found returns CODEC_ID_NONE. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + *) function av_codec_get_id(var tags: PAVCodecTag; tag: cuint): TCodecID; cdecl; external av__format; + +(** + * Gets the codec tag for the given codec id id. + * If no codec tag is found returns 0. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + *) function av_codec_get_tag(var tags: PAVCodecTag; id: TCodecID): cuint; cdecl; external av__format; {$IFEND} @@ -1120,7 +1293,7 @@ function av_find_input_format(short_name: PAnsiChar): PAVInputFormat; cdecl; external av__format; (** - * Guess file format. + * Guesses file format. * * @param is_opened Whether the file is already opened; determines whether * demuxers with or without AVFMT_NOFILE are probed. @@ -1128,17 +1301,33 @@ function av_find_input_format(short_name: PAnsiChar): PAVInputFormat; function av_probe_input_format(pd: PAVProbeData; is_opened: cint): PAVInputFormat; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52062000} // 52.62.0 +(** + * Guesses the file format. + * + * @param is_opened Whether the file is already opened; determines whether + * demuxers with or without AVFMT_NOFILE are probed. + * @param score_max A probe score larger that this is required to accept a + * detection, the variable is set to the actual detection + * score afterwards. + * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended + * to retry with a larger probe buffer. + *) +function av_probe_input_format2(pd: PAVProbeData; is_opened: cint; score_max: PCint): PAVInputFormat; + cdecl; external av__format; +{$IFEND} + (** * Allocates all the structures needed to read an input stream. * This does not open the needed codecs for decoding the stream[s]. *) -function av_open_input_stream(ic_ptr: PAVFormatContext; +function av_open_input_stream(var ic_ptr: PAVFormatContext; pb: PByteIOContext; filename: PAnsiChar; fmt: PAVInputFormat; ap: PAVFormatParameters): cint; cdecl; external av__format; (** - * Open a media file as input. The codecs are not opened. Only the file + * Opens a media file as input. The codecs are not opened. Only the file * header (if present) is read. * * @param ic_ptr The opened media file handle is put here. @@ -1156,7 +1345,7 @@ function av_open_input_file(var ic_ptr: PAVFormatContext; filename: PAnsiChar; {$IF LIBAVFORMAT_VERSION >= 52026000} // 52.26.0 (** - * Allocate an AVFormatContext. + * Allocates an AVFormatContext. * Can be freed with av_free() but do not forget to free everything you * explicitly allocated as well! *) @@ -1173,7 +1362,7 @@ function av_alloc_format_context(): PAVFormatContext; {$IFEND} (** - * Read packets of a media file to get stream information. This + * Reads packets of a media file to get stream information. This * is useful for file formats with no headers such as MPEG. This * function also computes the real framerate in case of MPEG-2 repeat * frame mode. @@ -1189,7 +1378,7 @@ function av_find_stream_info(ic: PAVFormatContext): cint; cdecl; external av__format; (** - * Read a transport packet from a media file. + * Reads a transport packet from a media file. * * This function is obsolete and should never be used. * Use av_read_frame() instead. @@ -1202,7 +1391,7 @@ function av_read_packet(s: PAVFormatContext; var pkt: TAVPacket): cint; cdecl; external av__format; (** - * Return the next frame of a stream. + * Returns the next frame of a stream. * * The returned packet is valid * until the next av_read_frame() or until av_close_input_file() and @@ -1224,7 +1413,7 @@ function av_read_frame(s: PAVFormatContext; var pkt: TAVPacket): cint; cdecl; external av__format; (** - * Seek to the keyframe at timestamp. + * Seeks to the keyframe at timestamp. * 'timestamp' in 'stream_index'. * @param stream_index If stream_index is (-1), a default * stream is selected, and timestamp is automatically converted @@ -1240,7 +1429,7 @@ function av_seek_frame(s: PAVFormatContext; stream_index: cint; timestamp: cint6 {$IF LIBAVFORMAT_VERSION >= 52026000} // 52.26.0 (** - * Seek to timestamp ts. + * Seeks to timestamp ts. * Seeking will be done so that the point from which all active streams * can be presented successfully will be closest to ts and within min/max_ts. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. @@ -1259,7 +1448,7 @@ function av_seek_frame(s: PAVFormatContext; stream_index: cint; timestamp: cint6 * @param ts target timestamp * @param max_ts largest acceptable timestamp * @param flags flags - * @returns >=0 on success, error code otherwise + * @return >=0 on success, error code otherwise * * @NOTE This is part of the new seek API which is still under construction. * Thus do not use this yet. It may change at any time, do not expect @@ -1275,14 +1464,14 @@ function avformat_seek_file(s: PAVFormatContext; {$IFEND} (** - * Start playing a network-based stream (e.g. RTSP stream) at the + * Starts playing a network-based stream (e.g. RTSP stream) at the * current position. *) function av_read_play(s: PAVFormatContext): cint; cdecl; external av__format; (** - * Pause a network-based stream (e.g. RTSP stream). + * Pauses a network-based stream (e.g. RTSP stream). * * Use av_read_play() to resume it. *) @@ -1291,7 +1480,7 @@ function av_read_pause(s: PAVFormatContext): cint; {$IF LIBAVFORMAT_VERSION >= 52003000} // 52.3.0 (** - * Free a AVFormatContext allocated by av_open_input_stream. + * Frees a AVFormatContext allocated by av_open_input_stream. * @param s context to free *) procedure av_close_input_stream(s: PAVFormatContext); @@ -1299,7 +1488,7 @@ procedure av_close_input_stream(s: PAVFormatContext); {$IFEND} (** - * Close a media file (but not its codecs). + * Closes a media file (but not its codecs). * * @param s media file handle *) @@ -1307,7 +1496,7 @@ procedure av_close_input_file(s: PAVFormatContext); cdecl; external av__format; (** - * Add a new stream to a media file. + * Adds a new stream to a media file. * * Can only be called in the read_header() function. If the flag * AVFMTCTX_NOHEADER is in the format context, then new streams @@ -1325,7 +1514,7 @@ function av_new_program(s: PAVFormatContext; id: cint): PAVProgram; {$IF LIBAVFORMAT_VERSION >= 52014000} // 52.14.0 (** - * Add a new chapter. + * Adds a new chapter. * This function is NOT part of the public API * and should ONLY be used by demuxers. * @@ -1343,7 +1532,7 @@ function ff_new_chapter(s: PAVFormatContext; id: cint; time_base: TAVRational; {$IFEND} (** - * Set the pts for a given stream. + * Sets the pts for a given stream. * * @param s stream * @param pts_wrap_bits number of bits effectively used by the pts @@ -1352,13 +1541,20 @@ function ff_new_chapter(s: PAVFormatContext; id: cint; time_base: TAVRational; * @param pts_den denominator to convert to seconds (MPEG: 90000) *) procedure av_set_pts_info(s: PAVStream; pts_wrap_bits: cint; +{$IF LIBAVFORMAT_VERSION < 52036000} // < 52.36.0 pts_num: cint; pts_den: cint); +{$ELSE} + pts_num: cuint; pts_den: cuint); +{$IFEND} cdecl; external av__format; const AVSEEK_FLAG_BACKWARD = 1; ///< seek backward AVSEEK_FLAG_BYTE = 2; ///< seeking based on position in bytes AVSEEK_FLAG_ANY = 4; ///< seek to any frame, even non-keyframes +{$IF LIBAVFORMAT_VERSION >= 52037000} // >= 52.37.0 + AVSEEK_FLAG_FRAME = 8; +{$IFEND} function av_find_default_stream_index(s: PAVFormatContext): cint; cdecl; external av__format; @@ -1387,7 +1583,7 @@ procedure ff_reduce_index(s: PAVFormatContext; stream_index: cint); {$IFEND} (** - * Add an index entry into a sorted list. Update the entry if the list + * Adds an index entry into a sorted list. Updates the entry if the list * already contains it. * * @param timestamp timestamp in the timebase of the given stream @@ -1447,7 +1643,7 @@ function av_set_parameters(s: PAVFormatContext; ap: PAVFormatParameters): cint; cdecl; external av__format; (** - * Allocate the stream private data and write the stream header to an + * Allocates the stream private data and writes the stream header to an * output media file. * * @param s media file handle @@ -1457,7 +1653,7 @@ function av_write_header(s: PAVFormatContext): cint; cdecl; external av__format; (** - * Write a packet to an output media file. + * Writes a packet to an output media file. * * The packet shall contain one audio or video frame. * The packet must be correctly interleaved according to the container @@ -1490,7 +1686,7 @@ function av_interleaved_write_frame(s: PAVFormatContext; var pkt: TAVPacket): ci cdecl; external av__format; (** - * Interleave a packet per dts in an output media file. + * Interleaves a packet per dts in an output media file. * * Packets with pkt->destruct == av_destruct_packet will be freed inside this * function, so they cannot be used after it. Note that calling av_free_packet() @@ -1527,8 +1723,8 @@ procedure ff_interleave_add_packet(s: PAVFormatContext; {$IFEND} (** - * @brief Write the stream trailer to an output media file and - * free the file private data. + * Writes the stream trailer to an output media file and frees the + * file private data. * * May only be called after a successful call to av_write_header. * @@ -1639,7 +1835,7 @@ function av_get_frame_filename(buf: PAnsiChar; buf_size: cint; {$IFEND}; (** - * Check whether filename actually is a numbered sequence generator. + * Checks whether filename actually is a numbered sequence generator. * * @param filename possible numbered sequence string * @return 1 if a valid numbered sequence string, 0 otherwise @@ -1652,7 +1848,7 @@ function av_filename_number_test(filename: PAnsiChar): cint; {$IF LIBAVFORMAT_VERSION >= 51012002} // 51.12.2 (** - * Generate an SDP for an RTP session. + * Generates an SDP for an RTP session. * * @param ac array of AVFormatContexts describing the RTP streams. If the * array is composed by only one context, such context can contain @@ -1669,6 +1865,17 @@ function avf_sdp_create(ac: PPAVFormatContext; n_files: cint; buff: PByteArray; cdecl; external av__format; {$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52060000} // 52.60.0 +(** + * Returns a positive value if the given filename has one of the given + * extensions, 0 otherwise. + * + * @param extensions a comma-separated list of filename extensions + *) +function av_match_ext(filename: {const} Pchar; extensions: {const} Pchar): cint; + cdecl; external av__format; +{$IFEND} + implementation {$IF LIBAVFORMAT_VERSION < 51012002} // 51.12.2 @@ -1686,7 +1893,7 @@ begin end; {$IFEND} -{$IF LIBAVCODEC_VERSION < 52032000} // < 52.32.0 +{$IF LIBAVFORMAT_VERSION < 52032000} // < 52.32.0 procedure av_free_packet(pkt: PAVPacket); begin if ((pkt <> nil) and (@pkt^.destruct <> nil)) then diff --git a/cmake/src/lib/ffmpeg/avio.pas b/cmake/src/lib/ffmpeg/avio.pas index dc0a330b..4863ee39 100644 --- a/cmake/src/lib/ffmpeg/avio.pas +++ b/cmake/src/lib/ffmpeg/avio.pas @@ -28,11 +28,11 @@ (* * Conversion of libavformat/avio.h * unbuffered I/O operations - * revision 16100, Sat Dec 13 13:39:13 2008 UTC - * update Tue, Jun 10 01:00:00 2009 UTC - * * @warning This file has to be considered an internal but installed * header, so it should not be directly included in your projects. + * + * update to + * Max. avformat version: 52.62.0, revision 23004, Tue May 11 19:29:00 2010 CET *) unit avio; @@ -70,6 +70,16 @@ const *) AVSEEK_SIZE = $10000; +{$IF LIBAVFORMAT_VERSION >= 52056000} // 52.56.0 + (** + * Oring this flag as into the "whence" parameter to a seek function causes it to + * seek by any means (like reopening and linear reading) or other normally unreasonble + * means that can be extreemly slow. + * This may be ignored by the seek code. + *) + AVSEEK_FORCE = $20000; +{$IFEND} + type TURLInterruptCB = function (): cint; cdecl; @@ -93,7 +103,7 @@ type is_streamed: cint; (**< true if streamed (no seek possible), default = false *) max_packet_size: cint; (**< if non zero, the stream is packetized with this max packet size *) priv_data: pointer; - filename: PAnsiChar; (**< specified filename *) + filename: PAnsiChar; (**< specified URL *) end; PPURLContext = ^PURLContext; @@ -106,16 +116,54 @@ type TURLProtocol = record name: PAnsiChar; +{$IF LIBAVFORMAT_VERSION < 52047000} // 52.47.0 url_open: function (h: PURLContext; filename: {const} PAnsiChar; flags: cint): cint; cdecl; +{$ELSE} + url_open: function (h: PURLContext; url: {const} PAnsiChar; flags: cint): cint; cdecl; +{$IFEND} + +(** + * Reads up to size bytes from the resource accessed by h, and stores + * the read bytes in buf. + * + * @return The number of bytes actually read, or a negative value + * corresponding to an AVERROR code in case of error. A value of zero + * indicates that it is not possible to read more from the accessed + * resource (except if the value of the size argument is also zero). + *) url_read: function (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; - url_read_complete: function (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; + +(** + * Read as many bytes as possible (up to size), calling the + * read function multiple times if necessary. + * Will also retry if the read function returns AVERROR(EAGAIN). + * This makes special short-read handling in applications + * unnecessary, if the return value is < size then it is + * certain there was either an error or the end of file was reached. + *) url_write: function (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; + +(** + * Changes the position that will be used by the next read/write + * operation on the resource accessed by h. + * + * @param pos specifies the new position to set + * @param whence specifies how pos should be interpreted, it must be + * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the + * current position), SEEK_END (seek from the end), or AVSEEK_SIZE + * (return the filesize of the requested resource, pos is ignored). + * @return a negative value corresponding to an AVERROR code in case + * of failure, or the resulting file position, measured in bytes from + * the beginning of the file. You can use this feature together with + * SEEK_CUR to read the current file position. + *) url_seek: function (h: PURLContext; pos: cint64; whence: cint): cint64; cdecl; + url_close: function (h: PURLContext): cint; cdecl; next: PURLProtocol; {$IF (LIBAVFORMAT_VERSION >= 52001000) and (LIBAVFORMAT_VERSION < 52004000)} // 52.1.0 .. 52.4.0 - url_read_play: function (h: PURLContext): cint; - url_read_pause: function (h: PURLContext): cint; + url_read_play: function (h: PURLContext): cint; cdecl; + url_read_pause: function (h: PURLContext): cint; cdecl; {$IFEND} {$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 url_read_pause: function (h: PURLContext; pause: cint): cint; cdecl; @@ -124,6 +172,9 @@ type url_read_seek: function (h: PURLContext; stream_index: cint; timestamp: cint64; flags: cint): cint64; cdecl; {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52031000} // 52.31.0 + url_get_file_handle: function (h: PURLContext): cint; cdecl; + {$IFEND} end; (** @@ -168,31 +219,85 @@ type {$IF LIBAVFORMAT_VERSION >= 52021000} // 52.21.0 +(** + * Creates an URLContext for accessing to the resource indicated by + * URL, and opens it using the URLProtocol up. + * + * @param puc pointer to the location where, in case of success, the + * function puts the pointer to the created URLContext + * @param flags flags which control how the resource indicated by URL + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + *) function url_open_protocol(puc: PPURLContext; up: PURLProtocol; +{$IF LIBAVFORMAT_VERSION < 52047000} // 52.47.0 filename: {const} PAnsiChar; flags: cint): cint; +{$ELSE} + url: {const} PAnsiChar; flags: cint): cint; +{$IFEND} cdecl; external av__format; {$IFEND} + +(** + * Creates an URLContext for accessing to the resource indicated by + * url, and opens it. + * + * @param puc pointer to the location where, in case of success, the + * function puts the pointer to the created URLContext + * @param flags flags which control how the resource indicated by url + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + *) +{$IF LIBAVFORMAT_VERSION < 52047000} // 52.47.0 function url_open(h: PPointer; filename: {const} PAnsiChar; flags: cint): cint; +{$ELSE} +function url_open(h: PPointer; url: {const} PAnsiChar; flags: cint): cint; +{$IFEND} cdecl; external av__format; function url_read (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52034000} // 52.34.0 +function url_read_complete (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; + cdecl; external av__format; +{$IFEND} function url_write (h: PURLContext; buf: PByteArray; size: cint): cint; cdecl; external av__format; function url_seek (h: PURLContext; pos: cint64; whence: cint): cint64; cdecl; external av__format; + +(** + * Closes the resource accessed by the URLContext h, and frees the + * memory used by it. + * + * @return a negative value if an error condition occurred, 0 + * otherwise + *) function url_close (h: PURLContext): cint; cdecl; external av__format; + +(** + * Returns a non-zero value if the resource indicated by url + * exists, 0 otherwise. + *) +{$IF LIBAVFORMAT_VERSION < 52047000} // 52.47.0 function url_exist(filename: {const} PAnsiChar): cint; +{$ELSE} +function url_exist(url: {const} PAnsiChar): cint; +{$IFEND} cdecl; external av__format; + function url_filesize (h: PURLContext): cint64; cdecl; external av__format; -{ + +(** * Return the file descriptor associated with this URL. For RTP, this * will return only the RTP file descriptor, not the RTCP file descriptor. * To get both, use rtp_get_file_handles(). * * @return the file descriptor associated with this URL, or <0 on error. -} + *) (* not implemented *) function url_get_file_handle(h: PURLContext): cint; cdecl; external av__format; @@ -264,30 +369,36 @@ var url_interrupt_cb: PURLInterruptCB; external av__format; **) -{ -* If protocol is NULL, returns the first registered protocol, -* if protocol is non-NULL, returns the next registered protocol after protocol, -* or NULL if protocol is the last one. -} {$IF LIBAVFORMAT_VERSION >= 52002000} // 52.2.0 +(** + * If protocol is NULL, returns the first registered protocol, + * if protocol is non-NULL, returns the next registered protocol after protocol, + * or NULL if protocol is the last one. + *) function av_protocol_next(p: PURLProtocol): PURLProtocol; cdecl; external av__format; {$IFEND} {$IF LIBAVFORMAT_VERSION <= 52028000} // 52.28.0 +(** + * Registers the URLProtocol protocol. + *) (** * @deprecated Use av_register_protocol() instead. *) -function register_protocol (protocol: PURLProtocol): cint; +function register_protocol(protocol: PURLProtocol): cint; cdecl; external av__format; +(** Alias for register_protocol() *) +function av_register_protocol(protocol: PURLProtocol): cint; + cdecl; external av__format name 'register_protocol'; {$ELSE} -function av_register_protocol (protocol: PURLProtocol): cint; +function av_register_protocol(protocol: PURLProtocol): cint; cdecl; external av__format; {$IFEND} type - TReadWriteFunc = function (opaque: Pointer; buf: PByteArray; buf_size: cint): cint; cdecl; - TSeekFunc = function (opaque: Pointer; offset: cint64; whence: cint): cint64; cdecl; + TReadWriteFunc = function(opaque: Pointer; buf: PByteArray; buf_size: cint): cint; cdecl; + TSeekFunc = function(opaque: Pointer; offset: cint64; whence: cint): cint64; cdecl; function init_put_byte(s: PByteIOContext; buffer: PByteArray; @@ -400,11 +511,10 @@ function url_fgets(s: PByteIOContext; buf: PAnsiChar; buf_size: cint): PAnsiChar procedure put_flush_packet (s: PByteIOContext); cdecl; external av__format; - (** * Reads size bytes from ByteIOContext into buf. - * @returns number of bytes read or AVERROR + * @return number of bytes read or AVERROR *) function get_buffer(s: PByteIOContext; buf: PByteArray; size: cint): cint; cdecl; external av__format; @@ -413,7 +523,7 @@ function get_buffer(s: PByteIOContext; buf: PByteArray; size: cint): cint; * Reads size bytes from ByteIOContext into buf. * This reads at most 1 packet. If that is not enough fewer bytes will be * returned. - * @returns number of bytes read or AVERROR + * @return number of bytes read or AVERROR *) function get_partial_buffer(s: PByteIOContext; buf: PByteArray; size: cint): cint; cdecl; external av__format; @@ -449,8 +559,17 @@ function ff_get_v(bc: PByteIOContext): cuint64; function url_is_streamed(s: PByteIOContext): cint; {$IFDEF HasInline}inline;{$ENDIF} -(** @note when opened as read/write, the buffers are only used for - writing *) +(** + * Creates and initializes a ByteIOContext for accessing the + * resource referenced by the URLContext h. + * @note When the URLContext h has been opened in read+write mode, the + * ByteIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created ByteIOContext. + * In case of failure the pointed to value is set to NULL. + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + *) {$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 function url_fdopen (var s: PByteIOContext; h: PURLContext): cint; {$ELSE} @@ -462,6 +581,7 @@ function url_fdopen (s: PByteIOContext; h: PURLContext): cint; function url_setbufsize (s: PByteIOContext; buf_size: cint): cint; cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION_MAJOR < 53} {$IF LIBAVFORMAT_VERSION >= 51015000} // 51.15.0 (** Reset the buffer for reading or writing. * @note Will drop any data currently in the buffer without transmitting it. @@ -470,13 +590,47 @@ function url_setbufsize (s: PByteIOContext; buf_size: cint): cint; function url_resetbuf(s: PByteIOContext; flags: cint): cint; cdecl; external av__format; {$IFEND} +{$IFEND} -(** @note when opened as read/write, the buffers are only used for - writing *) +{$IF LIBAVFORMAT_VERSION >= 52061000} // 52.61.0 +(** + * Rewinds the ByteIOContext using the specified buffer containing the first buf_size bytes of the file. + * Used after probing to avoid seeking. + * Joins buf and s->buffer, taking any overlap into consideration. + * @note s->buffer must overlap with buf or they can't be joined and the function fails + * @note This function is NOT part of the public API + * + * @param s The read-only ByteIOContext to rewind + * @param buf The probe buffer containing the first buf_size bytes of the file + * @param buf_size The size of buf + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + *) +function ff_rewind_with_probe_data(s: PByteIOContext; buf: PAnsiChar; buf_size: cint): cint; + cdecl; external av__format; +{$IFEND} + +(** + * Creates and initializes a ByteIOContext for accessing the + * resource indicated by url. + * @note When the resource indicated by url has been opened in + * read+write mode, the ByteIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created ByteIOContext. + * In case of failure the pointed to value is set to NULL. + * @param flags flags which control how the resource indicated by url + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + *) +{$IF LIBAVFORMAT_VERSION < 52047000} // 52.47.0 {$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 function url_fopen(var s: PByteIOContext; filename: {const} PAnsiChar; flags: cint): cint; {$ELSE} function url_fopen(s: PByteIOContext; filename: {const} PAnsiChar; flags: cint): cint; +{$IFEND} +{$ELSE} +function url_fopen(var s: PByteIOContext; url: {const} PAnsiChar; flags: cint): cint; {$IFEND} cdecl; external av__format; function url_fclose(s: PByteIOContext): cint; diff --git a/cmake/src/lib/ffmpeg/avutil.pas b/cmake/src/lib/ffmpeg/avutil.pas index 6a93ea12..c26700c6 100644 --- a/cmake/src/lib/ffmpeg/avutil.pas +++ b/cmake/src/lib/ffmpeg/avutil.pas @@ -28,22 +28,20 @@ * Conversions of * * libavutil/avutil.h: - * Min. version: 49.0.1, revision 6577, Sat Oct 7 15:30:46 2006 UTC - * Max. version: 49.14.0, revision 16912, Sun Feb 1 02:00:19 2009 UTC + * Min. version: 49.0.1, revision 6577, Sat Oct 7 15:30:46 2006 UTC + * Max. version: 50.15.2, revision 23059, Tue May 11 22:05:00 2010 CET * * libavutil/mem.h: * revision 16590, Tue Jan 13 23:44:16 2009 UTC * * libavutil/log.h: * revision 16571, Tue Jan 13 00:14:43 2009 UTC + * + * include/keep pixfmt.h (change in revision 50.01.0) + * Maybe, the pixelformats are not needed, but it has not been checked. + * log.h is only partial. + * *) -{ - Update changes auf avutil.h, mem.h and log.h - Max. version 50.03.0, Tue, Jun 09 24:00:00 2009 UTC - include/keep pixfmt.h (change in revision 50.01.0) - Maybe, the pixelformats are not needed, but it has not been checked. - log.h is only partial. -} unit avutil; @@ -65,13 +63,41 @@ uses ctypes, mathematics, rational, + {$IFDEF UNIX} + BaseUnix, + {$ENDIF} UConfig; const + (* + * IMPORTANT: The official FFmpeg C headers change very quickly. Often some + * of the data structures are changed so that they become incompatible with + * older header files. The Pascal headers have to be adjusted to those changes, + * otherwise the application might crash randomly or strange bugs (not + * necessarily related to video or audio due to buffer overflows etc.) might + * occur. + * + * In the past users reported problems with USDX that took hours to fix and + * the problem was an unsupported version of FFmpeg. So we decided to disable + * support for future versions of FFmpeg until the headers are revised by us + * for that version as they otherwise most probably will break USDX. + * + * If the headers do not yet support your FFmpeg version you may want to + * adjust the max. version numbers manually but please note: it may work but + * in many cases it does not. The USDX team does NOT PROVIDE ANY SUPPORT + * for the game if the MAX. VERSION WAS CHANGED. + * + * The only safe way to support new versions of FFmpeg is to add the changes + * of the FFmpeg git repository C headers to the Pascal headers. + * You can accelerate this process by posting a patch with the git changes + * translated to Pascal to our bug tracker (please join our IRC chat before + * you start working on it). Simply adjusting the max. versions is NOT a valid + * fix. + *) (* Max. supported version by this header *) LIBAVUTIL_MAX_VERSION_MAJOR = 50; - LIBAVUTIL_MAX_VERSION_MINOR = 3; - LIBAVUTIL_MAX_VERSION_RELEASE = 0; + LIBAVUTIL_MAX_VERSION_MINOR = 15; + LIBAVUTIL_MAX_VERSION_RELEASE = 2; LIBAVUTIL_MAX_VERSION = (LIBAVUTIL_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBAVUTIL_MAX_VERSION_MINOR * VERSION_MINOR) + (LIBAVUTIL_MAX_VERSION_RELEASE * VERSION_RELEASE); @@ -101,6 +127,41 @@ function avutil_version(): cuint; cdecl; external av__format; {$IFEND} +{$IF LIBAVUTIL_VERSION >= 50004000} // >= 50.4.0 +(** + * Returns the libavutil build-time configuration. + *) +function avutil_configuration(): PAnsiChar; + cdecl; external av__format; + +(** + * Returns the libavutil license. + *) +function avutil_license(): PAnsiChar; + cdecl; external av__format; +{$IFEND} + +{ + TAVMediaType moved to avutil in LIBAVUTIL_VERSION 50.14.0 + but moving it in the pascal headers was not really necessary + but caused problems. So, I (KMS) left it there. + +type + TAVMediaType = ( + AVMEDIA_TYPE_UNKNOWN = -1, + AVMEDIA_TYPE_VIDEO, + AVMEDIA_TYPE_AUDIO, + AVMEDIA_TYPE_DATA, + AVMEDIA_TYPE_SUBTITLE, + AVMEDIA_TYPE_ATTACHMENT, + AVMEDIA_TYPE_NB + ); +} + +{$INCLUDE error.pas} + +(* libavutil/pixfmt.h up to revision 23144, May 16 2010 *) + type (** * Pixel format. Notes: @@ -148,8 +209,8 @@ type PIX_FMT_RGB555, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), in CPU endianness, most significant bit to 0 {$IFEND} PIX_FMT_GRAY8, ///< Y , 8bpp - PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black - PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white + PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb + PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG) PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG) @@ -166,12 +227,12 @@ type PIX_FMT_BGR555, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), in CPU endianness, most significant bit to 1 {$IFEND} PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) - PIX_FMT_BGR4, ///< packed RGB 1:2:1, 4bpp, (msb)1B 2G 1R(lsb) + PIX_FMT_BGR4, ///< packed RGB 1:2:1, bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) - PIX_FMT_RGB4, ///< packed RGB 1:2:1, 4bpp, (msb)1R 2G 1B(lsb) + PIX_FMT_RGB4, ///< packed RGB 1:2:1, bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) - PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV + PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) PIX_FMT_NV21, ///< as above, but U and V bytes are swapped {$IF LIBAVUTIL_VERSION <= 50001000} // 50.01.0 PIX_FMT_RGB32_1, ///< packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in CPU endianness @@ -193,8 +254,8 @@ type PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers {$IF LIBAVUTIL_VERSION >= 49015000} // 49.15.0 - PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, big-endian - PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, little-endian + PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian {$IFEND} {$IF LIBAVUTIL_VERSION >= 50001000} // 50.01.0 PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian @@ -267,11 +328,13 @@ const PIX_FMT_YUV422 = PIX_FMT_YUYV422; {$IFEND} -(* libavutil/common.h *) // until now MKTAG is all from common.h KMS 9/6/2009 +(* libavutil/common.h *) // until now MKTAG and MKBETAG is all from common.h KMS 19/5/2010 function MKTAG(a, b, c, d: AnsiChar): integer; +function MKBETAG(a, b, c, d: AnsiChar): integer; (* libavutil/mem.h *) + (* memory handling functions *) (** @@ -287,7 +350,7 @@ function av_malloc(size: cuint): pointer; (** * Allocates or reallocates a block of memory. - * If ptr is NULL and size > 0, allocates a new block. If \p + * If ptr is NULL and size > 0, allocates a new block. If * size is zero, frees the memory block pointed to by ptr. * @param size Size in bytes for the memory block to be allocated or * reallocated. @@ -326,7 +389,7 @@ function av_mallocz(size: cuint): pointer; * Duplicates the string s. * @param s string to be duplicated. * @return Pointer to a newly allocated string containing a - * copy of \p s or NULL if the string cannot be allocated. + * copy of s or NULL if the string cannot be allocated. *) function av_strdup({const} s: PAnsiChar): PAnsiChar; cdecl; external av__util; {av_malloc_attrib} @@ -388,11 +451,40 @@ const AV_LOG_DEBUG = 48; {$IFEND} +(** + * Sends the specified message to the log if the level is less than or equal + * to the current av_log_level. By default, all logging messages are sent to + * stderr. This behavior can be altered by setting a different av_vlog callback + * function. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param fmt The format string (printf-compatible) that specifies how + * subsequent arguments are converted to output. + * @see av_vlog + *) + +{** to be translated if needed +#ifdef __GNUC__ +void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); +#else +void av_log(void*, int level, const char *fmt, ...); +#endif + +void av_vlog(void*, int level, const char *fmt, va_list); +**} + function av_log_get_level(): cint; cdecl; external av__util; procedure av_log_set_level(level: cint); cdecl; external av__util; +{** to be translated if needed +void av_log_set_callback(void (*)(void*, int, const char*, va_list)); +void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); +**} implementation @@ -403,4 +495,10 @@ begin Result := (ord(a) or (ord(b) shl 8) or (ord(c) shl 16) or (ord(d) shl 24)); end; +function MKBETAG(a, b, c, d: AnsiChar): integer; +begin + Result := (ord(d) or (ord(c) shl 8) or (ord(b) shl 16) or (ord(a) shl 24)); +end; + + end. diff --git a/cmake/src/lib/ffmpeg/error.pas b/cmake/src/lib/ffmpeg/error.pas new file mode 100644 index 00000000..95cecd0f --- /dev/null +++ b/cmake/src/lib/ffmpeg/error.pas @@ -0,0 +1,113 @@ +(* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * This is a part of the Pascal port of ffmpeg. + * - Changes and updates by the UltraStar Deluxe Team + * + * Conversion of libavutil/error.h + * Max. avutil version: 50.15.2, revision 23059, Tue May 11 18:30 2010 CET + * + *) + +{$IF LIBAVUTIL_VERSION >= 50012000} // >= 50.12.0 + +{* error handling *} + +const +{$IFDEF UNIX} + ENOENT = ESysENOENT; + EIO = ESysEIO; + ENOMEM = ESysENOMEM; + EINVAL = ESysEINVAL; + EDOM = ESysEDOM; + ENOSYS = ESysENOSYS; + EILSEQ = ESysEILSEQ; + EPIPE = ESysEPIPE; +{$ELSE} + ENOENT = 2; + EIO = 5; + ENOMEM = 12; + EINVAL = 22; + EPIPE = 32; // just an assumption. needs to be checked. + EDOM = 33; + {$IFDEF MSWINDOWS} + // Note: we assume that ffmpeg was compiled with MinGW. + // This must be changed if DLLs were compiled with cygwin. + ENOSYS = 40; // MSVC/MINGW: 40, CYGWIN: 88, LINUX/FPC: 38 + EILSEQ = 42; // MSVC/MINGW: 42, CYGWIN: 138, LINUX/FPC: 84 + {$ENDIF} +{$ENDIF} + +(** + * We need the sign of the error, because some platforms have + * E* and errno already negated. The previous version failed + * with Delphi, because it needed EINVAL defined. + * Warning: This code is platform dependent and assumes constants + * to be 32 bit. + * This version does the following steps: + * 1) shr 30: shifts the sign bit to bit position 2 + * 2) and $00000002: sets all other bits to zero + * positive EINVAL gives 0, negative gives 2 + * 3) not: inverts all bits. This gives -1 and -3 + * 3) - 1: positive EINVAL gives -1, negative 1 + *) +const + AVERROR_SIGN = (EINVAL shr 30) and $00000002 - 1; + +(* +#if EINVAL > 0 +#define AVERROR(e) (-(e)) {**< Returns a negative error code from a POSIX error code, to return from library functions. *} +#define AVUNERROR(e) (-(e)) {**< Returns a POSIX error code from a library function error return value. *} +#else +{* Some platforms have E* and errno already negated. *} +#define AVERROR(e) (e) +#define AVUNERROR(e) (e) +#endif +*) + +const + AVERROR_UNKNOWN = AVERROR_SIGN * EINVAL; (**< unknown error *) + AVERROR_IO = AVERROR_SIGN * EIO; (**< I/O error *) + AVERROR_NUMEXPECTED = AVERROR_SIGN * EDOM; (**< Number syntax expected in filename. *) + AVERROR_INVALIDDATA = AVERROR_SIGN * EINVAL; (**< invalid data found *) + AVERROR_NOMEM = AVERROR_SIGN * ENOMEM; (**< not enough memory *) + AVERROR_NOFMT = AVERROR_SIGN * EILSEQ; (**< unknown format *) + AVERROR_NOTSUPP = AVERROR_SIGN * ENOSYS; (**< Operation not supported. *) + AVERROR_NOENT = AVERROR_SIGN * ENOENT; (**< No such file or directory. *) +{$IF LIBAVCODEC_VERSION >= 52017000} // 52.17.0 + AVERROR_EOF = AVERROR_SIGN * EPIPE; (**< End of file. *) +{$IFEND} + // Note: function calls as constant-initializers are invalid + //AVERROR_PATCHWELCOME = -MKTAG('P','A','W','E'); {**< Not yet implemented in FFmpeg. Patches welcome. *} + AVERROR_PATCHWELCOME = -(ord('P') or (ord('A') shl 8) or (ord('W') shl 16) or (ord('E') shl 24)); +{$IFEND} + +{$IF LIBAVUTIL_VERSION >= 50013000} // >= 50.13.0 +(* + * Puts a description of the AVERROR code errnum in errbuf. + * In case of failure the global variable errno is set to indicate the + * error. Even in case of failure av_strerror() will print a generic + * error message indicating the errnum provided to errbuf. + * + * @param errbuf_size the size in bytes of errbuf + * @return 0 on success, a negative value if a description for errnum + * cannot be found + *) + +function av_strerror(errnum: cint; errbuf: Pchar; errbuf_size: cint): cint; + cdecl; external av__util; +{$IFEND} diff --git a/cmake/src/lib/ffmpeg/mathematics.pas b/cmake/src/lib/ffmpeg/mathematics.pas index 92ee0a5e..3a1f6a2c 100644 --- a/cmake/src/lib/ffmpeg/mathematics.pas +++ b/cmake/src/lib/ffmpeg/mathematics.pas @@ -26,10 +26,8 @@ (* * Conversion of libavutil/mathematics.h - * revision 16844, Wed Jan 28 08:50:10 2009 UTC + * avutil max. version 50.15.2, revision 23059, Tue May 11 22:10:00 2010 CET * - * update, MiSchi, no code change - * Fri Jun 12 2009 21:50:00 UTC *) unit mathematics; @@ -53,8 +51,18 @@ const M_E = 2.7182818284590452354; // e M_LN2 = 0.69314718055994530942; // log_e 2 M_LN10 = 2.30258509299404568402; // log_e 10 +{$IF LIBAVUTIL_VERSION >= 50009000} // >= 50.9.0 + M_LOG2_10 = 3.32192809488736234787; // log_2 10 +{$IFEND} M_PI = 3.14159265358979323846; // pi M_SQRT1_2 = 0.70710678118654752440; // 1/sqrt(2) +{$IF LIBAVUTIL_VERSION >= 50014000} // >= 50.14.0 + M_SQRT2 = 1.41421356237309504880; // sqrt(2) +{$IFEND} +{$IF LIBAVUTIL_VERSION >= 50005001} // >= 50.5.1 + NAN = 0.0/0.0; + INFINITY = 1.0/0.0; +{$IFEND} type TAVRounding = ( @@ -66,6 +74,11 @@ type ); {$IF LIBAVUTIL_VERSION >= 49013000} // 49.13.0 +(** + * Returns the greatest common divisor of a and b. + * If both a or b are 0 or either or both are <0 then behavior is + * undefined. + *) function av_gcd(a: cint64; b: cint64): cint64; cdecl; external av__util; {av_const} {$IFEND} @@ -90,6 +103,17 @@ function av_rescale_rnd (a, b, c: cint64; enum: TAVRounding): cint64; function av_rescale_q (a: cint64; bq, cq: TAVRational): cint64; cdecl; external av__util; {av_const} +{$IF LIBAVUTIL_VERSION >= 50008000} // 50.8.0 +(** + * Compares 2 timestamps each in its own timebases. + * The result of the function is undefined if one of the timestamps + * is outside the int64_t range when represented in the others timebase. + * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position + *) +function av_compare_ts(ts_a: cint64; tb_a: TAVRational; ts_b: cint64; tb_b: TAVRational): cint; + cdecl; external av__util; +{$IFEND} + implementation end. diff --git a/cmake/src/lib/ffmpeg/opt.pas b/cmake/src/lib/ffmpeg/opt.pas index a2e2cce9..c755ed35 100644 --- a/cmake/src/lib/ffmpeg/opt.pas +++ b/cmake/src/lib/ffmpeg/opt.pas @@ -23,14 +23,10 @@ * - For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT * in the source codes. * - Changes and updates by the UltraStar Deluxe Team - *) - -(* + * * Conversion of libavcodec/opt.h - * revision 16912, Sun Feb 1 02:00:19 2009 UTC + * Max. avcodec version: 52.67.0, revision 23057, Tue May 11 18:17 2010 CET * - * update, MiSchi, no code change - * Fri Jun 12 2009 21:50:00 UTC *) unit opt; @@ -110,6 +106,53 @@ type unit_: {const} PAnsiChar; end; +{$IF LIBAVCODEC_VERSION >= 52042000} // >= 52.42.0 +(** + * AVOption2. + * THIS IS NOT PART OF THE API/ABI YET! + * This is identical to AVOption except that default_val was replaced by + * an union, it should be compatible with AVOption on normal platforms. + *) +type + PAVOption2 = ^TAVOption2; + TAVOption2 = record + name : {const} PAnsiChar; + + (** + * short English help text + * @todo What about other languages? + *) + help : {const} PAnsiChar; + + (** + * The offset relative to the context structure where the option + * value is stored. It should be 0 for named constants. + *) + offset : cint; + type_ : TAVOptionType; + + (** + * the default value for scalar options + *) + default_val : record + case cint of + 0 : (dbl: cdouble); + 1 : (str: PAnsiChar); + end; + min : cdouble; + max : cdouble; + flags : cint; +//FIXME think about enc-audio, ... style flags + + (** + * The logical unit to which the option belongs. Non-constant + * options and corresponding named constants share the same + * unit. May be NULL. + *) + unit_: {const} PAnsiChar; + end; +{$IFEND} + {$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 (** * Looks for an option in obj. Looks only for the options which @@ -189,10 +232,10 @@ function av_set_q(obj: pointer; name: {const} PAnsiChar; n: TAVRational): PAVOpt function av_set_int(obj: pointer; name: {const} PAnsiChar; n: cint64): PAVOption; cdecl; external av__codec; -function av_get_double(obj: pointer; name: {const} PAnsiChar; var o_out: PAVOption): cdouble; +function av_get_double(obj: pointer; name: {const} PAnsiChar; var o_out: {const} PAVOption): cdouble; cdecl; external av__codec; -function av_get_q(obj: pointer; name: {const} PAnsiChar; var o_out: PAVOption): TAVRational; +function av_get_q(obj: pointer; name: {const} PAnsiChar; var o_out: {const} PAVOption): TAVRational; cdecl; external av__codec; function av_get_int(obj: pointer; name: {const} PAnsiChar; var o_out: {const} PAVOption): cint64; diff --git a/cmake/src/lib/ffmpeg/rational.pas b/cmake/src/lib/ffmpeg/rational.pas index b940009d..6ca9c0d1 100644 --- a/cmake/src/lib/ffmpeg/rational.pas +++ b/cmake/src/lib/ffmpeg/rational.pas @@ -27,10 +27,8 @@ (* * Conversion of libavutil/rational.h - * revision 16912, Sun Feb 1 02:00:19 2009 UTC + * avutil max. version 50.15.2, revision 23059, Tue May 11 22:10:00 2010 CET * - * update, MiSchi, no code change - * Fri Jun 12 2009 22:20:00 UTC *) unit rational; diff --git a/cmake/src/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt b/cmake/src/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt deleted file mode 100644 index c2f5826a..00000000 --- a/cmake/src/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt +++ /dev/null @@ -1,24 +0,0 @@ -If you are using fink to install ffmpeg and friends, -you can skip the rest of this notes. - -How to download an build ffmpeg for UltraStar Deluxe on Mac OS X: - -1. Open a terminal. - -2. cd into the Game/Code/lib/ffmpeg/src/MacOSX directory - -3. Run the following command: - -svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg - -4. The compile ffmpeg. I made a script for this: - -./build_ffmpeg.sh - -5. On OS X you have to patch the the dylibs. Run the following - script. It patches the dylibs and copies them to the - lib/ffmpeg dir: - -./copy_and_patch_dylibs.sh - -You're done. diff --git a/cmake/src/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh b/cmake/src/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh deleted file mode 100755 index bcb3ca1e..00000000 --- a/cmake/src/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -cd ffmpeg -./configure --enable-shared --disable-static --disable-mmx -make - diff --git a/cmake/src/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh b/cmake/src/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh deleted file mode 100755 index 064d2ecc..00000000 --- a/cmake/src/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Copy dylibs: -cp ffmpeg/libavcodec/libavcodec.51.dylib ../../libavcodec.dylib -cp ffmpeg/libavformat/libavformat.52.dylib ../../libavformat.dylib -cp ffmpeg/libavutil/libavutil.49.dylib ../../libavutil.dylib - -# Patching libavcodec: -install_name_tool -id @executable_path/libavcodec.dylib ../../libavcodec.dylib -install_name_tool -change /usr/local/lib/libavutil.dylib @executable_path/libavutil.dylib ../../libavcodec.dylib - -# Patching libavformat: -install_name_tool -id @executable_path/libavformat.dylib ../../libavformat.dylib -install_name_tool -change /usr/local/lib/libavutil.dylib @executable_path/libavutil.dylib ../../libavformat.dylib -install_name_tool -change /usr/local/lib/libavcodec.dylib @executable_path/libavcodec.dylib ../../libavformat.dylib - -# Patching libavcodec: -install_name_tool -id @executable_path/libavutil.dylib ../../libavutil.dylib - -# Printing result: -otool -L ../../libavutil.dylib -otool -L ../../libavcodec.dylib -otool -L ../../libavformat.dylib \ No newline at end of file diff --git a/cmake/src/lib/ffmpeg/swscale.pas b/cmake/src/lib/ffmpeg/swscale.pas index c0aabf45..4f923f04 100644 --- a/cmake/src/lib/ffmpeg/swscale.pas +++ b/cmake/src/lib/ffmpeg/swscale.pas @@ -23,7 +23,7 @@ (* * Conversion of libswscale/swscale.h - * revision 27592, Fri Sep 12 21:46:53 2008 UTC + * Max. version: 0.10.0, revision 31050, Tue May 11 19:40:00 2010 CET *) unit swscale; @@ -49,10 +49,35 @@ uses UConfig; const + (* + * IMPORTANT: The official FFmpeg C headers change very quickly. Often some + * of the data structures are changed so that they become incompatible with + * older header files. The Pascal headers have to be adjusted to those changes, + * otherwise the application might crash randomly or strange bugs (not + * necessarily related to video or audio due to buffer overflows etc.) might + * occur. + * + * In the past users reported problems with USDX that took hours to fix and + * the problem was an unsupported version of FFmpeg. So we decided to disable + * support for future versions of FFmpeg until the headers are revised by us + * for that version as they otherwise most probably will break USDX. + * + * If the headers do not yet support your FFmpeg version you may want to + * adjust the max. version numbers manually but please note: it may work but + * in many cases it does not. The USDX team does NOT PROVIDE ANY SUPPORT + * for the game if the MAX. VERSION WAS CHANGED. + * + * The only safe way to support new versions of FFmpeg is to add the changes + * of the FFmpeg git repository C headers to the Pascal headers. + * You can accelerate this process by posting a patch with the git changes + * translated to Pascal to our bug tracker (please join our IRC chat before + * you start working on it). Simply adjusting the max. versions is NOT a valid + * fix. + *) (* Max. supported version by this header *) - LIBSWSCALE_MAX_VERSION_MAJOR = 0; - LIBSWSCALE_MAX_VERSION_MINOR = 7; - LIBSWSCALE_MAX_VERSION_RELEASE = 1; + LIBSWSCALE_MAX_VERSION_MAJOR = 0; + LIBSWSCALE_MAX_VERSION_MINOR = 10; + LIBSWSCALE_MAX_VERSION_RELEASE = 0; LIBSWSCALE_MAX_VERSION = (LIBSWSCALE_MAX_VERSION_MAJOR * VERSION_MAJOR) + (LIBSWSCALE_MAX_VERSION_MINOR * VERSION_MINOR) + (LIBSWSCALE_MAX_VERSION_RELEASE * VERSION_RELEASE); @@ -78,6 +103,20 @@ function swscale_version(): cuint; cdecl; external sw__scale; {$IFEND} +{$IF LIBSWSCALE_VERSION >= 000007002} // 0.7.2 +(** + * Returns the libswscale build-time configuration. + *) +function swscale_configuration(): PAnsiChar; + cdecl; external sw__scale; + +(** + * Returns the libswscale license. + *) +function swscale_license(): PAnsiChar; + cdecl; external sw__scale; +{$IFEND} + const (* values for the flags, the stuff on the command line is different *) SWS_FAST_BILINEAR = 1; @@ -124,6 +163,18 @@ const SWS_CS_SMPTE240M = 7; SWS_CS_DEFAULT = 5; +{$IF LIBSWSCALE_VERSION >= 000010000} // 0.10.0 +(** + * Returns a pointer to yuv<->rgb coefficients for the given colorspace + * suitable for sws_setColorspaceDetails(). + * + * @param colorspace One of the SWS_CS_* macros. If invalid, + * SWS_CS_DEFAULT is used. + *) + function sws_getCoefficients(colorspace: cint): Pcint; + cdecl; external sw__scale; +{$IFEND} + type // when used for filters they must have an odd number of elements @@ -148,6 +199,26 @@ type {internal structure} end; +{$IF LIBSWSCALE_VERSION >= 000008000} // 0.8.0 +(** + * Returns a positive value if pix_fmt is a supported input format, 0 + * otherwise. + *) + function sws_isSupportedInput(pix_fmt: TAVPixelFormat): cint; + cdecl; external sw__scale; + +(** + * Returns a positive value if pix_fmt is a supported output format, 0 + * otherwise. + *) + function sws_isSupportedOutput(pix_fmt: TAVPixelFormat): cint; + cdecl; external sw__scale; +{$IFEND} + +(** + * Frees the swscaler context swsContext. + * If swsContext is NULL, then does nothing. + *) procedure sws_freeContext(swsContext: PSwsContext); cdecl; external sw__scale; @@ -175,6 +246,10 @@ function sws_getContext(srcW: cint; srcH: cint; srcFormat: TAVPixelFormat; * slice in the image in dst. A slice is a sequence of consecutive * rows in an image. * + * Slices have to be provided in sequential order, either in + * top-bottom or bottom-top order. If slices are provided in + * non-sequential order the behavior of the function is undefined. + * * @param context the scaling context previously created with * sws_getContext() * @param srcSlice the array containing the pointers to the planes of @@ -192,14 +267,15 @@ function sws_getContext(srcW: cint; srcH: cint; srcFormat: TAVPixelFormat; * the destination image * @return the height of the output slice *) -function sws_scale(context: PSwsContext; srcSlice: PPCuint8Array; srcStride: PCintArray; - srcSliceY: cint; srcSliceH: cint; dst: PPCuint8Array; dstStride: PCintArray): cint; +function sws_scale(context: PSwsContext; {const} srcSlice: PPCuint8Array; {const} srcStride: PCintArray; + srcSliceY: cint; srcSliceH: cint; {const} dst: PPCuint8Array; {const} dstStride: PCintArray): cint; cdecl; external sw__scale; {$IF LIBSWSCALE_VERSION_MAJOR < 1} // deprecated. Use sws_scale() instead. -function sws_scale_ordered(context: PSwsContext; src: PPCuint8Array; srcStride: PCintArray; - srcSliceY: cint; srcSliceH: cint; dst: PPCuint8Array; dstStride: PCintArray): cint; +function sws_scale_ordered(context: PSwsContext; {const} src: PPCuint8Array; + srcStride: PCintArray; srcSliceY: cint; srcSliceH: cint; + dst: PPCuint8Array; dstStride: PCintArray): cint; cdecl; external sw__scale; deprecated; {$IFEND} -- cgit v1.2.3