Commit fcdc385a authored by Wim Taymans's avatar Wim Taymans

port to new map API

parent 130a8335
......@@ -716,8 +716,7 @@ gst_visual_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
gboolean need_skip;
const guint16 *data;
guint64 dist, timestamp;
guint8 *outdata;
gsize outsize;
GstMapInfo outmap;
GST_DEBUG_OBJECT (visual, "processing buffer");
......@@ -855,12 +854,12 @@ gst_visual_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
goto beach;
}
}
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
visual_video_set_buffer (visual->video, outdata);
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
visual_video_set_buffer (visual->video, outmap.data);
visual_audio_analyze (visual->audio);
visual_actor_run (visual->actor, visual->audio);
visual_video_set_buffer (visual->video, NULL);
gst_buffer_unmap (outbuf, outdata, outsize);
gst_buffer_unmap (outbuf, &outmap);
GST_DEBUG_OBJECT (visual, "rendered one frame");
gst_adapter_unmap (visual->adapter);
......
......@@ -197,8 +197,9 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const GValue *codec_data;
GstBuffer *buffer;
guint8 *data, *ptr;
gsize size, left;
GstMapInfo map;
guint8 *ptr;
gsize left;
guint32 sizes[3];
GstCaps *outcaps;
gint i, offs;
......@@ -222,10 +223,10 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
/* first 22 bytes are bits_per_sample, channel_mask, GUID
* Then we get 3 LE guint32 with the 3 header sizes
* then we get the bytes of the 3 headers. */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
ptr = data;
left = size;
ptr = map.data;
left = map.size;
GST_LOG_OBJECT (ogg, "configuring codec_data of size %" G_GSIZE_FORMAT, left);
......@@ -267,7 +268,7 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
offs += sizes[i];
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
return TRUE;
......@@ -285,7 +286,7 @@ wrong_format:
buffer_too_small:
{
GST_DEBUG_OBJECT (ogg, "codec_data is too small");
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
return FALSE;
}
}
......
......@@ -790,8 +790,8 @@ gst_ogg_mux_decorate_buffer (GstOggMux * ogg_mux, GstOggPadData * pad,
gint64 duration, granule, limit;
GstClockTime next_time;
GstClockTimeDiff diff;
GstMapInfo map;
ogg_packet packet;
gsize size;
/* ensure messing with metadata is ok */
buf = gst_buffer_make_writable (buf);
......@@ -813,10 +813,11 @@ gst_ogg_mux_decorate_buffer (GstOggMux * ogg_mux, GstOggPadData * pad,
pad->map.granulerate_n <= 0 || pad->map.granulerate_d <= 0)
goto no_granule;
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
duration = gst_ogg_stream_get_packet_duration (&pad->map, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
/* give up if no duration can be determined, relying on upstream */
if (G_UNLIKELY (duration < 0)) {
......@@ -946,10 +947,11 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux, gboolean * popped)
/* and we have one */
ogg_packet packet;
gboolean is_header;
gsize size;
GstMapInfo map;
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
/* if we're not yet in data mode, ensure we're setup on the first packet */
if (!pad->have_type) {
......@@ -989,7 +991,7 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux, gboolean * popped)
else /* fallback (FIXME 0.11: remove IN_CAPS hack) */
is_header = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
if (is_header) {
GST_DEBUG_OBJECT (ogg_mux,
......@@ -1160,12 +1162,14 @@ gst_ogg_mux_submit_skeleton_header_packet (GstOggMux * mux,
ogg_stream_state * os, GstBuffer * buf, gboolean bos, gboolean eos)
{
ogg_packet packet;
gsize size;
GstMapInfo map;
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
gst_ogg_mux_create_header_packet_with_flags (&packet, bos, eos);
ogg_stream_packetin (os, &packet);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
}
......@@ -1354,7 +1358,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
GstCaps *caps;
GstStructure *structure;
GstBuffer *hbuf;
gsize size;
GstMapInfo map;
pad = (GstOggPadData *) walk->data;
thepad = pad->collect.pad;
......@@ -1383,15 +1387,16 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
}
/* create a packet from the buffer */
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
gst_ogg_mux_create_header_packet (&packet, pad);
/* swap the packet in */
ogg_stream_packetin (&pad->map.stream, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
GST_LOG_OBJECT (thepad, "flushing out BOS page");
......@@ -1452,19 +1457,20 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
GstBuffer *buf = GST_BUFFER (hwalk->data);
ogg_packet packet;
ogg_page page;
gsize size;
GstMapInfo map;
hwalk = hwalk->next;
/* create a packet from the buffer */
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
gst_ogg_mux_create_header_packet (&packet, pad);
/* swap the packet in */
ogg_stream_packetin (&pad->map.stream, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
/* if last header, flush page */
......@@ -1655,7 +1661,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GstOggPadData *pad = ogg_mux->pulling;
gint64 duration;
gboolean force_flush;
gsize size;
GstMapInfo map;
GST_LOG_OBJECT (ogg_mux->pulling->collect.pad, "pulling from pad");
......@@ -1679,8 +1685,9 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
}
/* create a packet from the buffer */
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
if (packet.granulepos == -1)
packet.granulepos = 0;
......@@ -1770,7 +1777,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GST_DEBUG_OBJECT (pad->collect.pad, "swapping in BOS packet");
ogg_stream_packetin (&pad->map.stream, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
pad->data_pushed = TRUE;
gp_time = GST_BUFFER_OFFSET (pad->buffer);
......
......@@ -288,11 +288,10 @@ static GstFlowReturn
gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
{
gsize size;
guint8 *data;
gchar *oggbuffer;
GstFlowReturn ret = GST_FLOW_OK;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
size = gst_buffer_get_size (buffer);
GST_DEBUG_OBJECT (ogg, "submitting %" G_GSIZE_FORMAT " bytes", size);
if (G_UNLIKELY (size == 0))
......@@ -306,7 +305,7 @@ gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
goto done;
}
memcpy (oggbuffer, data, size);
size = gst_buffer_extract (buffer, 0, oggbuffer, size);
if (G_UNLIKELY (ogg_sync_wrote (&ogg->sync, size) < 0)) {
GST_ELEMENT_ERROR (ogg, STREAM, DECODE, (NULL),
("failed to write %" G_GSIZE_FORMAT " bytes to the sync buffer", size));
......@@ -314,7 +313,6 @@ gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
}
done:
gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
......
......@@ -2188,8 +2188,7 @@ gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
const GValue *streamheader;
const GValue *first_element;
ogg_packet packet;
guint8 *data;
gsize size;
GstMapInfo map;
gboolean ret;
GST_INFO ("Checking streamheader on caps %" GST_PTR_FORMAT, caps);
......@@ -2228,21 +2227,20 @@ gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
return FALSE;
}
data = gst_buffer_map (buf, &size, 0, GST_MAP_READ);
if (data == NULL || size == 0) {
if (!gst_buffer_map (buf, &map, GST_MAP_READ) || map.size == 0) {
GST_ERROR ("invalid first streamheader buffer");
return FALSE;
}
GST_MEMDUMP ("streamheader", data, size);
GST_MEMDUMP ("streamheader", map.data, map.size);
packet.packet = data;
packet.bytes = size;
packet.packet = map.data;
packet.bytes = map.size;
GST_INFO ("Found headers on caps, using those to determine type");
ret = gst_ogg_stream_setup_map (pad, &packet);
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
return ret;
}
......@@ -717,17 +717,18 @@ gst_ogm_parse_comment_packet (GstOgmParse * ogm, GstBuffer * buf)
static void
gst_ogm_text_parse_strip_trailing_zeroes (GstOgmParse * ogm, GstBuffer * buf)
{
guint8 *data;
GstMapInfo map;
gsize size;
g_assert (gst_buffer_is_writable (buf));
/* zeroes are not valid UTF-8 characters, so strip them from output */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
while (size > 0 && data[size - 1] == '\0') {
gst_buffer_map (buf, &map, GST_MAP_WRITE);
size = map.size;
while (size > 0 && map.data[size - 1] == '\0') {
--size;
}
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
}
static GstFlowReturn
......@@ -845,18 +846,17 @@ gst_ogm_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstOgmParse *ogm = GST_OGM_PARSE (parent);
guint8 *data;
gsize size;
GstMapInfo map;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
if (size < 1)
gst_buffer_map (buf, &map, GST_MAP_READ);
if (map.size < 1)
goto buffer_too_small;
GST_LOG_OBJECT (ogm, "Packet with start code 0x%02x", data[0]);
GST_LOG_OBJECT (ogm, "Packet with start code 0x%02x", map.data[0]);
switch (data[0]) {
switch (map.data[0]) {
case 0x01:{
ret = gst_ogm_parse_stream_header (ogm, data + 1, size - 1);
ret = gst_ogm_parse_stream_header (ogm, map.data + 1, map.size - 1);
break;
}
case 0x03:{
......@@ -864,12 +864,12 @@ gst_ogm_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
break;
}
default:{
ret = gst_ogm_parse_data_packet (ogm, buf, data, size);
ret = gst_ogm_parse_data_packet (ogm, buf, map.data, map.size);
break;
}
}
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
if (ret != GST_FLOW_OK) {
......@@ -882,7 +882,7 @@ gst_ogm_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
buffer_too_small:
{
GST_ELEMENT_ERROR (ogm, STREAM, DECODE, (NULL), ("buffer too small"));
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
......
......@@ -2612,13 +2612,13 @@ wait_for_text_buf:
/* Push the video frame */
ret = gst_pad_push (overlay->srcpad, buffer);
} else {
gchar *in_text, *otext;
gsize in_size, osize;
GstMapInfo map;
gchar *in_text;
gsize in_size;
otext =
gst_buffer_map (overlay->text_buffer, &osize, NULL, GST_MAP_READ);
in_text = otext;
in_size = osize;
gst_buffer_map (overlay->text_buffer, &map, GST_MAP_READ);
in_text = (gchar *) map.data;
in_size = map.size;
/* g_markup_escape_text() absolutely requires valid UTF8 input, it
* might crash otherwise. We don't fall back on GST_SUBTITLE_ENCODING
......@@ -2652,11 +2652,11 @@ wait_for_text_buf:
GST_DEBUG_OBJECT (overlay, "No text to render (empty buffer)");
gst_base_text_overlay_render_text (overlay, " ", 1);
}
gst_buffer_unmap (overlay->text_buffer, otext, osize);
if (in_text != otext)
if (in_text != (gchar *) map.data)
g_free (in_text);
gst_buffer_unmap (overlay->text_buffer, &map);
GST_OBJECT_UNLOCK (overlay);
ret = gst_base_text_overlay_push_frame (overlay, buffer);
......
......@@ -471,6 +471,7 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
GstFlowReturn ret;
GstBuffer *outbuf;
GstCaps *caps = NULL, *padcaps;
GstMapInfo map;
guint8 *data;
gsize size;
gint n;
......@@ -478,7 +479,9 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
render = GST_TEXT_RENDER (parent);
data = gst_buffer_map (inbuf, &size, NULL, GST_MAP_READ);
gst_buffer_map (inbuf, &map, GST_MAP_READ);
data = map.data;
size = map.size;
/* somehow pango barfs over "\0" buffers... */
while (size > 0 &&
......@@ -491,7 +494,7 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
GST_DEBUG ("rendering '%*s'", (gint) size, data);
pango_layout_set_markup (render->layout, (gchar *) data, size);
gst_text_render_render_pangocairo (render);
gst_buffer_unmap (inbuf, data, size);
gst_buffer_unmap (inbuf, &map);
gst_text_render_check_argb (render);
......@@ -517,7 +520,10 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
outbuf = gst_buffer_new_and_alloc (render->width * render->height * 4);
gst_buffer_copy_into (outbuf, inbuf, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
data = map.data;
size = map.size;
if (render->use_ARGB) {
memset (data, 0, render->width * render->height * 4);
......@@ -566,7 +572,7 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
render->width * 4);
}
}
gst_buffer_unmap (outbuf, data, size);
gst_buffer_unmap (outbuf, &map);
ret = gst_pad_push (render->srcpad, outbuf);
......
......@@ -691,17 +691,18 @@ theora_dec_setcaps (GstTheoraDec * dec, GstCaps * caps)
if ((codec_data = gst_structure_get_value (s, "codec_data"))) {
if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
GstBuffer *buffer;
guint8 *data, *ptr;
gsize size, left;
GstMapInfo map;
guint8 *ptr;
gsize left;
guint offset;
buffer = gst_value_get_buffer (codec_data);
offset = 0;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
ptr = data;
left = size;
ptr = map.data;
left = map.size;
while (left > 2) {
guint psize;
......@@ -731,7 +732,7 @@ theora_dec_setcaps (GstTheoraDec * dec, GstCaps * caps)
ptr += psize;
offset += psize;
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
}
}
......@@ -1354,11 +1355,12 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
ogg_packet packet;
GstFlowReturn result = GST_FLOW_OK;
GstClockTime timestamp, duration;
gsize size;
GstMapInfo map;
/* make ogg_packet out of the buffer */
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
packet.granulepos = -1;
packet.packetno = 0; /* we don't really care */
packet.b_o_s = dec->have_header ? 0 : 1;
......@@ -1387,7 +1389,7 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
result = theora_handle_data_packet (dec, &packet, timestamp, duration);
}
done:
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
return result;
}
......
......@@ -1086,21 +1086,21 @@ theora_enc_read_multipass_cache (GstTheoraEnc * enc)
while (!done) {
if (gst_adapter_available (enc->multipass_cache_adapter) == 0) {
guint8 *data;
gsize size;
GstMapInfo map;
cache_buf = gst_buffer_new_and_alloc (512);
data = gst_buffer_map (cache_buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (cache_buf, &map, GST_MAP_READ);
stat = g_io_channel_read_chars (enc->multipass_cache_fd,
(gchar *) data, size, &bytes_read, NULL);
(gchar *) map.data, map.size, &bytes_read, NULL);
if (bytes_read <= 0) {
gst_buffer_unmap (cache_buf, data, 0);
gst_buffer_unmap (cache_buf, &map);
gst_buffer_unref (cache_buf);
break;
} else {
gst_buffer_unmap (cache_buf, data, bytes_read);
gst_buffer_unmap (cache_buf, &map);
gst_buffer_resize (cache_buf, 0, bytes_read);
gst_adapter_push (enc->multipass_cache_adapter, cache_buf);
}
}
......
......@@ -300,20 +300,21 @@ theora_parse_set_streamheader (GstTheoraParse * parse)
ogg_packet packet;
GstBuffer *buf;
int ret;
gsize size;
GstMapInfo map;
buf = parse->streamheader[i];
if (buf == NULL)
continue;
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
gst_buffer_map (buf, &map, GST_MAP_READ);
packet.packet = map.data;
packet.bytes = map.size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
packet.packetno = i + 1;
packet.e_o_s = 0;
packet.b_o_s = (i == 0);
ret = th_decode_headerin (&parse->info, &parse->comment, &setup, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unmap (buf, &map);
if (ret < 0) {
GST_WARNING_OBJECT (parse, "Failed to decode Theora header %d: %d\n",
i + 1, ret);
......@@ -645,19 +646,19 @@ theora_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstFlowReturn ret;
GstTheoraParse *parse;
guint8 *data, header;
gsize size;
GstMapInfo map;
guint8 header;
gboolean have_header;
parse = GST_THEORA_PARSE (parent);
have_header = FALSE;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
header = data[0];
gst_buffer_unmap (buffer, data, size);
gst_buffer_map (buffer, &map, GST_MAP_READ);
header = map.data[0];
gst_buffer_unmap (buffer, &map);
if (size >= 1) {
if (map.size >= 1) {
if (header & 0x80)
have_header = TRUE;
}
......
......@@ -442,13 +442,14 @@ vorbis_dec_handle_header_buffer (GstVorbisDec * vd, GstBuffer * buffer)
ogg_packet *packet;
ogg_packet_wrapper packet_wrapper;
GstFlowReturn ret;
GstMapInfo map;
gst_ogg_packet_wrapper_map (&packet_wrapper, buffer);
gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map);
packet = gst_ogg_packet_from_wrapper (&packet_wrapper);
ret = vorbis_handle_header_packet (vd, packet);
gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer);
gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map);
return ret;
}
......@@ -518,7 +519,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
guint sample_count;
GstBuffer *out = NULL;
GstFlowReturn result;
guint8 *data;
GstMapInfo map;
gsize size;
if (G_UNLIKELY (!vd->initialized)) {
......@@ -563,10 +564,10 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
/* alloc buffer for it */
out = gst_buffer_new_allocate (NULL, size, 0);
data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (out, &map, GST_MAP_WRITE);
/* get samples ready for reading now, should be sample_count */
#ifdef USE_TREMOLO
if (G_UNLIKELY (vorbis_dsp_pcmout (&vd->vd, data, sample_count) !=
if (G_UNLIKELY (vorbis_dsp_pcmout (&vd->vd, map.data, sample_count) !=
sample_count))
#else
if (G_UNLIKELY (vorbis_synthesis_pcmout (&vd->vd, &pcm) != sample_count))
......@@ -575,17 +576,17 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
#ifdef USE_TREMOLO
if (vd->info.channels < 9)
gst_audio_reorder_channels (data, size, GST_VORBIS_AUDIO_FORMAT,
gst_audio_reorder_channels (map.data, map.size, GST_VORBIS_AUDIO_FORMAT,
vd->info.channels, gst_vorbis_channel_positions[vd->info.channels - 1],
gst_vorbis_default_channel_positions[vd->info.channels - 1]);
#else
/* copy samples in buffer */
vd->copy_samples ((vorbis_sample_t *) data, pcm,
vd->copy_samples ((vorbis_sample_t *) map.data, pcm,
sample_count, vd->info.channels);
#endif
GST_LOG_OBJECT (vd, "setting output size to %" G_GSIZE_FORMAT, size);
gst_buffer_unmap (out, data, size);
GST_LOG_OBJECT (vd, "have output size of %" G_GSIZE_FORMAT, size);
gst_buffer_unmap (out, &map);
done:
/* whether or not data produced, consume one frame and advance time */
......@@ -633,6 +634,7 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
ogg_packet *packet;
ogg_packet_wrapper packet_wrapper;
GstFlowReturn result = GST_FLOW_OK;
GstMapInfo map;
GstVorbisDec *vd = GST_VORBIS_DEC (dec);
/* no draining etc */
......@@ -641,7 +643,7 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
GST_LOG_OBJECT (vd, "got buffer %p", buffer);
/* make ogg_packet out of the buffer */
gst_ogg_packet_wrapper_map (&packet_wrapper, buffer);
gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map);
packet = gst_ogg_packet_from_wrapper (&packet_wrapper);
/* set some more stuff */
packet->granulepos = -1;
......@@ -680,7 +682,7 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
done:
GST_LOG_OBJECT (vd, "unmap buffer %p", buffer);
gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer);
gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map);
return result;
......
......@@ -63,19 +63,18 @@ gst_ogg_packet_size (ogg_packet * p)
}
static inline void
gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer)
gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
{
gsize size;
gst_buffer_ref (buffer);
packet->packet = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
packet->bytes = size;
gst_buffer_map (buffer, map, GST_MAP_READ);
packet->packet = map->data;
packet->bytes = map->size;
}
static inline void
gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer)
gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
{
gst_buffer_unmap (buffer, packet->packet, packet->bytes);
gst_buffer_unmap (buffer, map);
gst_buffer_unref (buffer);
}
......
......@@ -678,9 +678,9 @@ gst_vorbis_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
{
GstVorbisEnc *vorbisenc;
GstFlowReturn ret = GST_FLOW_OK;
gfloat *data, *ptr;
GstMapInfo map;
gfloat *ptr;
gulong size;
gsize bsize;
gulong i, j;
float **vorbis_buffer;
GstBuffer *buf1, *buf2, *buf3;
......@@ -747,12 +747,11 @@ gst_vorbis_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)