[FFmpeg-devel] [RFC UNTESTED PATCH] Add IA-64 assembly byteswapping functions.
Diego 'Flameeyes' Pettenò
flameeyes
Thu Oct 23 03:11:10 CEST 2008
This *totally untested* patch copies over the IA-64 optimised
byteswapping code that is currently in glib 2.18.
_This patch is not meant to be reviewed for merging yet_. Since I,
obviously, don't have an IA-64 at home to even try to see if this
builds, I have also no interest in getting this merged for now.
The reason why I wrote and I'm sending this patch is that first of all
it is better for it to stay in the ML archives rather than my HD (I
guess Roundap would be an option too) and that I have also proposed
glib guys to take the ARM/SH4/BFIN optimised byteswapping from
libavutil (since they don't have anything beside x86, x86-64 and
IA-64), so it made sense to propose the other way around too.
If somebody has an IA-64 and wants to try this out, s/he may also pick
up the patch as proposal.
---
libavutil/bswap.h | 2 +
libavutil/ia64/bswap.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 0 deletions(-)
create mode 100644 libavutil/ia64/bswap.h
diff --git a/libavutil/bswap.h b/libavutil/bswap.h
index c14676e..1393731 100644
--- a/libavutil/bswap.h
+++ b/libavutil/bswap.h
@@ -38,6 +38,8 @@
# include "sh4/bswap.h"
#elif defined(ARCH_X86)
# include "x86/bswap.h"
+#elif defined(ARCH_IA64)
+# include "ia64/bswap.h"
#endif
#ifndef bswap_16
diff --git a/libavutil/ia64/bswap.h b/libavutil/ia64/bswap.h
new file mode 100644
index 0000000..54af702
--- /dev/null
+++ b/libavutil/ia64/bswap.h
@@ -0,0 +1,75 @@
+/*
+ * IA-64 byteswapping assembly taken from glib:
+ *
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * Modified by the GLib Team and others 1997-2000. See glib's AUTHORS
+ * file for a list of people on the GLib Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ *
+ *
+ *
+ * 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
+ */
+
+/**
+ * @file bswap.h
+ * IA-64 assembly byte swapping routines
+ */
+
+#ifndef AVUTIL_IA64_BSWAP_H
+#define AVUTIL_IA64_BSWAP_H
+
+#include <stdint.h>
+#include "config.h"
+#include "libavutil/common.h"
+
+#define bswap_16 bswap_16
+static av_always_inline av_const uint16_t bswap_16(uint16_t x)
+{
+ uint16_t __v;
+ __asm__ __volatile__ ("shl %0 = %1, 48 ;;"
+ "mux1 %0 = %0, @rev ;;"
+ : "=r" (__v)
+ : "r" (x));
+
+ return x;
+}
+
+#define bswap_32 bswap_32
+static av_always_inline av_const uint32_t bswap_32(uint32_t x)
+{
+ uint32_t __v;
+ __asm__ __volatile__ ("shl %0 = %1, 32 ;;"
+ "mux1 %0 = %0, @rev ;;"
+ : "=r" (__v)
+ : "r" (x));
+ return x;
+}
+
+#define bswap_64 bswap_64
+static inline uint64_t av_const bswap_64(uint64_t x)
+{
+ uint64_t __v;
+ __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;"
+ : "=r" (__v)
+ : "r" (x));
+ return x;
+}
+
+#endif /* AVUTIL_IA64_BSWAP_H */
More information about the ffmpeg-devel
mailing list