diff options
author | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-10-11 08:03:12 +0000 |
---|---|---|
committer | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-10-11 08:03:12 +0000 |
commit | 48676faa6c0da1eb77999512322896840ea13cb1 (patch) | |
tree | 34783f49bcbb5d159955d16e9648daa95a5b2d64 /Game/Code/lib/ffmpeg | |
parent | 2f80e3be339f528bd0c7ef54db8ff7cc641883e3 (diff) | |
download | usdx-48676faa6c0da1eb77999512322896840ea13cb1.tar.gz usdx-48676faa6c0da1eb77999512322896840ea13cb1.tar.xz usdx-48676faa6c0da1eb77999512322896840ea13cb1.zip |
major changes to FFMPEG Headers so they now support linux.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@500 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/lib/ffmpeg')
-rw-r--r-- | Game/Code/lib/ffmpeg/MATHEMATICS.pas | 124 | ||||
-rw-r--r-- | Game/Code/lib/ffmpeg/avcodec.pas | 132 | ||||
-rw-r--r-- | Game/Code/lib/ffmpeg/avformat.pas | 248 | ||||
-rw-r--r-- | Game/Code/lib/ffmpeg/avio.pas | 24 | ||||
-rw-r--r-- | Game/Code/lib/ffmpeg/avutil.pas | 20 | ||||
-rw-r--r-- | Game/Code/lib/ffmpeg/opt.pas | 19 | ||||
-rw-r--r-- | Game/Code/lib/ffmpeg/rational.pas | 29 |
7 files changed, 355 insertions, 241 deletions
diff --git a/Game/Code/lib/ffmpeg/MATHEMATICS.pas b/Game/Code/lib/ffmpeg/MATHEMATICS.pas index 9570d343..83121899 100644 --- a/Game/Code/lib/ffmpeg/MATHEMATICS.pas +++ b/Game/Code/lib/ffmpeg/MATHEMATICS.pas @@ -1,58 +1,66 @@ -unit MATHEMATICS;
-
-interface
-
-(*
- * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *)
-
-uses
- windows, rational;
-
-const
- av__util = 'avutil-49.dll';
-
-type
- TAVRounding = (
- AV_ROUND_ZERO = 0, ///< round toward zero
- AV_ROUND_INF = 1, ///< round away from zero
- AV_ROUND_DOWN = 2, ///< round toward -infinity
- AV_ROUND_UP = 3, ///< round toward +infinity
- AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
- AV_ROUND_FUCKING = $FFFFFF
- );
-
-(** * rescale a 64bit integer with rounding to nearest.
- * a simple a*b/c isn't possible as it can overflow *)
-function av_rescale (a, b, c: int64): int64;
- cdecl; external av__util;
-
-(**
- * rescale a 64bit integer with specified rounding.
- * a simple a*b/c isn't possible as it can overflow *)
-function av_rescale_rnd (a, b, c: int64; enum: TAVRounding): int64;
- cdecl; external av__util;
-
-(**
- * rescale a 64bit integer by 2 rational numbers. *)
-function av_rescale_q (a: int64; bq, cq: TAVRational): int64;
- cdecl; external av__util;
-
-implementation
-
-end.
-
\ No newline at end of file +unit MATHEMATICS; + +interface + +(* + * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> + * + * This library 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 of the License, or (at your option) any later version. + * + * This library 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + +{$MODE DELPHI} (* CAT *) +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) + +uses + rational; (* CAT *) + +const + av__util = 'libavutil.49'; (* CAT *) + +type + TAVRounding = ( + AV_ROUND_ZERO = 0, ///< round toward zero + AV_ROUND_INF = 1, ///< round away from zero + AV_ROUND_DOWN = 2, ///< round toward -infinity + AV_ROUND_UP = 3, ///< round toward +infinity + AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero + AV_ROUND_FUCKING = $FFFFFF + ); + +(** * rescale a 64bit integer with rounding to nearest. + * a simple a*b/c isn't possible as it can overflow *) +function av_rescale (a, b, c: int64): int64; + cdecl; external av__util; + +(** + * rescale a 64bit integer with specified rounding. + * a simple a*b/c isn't possible as it can overflow *) +function av_rescale_rnd (a, b, c: int64; enum: TAVRounding): int64; + cdecl; external av__util; + +(** + * rescale a 64bit integer by 2 rational numbers. *) +function av_rescale_q (a: int64; bq, cq: TAVRational): int64; + cdecl; external av__util; + +implementation + +end. + diff --git a/Game/Code/lib/ffmpeg/avcodec.pas b/Game/Code/lib/ffmpeg/avcodec.pas index bef5f687..c82bc329 100644 --- a/Game/Code/lib/ffmpeg/avcodec.pas +++ b/Game/Code/lib/ffmpeg/avcodec.pas @@ -15,32 +15,35 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) + +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + unit avcodec; +{$LINKLIB libavutil} +{$LINKLIB libavcodec} +{$MODE DELPHI } (* CAT *) +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) + interface uses - {$IFDEF win32} - windows, - {$ENDIF} - avutil, - rational, - opt; + avutil, rational, opt; // CAT const - {$IFDEF win32} - av__format = 'avformat-50.dll'; - {$ELSE} - av__format = 'libavformat.so'; // .0d - {$ENDIF} +(* version numbers are changed by The Creative CAT *) + av__format = 'libavformat.51'; - - LIBAVUTIL_VERSION_INT = ((51 shl 16) + (16 shl 8) + 0); - LIBAVUTIL_VERSION = '51.16.0'; + LIBAVUTIL_VERSION_INT = ((51 shl 16) + (12 shl 8) + 1); + LIBAVUTIL_VERSION = '51.12.1'; LIBAVUTIL_BUILD = LIBAVUTIL_VERSION_INT; AV_NOPTS_VALUE: int64 = $8000000000000000; AV_TIME_BASE = 1000000; + AV_TIME_BASE_Q : TAVRational = (num:1; den:AV_TIME_BASE); (* added by CAT *) type TCodecID = ( @@ -119,7 +122,8 @@ type CODEC_TYPE_VIDEO, CODEC_TYPE_AUDIO, CODEC_TYPE_DATA, - CODEC_TYPE_SUBTITLE + CODEC_TYPE_SUBTITLE, + CODEC_TYPE_NB (* CAT#3 *) ); //* currently unused, may be used if 24/32 bits samples ever supported */ @@ -347,11 +351,11 @@ type TAVFrame = record {200} (*** pointer to the picture planes. * this might be different from the first allocated byte *) - data: array [0..3] of pointer; + data: array [0..3] of pbyte; linesize: array [0..3] of integer; (*** pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer * this isn't used by lavc unless the default get/release_buffer() is used*) - base: array [0..3] of pchar; + base: array [0..3] of pbyte; (*** 1 -> keyframe, 0-> not *) key_frame: integer; (*** picture type of the frame, see ?_TYPE below.*) @@ -374,7 +378,7 @@ type (*** QP store stride*) qstride: integer; (*** mbskip_table[mb]>=1 if MB didnt change*) - mbskip_table: pchar; + mbskip_table: pbyte; (** * Motion vector table. * @code @@ -403,9 +407,9 @@ type (*** when decoding, this signal how much the picture must be delayed. * extra_delay = repeat_pict / (2*fps)*) repeat_pict: integer; - qscale_type: Integer; + qscale_type: integer; (*** The content of the picture is interlaced.*) - interlaced_frame: Integer; + interlaced_frame: integer; (*** if the content is interlaced, is top field displayed first.*) top_field_first: integer; (*** Pan scan.*) @@ -416,9 +420,9 @@ type * - decoding: set by lavc (before get_buffer() call))*) buffer_hints: integer; (*** DCT coeffitients*) - dct_coeff: PSmallInt; + dct_coeff: PsmallInt; (*** Motion referece frame index*) - ref_index: array [0..1] of pchar; + ref_index: array [0..1] of pshortint; end; const @@ -573,12 +577,12 @@ const X264_PART_B8X8 = $100; (* Analyse b16x8, b8x16 and b8x8 *) type - PAVCLASS = ^TAVCLASS; + PAVClass = ^TAVClass; PAVCodecContext = ^TAVCodecContext; PAVCodec = ^TAVCodec; PAVPaletteControl = ^TAVPaletteControl; - TAVCLASS = record {12} + TAVclass = record {12} class_name: pchar; (* actually passing a pointer to an AVCodecContext or AVFormatContext, which begin with an AVClass. @@ -629,7 +633,7 @@ type * - encoding: set/allocated/freed by lavc. * - decoding: set/allocated/freed by user. *) - extradata: pointer; + extradata: pbyte; extradata_size: integer; (** @@ -787,8 +791,8 @@ type * this is used to workaround some encoder bugs * - encoding: set by user, if not then the default based on codec_id will be used * - decoding: set by user, will be converted to upper case by lavc during init *) -// codec_tag: cardinal; // можно array [0..3] of char - тогда видно FOURCC - codec_tag: array [0..3] of char; + codec_tag: cardinal; // можно array [0..3] of char - тогда видно FOURCC +// codec_tag: array [0..3] of char; (*** workaround bugs in encoders which sometimes cannot be detected automatically. * - encoding: set by user @@ -966,7 +970,7 @@ type (*** slice offsets in the frame in bytes. * - encoding: set/allocated by lavc * - decoding: set/allocated by user (or NULL) *) - slice_offset: PInteger; + slice_offset: Pinteger; (*** error concealment flags. * - encoding: unused @@ -1517,7 +1521,7 @@ type _type: TCodecType; id: TCodecID; priv_data_size: integer; - init: function (avctx: pAVCodecContext): integer; cdecl; + init: function (avctx: PAVCodecContext): integer; cdecl; (* typo corretion by the Creative CAT *) encode: function (avctx: PAVCodecContext; buf: pchar; buf_size: integer; data: pointer): integer; cdecl; close: function (avctx: PAVCodecContext): integer; cdecl; decode: function (avctx: PAVCodecContext; outdata: pointer; outdata_size: PInteger; @@ -1731,12 +1735,18 @@ procedure av_resample_close (c: PAVResampleContext); procedure avcodec_get_context_defaults (s: PAVCodecContext); cdecl; external av__codec; - function avcodec_alloc_context (): PAVCodecContext; + function avcodec_alloc_context : PAVCodecContext; cdecl; external av__codec; +(* favourite of The Creative CAT + function avcodec_alloc_context (): PAVCodecContext; + cdecl; external av__codec; *) procedure avcodec_get_frame_defaults (pic: PAVFrame); cdecl; external av__codec; - function avcodec_alloc_frame (): PAVFrame; + function avcodec_alloc_frame : PAVFrame; cdecl; external av__codec; +(* favourite of The Creative CAT + function avcodec_alloc_frame (): PAVFrame; + cdecl; external av__codec; *) function avcodec_default_get_buffer (s: PAVCodecContext; pic: PAVFrame): integer; cdecl; external av__codec; @@ -1782,9 +1792,15 @@ procedure av_resample_close (c: PAVResampleContext); * @return 0 if successful, -1 if not. *) +(** This comment was added by the Creative CAT. frame_size_ptr was changed to + variable refference. + + * @deprecated Use avcodec_decode_audio2() instead. + *) + function avcodec_decode_audio (avctx: PAVCodecContext; samples: Pword; - frame_size_ptr: pinteger; - buf: pchar; buf_size: integer): integer; + var frame_size_ptr: integer; + buf: pchar; buf_size: integer): integer; cdecl; external av__codec; (* decode a frame. * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes @@ -1793,8 +1809,47 @@ procedure av_resample_close (c: PAVResampleContext); * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero * @return -1 if error, otherwise return the number of * bytes used. *) + + function avcodec_decode_audio2(avctx : PAVCodecContext; samples : PWord; + var frame_size_ptr : integer; + buf: pchar; buf_size: integer): integer; + cdecl; external av__codec; +(* Added by The Creative CAT +/** + * Decodes a video frame from \p buf into \p picture. + * The avcodec_decode_video() function decodes a video frame from the input + * buffer \p buf of size \p buf_size. To decode it, it makes use of the + * video codec which was coupled with \p avctx using avcodec_open(). The + * resulting decoded frame is stored in \p picture. + * + * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer \p buf and output buffer \p + * samples. The alignment requirements depend on the CPU: on some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. In practice, the + * bitstream should have 4 byte alignment at minimum and all sample data should + * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If + * the linesize is not a multiple of 16 then there's no sense in aligning the + * start of the buffer to 16. + * + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * @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. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +*) + function avcodec_decode_video (avctx: PAVCodecContext; picture: PAVFrame; - got_picture_ptr: pinteger; + var got_picture_ptr: integer; (* favour of The Creative CAT *) buf: PByte; buf_size: integer): integer; cdecl; external av__codec; @@ -1802,19 +1857,18 @@ procedure av_resample_close (c: PAVResampleContext); got_sub_ptr: pinteger; const buf: pchar; buf_size: integer): integer; cdecl; external av__codec; - - {$IFNDEF FPC} function avcodec_parse_frame (avctx: PAVCodecContext; pdata: PPointer; data_size_ptr: pinteger; buf: pchar; buf_size: integer): integer; cdecl; external av__codec; - {$ENDIF} + function avcodec_encode_audio (avctx: PAVCodecContext; buf: PByte; - buf_size: integer; const samples: Pword): integer; + buf_size: integer; const samples: PWord): integer; cdecl; external av__codec; (* avcodec_encode_video: -1 if error *) - function avcodec_encode_video (avctx: PAVCodecContext; buf: pointer; + (* type of the second argument is changed by The Creative CAT *) + function avcodec_encode_video (avctx: PAVCodecContext; buf: PByte; buf_size: integer; pict: PAVFrame): integer; cdecl; external av__codec; function avcodec_encode_subtitle (avctx: PAVCodecContext; buf: pchar; diff --git a/Game/Code/lib/ffmpeg/avformat.pas b/Game/Code/lib/ffmpeg/avformat.pas index 312fb67d..7fd009e9 100644 --- a/Game/Code/lib/ffmpeg/avformat.pas +++ b/Game/Code/lib/ffmpeg/avformat.pas @@ -15,33 +15,29 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) + +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + unit avformat; -interface +{$LINKLIB libavutil} +{$LINKLIB libavformat} +{$MODE DELPHI } (* CAT *) +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} +interface uses - {$IFDEF win32} - windows, - {$ENDIF} - avcodec, - avio, - rational, - avutil; + avcodec, avio, rational, avutil; (* CAT *) const - {$IFDEF win32} - av__format = 'avformat-50.dll'; - {$ELSE} - av__format = 'libavformat.so'; // .0d - av__codec = 'libavcodec.so'; - {$ENDIF} - - LIBAVUTIL_VERSION_INT = ((49 shl 16) + (0 shl 8) + 1); - LIBAVUTIL_VERSION = '49.0.1'; + av__format = 'libavformat.51'; (* CAT *) + + LIBAVUTIL_VERSION_INT = ((51 shl 16) + (12 shl 8) + 1); + LIBAVUTIL_VERSION = '51.12.1'; LIBAVUTIL_BUILD = LIBAVUTIL_VERSION_INT; MAXINT64 = $7fffffffffffffff; @@ -49,10 +45,37 @@ const PKT_FLAG_KEY = $0001; - (* AVImageFormat.flags field constants *) - AVIMAGE_INTERLEAVED = $0001; (* image format support interleaved output *) - MAX_STREAMS = 20; +(*************************************************) +(* input/output formats *) + + AVPROBE_SCORE_MAX = 100; ///< max score, half of that is used for file extension based detection + AVPROBE_PADDING_SIZE = 32; ///< extra allocated bytes at the end of the probe buffer + +//! demuxer will use url_fopen, no opened file should be provided by the caller + AVFMT_NOFILE = $0001; + AVFMT_NEEDNUMBER = $0002; (**< needs '%d' in filename *) + AVFMT_SHOW_IDS = $0008; (**< show format stream IDs numbers *) + AVFMT_RAWPICTURE = $0020; (**< format wants AVPicture structure for + raw picture data *) + AVFMT_GLOBALHEADER = $0040; (**< format wants global header *) + AVFMT_NOTIMESTAMPS = $0080; (**< format does not need / have any timestamps *) + AVFMT_GENERIC_INDEX = $0100; (**< use generic index building code *) + + AVINDEX_KEYFRAME = $0001; + + MAX_REORDER_DELAY = 4; + + AVFMTCTX_NOHEADER = $0001; (**< signal that no header is present + (streams are added dynamically) *) + MAX_STREAMS = 20; + AVFMT_NOOUTPUTLOOP = -1; + AVFMT_INFINITEOUTPUTLOOP = 0; + AVFMT_FLAG_GENPTS = $0001; ///< generate pts if missing 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 + type + HFILE = THandle; /// (* CAT *) int = integer; PAVPacket = ^TAVPacket; @@ -75,9 +98,10 @@ type stream_index: integer; flags: integer; duration: integer; ///< presentation duration in time_base units (0 if not available) - destruct: procedure (p: PAVPacket); + destruct: procedure (p: PAVPacket); (* This cannot be var : TAVPacket. + because TAVPacket is not completely defined yet *) priv: pointer; - pos: int64; ///< byte position in stream, -1 if unknown + pos: int64 ///< byte position in stream, -1 if unknown end; (*************************************************) @@ -90,9 +114,6 @@ type val, num, den: int64; end; -(*************************************************) -(* input/output formats *) - (* this structure contains the data a format has to probe a file *) TAVProbeData = record {12} filename: pchar; @@ -107,9 +128,9 @@ type width: integer; height: integer; pix_fmt: TAVPixelFormat; - image_format: PAVImageFormat; (* 4 bytes *) +{ image_format: PAVImageFormat; (* 4 bytes *)} (* CAT#3 *) channel: integer; (* used to select dv channel *) - device: pchar; (* video, audio or DV device *) + device: pchar; (* video, audio or DV device, if LIBAVFORMAT_VERSION_INT < (52<<16) *) standard: pchar; (* tv standard, NTSC, PAL, SECAM *) // int mpeg2ts_raw:1; (* force raw MPEG2 transport stream output, if possible *) // int mpeg2ts_compute_pcr:1; (* compute exact PCR for each transport @@ -117,6 +138,7 @@ type // mpeg2ts_raw is TRUE *) // int initial_pause:1; (* do not begin to play the stream // immediately (RTSP only) *) +// int prealloced_context:1; dummy: byte; video_codec_id: TCodecID; audio_codec_id: TCodecID; @@ -133,13 +155,20 @@ type audio_codec: TCodecID; (* default audio codec *) video_codec: TCodecID; (* default video codec *) write_header: function (c: PAVFormatContext): integer; cdecl; - write_packet: function (c: PAVFormatContext; pkt: PAVPacket): integer; cdecl; + write_packet: function (c: PAVFormatContext; var pkt: TAVPacket): integer; cdecl; (* CAT#2 *) write_trailer: function (c: PAVFormatContext): integer; cdecl; (* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER *) flags: integer; (* currently only used to set pixel format if not YUV420P *) set_parameters: function (c: PAVFormatContext; f: PAVFormatParameters): integer; cdecl; interleave_packet: function (s: PAVFormatContext; _out: PAVPacket; _in: PAVPacket; flush: integer): integer; cdecl; + + (** + * list of supported codec_id-codec_tag pairs, ordered by "better choice first" + * the arrays are all CODEC_ID_NONE terminated + *) + //const struct AVCodecTag **codec_tag; + (* private fields *) next: PAVOutputFormat; end; @@ -159,7 +188,7 @@ type (* read one packet and put it in 'pkt'. pts and flags are also set. 'av_new_stream' can be called only if the flag AVFMTCTX_NOHEADER is used. *) - read_packet: function (c: PAVFormatContext; pkt: PAVPacket): integer; cdecl; + read_packet: function (c: PAVFormatContext; var pkt: TAVPacket): integer; cdecl; (* close the stream. The AVFormatContext and AVStreams are not freed by this function *) read_close: function (c: PAVFormatContext): integer; cdecl; @@ -188,55 +217,66 @@ type (* pause playing - only meaningful if using a network based format (RTSP) *) read_pause: function (c: PAVFormatContext): integer; cdecl; + //const struct AVCodecTag **codec_tag; + (* private fields *) next: PAVInputFormat; end; + TAVStreamParseType = ( + AVSTREAM_PARSE_NONE, + AVSTREAM_PARSE_FULL, (**< full parsing and repack *) + AVSTREAM_PARSE_HEADERS, (**< only parse headers, don't repack *) + AVSTREAM_PARSE_TIMESTAMPS (**< full parsing and interpolation of timestamps for frames not starting on packet boundary *) + ); + TAVIndexEntry = record {24} pos: int64; timestamp: int64; (* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed *) flags: integer; +// int flags:2; +// int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align). min_distance: integer; (* min distance between this and the previous keyframe, used to avoid unneeded searching *) end; TAVStream = record {168} - index: integer; (* stream index in AVFormatContext *) - id: integer; (* format specific stream id *) - codec: PAVCodecContext; (* codec context *) + index: integer; (* stream index in AVFormatContext *) {4-4} + id: integer; (* format specific stream id *) {4-8} + codec: PAVCodecContext; (* codec context *) {4-12} (*** real base frame rate of the stream. * for example if the timebase is 1/90000 and all frames have either * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1 *) - r_frame_rate: TAVRational; - priv_data: pointer; + r_frame_rate: TAVRational; {4*2=8-20} + priv_data: pointer; {4-24} (* internal data used in av_find_stream_info() *) - codec_info_duration: int64; - codec_info_nb_frames: integer; + codec_info_duration: int64; (* #if LIBAVFORMAT_VERSION_INT < (52<<16) *) {8-32} + codec_info_nb_frames: integer; (* #if LIBAVFORMAT_VERSION_INT < (52<<16) *) {4-38} (* encoding: PTS generation when outputing stream *) - pts: TAVFrac; + pts: TAVFrac; {8*3=24-62} (*** this is the fundamental unit of time (in seconds) in terms * of which frame timestamps are represented. for fixed-fps content, * timebase should be 1/framerate and timestamp increments should be * identically 1. *) - time_base: TAVRational; - pts_wrap_bits: integer; (* number of bits in pts (used for wrapping control) *) + time_base: TAVRational; {4*2=8-70} + pts_wrap_bits: integer; (* number of bits in pts (used for wrapping control) *) {4-74} (* ffmpeg.c private use *) - stream_copy: integer; (* if TRUE, just copy stream *) - discard: TAVDiscard; ///< selects which packets can be discarded at will and dont need to be demuxed + stream_copy: integer; (* if TRUE, just copy stream *) {4-78} + discard: TAVDiscard; ///< selects which packets can be discarded at will and dont need to be demuxed {4-82} //FIXME move stuff to a flags field? (* quality, as it has been removed from AVCodecContext and put in AVVideoFrame * MN:dunno if thats the right place, for it *) - quality: single; + quality: single; {4-86} (* decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds. *) - start_time: int64; - (* decoding: duration of the stream, in AV_TIME_BASE fractional seconds. *) - duration: int64; + start_time: int64; {8-92} + (* decoding: duration of the stream, in stream time base. *) + duration: int64; {8-100} - language: array [0..3] of char; (* ISO 639 3-letter language code (empty string if undefined) *) + language: array [0..3] of char; (* ISO 639 3-letter language code (empty string if undefined) *)(* 101 th byte - 1 base *) {4-104} (* av_read_frame() support *) - need_parsing: integer; ///< 1->full parsing needed, 2->only parse headers dont repack + need_parsing: TAVStreamParseType;//CAT#3 ///< 1->full parsing needed, 2->only parse headers dont repack parser: PAVCodecParserContext; cur_dts: int64; @@ -245,10 +285,10 @@ type (* av_seek_frame() support *) index_entries: PAVIndexEntry; (* only used if the format does not support seeking natively *) nb_index_entries: integer; - index_entries_allocated_size: integer; + index_entries_allocated_size: cardinal; (* CAT#3 *) nb_frames: int64; ///< number of frames in this stream if known or 0 - pts_buffer: array [0..4] of int64; + pts_buffer: array [0..MAX_REORDER_DELAY] of int64 end; (* format I/O context *) @@ -259,7 +299,7 @@ type oformat: PAVOutputFormat; priv_data: pointer; pb: TByteIOContext; - nb_streams: cardinal;// integer; + nb_streams: cardinal; (* CAT#3 *) streams: array [0..MAX_STREAMS - 1] of PAVStream; filename: array [0..1023] of char; (* input or output filename *) (* stream info *) @@ -297,7 +337,7 @@ type (* av_read_frame() support *) cur_st: PAVStream; - cur_ptr: pchar; + cur_ptr: pbyte; cur_len: integer; cur_pkt: TAVPacket; @@ -317,6 +357,14 @@ type loop_input: integer; (* decoding: size of data to probe; encoding unused *) probesize: cardinal; + + (** + * maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info() + *) + max_analyze_duration: integer; + + key: pbyte; + keylen : integer end; TAVPacketList = record {64} @@ -353,23 +401,19 @@ type flags: integer; next: PAVImageFormat; end; - - {$IFNDEF win32} - HFILE = THandle; - {$ENDIF} -procedure av_destruct_packet_nofree (pkt: PAVPacket); +procedure av_destruct_packet_nofree (var pkt: TAVPacket); (* CAT#2 *) cdecl; external av__format; -procedure av_destruct_packet (pkt: PAVPacket); +procedure av_destruct_packet (var pkt: TAVPacket); (* CAT#2 *) cdecl; external av__format; (* initialize optional fields of a packet *) -procedure av_init_packet (pkt: PAVPacket); +procedure av_init_packet (var pkt: TAVPacket); (* CAT#2 *) -function av_new_packet(pkt: PAVPacket; size: integer): integer; +function av_new_packet(var pkt: TAVPacket; size: integer): integer; (* CAT#2 *) cdecl; external av__format; -function av_get_packet (s: PByteIOContext; pkt: PAVPacket; size: integer): integer; +function av_get_packet (s: PByteIOContext; var pkt: TAVPacket; size: integer): integer; (* CAT#2 *) cdecl; external av__format; function av_dup_packet (pkt: PAVPacket): integer; @@ -378,7 +422,7 @@ function av_dup_packet (pkt: PAVPacket): integer; (** * Free a packet * * @param pkt packet to free *) -procedure av_free_packet (pkt: PAVPacket); +procedure av_free_packet (var pkt: TAVPacket); (* CAT#2 *) procedure av_register_image_format (img_fmt: PAVImageFormat); cdecl; external av__format; @@ -408,15 +452,29 @@ function av_write_image(pb: PByteIOContext; fmt: PAVImageFormat; img: PAVImageIn //#include "rtsp.h" (* utils.c *) - procedure av_register_input_format (format: PAVInputFormat); cdecl; external av__format; - procedure av_register_output_format (format: PAVOutputFormat); cdecl; external av__format; - function guess_stream_format (short_name: pchar; filename: pchar; mime_type: pchar): PAVOutputFormat; cdecl; external av__format; - function guess_format(short_name: pchar; filename: pchar; mime_type: pchar): PAVOutputFormat; cdecl; external av__format; + procedure av_register_input_format (format: PAVInputFormat); + cdecl; external av__format; + + procedure av_register_output_format (format: PAVOutputFormat); + cdecl; external av__format; + + function guess_stream_format (short_name: pchar; filename: pchar; mime_type: pchar): PAVOutputFormat; + cdecl; external av__format; + + function guess_format(short_name: pchar; filename: pchar; mime_type: pchar): PAVOutputFormat; + cdecl; external av__format; + function av_guess_codec(fmt: PAVOutputFormat; short_name: pchar; - filename: pchar; mime_type: pchar; _type: TCodecType): TCodecID; cdecl; external av__format; - procedure av_hex_dump (f: HFILE; buf: pchar; size: integer); cdecl; external av__format; - procedure av_pkt_dump(f: HFILE; pkt: pAVPacket; dump_payload: integer); cdecl; external av__format; - procedure av_register_all (); cdecl; external av__format; + filename: pchar; mime_type: pchar; _type: TCodecType): TCodecID; + cdecl; external av__format; + + procedure av_hex_dump (f: HFILE; buf: pchar; size: integer); + cdecl; external av__format; + procedure av_pkt_dump(f: HFILE; var pkt: TAVPacket; dump_payload: integer); (* CAT#2 *) + cdecl; external av__format; + + procedure av_register_all (); + cdecl; external av__format; (* media file input *) @@ -467,7 +525,7 @@ const function av_find_stream_info (ic: PAVFormatContext): integer; cdecl; external av__format; - function av_read_packet (s: PAVFormatContext; pkt: PAVPacket): integer; + function av_read_packet (s: PAVFormatContext; var pkt: TAVPacket): integer; (* CAT#2 *) cdecl; external av__format; (*** Return the next frame of a stream. * @@ -487,7 +545,7 @@ const * * @return 0 if OK, < 0 if error or end of file. *) - function av_read_frame (s: PAVFormatContext; pkt: PAVPacket): integer; + function av_read_frame (s: PAVFormatContext; var pkt: TAVPacket): integer; (* CAT#2 *) cdecl; external av__format; function av_seek_frame (s: PAVFormatContext; stream_index: integer; timestamp: int64; flags: integer): integer; cdecl; external av__format; @@ -530,11 +588,11 @@ const function av_write_header (s: PAVFormatContext): integer; cdecl; external av__format; - function av_write_frame(s: PAVFormatContext; pkt: PAVPacket): integer; - cdecl; external av__format; + function av_write_frame(s: PAVFormatContext; var pkt: TAVPacket): integer; + cdecl; external av__format; (* CAT#2 *) - function av_interleaved_write_frame (s: PAVFormatContext; pkt: PAVPacket): integer; - cdecl; external av__format; + function av_interleaved_write_frame (s: PAVFormatContext; var pkt: TAVPacket): integer; + cdecl; external av__format; (* CAT#2 *) function av_interleave_packet_per_dts(s: PAVFormatContext; _out: PAVPacket; pkt: PAVPacket; flush: integer): integer; @@ -559,7 +617,6 @@ const const FFM_PACKET_SIZE = 4096; - {$IFNDEF FPC} function ffm_read_write_index (fd: integer): int64; cdecl; external av__format; @@ -568,23 +625,20 @@ const procedure ffm_set_write_index (s: PAVFormatContext; pos: int64; file_size: int64); cdecl; external av__format; - {$ENDIF} - + function find_info_tag (arg: pchar; arg_size: integer; tag1: pchar; info: pchar): integer; cdecl; external av__format; - {$IFNDEF FPC} function get_frame_filename(buf: pchar; buf_size: integer; path: pchar; number: integer): integer; cdecl; external av__format; - function filename_number_test (filename: pchar): integer; cdecl; external av__format; + (* grab specific *) function video_grab_init (): integer; cdecl; external av__format; - function audio_init (): integer; cdecl; external av__format; @@ -593,7 +647,6 @@ const cdecl; external av__format; function dc1394_init (): integer; cdecl; external av__format; - {$ENDIF} function strstart(str: pchar; val: pchar; ptr: PPointer): integer; cdecl; external av__format; @@ -610,21 +663,24 @@ const implementation -procedure av_init_packet (pkt: PAVPacket); +procedure av_init_packet (var pkt: TAVPacket); (* CAT#2 + bug fix *) begin - pkt.pts := AV_NOPTS_VALUE; - pkt.dts := AV_NOPTS_VALUE; - pkt.pos := -1; - pkt.duration := 0; - pkt.flags := 0; - pkt.stream_index := 0; - pkt.destruct := @av_destruct_packet_nofree; + with pkt do begin + pts := AV_NOPTS_VALUE; + dts := AV_NOPTS_VALUE; + pos := -1; + duration := 0; + flags := 0; + stream_index := 0; + destruct := @av_destruct_packet_nofree + end end; -procedure av_free_packet (pkt: PAVPacket); +procedure av_free_packet (var pkt: TAVPacket); (* CAT#2 *) begin - if (pkt <> nil) and (@pkt^.destruct <> nil) then - pkt^.destruct (pkt); + if @pkt.destruct <> nil then pkt.destruct (@pkt) +{ if (pkt <> nil) and (@pkt^.destruct <> nil) then + pkt^.destruct (pkt)} end; end. diff --git a/Game/Code/lib/ffmpeg/avio.pas b/Game/Code/lib/ffmpeg/avio.pas index 84622f0d..f1abea3e 100644 --- a/Game/Code/lib/ffmpeg/avio.pas +++ b/Game/Code/lib/ffmpeg/avio.pas @@ -16,21 +16,21 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) -unit avio; -interface +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + +unit avio; +{$MODE DELPHI } (* CAT *) +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) -{$IFDEF win32} -uses - windows; -{$ENDIF} +interface (* Widows unit is deleted by CAT *) const - {$IFDEF win32} - av__format = 'avformat-50.dll'; - {$ELSE} - av__format = 'libavformat.so'; // .0d - {$ENDIF} +(* version numbers are changed by The Creative CAT *) + av__format = 'libavformat.51'; URL_RDONLY = 0; URL_WRONLY = 1; @@ -230,14 +230,12 @@ type procedure init_checksum (s: PByteIOContext; update_checksum: pointer; checksum: cardinal); cdecl; external av__format; - {$IFNDEF FPC} function udp_set_remote_url(h: PURLContext; const uri: pchar): integer; cdecl; external av__format; function udp_get_local_port(h: PURLContext): integer; cdecl; external av__format; function udp_get_file_handle(h: PURLContext): integer; cdecl; external av__format; - {$ENDIF} implementation diff --git a/Game/Code/lib/ffmpeg/avutil.pas b/Game/Code/lib/ffmpeg/avutil.pas index 7c5926ab..5b5d6762 100644 --- a/Game/Code/lib/ffmpeg/avutil.pas +++ b/Game/Code/lib/ffmpeg/avutil.pas @@ -15,21 +15,23 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) unit avutil; +{$MODE DELPHI} +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) interface - const - {$IFDEF win32} - av__util = 'avutil-49.dll'; - {$ELSE} - av__util = 'libavutil.so'; // .0d - {$ENDIF} - - LIBAVUTIL_VERSION_INT = ((49 shl 16) + (0 shl 8) + 1); - LIBAVUTIL_VERSION = '49.0.1'; +(* version numbers are changed by The Creative CAT *) + av__util = 'libavutil.49'; + + LIBAVUTIL_VERSION_INT = ((49 shl 16) + (4 shl 8) + 1); + LIBAVUTIL_VERSION = '49.4.1'; LIBAVUTIL_BUILD = LIBAVUTIL_VERSION_INT; type diff --git a/Game/Code/lib/ffmpeg/opt.pas b/Game/Code/lib/ffmpeg/opt.pas index c8b72479..0acead1f 100644 --- a/Game/Code/lib/ffmpeg/opt.pas +++ b/Game/Code/lib/ffmpeg/opt.pas @@ -16,15 +16,19 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + unit opt; +{$MODE DELPHI} (* CAT *) +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) interface uses - {$IFDEF win32} - windows, - {$ENDIF} - rational; + rational; (* CAT *) type TAVOptionType = ( @@ -39,12 +43,9 @@ type ); const +(* version numbers are changed by The Creative CAT *) + av__codec = 'libavcodec.51'; - {$IFDEF win32} - av__codec = 'avcodec-51.dll'; - {$ELSE} - av__codec = 'avcodec.so'; // .0d - {$ENDIF} AV_OPT_FLAG_ENCODING_PARAM = 1; ///< a generic parameter which can be set by the user for muxing or encoding AV_OPT_FLAG_DECODING_PARAM = 2; ///< a generic parameter which can be set by the user for demuxing or decoding diff --git a/Game/Code/lib/ffmpeg/rational.pas b/Game/Code/lib/ffmpeg/rational.pas index 40d1f093..bd2cc94f 100644 --- a/Game/Code/lib/ffmpeg/rational.pas +++ b/Game/Code/lib/ffmpeg/rational.pas @@ -16,23 +16,20 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) -unit rational; +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) -interface +unit rational; +{$MODE DELPHI} (* CAT *) +{$PACKENUM 4} (* every enum type variables uses 4 bytes, CAT *) +{$PACKRECORDS C} (* GCC compatible, Record Packing, CAT *) -{$IFDEF win32} -uses - windows; -{$endif} +interface (* unit windows is deleted by CAT *) const - - {$IFDEF win32} - av__util = 'avutil-49.dll'; - {$ELSE} - av__util = 'libavutil.so'; // .0d - {$ENDIF} - +(* version numbers are changed by The Creative CAT *) + av__util = 'libavutil.49'; type @@ -82,10 +79,8 @@ var begin tmp := a.num * b.den - b.num * a.den; - if tmp = 0 then - Result := (tmp shr 63) or 1 - else - Result := 0; + if tmp <> 0 then Result := (tmp shr 63) or 1 (* fixed by CAT *) + else Result := 0 end; function av_q2d(a: TAVRational): double; |