summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2012-01-25 18:49:58 +0100
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2012-01-25 18:50:40 +0100
commit12ee41829c4e1d350adeb898c721724550620260 (patch)
treefa2f03da024198b1207562f09e82c96f2858ac8b /ext
parent7aead77649ed8c1531d4e969651452dcb40f8c70 (diff)
downloadgstreamer-plugins-bad-12ee41829c4e1d350adeb898c721724550620260.tar.gz
port some more to new memory API
Fixes #668677.
Diffstat (limited to 'ext')
-rw-r--r--ext/assrender/gstassrender.c21
-rw-r--r--ext/dts/gstdtsdec.c15
-rw-r--r--ext/faac/gstfaac.c22
-rw-r--r--ext/faad/gstfaad.c19
-rw-r--r--ext/flite/gstflitetestsrc.c6
-rw-r--r--ext/gme/gstgme.c17
-rw-r--r--ext/mplex/gstmplexoutputstream.cc5
-rw-r--r--ext/rtmp/gstrtmpsink.c11
-rw-r--r--ext/rtmp/gstrtmpsrc.c9
-rw-r--r--ext/voaacenc/gstvoaacenc.c40
-rw-r--r--ext/voamrwbenc/gstvoamrwbenc.c20
-rw-r--r--ext/vp8/gstvp8dec.c17
-rw-r--r--ext/vp8/gstvp8enc.c7
13 files changed, 111 insertions, 98 deletions
diff --git a/ext/assrender/gstassrender.c b/ext/assrender/gstassrender.c
index fb3978949..e4840c6b7 100644
--- a/ext/assrender/gstassrender.c
+++ b/ext/assrender/gstassrender.c
@@ -826,8 +826,7 @@ gst_ass_render_setcaps_text (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const GValue *value;
GstBuffer *priv;
- gchar *codec_private;
- gsize codec_private_size;
+ GstMapInfo map;
gboolean ret = FALSE;
structure = gst_caps_get_structure (caps, 0);
@@ -842,16 +841,14 @@ gst_ass_render_setcaps_text (GstPad * pad, GstCaps * caps)
priv = gst_value_get_buffer (value);
g_return_val_if_fail (priv != NULL, FALSE);
- codec_private =
- gst_buffer_map (priv, &codec_private_size, NULL, GST_MAP_READ);
+ gst_buffer_map (priv, &map, GST_MAP_READ);
if (!render->ass_track)
render->ass_track = ass_new_track (render->ass_library);
- ass_process_codec_private (render->ass_track,
- codec_private, codec_private_size);
+ ass_process_codec_private (render->ass_track, (char *) map.data, map.size);
- gst_buffer_unmap (priv, codec_private, codec_private_size);
+ gst_buffer_unmap (priv, &map);
GST_DEBUG_OBJECT (render, "ass track created");
@@ -877,8 +874,7 @@ static void
gst_ass_render_process_text (GstAssRender * render, GstBuffer * buffer,
GstClockTime running_time, GstClockTime duration)
{
- gchar *data;
- gsize size;
+ GstMapInfo map;
gdouble pts_start, pts_end;
pts_start = running_time;
@@ -891,13 +887,14 @@ gst_ass_render_process_text (GstAssRender * render, GstBuffer * buffer,
" and duration %" GST_TIME_FORMAT, GST_TIME_ARGS (running_time),
GST_TIME_ARGS (duration));
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
g_mutex_lock (&render->ass_mutex);
- ass_process_chunk (render->ass_track, data, size, pts_start, pts_end);
+ ass_process_chunk (render->ass_track, (gchar *) map.data, map.size,
+ pts_start, pts_end);
g_mutex_unlock (&render->ass_mutex);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
}
diff --git a/ext/dts/gstdtsdec.c b/ext/dts/gstdtsdec.c
index 74ef14c01..11fa3b219 100644
--- a/ext/dts/gstdtsdec.c
+++ b/ext/dts/gstdtsdec.c
@@ -488,6 +488,7 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
gboolean need_renegotiation = FALSE;
guint8 *data;
gsize size;
+ GstMapInfo map;
gint chans;
gint length = 0, flags, sample_rate, bit_rate, frame_length;
GstFlowReturn result = GST_FLOW_OK;
@@ -500,7 +501,9 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
return GST_FLOW_OK;
/* parsed stuff already, so this should work out fine */
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
g_assert (size >= 7);
bit_rate = dts->bit_rate;
@@ -585,12 +588,12 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
flags |= DCA_ADJUST_LEVEL;
dts->level = 1;
if (dca_frame (dts->state, data, &flags, &dts->level, dts->bias)) {
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
GST_AUDIO_DECODER_ERROR (dts, 1, STREAM, DECODE, (NULL),
("dts_frame error"), result);
goto exit;
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
channels = flags & (DCA_CHANNEL_MASK | DCA_LFE);
if (dts->using_channels != channels) {
@@ -621,7 +624,9 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
outbuf =
gst_buffer_new_and_alloc (256 * chans * (SAMPLE_WIDTH / 8) * num_blocks);
- data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
+ gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
+ data = map.data;
+ size = map.size;
{
guint8 *ptr = data;
for (i = 0; i < num_blocks; i++) {
@@ -645,7 +650,7 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
ptr += 256 * chans * (SAMPLE_WIDTH / 8);
}
}
- gst_buffer_unmap (outbuf, data, size);
+ gst_buffer_unmap (outbuf, &map);
result = gst_audio_decoder_finish_frame (bdec, outbuf, 1);
diff --git a/ext/faac/gstfaac.c b/ext/faac/gstfaac.c
index add4a4ff9..7ce63a84b 100644
--- a/ext/faac/gstfaac.c
+++ b/ext/faac/gstfaac.c
@@ -644,14 +644,13 @@ gst_faac_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *out_buf;
gsize size, ret_size;
+ GstMapInfo map, omap;
guint8 *data;
- guint8 *out_data;
- gsize out_size;
GstAudioInfo *info =
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (faac));
out_buf = gst_buffer_new_and_alloc (faac->bytes);
- out_data = gst_buffer_map (out_buf, &out_size, NULL, GST_MAP_WRITE);
+ gst_buffer_map (out_buf, &omap, GST_MAP_WRITE);
if (G_LIKELY (in_buf)) {
if (memcmp (info->position, aac_channel_positions[info->channels - 1],
@@ -661,26 +660,29 @@ gst_faac_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
info->channels, info->position,
aac_channel_positions[info->channels - 1]);
}
- data = gst_buffer_map (in_buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (in_buf, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
} else {
data = NULL;
size = 0;
}
if (G_UNLIKELY ((ret_size = faacEncEncode (faac->handle, (gint32 *) data,
- size / (info->finfo->width / 8), out_data, out_size)) < 0))
+ size / (info->finfo->width / 8), omap.data, omap.size)) < 0))
goto encode_failed;
if (in_buf)
- gst_buffer_unmap (in_buf, data, -1);
+ gst_buffer_unmap (in_buf, &map);
GST_LOG_OBJECT (faac, "encoder return: %" G_GSIZE_FORMAT, ret_size);
if (ret_size > 0) {
- gst_buffer_unmap (out_buf, out_data, ret_size);
+ gst_buffer_unmap (out_buf, &omap);
+ gst_buffer_resize (out_buf, 0, ret_size);
ret = gst_audio_encoder_finish_frame (enc, out_buf, faac->samples);
} else {
- gst_buffer_unmap (out_buf, out_data, 0);
+ gst_buffer_unmap (out_buf, &omap);
gst_buffer_unref (out_buf);
/* re-create encoder after final flush */
if (!in_buf) {
@@ -698,8 +700,8 @@ encode_failed:
{
GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
if (in_buf)
- gst_buffer_unmap (in_buf, data, -1);
- gst_buffer_unmap (out_buf, out_data, 0);
+ gst_buffer_unmap (in_buf, &map);
+ gst_buffer_unmap (out_buf, &omap);
gst_buffer_unref (out_buf);
return GST_FLOW_ERROR;
}
diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c
index 09fdf41fb..15902f6f8 100644
--- a/ext/faad/gstfaad.c
+++ b/ext/faad/gstfaad.c
@@ -262,6 +262,7 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
GstStructure *str = gst_caps_get_structure (caps, 0);
GstBuffer *buf;
const GValue *value;
+ GstMapInfo map;
guint8 *cdata;
gsize csize;
@@ -285,7 +286,9 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
buf = gst_value_get_buffer (value);
g_return_val_if_fail (buf != NULL, FALSE);
- cdata = gst_buffer_map (buf, &csize, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ cdata = map.data;
+ csize = map.size;
if (csize < 2)
goto wrong_length;
@@ -319,6 +322,7 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
faad->channels = 0;
faad->init = TRUE;
+ gst_buffer_unmap (buf, &map);
} else if ((value = gst_structure_get_value (str, "framed")) &&
g_value_get_boolean (value) == TRUE) {
faad->packetised = TRUE;
@@ -356,21 +360,21 @@ wrong_length:
{
GST_DEBUG_OBJECT (faad, "codec_data less than 2 bytes long");
gst_object_unref (faad);
- gst_buffer_unmap (buf, cdata, csize);
+ gst_buffer_unmap (buf, &map);
return FALSE;
}
open_failed:
{
GST_DEBUG_OBJECT (faad, "failed to create decoder");
gst_object_unref (faad);
- gst_buffer_unmap (buf, cdata, csize);
+ gst_buffer_unmap (buf, &map);
return FALSE;
}
init_failed:
{
GST_DEBUG_OBJECT (faad, "faacDecInit2() failed");
gst_object_unref (faad);
- gst_buffer_unmap (buf, cdata, csize);
+ gst_buffer_unmap (buf, &map);
return FALSE;
}
}
@@ -662,6 +666,7 @@ gst_faad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
{
GstFaad *faad;
GstFlowReturn ret = GST_FLOW_OK;
+ GstMapInfo map;
gsize input_size;
guchar *input_data;
GstBuffer *outbuf;
@@ -674,7 +679,9 @@ gst_faad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
if (G_UNLIKELY (!buffer))
return GST_FLOW_OK;
- input_data = gst_buffer_map (buffer, &input_size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ input_data = map.data;
+ input_size = map.size;
init:
/* init if not already done during capsnego */
@@ -763,7 +770,7 @@ init:
} while (FALSE);
out:
- gst_buffer_unmap (buffer, input_data, input_size);
+ gst_buffer_unmap (buffer, &map);
return ret;
diff --git a/ext/flite/gstflitetestsrc.c b/ext/flite/gstflitetestsrc.c
index c31fb96dc..0c9118b9c 100644
--- a/ext/flite/gstflitetestsrc.c
+++ b/ext/flite/gstflitetestsrc.c
@@ -444,6 +444,7 @@ gst_flite_test_src_create (GstBaseSrc * basesrc, guint64 offset,
GstBuffer *buf;
char *text;
int i;
+ GstMapInfo map;
gint16 *data;
cst_wave *wave;
gsize size;
@@ -460,12 +461,13 @@ gst_flite_test_src_create (GstBaseSrc * basesrc, guint64 offset,
size = src->info.channels * sizeof (gint16) * wave->num_samples;
buf = gst_buffer_new_and_alloc (size);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ data = (gint16 *) map.data;
memset (data, 0, size);
for (i = 0; i < wave->num_samples; i++) {
data[i * src->info.channels + src->channel] = wave->samples[i];
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
src->channel++;
if (src->channel == src->info.channels) {
diff --git a/ext/gme/gstgme.c b/ext/gme/gstgme.c
index 75d9ff423..a3cfdaaba 100644
--- a/ext/gme/gstgme.c
+++ b/ext/gme/gstgme.c
@@ -353,14 +353,14 @@ gst_gme_play (GstPad * pad)
const int NUM_SAMPLES = 1600; /* 4 bytes (stereo 16-bit) per sample */
if (!seeking) {
- short *data;
+ GstMapInfo map;
out = gst_buffer_new_and_alloc (NUM_SAMPLES * 4);
GST_BUFFER_TIMESTAMP (out) = gme_tell (gme->player) * GST_MSECOND;
- data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
- gme_err = gme_play (gme->player, NUM_SAMPLES * 2, data);
- gst_buffer_unmap (out, data, -1);
+ gst_buffer_map (out, &map, GST_MAP_WRITE);
+ gme_err = gme_play (gme->player, NUM_SAMPLES * 2, (short *) map.data);
+ gst_buffer_unmap (out, &map);
if (gme_err) {
GST_ELEMENT_ERROR (gme, STREAM, DEMUX, (NULL), (gme_err));
@@ -412,8 +412,7 @@ gme_setup (GstGmeDec * gme)
guint64 fade_time;
GstBuffer *buffer;
GstSegment seg;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
if (!gst_adapter_available (gme->adapter) || !gme_negotiate (gme)) {
return FALSE;
@@ -423,9 +422,9 @@ gme_setup (GstGmeDec * gme)
gst_adapter_take_buffer (gme->adapter,
gst_adapter_available (gme->adapter));
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- gme_err = gme_open_data (data, size, &gme->player, 32000);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ gme_err = gme_open_data (map.data, map.size, &gme->player, 32000);
+ gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
if (gme_err || !gme->player) {
diff --git a/ext/mplex/gstmplexoutputstream.cc b/ext/mplex/gstmplexoutputstream.cc
index 6be1ccad7..8f56540fd 100644
--- a/ext/mplex/gstmplexoutputstream.cc
+++ b/ext/mplex/gstmplexoutputstream.cc
@@ -101,12 +101,9 @@ void
GstMplexOutputStream::Write (guint8 * data, guint len)
{
GstBuffer *buf;
- gpointer bdata;
buf = gst_buffer_new_and_alloc (len);
- bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- memcpy (bdata, data, len);
- gst_buffer_unmap (buf, bdata, -1);
+ gst_buffer_fill (buf, 0, data, len);
size += len;
GST_MPLEX_MUTEX_LOCK (mplex);
diff --git a/ext/rtmp/gstrtmpsink.c b/ext/rtmp/gstrtmpsink.c
index 23d580cfd..17a2865c6 100644
--- a/ext/rtmp/gstrtmpsink.c
+++ b/ext/rtmp/gstrtmpsink.c
@@ -205,8 +205,7 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstRTMPSink *sink = GST_RTMP_SINK (bsink);
GstBuffer *reffed_buf = NULL;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
if (sink->first) {
/* open the connection */
@@ -244,12 +243,12 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GST_LOG_OBJECT (sink, "Sending %" G_GSIZE_FORMAT " bytes to RTMP server",
gst_buffer_get_size (buf));
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
- if (!RTMP_Write (sink->rtmp, (char *) data, size))
+ if (!RTMP_Write (sink->rtmp, (char *) map.data, map.size))
goto write_failed;
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
if (reffed_buf)
gst_buffer_unref (reffed_buf);
@@ -259,7 +258,7 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
write_failed:
{
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL), ("Failed to write data"));
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
if (reffed_buf)
gst_buffer_unref (reffed_buf);
return GST_FLOW_ERROR;
diff --git a/ext/rtmp/gstrtmpsrc.c b/ext/rtmp/gstrtmpsrc.c
index 1f0ba8519..5b4fe1a6e 100644
--- a/ext/rtmp/gstrtmpsrc.c
+++ b/ext/rtmp/gstrtmpsrc.c
@@ -294,7 +294,8 @@ gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
{
GstRTMPSrc *src;
GstBuffer *buf;
- guint8 *data, *bdata;
+ GstMapInfo map;
+ guint8 *data;
guint todo;
gsize bsize;
int read;
@@ -316,7 +317,8 @@ gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
}
bsize = todo = size;
- bdata = data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ data = map.data;
read = bsize = 0;
while (todo > 0) {
@@ -342,7 +344,8 @@ gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
}
GST_LOG (" got size %d", read);
}
- gst_buffer_unmap (buf, bdata, bsize);
+ gst_buffer_unmap (buf, &map);
+ gst_buffer_resize (buf, 0, bsize);
if (src->discont) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
diff --git a/ext/voaacenc/gstvoaacenc.c b/ext/voaacenc/gstvoaacenc.c
index 9f48ed840..ec12312fa 100644
--- a/ext/voaacenc/gstvoaacenc.c
+++ b/ext/voaacenc/gstvoaacenc.c
@@ -361,14 +361,14 @@ gst_voaacenc_create_source_pad_caps (GstVoAacEnc * voaacenc)
GstCaps *caps = NULL;
gint index;
GstBuffer *codec_data;
- guint8 *data;
+ GstMapInfo map;
if ((index = gst_voaacenc_get_rate_index (voaacenc->rate)) >= 0) {
codec_data = gst_buffer_new_and_alloc (VOAAC_ENC_CODECDATA_LEN);
- data = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (codec_data, &map, GST_MAP_WRITE);
/* LC profile only */
- data[0] = ((0x02 << 3) | (index >> 1));
- data[1] = ((index & 0x01) << 7) | (voaacenc->channels << 3);
+ map.data[0] = ((0x02 << 3) | (index >> 1));
+ map.data[1] = ((index & 0x01) << 7) | (voaacenc->channels << 3);
caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, VOAAC_ENC_MPEGVERSION,
@@ -378,9 +378,9 @@ gst_voaacenc_create_source_pad_caps (GstVoAacEnc * voaacenc)
(voaacenc->output_format ? "adts" : "raw")
, NULL);
- gst_codec_utils_aac_caps_set_level_and_profile (caps, data,
+ gst_codec_utils_aac_caps_set_level_and_profile (caps, map.data,
VOAAC_ENC_CODECDATA_LEN);
- gst_buffer_unmap (codec_data, data, -1);
+ gst_buffer_unmap (codec_data, &map);
if (!voaacenc->output_format) {
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, codec_data,
@@ -436,8 +436,7 @@ gst_voaacenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
VO_AUDIO_OUTPUTINFO output_info = { {0} };
VO_CODECBUFFER input = { 0 };
VO_CODECBUFFER output = { 0 };
- gsize size;
- guint8 *data, *out_data;
+ GstMapInfo map, omap;
GstAudioInfo *info = gst_audio_encoder_get_audio_info (benc);
voaacenc = GST_VOAACENC (benc);
@@ -458,39 +457,40 @@ gst_voaacenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
aac_channel_positions[info->channels - 1]);
}
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
- if (G_UNLIKELY (size < voaacenc->inbuf_size)) {
- gst_buffer_unmap (buf, data, -1);
- GST_DEBUG_OBJECT (voaacenc, "discarding trailing data %d", (gint) size);
+ if (G_UNLIKELY (map.size < voaacenc->inbuf_size)) {
+ gst_buffer_unmap (buf, &map);
+ GST_DEBUG_OBJECT (voaacenc, "discarding trailing data %d", (gint) map.size);
ret = gst_audio_encoder_finish_frame (benc, NULL, -1);
goto exit;
}
/* max size */
out = gst_buffer_new_and_alloc (voaacenc->inbuf_size);
- out_data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (out, &omap, GST_MAP_WRITE);
- output.Buffer = out_data;
+ output.Buffer = omap.data;
output.Length = voaacenc->inbuf_size;
- g_assert (size == voaacenc->inbuf_size);
- input.Buffer = data;
+ g_assert (map.size == voaacenc->inbuf_size);
+ input.Buffer = map.data;
input.Length = voaacenc->inbuf_size;
voaacenc->codec_api.SetInputData (voaacenc->handle, &input);
/* encode */
if (voaacenc->codec_api.GetOutputData (voaacenc->handle, &output,
&output_info) != VO_ERR_NONE) {
- gst_buffer_unmap (buf, data, -1);
- gst_buffer_unmap (out, out_data, -1);
+ gst_buffer_unmap (buf, &map);
+ gst_buffer_unmap (out, &omap);
gst_buffer_unref (out);
goto encode_failed;
}
GST_LOG_OBJECT (voaacenc, "encoded to %d bytes", output.Length);
- gst_buffer_unmap (out, out_data, output.Length);
- gst_buffer_unmap (buf, data, -1);
+ gst_buffer_unmap (buf, &map);
+ gst_buffer_unmap (out, &omap);
+ gst_buffer_resize (out, 0, output.Length);
ret = gst_audio_encoder_finish_frame (benc, out, 1024);
diff --git a/ext/voamrwbenc/gstvoamrwbenc.c b/ext/voamrwbenc/gstvoamrwbenc.c
index 0721c87f1..304ef1d3e 100644
--- a/ext/voamrwbenc/gstvoamrwbenc.c
+++ b/ext/voamrwbenc/gstvoamrwbenc.c
@@ -268,8 +268,7 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
const int buffer_size = sizeof (short) * L_FRAME16k;
GstBuffer *out;
gint outsize;
- gsize size;
- guint8 *data, *outdata;
+ GstMapInfo map, omap;
amrwbenc = GST_VOAMRWBENC (benc);
@@ -281,24 +280,25 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
goto done;
}
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
- if (G_UNLIKELY (size < buffer_size)) {
- GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d", (gint) size);
- gst_buffer_unmap (buffer, data, -1);
+ if (G_UNLIKELY (map.size < buffer_size)) {
+ GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d", (gint) map.size);
+ gst_buffer_unmap (buffer, &map);
ret = gst_audio_encoder_finish_frame (benc, NULL, -1);
goto done;
}
out = gst_buffer_new_and_alloc (buffer_size);
- outdata = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (out, &omap, GST_MAP_WRITE);
/* encode */
outsize = E_IF_encode (amrwbenc->handle, amrwbenc->bandmode,
- (const short *) data, (unsigned char *) outdata, 0);
+ (const short *) map.data, (unsigned char *) omap.data, 0);
GST_LOG_OBJECT (amrwbenc, "encoded to %d bytes", outsize);
- gst_buffer_unmap (out, outdata, outsize);
- gst_buffer_unmap (buffer, data, -1);
+ gst_buffer_unmap (out, &omap);
+ gst_buffer_unmap (buffer, &map);
+ gst_buffer_resize (out, 0, outsize);
ret = gst_audio_encoder_finish_frame (benc, out, L_FRAME16k);
diff --git a/ext/vp8/gstvp8dec.c b/ext/vp8/gstvp8dec.c
index c4d17a7b7..f00347a7b 100644
--- a/ext/vp8/gstvp8dec.c
+++ b/ext/vp8/gstvp8dec.c
@@ -366,8 +366,7 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder,
vpx_image_t *img;
long decoder_deadline = 0;
GstClockTimeDiff deadline;
- gsize size;
- gpointer data;
+ GstMapInfo map;
GST_DEBUG_OBJECT (decoder, "handle_frame");
@@ -383,13 +382,13 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder,
memset (&stream_info, 0, sizeof (stream_info));
stream_info.sz = sizeof (stream_info);
- data = gst_buffer_map (frame->sink_buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (frame->sink_buffer, &map, GST_MAP_READ);
status =
- vpx_codec_peek_stream_info (&vpx_codec_vp8_dx_algo, data, size,
+ vpx_codec_peek_stream_info (&vpx_codec_vp8_dx_algo, map.data, map.size,
&stream_info);
- gst_buffer_unmap (frame->sink_buffer, data, size);
+ gst_buffer_unmap (frame->sink_buffer, &map);
if (status != VPX_CODEC_OK || !stream_info.is_kf) {
GST_WARNING_OBJECT (decoder, "No keyframe, skipping");
@@ -456,11 +455,13 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder,
decoder_deadline = MAX (1, deadline / GST_MSECOND);
}
- data = gst_buffer_map (frame->sink_buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (frame->sink_buffer, &map, GST_MAP_READ);
- status = vpx_codec_decode (&dec->decoder, data, size, NULL, decoder_deadline);
+ status =
+ vpx_codec_decode (&dec->decoder, map.data, map.size, NULL,
+ decoder_deadline);
- gst_buffer_unmap (frame->sink_buffer, data, size);
+ gst_buffer_unmap (frame->sink_buffer, &map);
if (status) {
GST_ELEMENT_ERROR (decoder, LIBRARY, ENCODE,
diff --git a/ext/vp8/gstvp8enc.c b/ext/vp8/gstvp8enc.c
index ea92a76ce..0652ffd00 100644
--- a/ext/vp8/gstvp8enc.c
+++ b/ext/vp8/gstvp8enc.c
@@ -854,7 +854,7 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
const GstTagList *iface_tags;
GValue array = { 0, };
GValue value = { 0, };
- gsize size;
+ GstMapInfo map;
s = gst_caps_get_structure (caps, 0);
/* put buffers in a fixed list */
@@ -863,7 +863,8 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
/* Create Ogg stream-info */
stream_hdr = gst_buffer_new_and_alloc (26);
- data = gst_buffer_map (stream_hdr, &size, NULL, GST_MAP_WRITE);
+ gst_buffer_map (stream_hdr, &map, GST_MAP_WRITE);
+ data = map.data;
GST_WRITE_UINT8 (data, 0x4F);
GST_WRITE_UINT32_BE (data + 1, 0x56503830); /* "VP80" */
@@ -877,7 +878,7 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
GST_WRITE_UINT32_BE (data + 18, info->fps_n);
GST_WRITE_UINT32_BE (data + 22, info->fps_d);
- gst_buffer_unmap (stream_hdr, data, size);
+ gst_buffer_unmap (stream_hdr, &map);
GST_BUFFER_FLAG_SET (stream_hdr, GST_BUFFER_FLAG_IN_CAPS);
gst_value_set_buffer (&value, stream_hdr);