mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
bitreader/bytereader: API: Add gst_(bit|byte)_reader_get_size()
... and GST_(BYTE|BIT)_READER() casts.
This commit is contained in:
parent
c7438c738b
commit
f4c12be109
4 changed files with 54 additions and 0 deletions
|
@ -197,6 +197,24 @@ gst_bit_reader_get_remaining (const GstBitReader * reader)
|
|||
return reader->size * 8 - (reader->byte * 8 + reader->bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_size:
|
||||
* @reader: a #GstBitReader instance
|
||||
*
|
||||
* Returns the total number of bits of a #GstBitReader instance.
|
||||
*
|
||||
* Returns: The total number of bits of @reader instance.
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
guint
|
||||
gst_bit_reader_get_size (const GstBitReader * reader)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, 0);
|
||||
|
||||
return reader->size * 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_skip:
|
||||
* @reader: a #GstBitReader instance
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_BIT_READER(reader) ((GstBitReader *) (reader))
|
||||
|
||||
/**
|
||||
* GstBitReader:
|
||||
* @data: Data from which the bit reader will read
|
||||
|
@ -56,6 +58,8 @@ gboolean gst_bit_reader_set_pos (GstBitReader *reader, guint pos);
|
|||
guint gst_bit_reader_get_pos (const GstBitReader *reader);
|
||||
guint gst_bit_reader_get_remaining (const GstBitReader *reader);
|
||||
|
||||
guint gst_bit_reader_get_size (const GstBitReader *reader);
|
||||
|
||||
gboolean gst_bit_reader_skip (GstBitReader *reader, guint nbits);
|
||||
gboolean gst_bit_reader_skip_to_byte (GstBitReader *reader);
|
||||
|
||||
|
|
|
@ -202,7 +202,26 @@ gst_byte_reader_get_remaining (const GstByteReader * reader)
|
|||
return _gst_byte_reader_get_remaining_inline (reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_byte_reader_get_size:
|
||||
* @reader: a #GstByteReader instance
|
||||
*
|
||||
* Returns the total number of bytes of a #GstByteReader instance.
|
||||
*
|
||||
* Returns: The total number of bytes of @reader instance.
|
||||
*
|
||||
* Since: 0.10.25
|
||||
*/
|
||||
guint
|
||||
gst_byte_reader_get_size (const GstByteReader * reader)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, 0);
|
||||
|
||||
return _gst_byte_reader_get_size_inline (reader);
|
||||
}
|
||||
|
||||
#define gst_byte_reader_get_remaining _gst_byte_reader_get_remaining_inline
|
||||
#define gst_byte_reader_get_size _gst_byte_reader_get_size_inline
|
||||
|
||||
/**
|
||||
* gst_byte_reader_skip:
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_BYTE_READER(reader) ((GstByteReader *) (reader))
|
||||
|
||||
/**
|
||||
* GstByteReader:
|
||||
* @data: Data from which the bit reader will read
|
||||
|
@ -53,6 +55,8 @@ gboolean gst_byte_reader_set_pos (GstByteReader *reader, guint pos);
|
|||
guint gst_byte_reader_get_pos (const GstByteReader *reader);
|
||||
guint gst_byte_reader_get_remaining (const GstByteReader *reader);
|
||||
|
||||
guint gst_byte_reader_get_size (const GstByteReader *reader);
|
||||
|
||||
gboolean gst_byte_reader_skip (GstByteReader *reader, guint nbytes);
|
||||
|
||||
gboolean gst_byte_reader_get_uint8 (GstByteReader *reader, guint8 *val);
|
||||
|
@ -254,6 +258,12 @@ _gst_byte_reader_get_remaining_inline (const GstByteReader * reader)
|
|||
return reader->size - reader->byte;
|
||||
}
|
||||
|
||||
static inline guint
|
||||
_gst_byte_reader_get_size_inline (const GstByteReader * reader)
|
||||
{
|
||||
return reader->size;
|
||||
}
|
||||
|
||||
#define __GST_BYTE_READER_GET_PEEK_BITS_INLINE(bits,type,name) \
|
||||
\
|
||||
static inline gboolean \
|
||||
|
@ -311,6 +321,9 @@ __GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gdouble,float64_be)
|
|||
#define gst_byte_reader_get_remaining(reader) \
|
||||
_gst_byte_reader_get_remaining_inline(reader)
|
||||
|
||||
#define gst_byte_reader_get_size(reader) \
|
||||
_gst_byte_reader_get_size_inline(reader)
|
||||
|
||||
/* we use defines here so we can add the G_LIKELY() */
|
||||
#define gst_byte_reader_get_uint8(reader,val) \
|
||||
G_LIKELY(_gst_byte_reader_get_uint8_inline(reader,val))
|
||||
|
|
Loading…
Reference in a new issue