aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2012-03-18 23:05:42 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2012-03-18 23:05:42 +0000
commitc4f46eeed8de14c51b38de296b5dccb9e183cb1a (patch)
treef8216bf6e97def3bd6fc9a73da08b41174d1567f
parent96a355913e633a41b6e9192b0791ffb47aecbe20 (diff)
downloadusdx-c4f46eeed8de14c51b38de296b5dccb9e183cb1a.tar.gz
usdx-c4f46eeed8de14c51b38de296b5dccb9e183cb1a.tar.xz
usdx-c4f46eeed8de14c51b38de296b5dccb9e183cb1a.zip
start version 0.7 of ffmpeg
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2841 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--src/lib/ffmpeg7/error.pas124
-rw-r--r--src/lib/ffmpeg7/mathematics.pas119
-rw-r--r--src/lib/ffmpeg7/rational.pas170
3 files changed, 413 insertions, 0 deletions
diff --git a/src/lib/ffmpeg7/error.pas b/src/lib/ffmpeg7/error.pas
new file mode 100644
index 00000000..382f40bf
--- /dev/null
+++ b/src/lib/ffmpeg7/error.pas
@@ -0,0 +1,124 @@
+(*
+ * 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
+ * avutil version 50.43.0
+ *
+ *)
+
+(**
+ * @file
+ * error code definitions
+ *)
+
+{* 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) - 1: positive EINVAL gives -1, negative 1
+ *)
+const
+ AVERROR_SIGN = (EINVAL shr 30) and $00000002 - 1;
+
+(*
+#if EDOM > 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_INVALIDDATA = AVERROR_SIGN * EINVAL; (**< Invalid data found when processing input *)
+ AVERROR_IO = AVERROR_SIGN * EIO; (**< I/O error *)
+ AVERROR_NOENT = AVERROR_SIGN * ENOENT; (**< No such file or directory. *)
+ AVERROR_NOFMT = AVERROR_SIGN * EILSEQ; (**< unknown format *)
+ AVERROR_NOMEM = AVERROR_SIGN * ENOMEM; (**< not enough memory *)
+ AVERROR_NOTSUPP = AVERROR_SIGN * ENOSYS; (**< Operation not supported. *)
+ AVERROR_NUMEXPECTED = AVERROR_SIGN * EDOM; (**< Number syntax expected in filename. *)
+ AVERROR_UNKNOWN = AVERROR_SIGN * EINVAL; (**< Unknown error *)
+
+ AVERROR_EOF = AVERROR_SIGN * EPIPE; (**< End of file. *)
+
+ // Note: function calls as constant-initializers are invalid
+ AVERROR_PATCHWELCOME = -(ord('P') or (ord('A') shl 8) or (ord('W') shl 16) or (ord('E') shl 24)); ///< Not yet implemented in Libav, patches welcome
+
+ AVERROR_BSF_NOT_FOUND = -(ord($F8) or (ord('B') shl 8) or (ord('S') shl 16) or (ord('F') shl 24)); ///< Bitstream filter not found
+ AVERROR_DECODER_NOT_FOUND = -(ord($F8) or (ord('D') shl 8) or (ord('E') shl 16) or (ord('C') shl 24)); ///< Decoder not found
+ AVERROR_DEMUXER_NOT_FOUND = -(ord($F8) or (ord('D') shl 8) or (ord('E') shl 16) or (ord('M') shl 24)); ///< Demuxer not found
+ AVERROR_ENCODER_NOT_FOUND = -(ord($F8) or (ord('E') shl 8) or (ord('N') shl 16) or (ord('C') shl 24)); ///< Encoder not found
+ AVERROR_EXIT = -(ord('E') or (ord('X') shl 8) or (ord('I') shl 16) or (ord('T') shl 24)); ///< Immediate exit was requested; the called function should not be restarted
+ AVERROR_FILTER_NOT_FOUND = -(ord($F8) or (ord('F') shl 8) or (ord('I') shl 16) or (ord('L') shl 24)); ///< Filter not found
+ AVERROR_MUXER_NOT_FOUND = -(ord($F8) or (ord('M') shl 8) or (ord('U') shl 16) or (ord('X') shl 24)); ///< Muxer not found
+ AVERROR_OPTION_NOT_FOUND = -(ord($F8) or (ord('O') shl 8) or (ord('P') shl 16) or (ord('T') shl 24)); ///< Option not found
+ AVERROR_PROTOCOL_NOT_FOUND = -(ord($F8) or (ord('P') shl 8) or (ord('R') shl 16) or (ord('O') shl 24)); ///< Protocol not found
+ AVERROR_STREAM_NOT_FOUND = -(ord($F8) or (ord('S') shl 8) or (ord('T') shl 16) or (ord('R') shl 24)); ///< Stream not found
+
+(*
+ * Put 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 errnum error code to describe
+ * @param errbuf buffer to which description is written
+ * @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: PAnsiChar; errbuf_size: size_t): cint;
+ cdecl; external av__util;
diff --git a/src/lib/ffmpeg7/mathematics.pas b/src/lib/ffmpeg7/mathematics.pas
new file mode 100644
index 00000000..20ee21c2
--- /dev/null
+++ b/src/lib/ffmpeg7/mathematics.pas
@@ -0,0 +1,119 @@
+(*
+ * 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.
+ * - Changes and updates by the UltraStar Deluxe Team
+ *
+ * Conversion of libavutil/mathematics.h
+ * avutil version 50.43.0
+ *
+ *)
+
+unit mathematics;
+
+{$IFDEF FPC}
+ {$MODE DELPHI }
+ {$PACKENUM 4} (* use 4-byte enums *)
+ {$PACKRECORDS C} (* C/C++-compatible record packing *)
+{$ELSE}
+ {$MINENUMSIZE 4} (* use 4-byte enums *)
+{$ENDIF}
+
+interface
+
+uses
+ ctypes,
+ rational,
+ UConfig;
+
+const
+ M_E = 2.7182818284590452354; // e
+ M_LN2 = 0.69314718055994530942; // log_e 2
+ M_LN10 = 2.30258509299404568402; // log_e 10
+ M_LOG2_10 = 3.32192809488736234787; // log_2 10
+ M_PHI = 1.61803398874989484820; // phi / golden ratio
+ M_PI = 3.14159265358979323846; // pi
+ M_SQRT1_2 = 0.70710678118654752440; // 1/sqrt(2)
+ M_SQRT2 = 1.41421356237309504880; // sqrt(2)
+ NAN = 0.0/0.0;
+ INFINITY = 1.0/0.0;
+
+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.
+ );
+
+(**
+ * Return 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}
+
+(**
+ * Rescale a 64-bit integer with rounding to nearest.
+ * A simple a*b/c isn't possible as it can overflow.
+ *)
+function av_rescale (a, b, c: cint64): cint64;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Rescale a 64-bit integer with specified rounding.
+ * A simple a*b/c isn't possible as it can overflow.
+ *)
+function av_rescale_rnd (a, b, c: cint64; enum: TAVRounding): cint64;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Rescale a 64-bit integer by 2 rational numbers.
+ *)
+function av_rescale_q (a: cint64; bq, cq: TAVRational): cint64;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Compare 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;
+
+(**
+ * Compare 2 integers modulo mod.
+ * That is we compare integers a and b for which only the least
+ * significant log2(mod) bits are known.
+ *
+ * @param mod must be a power of 2
+ * @return a negative value if a is smaller than b
+ * a positiv value if a is greater than b
+ * 0 if a equals b
+ *)
+function av_compare_mod(a: cuint64; b: cuint64; modVar: cuint64): cint64;
+ cdecl; external av__util;
+
+implementation
+
+end.
diff --git a/src/lib/ffmpeg7/rational.pas b/src/lib/ffmpeg7/rational.pas
new file mode 100644
index 00000000..45ca8b87
--- /dev/null
+++ b/src/lib/ffmpeg7/rational.pas
@@ -0,0 +1,170 @@
+(*
+ * rational numbers
+ * Copyright (c) 2003 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.
+ * - Changes and updates by the UltraStar Deluxe Team
+ *
+ * Conversion of libavutil/rational.h
+ * avutil version 50.43.0
+ *
+ *)
+
+unit rational;
+
+{$IFDEF FPC}
+ {$MODE DELPHI}
+ {$PACKENUM 4} (* use 4-byte enums *)
+ {$PACKRECORDS C} (* C/C++-compatible record packing *)
+{$ELSE}
+ {$MINENUMSIZE 4} (* use 4-byte enums *)
+{$ENDIF}
+
+{$I switches.inc}
+
+interface
+
+uses
+ ctypes,
+ UConfig;
+
+type
+ (*
+ * rational number numerator/denominator
+ *)
+ PAVRational = ^TAVRational;
+ TAVRational = record
+ num: cint; ///< numerator
+ den: cint; ///< denominator
+ end;
+
+ TAVRationalArray = array[0 .. (MaxInt div SizeOf(TAVRational))-1] of TAVRational;
+ PAVRationalArray = ^TAVRationalArray;
+
+(**
+ * Compare two rationals.
+ * @param a first rational
+ * @param b second rational
+ * @return 0 if a==b, 1 if a>b and -1 if a<b
+ *)
+function av_cmp_q(a: TAVRational; b: TAVRational): cint; {$IFDEF HasInline}inline;{$ENDIF}
+
+(**
+ * Convert rational to double.
+ * @param a rational to convert
+ * @return (double) a
+ *)
+function av_q2d(a: TAVRational): cdouble; {$IFDEF HasInline}inline;{$ENDIF}
+
+(**
+ * Reduce a fraction.
+ * This is useful for framerate calculations.
+ * @param dst_num destination numerator
+ * @param dst_den destination denominator
+ * @param num source numerator
+ * @param den source denominator
+ * @param max the maximum allowed for dst_num & dst_den
+ * @return 1 if exact, 0 otherwise
+ *)
+function av_reduce(dst_num: PCint; dst_den: PCint; num: cint64; den: cint64; max: cint64): cint;
+ cdecl; external av__util;
+
+(**
+ * Multiply two rationals.
+ * @param b first rational
+ * @param c second rational
+ * @return b*c
+ *)
+function av_mul_q(b: TAVRational; c: TAVRational): TAVRational;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Divide one rational by another.
+ * @param b first rational
+ * @param c second rational
+ * @return b/c
+ *)
+function av_div_q(b: TAVRational; c: TAVRational): TAVRational;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Add two rationals.
+ * @param b first rational
+ * @param c second rational
+ * @return b+c
+ *)
+function av_add_q(b: TAVRational; c: TAVRational): TAVRational;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Subtract one rational from another.
+ * @param b first rational
+ * @param c second rational
+ * @return b-c
+ *)
+function av_sub_q(b: TAVRational; c: TAVRational): TAVRational;
+ cdecl; external av__util; {av_const}
+
+(**
+ * Convert a double precision floating point number to a rational.
+ * inf is expressed as {1,0} or {-1,0} depending on the sign.
+ *
+ * @param d double to convert
+ * @param max the maximum allowed numerator and denominator
+ * @return (AVRational) d
+ *)
+function av_d2q(d: cdouble; max: cint): TAVRational;
+ cdecl; external av__util; {av_const}
+
+(**
+ * @return 1 if q1 is nearer to q than q2, -1 if q2 is nearer
+ * than q1, 0 if they have the same distance.
+ *)
+function av_nearer_q(q, q1, q2: TAVRational): cint;
+ cdecl; external av__util;
+
+(**
+ * Find the nearest value in q_list to q.
+ * @param q_list an array of rationals terminated by {0, 0}
+ * @return the index of the nearest value found in the array
+ *)
+function av_find_nearest_q_idx(q: TAVRational; q_list: {const} PAVRationalArray): cint;
+ cdecl; external av__util;
+
+implementation
+
+function av_cmp_q (a: TAVRational; b: TAVRational): cint;
+var
+ tmp: cint64;
+begin
+ tmp := a.num * cint64(b.den) - b.num * cint64(a.den);
+
+ if (tmp <> 0) then
+ Result := (tmp shr 63) or 1
+ else
+ Result := 0
+end;
+
+function av_q2d(a: TAVRational): cdouble;
+begin
+ Result := a.num / a.den;
+end;
+
+end.