mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
bytereader: add unchecked and inline versions of the float getters/peekers
API: gst_byte_reader_get_float*_unchecked()
This commit is contained in:
parent
31ab124487
commit
4c103b00b5
4 changed files with 158 additions and 84 deletions
|
@ -508,6 +508,16 @@ gst_byte_reader_peek_uint32_le_unchecked
|
|||
gst_byte_reader_peek_uint64_be_unchecked
|
||||
gst_byte_reader_peek_uint64_le_unchecked
|
||||
|
||||
gst_byte_reader_get_float32_le_unchecked
|
||||
gst_byte_reader_get_float32_be_unchecked
|
||||
gst_byte_reader_get_float64_le_unchecked
|
||||
gst_byte_reader_get_float64_be_unchecked
|
||||
|
||||
gst_byte_reader_peek_float32_le_unchecked
|
||||
gst_byte_reader_peek_float32_be_unchecked
|
||||
gst_byte_reader_peek_float64_le_unchecked
|
||||
gst_byte_reader_peek_float64_be_unchecked
|
||||
|
||||
gst_byte_reader_dup_data_unchecked
|
||||
gst_byte_reader_get_data_unchecked
|
||||
gst_byte_reader_peek_data_unchecked
|
||||
|
|
|
@ -505,6 +505,104 @@ gint64 gst_byte_reader_get_int64_be_unchecked (GstByteReader * reader);
|
|||
gint64 gst_byte_reader_peek_int64_le_unchecked (GstByteReader * reader);
|
||||
gint64 gst_byte_reader_peek_int64_be_unchecked (GstByteReader * reader);
|
||||
|
||||
/**
|
||||
* gst_byte_reader_get_float32_le_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 32 bit little endian float without checking if there is enough
|
||||
* data available and update the current position.
|
||||
*
|
||||
* Returns: floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_peek_float32_le_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 32 bit little endian float without checking if there is enough
|
||||
* data available, but keep the current position.
|
||||
*
|
||||
* Returns: floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_get_float32_be_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 32 bit big endian float without checking if there is enough
|
||||
* data available and update the current position.
|
||||
*
|
||||
* Returns: floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_peek_float32_be_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 32 bit big endian float without checking if there is enough
|
||||
* data available, but keep the current position.
|
||||
*
|
||||
* Returns: floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_get_float64_le_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 64 bit little endian float without checking if there is enough
|
||||
* data available and update the current position.
|
||||
*
|
||||
* Returns: double precision floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_peek_float64_le_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 64 bit little endian float without checking if there is enough
|
||||
* data available, but keep the current position.
|
||||
*
|
||||
* Returns: double precision floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_get_float64_be_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 64 bit big endian float without checking if there is enough
|
||||
* data available and update the current position.
|
||||
*
|
||||
* Returns: double precision floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
/**
|
||||
* gst_byte_reader_peek_float64_be_unchecked:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Read a 64 bit big endian float without checking if there is enough
|
||||
* data available, but keep the current position.
|
||||
*
|
||||
* Returns: double precision floating point value read
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
|
||||
gfloat gst_byte_reader_get_float32_le_unchecked (GstByteReader * reader);
|
||||
gfloat gst_byte_reader_get_float32_be_unchecked (GstByteReader * reader);
|
||||
gdouble gst_byte_reader_get_float64_le_unchecked (GstByteReader * reader);
|
||||
gdouble gst_byte_reader_get_float64_be_unchecked (GstByteReader * reader);
|
||||
|
||||
gfloat gst_byte_reader_peek_float32_le_unchecked (GstByteReader * reader);
|
||||
gfloat gst_byte_reader_peek_float32_be_unchecked (GstByteReader * reader);
|
||||
gdouble gst_byte_reader_peek_float64_le_unchecked (GstByteReader * reader);
|
||||
gdouble gst_byte_reader_peek_float64_be_unchecked (GstByteReader * reader);
|
||||
|
||||
/**
|
||||
* gst_byte_reader_peek_data_unchecked:
|
||||
|
|
|
@ -693,7 +693,7 @@ gst_byte_reader_skip (GstByteReader * reader, guint nbytes)
|
|||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
#define GST_BYTE_READER_PEEK_GET_INTS(bits,type,name) \
|
||||
#define GST_BYTE_READER_PEEK_GET(bits,type,name) \
|
||||
gboolean \
|
||||
gst_byte_reader_get_##name (GstByteReader * reader, type * val) \
|
||||
{ \
|
||||
|
@ -712,28 +712,28 @@ gst_byte_reader_peek_##name (GstByteReader * reader, type * val) \
|
|||
return _gst_byte_reader_peek_##name##_inline (reader, val); \
|
||||
}
|
||||
|
||||
GST_BYTE_READER_PEEK_GET_INTS(8,guint8,uint8)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(8,gint8,int8)
|
||||
GST_BYTE_READER_PEEK_GET(8,guint8,uint8)
|
||||
GST_BYTE_READER_PEEK_GET(8,gint8,int8)
|
||||
|
||||
GST_BYTE_READER_PEEK_GET_INTS(16,guint16,uint16_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(16,guint16,uint16_be)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(16,gint16,int16_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(16,gint16,int16_be)
|
||||
GST_BYTE_READER_PEEK_GET(16,guint16,uint16_le)
|
||||
GST_BYTE_READER_PEEK_GET(16,guint16,uint16_be)
|
||||
GST_BYTE_READER_PEEK_GET(16,gint16,int16_le)
|
||||
GST_BYTE_READER_PEEK_GET(16,gint16,int16_be)
|
||||
|
||||
GST_BYTE_READER_PEEK_GET_INTS(24,guint32,uint24_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(24,guint32,uint24_be)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(24,gint32,int24_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(24,gint32,int24_be)
|
||||
GST_BYTE_READER_PEEK_GET(24,guint32,uint24_le)
|
||||
GST_BYTE_READER_PEEK_GET(24,guint32,uint24_be)
|
||||
GST_BYTE_READER_PEEK_GET(24,gint32,int24_le)
|
||||
GST_BYTE_READER_PEEK_GET(24,gint32,int24_be)
|
||||
|
||||
GST_BYTE_READER_PEEK_GET_INTS(32,guint32,uint32_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(32,guint32,uint32_be)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(32,gint32,int32_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(32,gint32,int32_be)
|
||||
GST_BYTE_READER_PEEK_GET(32,guint32,uint32_le)
|
||||
GST_BYTE_READER_PEEK_GET(32,guint32,uint32_be)
|
||||
GST_BYTE_READER_PEEK_GET(32,gint32,int32_le)
|
||||
GST_BYTE_READER_PEEK_GET(32,gint32,int32_be)
|
||||
|
||||
GST_BYTE_READER_PEEK_GET_INTS(64,guint64,uint64_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(64,guint64,uint64_be)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(64,gint64,int64_le)
|
||||
GST_BYTE_READER_PEEK_GET_INTS(64,gint64,int64_be)
|
||||
GST_BYTE_READER_PEEK_GET(64,guint64,uint64_le)
|
||||
GST_BYTE_READER_PEEK_GET(64,guint64,uint64_be)
|
||||
GST_BYTE_READER_PEEK_GET(64,gint64,int64_le)
|
||||
GST_BYTE_READER_PEEK_GET(64,gint64,int64_be)
|
||||
|
||||
/**
|
||||
* gst_byte_reader_get_float32_le:
|
||||
|
@ -839,60 +839,10 @@ GST_BYTE_READER_PEEK_GET_INTS(64,gint64,int64_be)
|
|||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
#define GST_BYTE_READER_READ_FLOATS(bits, type, TYPE) \
|
||||
gboolean \
|
||||
gst_byte_reader_get_float##bits##_le (GstByteReader *reader, g##type *val) \
|
||||
{ \
|
||||
g_return_val_if_fail (reader != NULL, FALSE); \
|
||||
g_return_val_if_fail (val != NULL, FALSE); \
|
||||
\
|
||||
if (gst_byte_reader_get_remaining (reader) < bits / 8) \
|
||||
return FALSE; \
|
||||
\
|
||||
*val = GST_READ_##TYPE##_LE (&reader->data[reader->byte]); \
|
||||
reader->byte += bits / 8; \
|
||||
return TRUE; \
|
||||
} \
|
||||
gboolean \
|
||||
gst_byte_reader_get_float##bits##_be (GstByteReader *reader, g##type *val) \
|
||||
{ \
|
||||
g_return_val_if_fail (reader != NULL, FALSE); \
|
||||
g_return_val_if_fail (val != NULL, FALSE); \
|
||||
\
|
||||
if (gst_byte_reader_get_remaining (reader) < bits / 8) \
|
||||
return FALSE; \
|
||||
\
|
||||
*val = GST_READ_##TYPE##_BE (&reader->data[reader->byte]); \
|
||||
reader->byte += bits / 8; \
|
||||
return TRUE; \
|
||||
} \
|
||||
gboolean \
|
||||
gst_byte_reader_peek_float##bits##_le (GstByteReader *reader, g##type *val) \
|
||||
{ \
|
||||
g_return_val_if_fail (reader != NULL, FALSE); \
|
||||
g_return_val_if_fail (val != NULL, FALSE); \
|
||||
\
|
||||
if (gst_byte_reader_get_remaining (reader) < bits / 8) \
|
||||
return FALSE; \
|
||||
\
|
||||
*val = GST_READ_##TYPE##_LE (&reader->data[reader->byte]); \
|
||||
return TRUE; \
|
||||
} \
|
||||
gboolean \
|
||||
gst_byte_reader_peek_float##bits##_be (GstByteReader *reader, g##type *val) \
|
||||
{ \
|
||||
g_return_val_if_fail (reader != NULL, FALSE); \
|
||||
g_return_val_if_fail (val != NULL, FALSE); \
|
||||
\
|
||||
if (gst_byte_reader_get_remaining (reader) < bits / 8) \
|
||||
return FALSE; \
|
||||
\
|
||||
*val = GST_READ_##TYPE##_BE (&reader->data[reader->byte]); \
|
||||
return TRUE; \
|
||||
}
|
||||
|
||||
GST_BYTE_READER_READ_FLOATS (32, float, FLOAT);
|
||||
GST_BYTE_READER_READ_FLOATS (64, double, DOUBLE);
|
||||
GST_BYTE_READER_PEEK_GET(32,gfloat,float32_le)
|
||||
GST_BYTE_READER_PEEK_GET(32,gfloat,float32_be)
|
||||
GST_BYTE_READER_PEEK_GET(64,gdouble,float64_le)
|
||||
GST_BYTE_READER_PEEK_GET(64,gdouble,float64_be)
|
||||
|
||||
/**
|
||||
* gst_byte_reader_get_data:
|
||||
|
|
|
@ -217,6 +217,11 @@ __GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,guint64,uint64_be,UINT64_BE,/* */)
|
|||
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gint64,int64_le,UINT64_LE,/* */)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gint64,int64_be,UINT64_BE,/* */)
|
||||
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,gfloat,float32_le,FLOAT_LE,/* */)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,gfloat,float32_be,FLOAT_BE,/* */)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gdouble,float64_le,DOUBLE_LE,/* */)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gdouble,float64_be,DOUBLE_BE,/* */)
|
||||
|
||||
#undef __GET_PEEK_BITS_UNCHECKED
|
||||
|
||||
static inline const guint8 *
|
||||
|
@ -294,6 +299,11 @@ __GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,guint64,uint64_be)
|
|||
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gint64,int64_le)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gint64,int64_be)
|
||||
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,gfloat,float32_le)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,gfloat,float32_be)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gdouble,float64_le)
|
||||
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gdouble,float64_be)
|
||||
|
||||
#undef __GST_BYTE_READER_GET_PEEK_BITS_INLINE
|
||||
|
||||
#ifndef GST_BYTE_READER_DISABLE_INLINES
|
||||
|
@ -376,19 +386,25 @@ __GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gint64,int64_be)
|
|||
#define gst_byte_reader_peek_int64_be(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_peek_int64_be_inline(reader,val))
|
||||
|
||||
#define gst_byte_reader_get_float32_le(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_get_float32_le_inline(reader,val))
|
||||
#define gst_byte_reader_get_float32_be(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_get_float32_be_inline(reader,val))
|
||||
#define gst_byte_reader_get_float64_le(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_get_float64_le_inline(reader,val))
|
||||
#define gst_byte_reader_get_float64_be(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_get_float64_be_inline(reader,val))
|
||||
#define gst_byte_reader_peek_float32_le(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_peek_float32_le_inline(reader,val))
|
||||
#define gst_byte_reader_peek_float32_be(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_peek_float32_be_inline(reader,val))
|
||||
#define gst_byte_reader_peek_float64_le(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_peek_float64_le_inline(reader,val))
|
||||
#define gst_byte_reader_peek_float64_be(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_peek_float64_be_inline(reader,val))
|
||||
|
||||
#endif /* GST_BYTE_READER_DISABLE_INLINES */
|
||||
|
||||
// FIXME:
|
||||
//gboolean gst_byte_reader_get_float32_le (GstByteReader *reader, gfloat *val);
|
||||
//gboolean gst_byte_reader_get_float32_be (GstByteReader *reader, gfloat *val);
|
||||
//gboolean gst_byte_reader_get_float64_le (GstByteReader *reader, gdouble *val);
|
||||
//gboolean gst_byte_reader_get_float64_be (GstByteReader *reader, gdouble *val);
|
||||
|
||||
//gboolean gst_byte_reader_peek_float32_le (GstByteReader *reader, gfloat *val);
|
||||
//gboolean gst_byte_reader_peek_float32_be (GstByteReader *reader, gfloat *val);
|
||||
//gboolean gst_byte_reader_peek_float64_le (GstByteReader *reader, gdouble *val);
|
||||
//gboolean gst_byte_reader_peek_float64_be (GstByteReader *reader, gdouble *val);
|
||||
|
||||
static inline gboolean
|
||||
_gst_byte_reader_dup_data_inline (GstByteReader * reader, guint size, guint8 ** val)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue