Browse code

Split libavutil/timer.h per architecture

Originally committed as revision 18304 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2009/04/02 07:56:22
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,41 @@
0
+/*
1
+ * Copyright (C) 2007 Marc Hoffman
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * FFmpeg is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#ifndef AVUTIL_BFIN_TIMER_H
21
+#define AVUTIL_BFIN_TIMER_H
22
+
23
+#include <stdint.h>
24
+
25
+#define AV_READ_TIME read_time
26
+
27
+static inline uint64_t read_time(void)
28
+{
29
+    union {
30
+        struct {
31
+            unsigned lo;
32
+            unsigned hi;
33
+        } p;
34
+        unsigned long long c;
35
+    } t;
36
+    __asm__ volatile ("%0=cycles; %1=cycles2;" : "=d" (t.p.lo), "=d" (t.p.hi));
37
+    return t.c;
38
+}
39
+
40
+#endif /* AVUTIL_BFIN_TIMER_H */
0 41
new file mode 100644
... ...
@@ -0,0 +1,47 @@
0
+/*
1
+ * Copyright (c) 2005 Luca Barbato <lu_zero@gentoo.org>
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * FFmpeg is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#ifndef AVUTIL_PPC_TIMER_H
21
+#define AVUTIL_PPC_TIMER_H
22
+
23
+#include <stdint.h>
24
+
25
+#define AV_READ_TIME read_time
26
+
27
+static inline uint64_t read_time(void)
28
+{
29
+    uint32_t tbu, tbl, temp;
30
+
31
+     /* from section 2.2.1 of the 32-bit PowerPC PEM */
32
+     __asm__ volatile(
33
+         "1:\n"
34
+         "mftbu  %2\n"
35
+         "mftb   %0\n"
36
+         "mftbu  %1\n"
37
+         "cmpw   %2,%1\n"
38
+         "bne    1b\n"
39
+     : "=r"(tbl), "=r"(tbu), "=r"(temp)
40
+     :
41
+     : "cc");
42
+
43
+     return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
44
+}
45
+
46
+#endif /* AVUTIL_PPC_TIMER_H */
... ...
@@ -28,51 +28,16 @@
28 28
 #include <stdint.h>
29 29
 #include "config.h"
30 30
 
31
-#if ARCH_X86 || ARCH_PPC || ARCH_BFIN
32
-#define AV_READ_TIME read_time
33
-#if ARCH_X86
34
-static inline uint64_t read_time(void)
35
-{
36
-    uint32_t a, d;
37
-    __asm__ volatile("rdtsc\n\t"
38
-                 : "=a" (a), "=d" (d));
39
-    return ((uint64_t)d << 32) + a;
40
-}
41
-#elif ARCH_BFIN
42
-static inline uint64_t read_time(void)
43
-{
44
-    union {
45
-        struct {
46
-            unsigned lo;
47
-            unsigned hi;
48
-        } p;
49
-        unsigned long long c;
50
-    } t;
51
-    __asm__ volatile ("%0=cycles; %1=cycles2;" : "=d" (t.p.lo), "=d" (t.p.hi));
52
-    return t.c;
53
-}
54
-#else //FIXME check ppc64
55
-static inline uint64_t read_time(void)
56
-{
57
-    uint32_t tbu, tbl, temp;
58
-
59
-     /* from section 2.2.1 of the 32-bit PowerPC PEM */
60
-     __asm__ volatile(
61
-         "1:\n"
62
-         "mftbu  %2\n"
63
-         "mftb   %0\n"
64
-         "mftbu  %1\n"
65
-         "cmpw   %2,%1\n"
66
-         "bne    1b\n"
67
-     : "=r"(tbl), "=r"(tbu), "=r"(temp)
68
-     :
69
-     : "cc");
70
-
71
-     return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
72
-}
31
+#if   ARCH_BFIN
32
+#   include "bfin/timer.h"
33
+#elif ARCH_PPC
34
+#   include "ppc/timer.h"
35
+#elif ARCH_X86
36
+#   include "x86/timer.h"
73 37
 #endif
74
-#elif HAVE_GETHRTIME
75
-#define AV_READ_TIME gethrtime
38
+
39
+#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
40
+#   define AV_READ_TIME gethrtime
76 41
 #endif
77 42
 
78 43
 #ifdef AV_READ_TIME
79 44
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+/*
1
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * FFmpeg is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#ifndef AVUTIL_X86_TIMER_H
21
+#define AVUTIL_X86_TIMER_H
22
+
23
+#include <stdint.h>
24
+
25
+#define AV_READ_TIME read_time
26
+
27
+static inline uint64_t read_time(void)
28
+{
29
+    uint32_t a, d;
30
+    __asm__ volatile("rdtsc" : "=a" (a), "=d" (d));
31
+    return ((uint64_t)d << 32) + a;
32
+}
33
+
34
+#endif /* AVUTIL_X86_TIMER_H */