}
# define _GST_FAST_READ(s, d) __gst_fast_read##s((const guint8 *)(d))
# define _GST_FAST_READ_SWAP(s, d) __gst_fast_read_swap##s((const guint8 *)(d))
+
+static inline void __gst_fast_write16 (guint8 *p, guint16 v) {
+ *(guint16*)(void*)(p) = v;
+}
+static inline void __gst_fast_write32 (guint8 *p, guint32 v) {
+ *(guint32*)(void*)(p) = v;
+}
+static inline void __gst_fast_write64 (guint8 *p, guint64 v) {
+ *(guint64*)(void*)(p) = v;
+}
+static inline void __gst_fast_write_swap16 (guint8 *p, guint16 v) {
+ *(guint16*)(void*)(p) = GUINT16_SWAP_LE_BE (v);
+}
+static inline void __gst_fast_write_swap32 (guint8 *p, guint32 v) {
+ *(guint32*)(void*)(p) = GUINT32_SWAP_LE_BE (v);
+}
+static inline void __gst_fast_write_swap64 (guint8 *p, guint64 v) {
+ *(guint64*)(void*)(p) = GUINT64_SWAP_LE_BE (v);
+}
+# define _GST_FAST_WRITE(s, d, v) __gst_fast_write##s((guint8 *)(d), (v))
+# define _GST_FAST_WRITE_SWAP(s, d, v) __gst_fast_write_swap##s((guint8 *)(d), (v))
#endif
#endif
*
* Store a 64 bit unsigned integer value in big endian format into the memory buffer.
*/
+/**
+ * GST_WRITE_UINT64_LE:
+ * @data: memory location
+ * @num: value to store
+ *
+ * Store a 64 bit unsigned integer value in little endian format into the memory buffer.
+ */
+#if GST_HAVE_UNALIGNED_ACCESS
+# if (G_BYTE_ORDER == G_BIG_ENDIAN)
+# define GST_WRITE_UINT64_BE(data,val) _GST_FAST_WRITE(64,data,val)
+# define GST_WRITE_UINT64_LE(data,val) _GST_FAST_WRITE_SWAP(64,data,val)
+# else
+# define GST_WRITE_UINT64_BE(data,val) _GST_FAST_WRITE_SWAP(64,data,val)
+# define GST_WRITE_UINT64_LE(data,val) _GST_FAST_WRITE(64,data,val)
+# endif
+#else
#define GST_WRITE_UINT64_BE(data, num) do { \
gpointer __put_data = data; \
_GST_PUT (__put_data, 0, 64, 56, num); \
_GST_PUT (__put_data, 7, 64, 0, num); \
} while (0)
-/**
- * GST_WRITE_UINT64_LE:
- * @data: memory location
- * @num: value to store
- *
- * Store a 64 bit unsigned integer value in little endian format into the memory buffer.
- */
#define GST_WRITE_UINT64_LE(data, num) do { \
gpointer __put_data = data; \
_GST_PUT (__put_data, 0, 64, 0, num); \
_GST_PUT (__put_data, 6, 64, 48, num); \
_GST_PUT (__put_data, 7, 64, 56, num); \
} while (0)
+#endif /* !GST_HAVE_UNALIGNED_ACCESS */
/**
* GST_WRITE_UINT32_BE:
*
* Store a 32 bit unsigned integer value in big endian format into the memory buffer.
*/
+/**
+ * GST_WRITE_UINT32_LE:
+ * @data: memory location
+ * @num: value to store
+ *
+ * Store a 32 bit unsigned integer value in little endian format into the memory buffer.
+ */
+#if GST_HAVE_UNALIGNED_ACCESS
+# if (G_BYTE_ORDER == G_BIG_ENDIAN)
+# define GST_WRITE_UINT32_BE(data,val) _GST_FAST_WRITE(32,data,val)
+# define GST_WRITE_UINT32_LE(data,val) _GST_FAST_WRITE_SWAP(32,data,val)
+# else
+# define GST_WRITE_UINT32_BE(data,val) _GST_FAST_WRITE_SWAP(32,data,val)
+# define GST_WRITE_UINT32_LE(data,val) _GST_FAST_WRITE(32,data,val)
+# endif
+#else
#define GST_WRITE_UINT32_BE(data, num) do { \
gpointer __put_data = data; \
_GST_PUT (__put_data, 0, 32, 24, num); \
_GST_PUT (__put_data, 3, 32, 0, num); \
} while (0)
-/**
- * GST_WRITE_UINT32_LE:
- * @data: memory location
- * @num: value to store
- *
- * Store a 32 bit unsigned integer value in little endian format into the memory buffer.
- */
#define GST_WRITE_UINT32_LE(data, num) do { \
gpointer __put_data = data; \
_GST_PUT (__put_data, 0, 32, 0, num); \
_GST_PUT (__put_data, 2, 32, 16, num); \
_GST_PUT (__put_data, 3, 32, 24, num); \
} while (0)
+#endif /* !GST_HAVE_UNALIGNED_ACCESS */
/**
* GST_WRITE_UINT24_BE:
*
* Store a 16 bit unsigned integer value in big endian format into the memory buffer.
*/
-#define GST_WRITE_UINT16_BE(data, num) do { \
- gpointer __put_data = data; \
- _GST_PUT (__put_data, 0, 16, 8, num); \
- _GST_PUT (__put_data, 1, 16, 0, num); \
- } while (0)
-
/**
* GST_WRITE_UINT16_LE:
* @data: memory location
*
* Store a 16 bit unsigned integer value in little endian format into the memory buffer.
*/
+#if GST_HAVE_UNALIGNED_ACCESS
+# if (G_BYTE_ORDER == G_BIG_ENDIAN)
+# define GST_WRITE_UINT16_BE(data,val) _GST_FAST_WRITE(16,data,val)
+# define GST_WRITE_UINT16_LE(data,val) _GST_FAST_WRITE_SWAP(16,data,val)
+# else
+# define GST_WRITE_UINT16_BE(data,val) _GST_FAST_WRITE_SWAP(16,data,val)
+# define GST_WRITE_UINT16_LE(data,val) _GST_FAST_WRITE(16,data,val)
+# endif
+#else
+#define GST_WRITE_UINT16_BE(data, num) do { \
+ gpointer __put_data = data; \
+ _GST_PUT (__put_data, 0, 16, 8, num); \
+ _GST_PUT (__put_data, 1, 16, 0, num); \
+ } while (0)
+
#define GST_WRITE_UINT16_LE(data, num) do { \
gpointer __put_data = data; \
_GST_PUT (__put_data, 0, 16, 0, num); \
_GST_PUT (__put_data, 1, 16, 8, num); \
} while (0)
+#endif /* !GST_HAVE_UNALIGNED_ACCESS */
/**
* GST_WRITE_UINT8: