Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
luzpaz
gstreamer
Commits
b8c1e813
Commit
b8c1e813
authored
Apr 19, 2011
by
Wim Taymans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer: add method to compare buffer data
Add method to compare the data in a buffer.
parent
24bb4140
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
gst/gstbuffer.c
gst/gstbuffer.c
+46
-0
gst/gstbuffer.h
gst/gstbuffer.h
+2
-0
No files found.
gst/gstbuffer.c
View file @
b8c1e813
...
...
@@ -1010,6 +1010,52 @@ gst_buffer_extract (GstBuffer * buffer, gsize offset, gpointer dest, gsize size)
}
}
/**
* gst_buffer_memcmp:
* @buffer: a #GstBuffer.
* @offset: the offset in @buffer
* @mem: the memory to compare
* @size: the size to compare
*
* Compare @size bytes starting from @offset in @buffer with the memory in @mem.
*/
gint
gst_buffer_memcmp
(
GstBuffer
*
buffer
,
gsize
offset
,
gconstpointer
mem
,
gsize
size
)
{
gsize
i
,
len
;
const
guint8
*
ptr
=
mem
;
gint
res
=
0
;
g_return_val_if_fail
(
GST_IS_BUFFER
(
buffer
),
0
);
g_return_val_if_fail
(
mem
!=
NULL
,
0
);
len
=
GST_BUFFER_MEM_LEN
(
buffer
);
for
(
i
=
0
;
i
<
len
&&
size
>
0
&&
res
==
0
;
i
++
)
{
guint8
*
data
;
gsize
ssize
,
tocmp
;
GstMemory
*
mem
;
mem
=
GST_BUFFER_MEM_PTR
(
buffer
,
i
);
data
=
gst_memory_map
(
mem
,
&
ssize
,
NULL
,
GST_MAP_READ
);
if
(
ssize
>
offset
)
{
/* we have enough */
tocmp
=
MIN
(
ssize
-
offset
,
size
);
res
=
memcmp
(
ptr
,
data
+
offset
,
tocmp
);
size
-=
tocmp
;
ptr
+=
tocmp
;
offset
=
0
;
}
else
{
/* offset past buffer, skip */
offset
-=
ssize
;
}
gst_memory_unmap
(
mem
,
data
,
ssize
);
}
return
res
;
}
/**
* gst_buffer_get_caps:
* @buffer: a #GstBuffer.
...
...
gst/gstbuffer.h
View file @
b8c1e813
...
...
@@ -294,6 +294,8 @@ void gst_buffer_fill (GstBuffer *buffer, gsize offset,
gconstpointer
src
,
gsize
size
);
void
gst_buffer_extract
(
GstBuffer
*
buffer
,
gsize
offset
,
gpointer
dest
,
gsize
size
);
gint
gst_buffer_memcmp
(
GstBuffer
*
buffer
,
gsize
offset
,
gconstpointer
mem
,
gsize
size
);
gsize
gst_buffer_get_size
(
GstBuffer
*
buffer
);
void
gst_buffer_resize
(
GstBuffer
*
buffer
,
gsize
offset
,
gsize
size
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment