mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
bytewriter: Add unchecked variants of the writing functions
These don't check if there's enough free space available and are available as inline functions only. API: gst_byte_writer_put_int8_unchecked API: gst_byte_writer_put_int16_be_unchecked API: gst_byte_writer_put_int16_le_unchecked API: gst_byte_writer_put_int24_be_unchecked API: gst_byte_writer_put_int24_le_unchecked API: gst_byte_writer_put_int32_be_unchecked API: gst_byte_writer_put_int32_le_unchecked API: gst_byte_writer_put_int64_be_unchecked API: gst_byte_writer_put_int64_le_unchecked API: gst_byte_writer_put_uint8_unchecked API: gst_byte_writer_put_uint16_be_unchecked API: gst_byte_writer_put_uint16_le_unchecked API: gst_byte_writer_put_uint24_be_unchecked API: gst_byte_writer_put_uint24_le_unchecked API: gst_byte_writer_put_uint32_be_unchecked API: gst_byte_writer_put_uint32_le_unchecked API: gst_byte_writer_put_uint64_be_unchecked API: gst_byte_writer_put_uint64_le_unchecked API: gst_byte_writer_put_float32_be_unchecked API: gst_byte_writer_put_float32_le_unchecked API: gst_byte_writer_put_float64_be_unchecked API: gst_byte_writer_put_float64_le_unchecked API: gst_byte_writer_put_data_unchecked API: gst_byte_writer_fill_unchecked
This commit is contained in:
parent
9bd4432d08
commit
69ef479ce4
3 changed files with 60 additions and 13 deletions
|
@ -614,6 +614,33 @@ gst_byte_writer_put_string_utf8
|
||||||
gst_byte_writer_put_data
|
gst_byte_writer_put_data
|
||||||
gst_byte_writer_fill
|
gst_byte_writer_fill
|
||||||
|
|
||||||
|
gst_byte_writer_put_int8_unchecked
|
||||||
|
gst_byte_writer_put_int16_be_unchecked
|
||||||
|
gst_byte_writer_put_int16_le_unchecked
|
||||||
|
gst_byte_writer_put_int24_be_unchecked
|
||||||
|
gst_byte_writer_put_int24_le_unchecked
|
||||||
|
gst_byte_writer_put_int32_be_unchecked
|
||||||
|
gst_byte_writer_put_int32_le_unchecked
|
||||||
|
gst_byte_writer_put_int64_be_unchecked
|
||||||
|
gst_byte_writer_put_int64_le_unchecked
|
||||||
|
|
||||||
|
gst_byte_writer_put_uint8_unchecked
|
||||||
|
gst_byte_writer_put_uint16_be_unchecked
|
||||||
|
gst_byte_writer_put_uint16_le_unchecked
|
||||||
|
gst_byte_writer_put_uint24_be_unchecked
|
||||||
|
gst_byte_writer_put_uint24_le_unchecked
|
||||||
|
gst_byte_writer_put_uint32_be_unchecked
|
||||||
|
gst_byte_writer_put_uint32_le_unchecked
|
||||||
|
gst_byte_writer_put_uint64_be_unchecked
|
||||||
|
gst_byte_writer_put_uint64_le_unchecked
|
||||||
|
|
||||||
|
gst_byte_writer_put_float32_be_unchecked
|
||||||
|
gst_byte_writer_put_float32_le_unchecked
|
||||||
|
gst_byte_writer_put_float64_be_unchecked
|
||||||
|
gst_byte_writer_put_float64_le_unchecked
|
||||||
|
|
||||||
|
gst_byte_writer_put_data_unchecked
|
||||||
|
gst_byte_writer_fill_unchecked
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
GST_BYTE_WRITER
|
GST_BYTE_WRITER
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
|
@ -37,6 +37,7 @@ libgstbase_@GST_MAJORMINOR@include_HEADERS = \
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
gstbytereader-docs.h \
|
gstbytereader-docs.h \
|
||||||
|
gstbytewriter-docs.h \
|
||||||
gstbitreader-docs.h
|
gstbitreader-docs.h
|
||||||
|
|
||||||
CLEANFILES = *.gcno *.gcda *.gcov
|
CLEANFILES = *.gcno *.gcda *.gcov
|
||||||
|
|
|
@ -203,20 +203,26 @@ _gst_byte_writer_ensure_free_space_inline (GstByteWriter * writer, guint size)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __GST_BYTE_WRITER_CREATE_WRITE_FUNC(bits,type,name,write_func) \
|
#define __GST_BYTE_WRITER_CREATE_WRITE_FUNC(bits,type,name,write_func) \
|
||||||
static inline gboolean \
|
static inline void \
|
||||||
_gst_byte_writer_put_##name##_inline (GstByteWriter *writer, type val) \
|
gst_byte_writer_put_##name##_unchecked (GstByteWriter *writer, type val) \
|
||||||
{ \
|
{ \
|
||||||
guint8 *write_data; \
|
guint8 *write_data; \
|
||||||
\
|
\
|
||||||
g_return_val_if_fail (writer != NULL, FALSE); \
|
|
||||||
\
|
|
||||||
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline(writer, bits/8))) \
|
|
||||||
return FALSE; \
|
|
||||||
\
|
|
||||||
write_data = (guint8 *) writer->parent.data + writer->parent.byte; \
|
write_data = (guint8 *) writer->parent.data + writer->parent.byte; \
|
||||||
write_func (write_data, val); \
|
write_func (write_data, val); \
|
||||||
writer->parent.byte += bits/8; \
|
writer->parent.byte += bits/8; \
|
||||||
writer->parent.size = MAX (writer->parent.size, writer->parent.byte); \
|
writer->parent.size = MAX (writer->parent.size, writer->parent.byte); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static inline gboolean \
|
||||||
|
_gst_byte_writer_put_##name##_inline (GstByteWriter *writer, type val) \
|
||||||
|
{ \
|
||||||
|
g_return_val_if_fail (writer != NULL, FALSE); \
|
||||||
|
\
|
||||||
|
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline(writer, bits/8))) \
|
||||||
|
return FALSE; \
|
||||||
|
\
|
||||||
|
gst_byte_writer_put_##name##_unchecked (writer, val); \
|
||||||
\
|
\
|
||||||
return TRUE; \
|
return TRUE; \
|
||||||
}
|
}
|
||||||
|
@ -247,6 +253,15 @@ __GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, gdouble, float64_le, GST_WRITE_DOUBLE_L
|
||||||
|
|
||||||
#undef __GST_BYTE_WRITER_CREATE_WRITE_FUNC
|
#undef __GST_BYTE_WRITER_CREATE_WRITE_FUNC
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
gst_byte_writer_put_data_unchecked (GstByteWriter * writer, const guint8 * data,
|
||||||
|
guint size)
|
||||||
|
{
|
||||||
|
memcpy ((guint8 *) & writer->parent.data[writer->parent.byte], data, size);
|
||||||
|
writer->parent.byte += size;
|
||||||
|
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
|
||||||
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
_gst_byte_writer_put_data_inline (GstByteWriter * writer, const guint8 * data,
|
_gst_byte_writer_put_data_inline (GstByteWriter * writer, const guint8 * data,
|
||||||
guint size)
|
guint size)
|
||||||
|
@ -256,13 +271,19 @@ _gst_byte_writer_put_data_inline (GstByteWriter * writer, const guint8 * data,
|
||||||
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
|
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
memcpy ((guint8 *) & writer->parent.data[writer->parent.byte], data, size);
|
gst_byte_writer_put_data_unchecked (writer, data, size);
|
||||||
writer->parent.byte += size;
|
|
||||||
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
gst_byte_writer_fill_unchecked (GstByteWriter * writer, guint8 value, guint size)
|
||||||
|
{
|
||||||
|
memset ((guint8 *) & writer->parent.data[writer->parent.byte], value, size);
|
||||||
|
writer->parent.byte += size;
|
||||||
|
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
|
||||||
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
_gst_byte_writer_fill_inline (GstByteWriter * writer, guint8 value, guint size)
|
_gst_byte_writer_fill_inline (GstByteWriter * writer, guint8 value, guint size)
|
||||||
{
|
{
|
||||||
|
@ -271,9 +292,7 @@ _gst_byte_writer_fill_inline (GstByteWriter * writer, guint8 value, guint size)
|
||||||
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
|
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
memset ((guint8 *) & writer->parent.data[writer->parent.byte], value, size);
|
gst_byte_writer_fill_unchecked (writer, value, size);
|
||||||
writer->parent.byte += size;
|
|
||||||
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue