diff options
author | FlyingRat <flyingrat@outlook.com> | 2013-04-07 16:36:04 +0200 |
---|---|---|
committer | FlyingRat <flyingrat@outlook.com> | 2013-04-07 16:36:04 +0200 |
commit | 0e63a815aa6af63a21848e04b683d3f506dd41b1 (patch) | |
tree | 002f61d8a5b1d294d99fd4ba5b6982d76a612f0c /lib/ffmpeg/compat | |
parent | 71862137c5337fc678681a23bfbc65f4db7a7b2f (diff) |
[FFmpeg] version bump to n1.2 (rev e820e3a) - lib/ffmpeg
This commit now contains the original patches sub directory:
patches - Org dir that contains applied xbmc custom patches.
patches/README-patches - New README file with info about xbmc patches.
patches/obsolete-patches - New dir with obsolete xbmc patches.
Diffstat (limited to 'lib/ffmpeg/compat')
-rw-r--r-- | lib/ffmpeg/compat/getopt.c | 86 | ||||
-rw-r--r-- | lib/ffmpeg/compat/msvcrt/snprintf.c | 71 | ||||
-rw-r--r-- | lib/ffmpeg/compat/msvcrt/snprintf.h | 38 | ||||
-rwxr-xr-x | lib/ffmpeg/compat/plan9/head | 10 | ||||
-rw-r--r-- | lib/ffmpeg/compat/plan9/main.c | 34 | ||||
-rwxr-xr-x | lib/ffmpeg/compat/plan9/printf | 2 | ||||
-rw-r--r-- | lib/ffmpeg/compat/strtod.c | 93 | ||||
-rw-r--r-- | lib/ffmpeg/compat/tms470/math.h | 7 | ||||
-rw-r--r-- | lib/ffmpeg/compat/va_copy.h | 26 |
9 files changed, 367 insertions, 0 deletions
diff --git a/lib/ffmpeg/compat/getopt.c b/lib/ffmpeg/compat/getopt.c new file mode 100644 index 0000000000..dd082ea2e6 --- /dev/null +++ b/lib/ffmpeg/compat/getopt.c @@ -0,0 +1,86 @@ +/* + * 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 file was copied from the following newsgroup posting: + * + * Newsgroups: mod.std.unix + * Subject: public domain AT&T getopt source + * Date: 3 Nov 85 19:34:15 GMT + * + * Here's something you've all been waiting for: the AT&T public domain + * source for getopt(3). It is the code which was given out at the 1985 + * UNIFORUM conference in Dallas. I obtained it by electronic mail + * directly from AT&T. The people there assure me that it is indeed + * in the public domain. + */ + +#include <stdio.h> +#include <string.h> + +static int opterr = 1; +static int optind = 1; +static int optopt; +static char *optarg; + +#undef fprintf + +static int getopt(int argc, char *argv[], char *opts) +{ + static int sp = 1; + int c; + char *cp; + + if (sp == 1) { + if (optind >= argc || + argv[optind][0] != '-' || argv[optind][1] == '\0') + return EOF; + else if (!strcmp(argv[optind], "--")) { + optind++; + return EOF; + } + } + optopt = c = argv[optind][sp]; + if (c == ':' || (cp = strchr(opts, c)) == NULL) { + fprintf(stderr, ": illegal option -- %c\n", c); + if (argv[optind][++sp] == '\0') { + optind++; + sp = 1; + } + return '?'; + } + if (*++cp == ':') { + if (argv[optind][sp+1] != '\0') + optarg = &argv[optind++][sp+1]; + else if(++optind >= argc) { + fprintf(stderr, ": option requires an argument -- %c\n", c); + sp = 1; + return '?'; + } else + optarg = argv[optind++]; + sp = 1; + } else { + if (argv[optind][++sp] == '\0') { + sp = 1; + optind++; + } + optarg = NULL; + } + + return c; +} diff --git a/lib/ffmpeg/compat/msvcrt/snprintf.c b/lib/ffmpeg/compat/msvcrt/snprintf.c new file mode 100644 index 0000000000..c64653fe82 --- /dev/null +++ b/lib/ffmpeg/compat/msvcrt/snprintf.c @@ -0,0 +1,71 @@ +/* + * C99-compatible snprintf() and vsnprintf() implementations + * Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.com> + * + * 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 + */ + +#include <stdio.h> +#include <stdarg.h> +#include <limits.h> +#include <string.h> + +#include "compat/va_copy.h" +#include "libavutil/error.h" + +#if defined(__MINGW32__) +#define EOVERFLOW EFBIG +#endif + +int avpriv_snprintf(char *s, size_t n, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret = avpriv_vsnprintf(s, n, fmt, ap); + va_end(ap); + + return ret; +} + +int avpriv_vsnprintf(char *s, size_t n, const char *fmt, + va_list ap) +{ + int ret; + va_list ap_copy; + + if (n == 0) + return _vscprintf(fmt, ap); + else if (n > INT_MAX) + return AVERROR(EOVERFLOW); + + /* we use n - 1 here because if the buffer is not big enough, the MS + * runtime libraries don't add a terminating zero at the end. MSDN + * recommends to provide _snprintf/_vsnprintf() a buffer size that + * is one less than the actual buffer, and zero it before calling + * _snprintf/_vsnprintf() to workaround this problem. + * See http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */ + memset(s, 0, n); + va_copy(ap_copy, ap); + ret = _vsnprintf(s, n - 1, fmt, ap_copy); + va_end(ap_copy); + if (ret == -1) + ret = _vscprintf(fmt, ap); + + return ret; +} diff --git a/lib/ffmpeg/compat/msvcrt/snprintf.h b/lib/ffmpeg/compat/msvcrt/snprintf.h new file mode 100644 index 0000000000..f02113c5a2 --- /dev/null +++ b/lib/ffmpeg/compat/msvcrt/snprintf.h @@ -0,0 +1,38 @@ +/* + * C99-compatible snprintf() and vsnprintf() implementations + * Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.com> + * + * 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 + */ + +#ifndef COMPAT_SNPRINTF_H +#define COMPAT_SNPRINTF_H + +#include <stdarg.h> +#include <stdio.h> + +int avpriv_snprintf(char *s, size_t n, const char *fmt, ...); +int avpriv_vsnprintf(char *s, size_t n, const char *fmt, va_list ap); + +#undef snprintf +#undef _snprintf +#undef vsnprintf +#define snprintf avpriv_snprintf +#define _snprintf avpriv_snprintf +#define vsnprintf avpriv_vsnprintf + +#endif /* COMPAT_SNPRINTF_H */ diff --git a/lib/ffmpeg/compat/plan9/head b/lib/ffmpeg/compat/plan9/head new file mode 100755 index 0000000000..2840b2d50f --- /dev/null +++ b/lib/ffmpeg/compat/plan9/head @@ -0,0 +1,10 @@ +#!/bin/sh + +n=10 + +case "$1" in + -n) n=$2; shift 2 ;; + -n*) n=${1#-n}; shift ;; +esac + +exec sed ${n}q "$@" diff --git a/lib/ffmpeg/compat/plan9/main.c b/lib/ffmpeg/compat/plan9/main.c new file mode 100644 index 0000000000..d46f96d170 --- /dev/null +++ b/lib/ffmpeg/compat/plan9/main.c @@ -0,0 +1,34 @@ +/* + * 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 + */ + +int plan9_main(int argc, char **argv); + +#undef main +int main(int argc, char **argv) +{ + /* The setfcr() function in lib9 is broken, must use asm. */ +#ifdef __i386 + short fcr; + __asm__ volatile ("fstcw %0 \n" + "or $63, %0 \n" + "fldcw %0 \n" + : "=m"(fcr)); +#endif + + return plan9_main(argc, argv); +} diff --git a/lib/ffmpeg/compat/plan9/printf b/lib/ffmpeg/compat/plan9/printf new file mode 100755 index 0000000000..1a70a9e91a --- /dev/null +++ b/lib/ffmpeg/compat/plan9/printf @@ -0,0 +1,2 @@ +#!/bin/sh +exec awk "BEGIN { for (i = 2; i < ARGC; i++) printf \"$1\", ARGV[i] }" "$@" diff --git a/lib/ffmpeg/compat/strtod.c b/lib/ffmpeg/compat/strtod.c new file mode 100644 index 0000000000..3a9452eac2 --- /dev/null +++ b/lib/ffmpeg/compat/strtod.c @@ -0,0 +1,93 @@ +/* + * C99-compatible strtod() implementation + * Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.com> + * + * 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 + */ + +#include <limits.h> +#include <stdlib.h> + +#include "libavutil/avstring.h" +#include "libavutil/mathematics.h" + +static char *check_nan_suffix(char *s) +{ + char *start = s; + + if (*s++ != '(') + return start; + + while ((*s >= 'a' && *s <= 'z') || (*s >= 'A' && *s <= 'Z') || + (*s >= '0' && *s <= '9') || *s == '_') + s++; + + return *s == ')' ? s + 1 : start; +} + +#undef strtod +double strtod(const char *, char **); + +double avpriv_strtod(const char *nptr, char **endptr) +{ + char *end; + double res; + + /* Skip leading spaces */ + while (av_isspace(*nptr)) + nptr++; + + if (!av_strncasecmp(nptr, "infinity", 8)) { + end = nptr + 8; + res = INFINITY; + } else if (!av_strncasecmp(nptr, "inf", 3)) { + end = nptr + 3; + res = INFINITY; + } else if (!av_strncasecmp(nptr, "+infinity", 9)) { + end = nptr + 9; + res = INFINITY; + } else if (!av_strncasecmp(nptr, "+inf", 4)) { + end = nptr + 4; + res = INFINITY; + } else if (!av_strncasecmp(nptr, "-infinity", 9)) { + end = nptr + 9; + res = -INFINITY; + } else if (!av_strncasecmp(nptr, "-inf", 4)) { + end = nptr + 4; + res = -INFINITY; + } else if (!av_strncasecmp(nptr, "nan", 3)) { + end = check_nan_suffix(nptr + 3); + res = NAN; + } else if (!av_strncasecmp(nptr, "+nan", 4) || + !av_strncasecmp(nptr, "-nan", 4)) { + end = check_nan_suffix(nptr + 4); + res = NAN; + } else if (!av_strncasecmp(nptr, "0x", 2) || + !av_strncasecmp(nptr, "-0x", 3) || + !av_strncasecmp(nptr, "+0x", 3)) { + /* FIXME this doesn't handle exponents, non-integers (float/double) + * and numbers too large for long long */ + res = strtoll(nptr, &end, 16); + } else { + res = strtod(nptr, &end); + } + + if (endptr) + *endptr = end; + + return res; +} diff --git a/lib/ffmpeg/compat/tms470/math.h b/lib/ffmpeg/compat/tms470/math.h new file mode 100644 index 0000000000..1104d744e7 --- /dev/null +++ b/lib/ffmpeg/compat/tms470/math.h @@ -0,0 +1,7 @@ +#include_next <math.h> + +#undef INFINITY +#undef NAN + +#define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 })) +#define NAN (*(const float*)((const unsigned []){ 0x7fc00000 })) diff --git a/lib/ffmpeg/compat/va_copy.h b/lib/ffmpeg/compat/va_copy.h new file mode 100644 index 0000000000..f894771949 --- /dev/null +++ b/lib/ffmpeg/compat/va_copy.h @@ -0,0 +1,26 @@ +/* + * MSVC Compatible va_copy macro + * Copyright (c) 2012 Derek Buitenhuis + * + * 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 + */ + +#include <stdarg.h> + +#if !defined(va_copy) && defined(_MSC_VER) +#define va_copy(dst, src) ((dst) = (src)) +#endif |