mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-25 01:54:17 +00:00
utils: make sure slow GST_READ_UINT* variants don't have unexpected side effects
Fixes unit test on systems where unaligned memory access is not possible. https://bugzilla.gnome.org/show_bug.cgi?id=695599
This commit is contained in:
parent
9baef63f5b
commit
1750620752
1 changed files with 45 additions and 8 deletions
|
@ -158,7 +158,7 @@ static inline guint64 __gst_fast_read_swap64(const guint8 *v) {
|
|||
# define GST_READ_UINT64_LE(data) _GST_FAST_READ (64, data)
|
||||
# endif
|
||||
#else
|
||||
# define GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \
|
||||
#define _GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \
|
||||
_GST_GET (data, 1, 64, 48) | \
|
||||
_GST_GET (data, 2, 64, 40) | \
|
||||
_GST_GET (data, 3, 64, 32) | \
|
||||
|
@ -167,7 +167,7 @@ static inline guint64 __gst_fast_read_swap64(const guint8 *v) {
|
|||
_GST_GET (data, 6, 64, 8) | \
|
||||
_GST_GET (data, 7, 64, 0))
|
||||
|
||||
# define GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \
|
||||
#define _GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \
|
||||
_GST_GET (data, 6, 64, 48) | \
|
||||
_GST_GET (data, 5, 64, 40) | \
|
||||
_GST_GET (data, 4, 64, 32) | \
|
||||
|
@ -175,6 +175,15 @@ static inline guint64 __gst_fast_read_swap64(const guint8 *v) {
|
|||
_GST_GET (data, 2, 64, 16) | \
|
||||
_GST_GET (data, 1, 64, 8) | \
|
||||
_GST_GET (data, 0, 64, 0))
|
||||
|
||||
#define GST_READ_UINT64_BE(data) __gst_slow_read64_be((const guint8 *)(data))
|
||||
static inline guint64 __gst_slow_read64_be (const guint8 * data) {
|
||||
return _GST_READ_UINT64_BE (data);
|
||||
}
|
||||
#define GST_READ_UINT64_LE(data) __gst_slow_read64_le((const guint8 *)(data))
|
||||
static inline guint64 __gst_slow_read64_le (const guint8 * data) {
|
||||
return _GST_READ_UINT64_LE (data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -199,15 +208,24 @@ static inline guint64 __gst_fast_read_swap64(const guint8 *v) {
|
|||
# define GST_READ_UINT32_LE(data) _GST_FAST_READ (32, data)
|
||||
# endif
|
||||
#else
|
||||
# define GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \
|
||||
#define _GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \
|
||||
_GST_GET (data, 1, 32, 16) | \
|
||||
_GST_GET (data, 2, 32, 8) | \
|
||||
_GST_GET (data, 3, 32, 0))
|
||||
|
||||
# define GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \
|
||||
#define _GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \
|
||||
_GST_GET (data, 2, 32, 16) | \
|
||||
_GST_GET (data, 1, 32, 8) | \
|
||||
_GST_GET (data, 0, 32, 0))
|
||||
|
||||
#define GST_READ_UINT32_BE(data) __gst_slow_read32_be((const guint8 *)(data))
|
||||
static inline guint32 __gst_slow_read32_be (const guint8 * data) {
|
||||
return _GST_READ_UINT32_BE (data);
|
||||
}
|
||||
#define GST_READ_UINT32_LE(data) __gst_slow_read32_le((const guint8 *)(data))
|
||||
static inline guint32 __gst_slow_read32_le (const guint8 * data) {
|
||||
return _GST_READ_UINT32_LE (data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -216,20 +234,30 @@ static inline guint64 __gst_fast_read_swap64(const guint8 *v) {
|
|||
*
|
||||
* Read a 24 bit unsigned integer value in big endian format from the memory buffer.
|
||||
*/
|
||||
#define GST_READ_UINT24_BE(data) (_GST_GET (data, 0, 32, 16) | \
|
||||
#define _GST_READ_UINT24_BE(data) (_GST_GET (data, 0, 32, 16) | \
|
||||
_GST_GET (data, 1, 32, 8) | \
|
||||
_GST_GET (data, 2, 32, 0))
|
||||
|
||||
#define GST_READ_UINT24_BE(data) __gst_slow_read24_be((const guint8 *)(data))
|
||||
static inline guint32 __gst_slow_read24_be (const guint8 * data) {
|
||||
return _GST_READ_UINT24_BE (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* GST_READ_UINT24_LE:
|
||||
* @data: memory location
|
||||
*
|
||||
* Read a 24 bit unsigned integer value in little endian format from the memory buffer.
|
||||
*/
|
||||
#define GST_READ_UINT24_LE(data) (_GST_GET (data, 2, 32, 16) | \
|
||||
#define _GST_READ_UINT24_LE(data) (_GST_GET (data, 2, 32, 16) | \
|
||||
_GST_GET (data, 1, 32, 8) | \
|
||||
_GST_GET (data, 0, 32, 0))
|
||||
|
||||
#define GST_READ_UINT24_LE(data) __gst_slow_read24_le((const guint8 *)(data))
|
||||
static inline guint32 __gst_slow_read24_le (const guint8 * data) {
|
||||
return _GST_READ_UINT24_LE (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* GST_READ_UINT16_BE:
|
||||
* @data: memory location
|
||||
|
@ -251,11 +279,20 @@ static inline guint64 __gst_fast_read_swap64(const guint8 *v) {
|
|||
# define GST_READ_UINT16_LE(data) _GST_FAST_READ (16, data)
|
||||
# endif
|
||||
#else
|
||||
# define GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \
|
||||
#define _GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \
|
||||
_GST_GET (data, 1, 16, 0))
|
||||
|
||||
# define GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \
|
||||
#define _GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \
|
||||
_GST_GET (data, 0, 16, 0))
|
||||
|
||||
#define GST_READ_UINT16_BE(data) __gst_slow_read16_be((const guint8 *)(data))
|
||||
static inline guint16 __gst_slow_read16_be (const guint8 * data) {
|
||||
return _GST_READ_UINT16_BE (data);
|
||||
}
|
||||
#define GST_READ_UINT16_LE(data) __gst_slow_read16_le((const guint8 *)(data))
|
||||
static inline guint16 __gst_slow_read16_le (const guint8 * data) {
|
||||
return _GST_READ_UINT16_LE (data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue