diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-06-20 20:47:46 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-06-20 20:47:46 +0200 |
commit | 4da42ebe4486f2960d64135395b1a9ef705d9429 (patch) | |
tree | 5e405819aa070d6313851ea324ffaf475523d02f /libavutil | |
parent | e632a430fe03dace7380c11e2bd62ea418e63abc (diff) | |
parent | 005c80b645cc6ab5f30cbc3e10ab66a15dfd107e (diff) | |
download | ffmpeg-4da42ebe4486f2960d64135395b1a9ef705d9429.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
MS Screen 1 decoder
aacdec: Fix popping channel layouts.
av_gettime: support Win32 without gettimeofday()
Use av_gettime() in various places
Move av_gettime() to libavutil
dct-test: use emms_c() from libavutil instead of duplicating it
mov: fix operator precedence bug
mathematics.h: remove a couple of math defines
Remove unnecessary inclusions of [sys/]time.h
lavf: remove unnecessary inclusions of unistd.h
bfin: libswscale: add const where appropriate to fix warnings
bfin: libswscale: remove unnecessary #includes
udp: Properly check for invalid sockets
tcp: Check the return value from getsockopt
network: Use av_strerror for getting error messages
udp: Properly print error from getnameinfo
mmst: Use AVUNERROR() to convert error codes to the right range for strerror
network: Pass pointers of the right type to get/setsockopt/ioctlsocket on windows
rtmp: Reduce the number of idle posts sent by sleeping 50ms
Conflicts:
Changelog
configure
libavcodec/aacdec.c
libavcodec/allcodecs.c
libavcodec/avcodec.h
libavcodec/dct-test.c
libavcodec/version.h
libavformat/riff.c
libavformat/udp.c
libavutil/Makefile
libswscale/bfin/yuv2rgb_bfin.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/Makefile | 2 | ||||
-rw-r--r-- | libavutil/des.c | 6 | ||||
-rw-r--r-- | libavutil/mathematics.h | 18 | ||||
-rw-r--r-- | libavutil/parseutils.c | 1 | ||||
-rw-r--r-- | libavutil/time.c | 46 | ||||
-rw-r--r-- | libavutil/time.h | 29 |
6 files changed, 79 insertions, 23 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile index 3dfe2fd29e..4a9eb807a5 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -39,6 +39,7 @@ HEADERS = adler32.h \ rational.h \ samplefmt.h \ sha.h \ + time.h \ timecode.h \ timestamp.h \ @@ -83,6 +84,7 @@ OBJS = adler32.o \ rc4.o \ samplefmt.o \ sha.o \ + time.o \ timecode.o \ tree.o \ utils.o \ diff --git a/libavutil/des.c b/libavutil/des.c index 4598f324bc..63eb7f52b5 100644 --- a/libavutil/des.c +++ b/libavutil/des.c @@ -343,7 +343,7 @@ void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) { #undef srand #include <stdlib.h> #include <stdio.h> -#include <sys/time.h> +#include "libavutil/time.h" static uint64_t rand64(void) { uint64_t r = rand(); r = (r << 32) | rand(); @@ -390,13 +390,11 @@ int main(void) { #ifdef GENTABLES int j; #endif - struct timeval tv; uint64_t key[3]; uint64_t data; uint64_t ct; uint64_t roundkeys[16]; - gettimeofday(&tv, NULL); - srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec); + srand(av_gettime()); key[0] = AV_RB64(test_key); data = AV_RB64(plain); gen_roundkeys(roundkeys, key[0]); diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h index 93314bae16..844747eeb2 100644 --- a/libavutil/mathematics.h +++ b/libavutil/mathematics.h @@ -26,30 +26,12 @@ #include "attributes.h" #include "rational.h" -#ifndef M_E -#define M_E 2.7182818284590452354 /* e */ -#endif -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 /* log_e 2 */ -#endif -#ifndef M_LN10 -#define M_LN10 2.30258509299404568402 /* log_e 10 */ -#endif #ifndef M_LOG2_10 #define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ #endif #ifndef M_PHI #define M_PHI 1.61803398874989484820 /* phi / golden ratio */ #endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ -#endif #ifndef NAN #define NAN (0.0/0.0) #endif diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 66c31e1e88..77ff888b81 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -21,7 +21,6 @@ * misc parsing utilities */ -#include <sys/time.h> #include <time.h> #include "avstring.h" diff --git a/libavutil/time.c b/libavutil/time.c new file mode 100644 index 0000000000..80c4029d9b --- /dev/null +++ b/libavutil/time.c @@ -0,0 +1,46 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include <stddef.h> +#include <stdint.h> +#if HAVE_GETTIMEOFDAY +#include <sys/time.h> +#elif HAVE_GETSYSTEMTIMEASFILETIME +#include <windows.h> +#endif + +#include "libavutil/time.h" + +int64_t av_gettime(void) +{ +#if HAVE_GETTIMEOFDAY + struct timeval tv; + gettimeofday(&tv, NULL); + return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; +#elif HAVE_GETSYSTEMTIMEASFILETIME + FILETIME ft; + int64_t t; + GetSystemTimeAsFileTime(&ft); + t = (int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime; + return t / 10 - 11644473600000000; /* Jan 1, 1601 */ +#else + return -1; +#endif +} diff --git a/libavutil/time.h b/libavutil/time.h new file mode 100644 index 0000000000..2ee7e08caf --- /dev/null +++ b/libavutil/time.h @@ -0,0 +1,29 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TIME_H +#define AVUTIL_TIME_H + +#include <stdint.h> + +/** + * Get the current time in microseconds. + */ +int64_t av_gettime(void); + +#endif /* AVUTIL_TIME_H */ |