Commit 3d25a4b4 authored by Wim Taymans's avatar Wim Taymans
Browse files

libs: port to new data API

parent 41025681
......@@ -988,7 +988,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
guint buf_size;
*buf = g_queue_pop_head (priv->queue);
buf_size = GST_BUFFER_SIZE (*buf);
buf_size = gst_buffer_get_size (*buf);
GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);
......@@ -998,7 +998,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
if (priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS)
priv->offset += buf_size;
if (caps) {
*buf = gst_buffer_make_metadata_writable (*buf);
*buf = gst_buffer_make_writable (*buf);
gst_buffer_set_caps (*buf, caps);
}
......@@ -1492,7 +1492,7 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
if (!steal_ref)
gst_buffer_ref (buffer);
g_queue_push_tail (priv->queue, buffer);
priv->queued_bytes += GST_BUFFER_SIZE (buffer);
priv->queued_bytes += gst_buffer_get_size (buffer);
g_cond_broadcast (priv->cond);
g_mutex_unlock (priv->mutex);
......
......@@ -93,7 +93,7 @@ gst_audio_frame_length (GstPad * pad, GstBuffer * buf)
/* FIXME: this function assumes the buffer size to be a whole multiple
* of the frame byte size
*/
return GST_BUFFER_SIZE (buf) / frame_byte_size;
return gst_buffer_get_size (buf) / frame_byte_size;
}
/**
......@@ -129,7 +129,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf)
length = GST_CLOCK_TIME_NONE;
} else {
structure = gst_caps_get_structure (caps, 0);
bytes = GST_BUFFER_SIZE (buf);
bytes = gst_buffer_get_size (buf);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
gst_structure_get_int (structure, "rate", &rate);
......@@ -155,7 +155,7 @@ gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf)
gboolean
gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf)
{
if (GST_BUFFER_SIZE (buf) % gst_audio_frame_byte_size (pad) == 0)
if (gst_buffer_get_size (buf) % gst_audio_frame_byte_size (pad) == 0)
return TRUE;
else
return FALSE;
......@@ -295,9 +295,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
GstBuffer *ret;
GstClockTime timestamp = GST_CLOCK_TIME_NONE, duration = GST_CLOCK_TIME_NONE;
guint64 offset = GST_BUFFER_OFFSET_NONE, offset_end = GST_BUFFER_OFFSET_NONE;
guint8 *data;
guint size;
gsize trim, size;
gboolean change_duration = TRUE, change_offset = TRUE, change_offset_end =
TRUE;
......@@ -313,8 +311,8 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
* Calculate the missing values for the calculations,
* they won't be changed later though. */
data = GST_BUFFER_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
trim = 0;
size = gst_buffer_get_size (buffer);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
......@@ -359,7 +357,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
diff = gst_util_uint64_scale (diff, rate, GST_SECOND);
if (change_offset)
offset += diff;
data += diff * frame_size;
trim += diff * frame_size;
size -= diff * frame_size;
}
......@@ -398,7 +396,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
if (change_duration)
duration -= gst_util_uint64_scale (diff, GST_SECOND, rate);
data += diff * frame_size;
trim += diff * frame_size;
size -= diff * frame_size;
}
......@@ -417,12 +415,11 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
}
}
/* Get a metadata writable buffer and apply all changes */
ret = gst_buffer_make_metadata_writable (buffer);
/* Get a writable buffer and apply all changes */
ret = gst_buffer_create_sub (buffer, offset, size);
gst_buffer_unref (buffer);
GST_BUFFER_TIMESTAMP (ret) = timestamp;
GST_BUFFER_SIZE (ret) = size;
GST_BUFFER_DATA (ret) = data;
if (change_duration)
GST_BUFFER_DURATION (ret) = duration;
......
......@@ -58,7 +58,7 @@ static GstStateChangeReturn gst_audio_filter_change_state (GstElement * element,
static gboolean gst_audio_filter_set_caps (GstBaseTransform * btrans,
GstCaps * incaps, GstCaps * outcaps);
static gboolean gst_audio_filter_get_unit_size (GstBaseTransform * btrans,
GstCaps * caps, guint * size);
GstCaps * caps, gsize * size);
#define do_init G_STMT_START { \
GST_DEBUG_CATEGORY_INIT (audiofilter_dbg, "audiofilter", 0, "audiofilter"); \
......@@ -154,7 +154,7 @@ gst_audio_filter_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
static gboolean
gst_audio_filter_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
guint * size)
gsize * size)
{
GstStructure *structure;
gboolean ret = TRUE;
......
......@@ -394,8 +394,8 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
/* set latency to one more segment as we need some headroom */
spec->seglatency = spec->segtotal + 1;
buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
buf->size = spec->segtotal * spec->segsize;
buf->memory = g_malloc0 (buf->size);
return TRUE;
......@@ -468,8 +468,8 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
csink = GST_AUDIO_SINK_GET_CLASS (sink);
/* free the buffer */
gst_buffer_unref (buf->data);
buf->data = NULL;
g_free (buf->memory);
buf->memory = NULL;
if (csink->unprepare)
result = csink->unprepare (sink);
......
......@@ -376,8 +376,8 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
if (!result)
goto could_not_open;
buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
buf->size = spec->segtotal * spec->segsize;
buf->memory = g_malloc0 (buf->size);
abuf = GST_AUDIORING_BUFFER (buf);
abuf->running = TRUE;
......@@ -418,8 +418,8 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
GST_OBJECT_LOCK (buf);
/* free the buffer */
gst_buffer_unref (buf->data);
buf->data = NULL;
g_free (buf->memory);
buf->memory = NULL;
if (csrc->unprepare)
result = csrc->unprepare (src);
......
......@@ -1327,8 +1327,9 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GstBaseAudioSink *sink;
GstRingBuffer *ringbuf;
gint64 diff, align, ctime, cstop;
gsize offset;
guint8 *data;
guint size;
gsize size;
guint samples, written;
gint bps;
gint accum;
......@@ -1367,7 +1368,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
bps = ringbuf->spec.bytes_per_sample;
size = GST_BUFFER_SIZE (buf);
size = gst_buffer_get_size (buf);
if (G_UNLIKELY (size % bps) != 0)
goto wrong_size;
......@@ -1382,7 +1383,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GST_TIME_FORMAT ", samples %u", GST_TIME_ARGS (time), in_offset,
GST_TIME_ARGS (bsink->segment.start), samples);
data = GST_BUFFER_DATA (buf);
offset = 0;
/* if not valid timestamp or we can't clip or sync, try to play
* sample ASAP */
......@@ -1391,7 +1392,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
render_stop = render_start + samples;
GST_DEBUG_OBJECT (sink,
"Buffer of size %u has no time. Using render_start=%" G_GUINT64_FORMAT,
GST_BUFFER_SIZE (buf), render_start);
size, render_start);
/* we don't have a start so we don't know stop either */
stop = -1;
goto no_sync;
......@@ -1445,7 +1446,7 @@ gst_base_audio_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GST_DEBUG_OBJECT (sink, "clipping start to %" GST_TIME_FORMAT " %"
G_GUINT64_FORMAT " samples", GST_TIME_ARGS (ctime), diff);
samples -= diff;
data += diff * bps;
offset += diff * bps;
time = ctime;
}
diff = stop - cstop;
......@@ -1625,10 +1626,11 @@ no_sync:
/* we need to accumulate over different runs for when we get interrupted */
accum = 0;
align_next = TRUE;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
do {
written =
gst_ring_buffer_commit_full (ringbuf, &sample_offset, data, samples,
out_samples, &accum);
gst_ring_buffer_commit_full (ringbuf, &sample_offset, data + offset,
samples, out_samples, &accum);
GST_DEBUG_OBJECT (sink, "wrote %u of %u", written, samples);
/* if we wrote all, we're done */
......@@ -1652,8 +1654,9 @@ no_sync:
break;
samples -= written;
data += written * bps;
offset += written * bps;
} while (TRUE);
gst_buffer_unmap (buf, data, size);
if (align_next)
sink->next_sample = sample_offset;
......@@ -1698,6 +1701,7 @@ stopping:
{
GST_DEBUG_OBJECT (sink, "preroll got interrupted: %d (%s)", ret,
gst_flow_get_name (ret));
gst_buffer_unmap (buf, data, size);
return ret;
}
sync_latency_failed:
......@@ -1741,6 +1745,7 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
GstBaseAudioSink *sink;
GstBuffer *buf;
GstFlowReturn ret;
gsize size;
basesink = GST_BASE_SINK (user_data);
sink = GST_BASE_AUDIO_SINK (user_data);
......@@ -1771,16 +1776,17 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
if (ret != GST_FLOW_OK)
goto preroll_error;
if (len != GST_BUFFER_SIZE (buf)) {
size = gst_buffer_get_size (buf);
if (len != size) {
GST_INFO_OBJECT (basesink,
"got different size than requested from sink pad: %u != %u", len,
GST_BUFFER_SIZE (buf));
len = MIN (GST_BUFFER_SIZE (buf), len);
"got different size than requested from sink pad: %u != %u", len, size);
len = MIN (size, len);
}
basesink->segment.last_stop += len;
memcpy (data, GST_BUFFER_DATA (buf), len);
gst_buffer_extract (buf, 0, data, len);
GST_BASE_SINK_PREROLL_UNLOCK (basesink);
GST_PAD_STREAM_UNLOCK (basesink->sinkpad);
......
......@@ -749,7 +749,7 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
{
GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc);
GstBuffer *buf;
guchar *data;
guchar *data, *ptr;
guint samples, total_samples;
guint64 sample;
gint bps;
......@@ -794,10 +794,9 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
/* FIXME, using a bufferpool would be nice here */
buf = gst_buffer_new_and_alloc (length);
data = GST_BUFFER_DATA (buf);
data = ptr = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
do {
read = gst_ring_buffer_read (ringbuffer, sample, data, samples);
read = gst_ring_buffer_read (ringbuffer, sample, ptr, samples);
GST_DEBUG_OBJECT (src, "read %u of %u", read, samples);
/* if we read all, we're done */
if (read == samples)
......@@ -813,8 +812,9 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
/* read next samples */
sample += read;
samples -= read;
data += read * bps;
ptr += read * bps;
} while (TRUE);
gst_buffer_unmap (buf, data, length);
/* mark discontinuity if needed */
if (G_UNLIKELY (sample != src->next_sample) && src->next_sample != -1) {
......
......@@ -1601,10 +1601,10 @@ default_commit (GstRingBuffer * buf, guint64 * sample,
gint inr, outr;
gboolean reverse;
g_return_val_if_fail (buf->data != NULL, -1);
g_return_val_if_fail (buf->memory != NULL, -1);
g_return_val_if_fail (data != NULL, -1);
dest = GST_BUFFER_DATA (buf->data);
dest = buf->memory;
segsize = buf->spec.segsize;
segtotal = buf->spec.segtotal;
bps = buf->spec.bytes_per_sample;
......@@ -1830,10 +1830,10 @@ gst_ring_buffer_read (GstRingBuffer * buf, guint64 sample, guchar * data,
guint to_read;
g_return_val_if_fail (GST_IS_RING_BUFFER (buf), -1);
g_return_val_if_fail (buf->data != NULL, -1);
g_return_val_if_fail (buf->memory != NULL, -1);
g_return_val_if_fail (data != NULL, -1);
dest = GST_BUFFER_DATA (buf->data);
dest = buf->memory;
segsize = buf->spec.segsize;
segtotal = buf->spec.segtotal;
bps = buf->spec.bytes_per_sample;
......@@ -1940,12 +1940,12 @@ gst_ring_buffer_prepare_read (GstRingBuffer * buf, gint * segment,
return FALSE;
}
g_return_val_if_fail (buf->data != NULL, FALSE);
g_return_val_if_fail (buf->memory != NULL, FALSE);
g_return_val_if_fail (segment != NULL, FALSE);
g_return_val_if_fail (readptr != NULL, FALSE);
g_return_val_if_fail (len != NULL, FALSE);
data = GST_BUFFER_DATA (buf->data);
data = buf->memory;
/* get the position of the pointer */
segdone = g_atomic_int_get (&buf->segdone);
......@@ -2012,7 +2012,7 @@ gst_ring_buffer_clear (GstRingBuffer * buf, gint segment)
g_return_if_fail (GST_IS_RING_BUFFER (buf));
/* no data means it's already cleared */
if (G_UNLIKELY (buf->data == NULL))
if (G_UNLIKELY (buf->memory == NULL))
return;
/* no empty_seg means it's not opened */
......@@ -2021,7 +2021,7 @@ gst_ring_buffer_clear (GstRingBuffer * buf, gint segment)
segment %= buf->spec.segtotal;
data = GST_BUFFER_DATA (buf->data);
data = buf->memory;
data += segment * buf->spec.segsize;
GST_LOG ("clear segment %d @%p", segment, data);
......
......@@ -257,7 +257,8 @@ struct _GstRingBuffer {
GCond *cond;
gboolean open;
gboolean acquired;
GstBuffer *data;
guint8 *memory;
gsize size;
GstRingBufferSpec spec;
GstRingBufferSegState *segstate;
gint samples_per_seg;
......
......@@ -1647,7 +1647,7 @@ gst_cdda_base_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
/* fallback duration: 4 bytes per sample, 44100 samples per second */
if (duration == GST_CLOCK_TIME_NONE) {
duration = gst_util_uint64_scale_int (GST_BUFFER_SIZE (buf) >> 2,
duration = gst_util_uint64_scale_int (gst_buffer_get_size (buf) >> 2,
GST_SECOND, 44100);
}
......
......@@ -908,18 +908,19 @@ gst_riff_create_video_caps (guint32 codec_fcc,
if (palette) {
GstBuffer *copy;
guint num_colors;
gsize size;
if (strf != NULL)
num_colors = strf->num_colors;
else
num_colors = 256;
if (GST_BUFFER_SIZE (palette) >= (num_colors * 4)) {
size = gst_buffer_get_size (palette);
if (size >= (num_colors * 4)) {
/* palette is always at least 256*4 bytes */
copy =
gst_buffer_new_and_alloc (MAX (GST_BUFFER_SIZE (palette), 256 * 4));
memcpy (GST_BUFFER_DATA (copy), GST_BUFFER_DATA (palette),
GST_BUFFER_SIZE (palette));
copy = gst_buffer_new_and_alloc (MAX (size, 256 * 4));
gst_buffer_copy_into (copy, palette, GST_BUFFER_COPY_MEMORY, 0, size);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
{
......@@ -1466,25 +1467,28 @@ gst_riff_create_audio_caps (guint16 codec_id,
guint16 valid_bits_per_sample;
guint32 channel_mask;
guint32 subformat_guid[4];
const guint8 *data;
guint8 *data;
gsize size;
channels_max = 8;
/* should be at least 22 bytes */
if (strf_data == NULL || GST_BUFFER_SIZE (strf_data) < 22) {
size = gst_buffer_get_size (strf_data);
if (strf_data == NULL || size < 22) {
GST_WARNING ("WAVE_FORMAT_EXTENSIBLE data size is %d (expected: 22)",
(strf_data) ? GST_BUFFER_SIZE (strf_data) : -1);
(strf_data) ? size : -1);
return NULL;
}
data = GST_BUFFER_DATA (strf_data);
data = gst_buffer_map (strf_data, &size, NULL, GST_MAP_READ);
valid_bits_per_sample = GST_READ_UINT16_LE (data);
channel_mask = GST_READ_UINT32_LE (data + 2);
subformat_guid[0] = GST_READ_UINT32_LE (data + 6);
subformat_guid[1] = GST_READ_UINT32_LE (data + 10);
subformat_guid[2] = GST_READ_UINT32_LE (data + 14);
subformat_guid[3] = GST_READ_UINT32_LE (data + 18);
gst_buffer_unmap (strf_data, data, size);
GST_DEBUG ("valid bps = %u", valid_bits_per_sample);
GST_DEBUG ("channel mask = 0x%08x", channel_mask);
......
......@@ -52,8 +52,10 @@ gst_riff_read_chunk (GstElement * element,
{
GstBuffer *buf;
GstFlowReturn res;
guint8 *data;
guint size;
guint64 offset = *_offset;
gsize bsize;
g_return_val_if_fail (element != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
......@@ -65,11 +67,13 @@ skip_junk:
size = 8;
if ((res = gst_pad_pull_range (pad, offset, size, &buf)) != GST_FLOW_OK)
return res;
else if (GST_BUFFER_SIZE (buf) < size)
else if (gst_buffer_get_size (buf) < size)
goto too_small;
*tag = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf) + 4);
data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
*tag = GST_READ_UINT32_LE (data);
size = GST_READ_UINT32_LE (data + 4);
gst_buffer_unmap (buf, data, bsize);
gst_buffer_unref (buf);
GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u",
......@@ -86,7 +90,7 @@ skip_junk:
if ((res = gst_pad_pull_range (pad, offset + 8, size, &buf)) != GST_FLOW_OK)
return res;
else if (GST_BUFFER_SIZE (buf) < size)
else if (gst_buffer_get_size (buf) < size)
goto too_small;
*_chunk_data = buf;
......@@ -99,7 +103,7 @@ too_small:
{
/* short read, we return UNEXPECTED to mark the EOS case */
GST_DEBUG_OBJECT (element, "not enough data (available=%u, needed=%u)",
GST_BUFFER_SIZE (buf), size);
gst_buffer_get_size (buf), size);
gst_buffer_unref (buf);
return GST_FLOW_UNEXPECTED;
}
......@@ -125,7 +129,8 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
{
guint size, bufsize;
guint32 fourcc;
guint8 *data;
guint8 *data, *ptr;
gsize bsize;
guint offset = *_offset;
g_return_val_if_fail (element != NULL, FALSE);
......@@ -137,7 +142,7 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
*chunk_data = NULL;
*_fourcc = 0;
bufsize = GST_BUFFER_SIZE (buf);
bufsize = gst_buffer_get_size (buf);
if (bufsize == offset)
goto end_offset;
......@@ -146,9 +151,11 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
goto too_small;
/* read header */
data = GST_BUFFER_DATA (buf) + offset;
fourcc = GST_READ_UINT32_LE (data);
size = GST_READ_UINT32_LE (data + 4);
data = ptr = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
ptr += offset;
fourcc = GST_READ_UINT32_LE (ptr);
size = GST_READ_UINT32_LE (ptr + 4);
gst_buffer_unmap (buf, data, bsize);
GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u",
GST_FOURCC_ARGS (fourcc), size);
......@@ -217,19 +224,21 @@ gst_riff_parse_file_header (GstElement * element,
{
guint8 *data;
guint32 tag;
gsize size;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (doctype != NULL, FALSE);
if (GST_BUFFER_SIZE (buf) < 12)
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
if (size < 12)
goto too_small;
data = GST_BUFFER_DATA (buf);
tag = GST_READ_UINT32_LE (data);
if (tag != GST_RIFF_TAG_RIFF && tag != GST_RIFF_TAG_AVF0)
goto not_riff;
*doctype = GST_READ_UINT32_LE (data + 8);
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
......@@ -240,7 +249,8 @@ too_small:
{
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
("Not enough data to parse RIFF header (%d available, %d needed)",
GST_BUFFER_SIZE (buf), 12));
size, 12));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return FALSE;
}
......@@ -249,6 +259,7 @@ not_riff:
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
("Stream is no RIFF stream: %" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (tag)));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return FALSE;
}
......@@ -272,14 +283,19 @@ gst_riff_parse_strh (GstElement * element,
GstBuffer * buf, gst_riff_strh ** _strh)
{
gst_riff_strh *strh;
guint8 *data;
gsize size;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (_strh != NULL, FALSE);
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strh))
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
if (size < sizeof (gst_riff_strh))
goto too_small;
strh = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
strh = g_memdup (data, size);
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
......@@ -329,7 +345,8 @@ too_small:
{
GST_ERROR_OBJECT (element,
"Too small strh (%d available, %d needed)",
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
size, (int) sizeof (gst_riff_strh));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return FALSE;
}
......@@ -357,15 +374,19 @@ gst_riff_parse_strf_vids (GstElement * element,
GstBuffer * buf, gst_riff_strf_vids ** _strf, GstBuffer ** data)
{
gst_riff_strf_vids *strf;
guint8 *bdata;
gsize size;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (_strf != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_vids))