mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
memory: fix alignment calculations
Fix the alignment calculation. Improve documentation.
This commit is contained in:
parent
d2d23074af
commit
c8fc05743d
1 changed files with 7 additions and 2 deletions
|
@ -131,7 +131,7 @@ _default_mem_new_block (gsize maxsize, gsize align, gsize offset, gsize size)
|
|||
data = (guint8 *) mem + sizeof (GstMemoryDefault);
|
||||
|
||||
if ((aoffset = ((guintptr) data & align)))
|
||||
aoffset = align - aoffset;
|
||||
aoffset = (align + 1) - aoffset;
|
||||
|
||||
_default_mem_init (mem, 0, NULL, slice_size, data, NULL, maxsize + align,
|
||||
aoffset + offset, size);
|
||||
|
@ -405,9 +405,12 @@ gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data,
|
|||
* @maxsize: allocated size of @data
|
||||
* @align: alignment for the data
|
||||
*
|
||||
* Allocate a new memory block with memory that is at least @maxsize big and las
|
||||
* Allocate a new memory block with memory that is at least @maxsize big and has
|
||||
* the given alignment.
|
||||
*
|
||||
* @align is given as a bitmask so that @align + 1 equals the amount of bytes to
|
||||
* align to. For example, to align to 8 bytes, use an alignment of 7.
|
||||
*
|
||||
* Returns: a new #GstMemory.
|
||||
*/
|
||||
GstMemory *
|
||||
|
@ -415,6 +418,8 @@ gst_memory_new_alloc (gsize maxsize, gsize align)
|
|||
{
|
||||
GstMemoryDefault *mem;
|
||||
|
||||
g_return_val_if_fail (((align + 1) & align) == 0, NULL);
|
||||
|
||||
mem = _default_mem_new_block (maxsize, align, 0, maxsize);
|
||||
|
||||
return (GstMemory *) mem;
|
||||
|
|
Loading…
Reference in a new issue