Commit f379a5da authored by Wim Taymans's avatar Wim Taymans

plugins: more porting to new memory API

parent 52447707
......@@ -651,6 +651,8 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
gboolean need_skip;
const guint16 *data;
guint64 dist, timestamp;
guint8 *outdata;
gsize outsize;
GST_DEBUG_OBJECT (visual, "processing buffer");
......@@ -697,7 +699,7 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
/* Read VISUAL_SAMPLES samples per channel */
data =
(const guint16 *) gst_adapter_peek (visual->adapter,
(const guint16 *) gst_adapter_map (visual->adapter,
VISUAL_SAMPLES * visual->bps);
#if defined(VISUAL_API_VERSION) && VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
......@@ -783,15 +785,20 @@ gst_visual_chain (GstPad * pad, GstBuffer * buffer)
if (outbuf == NULL) {
ret = get_buffer (visual, &outbuf);
if (ret != GST_FLOW_OK) {
gst_adapter_unmap (visual->adapter, 0);
goto beach;
}
}
visual_video_set_buffer (visual->video, GST_BUFFER_DATA (outbuf));
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
visual_video_set_buffer (visual->video, outdata);
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_DEBUG_OBJECT (visual, "rendered one frame");
gst_adapter_unmap (visual->adapter, 0);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = visual->duration;
......
......@@ -196,8 +196,8 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const GValue *codec_data;
GstBuffer *buffer;
guint8 *data;
guint size;
guint8 *data, *ptr;
gsize size, left;
guint32 sizes[3];
GstCaps *outcaps;
gint i, offs;
......@@ -221,31 +221,33 @@ 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_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
ptr = data;
left = size;
GST_LOG_OBJECT (ogg, "configuring codec_data of size %u", size);
GST_LOG_OBJECT (ogg, "configuring codec_data of size %u", left);
/* skip headers */
data += 22;
size -= 22;
ptr += 22;
left -= 22;
/* we need at least 12 bytes for the packet sizes of the 3 headers */
if (size < 12)
if (left < 12)
goto buffer_too_small;
/* read sizes of the 3 headers */
sizes[0] = GST_READ_UINT32_LE (data);
sizes[1] = GST_READ_UINT32_LE (data + 4);
sizes[2] = GST_READ_UINT32_LE (data + 8);
sizes[0] = GST_READ_UINT32_LE (ptr);
sizes[1] = GST_READ_UINT32_LE (ptr + 4);
sizes[2] = GST_READ_UINT32_LE (ptr + 8);
GST_DEBUG_OBJECT (ogg, "header sizes: %u %u %u", sizes[0], sizes[1],
sizes[2]);
size -= 12;
left -= 12;
/* and we need at least enough data for all the headers */
if (size < sizes[0] + sizes[1] + sizes[2])
if (left < sizes[0] + sizes[1] + sizes[2])
goto buffer_too_small;
/* set caps */
......@@ -264,6 +266,7 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
offs += sizes[i];
}
gst_buffer_unmap (buffer, data, size);
gst_caps_unref (outcaps);
return TRUE;
......@@ -282,6 +285,7 @@ wrong_format:
buffer_too_small:
{
GST_DEBUG_OBJECT (ogg, "codec_data is too small");
gst_buffer_unmap (buffer, data, size);
return FALSE;
}
}
......@@ -319,7 +323,7 @@ gst_ogg_avi_parse_push_packet (GstOggAviParse * ogg, ogg_packet * packet)
/* allocate space for header and body */
buffer = gst_buffer_new_and_alloc (packet->bytes);
memcpy (GST_BUFFER_DATA (buffer), packet->packet, packet->bytes);
gst_buffer_fill (buffer, 0, packet->packet, packet->bytes);
GST_LOG_OBJECT (ogg, "created buffer %p from page", buffer);
......@@ -340,15 +344,13 @@ gst_ogg_avi_parse_chain (GstPad * pad, GstBuffer * buffer)
{
GstFlowReturn result = GST_FLOW_OK;
GstOggAviParse *ogg;
guint8 *data;
guint size;
gchar *oggbuf;
gint ret = -1;
ogg = GST_OGG_AVI_PARSE (GST_OBJECT_PARENT (pad));
data = GST_BUFFER_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
size = gst_buffer_get_size (buffer);
GST_LOG_OBJECT (ogg, "Chain function received buffer of size %d", size);
......@@ -359,7 +361,7 @@ gst_ogg_avi_parse_chain (GstPad * pad, GstBuffer * buffer)
/* write data to sync layer */
oggbuf = ogg_sync_buffer (&ogg->sync, size);
memcpy (oggbuf, data, size);
gst_buffer_extract (buffer, 0, oggbuf, size);
ogg_sync_wrote (&ogg->sync, size);
gst_buffer_unref (buffer);
......
......@@ -581,7 +581,8 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
/* copy packet in buffer */
memcpy (buf->data, packet->packet + offset, packet->bytes - offset - trim);
gst_buffer_fill (buf, 0, packet->packet + offset,
packet->bytes - offset - trim);
GST_BUFFER_TIMESTAMP (buf) = out_timestamp;
GST_BUFFER_DURATION (buf) = out_duration;
......@@ -1400,15 +1401,14 @@ gst_ogg_demux_sink_event (GstPad * pad, GstEvent * event)
static GstFlowReturn
gst_ogg_demux_submit_buffer (GstOggDemux * ogg, GstBuffer * buffer)
{
gint size;
gsize size;
guint8 *data;
gchar *oggbuffer;
GstFlowReturn ret = GST_FLOW_OK;
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
GST_DEBUG_OBJECT (ogg, "submitting %u bytes", size);
GST_DEBUG_OBJECT (ogg, "submitting %" G_GSIZE_FORMAT " bytes", size);
if (G_UNLIKELY (size == 0))
goto done;
......@@ -1421,6 +1421,7 @@ gst_ogg_demux_submit_buffer (GstOggDemux * ogg, GstBuffer * buffer)
goto write_failed;
done:
gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
......@@ -1479,7 +1480,7 @@ gst_ogg_demux_get_data (GstOggDemux * ogg, gint64 end_offset)
if (ret != GST_FLOW_OK)
goto error;
ogg->read_offset += GST_BUFFER_SIZE (buffer);
ogg->read_offset += gst_buffer_get_size (buffer);
ret = gst_ogg_demux_submit_buffer (ogg, buffer);
......@@ -1725,7 +1726,7 @@ gst_ogg_demux_set_header_on_caps (GstOggDemux * ogg, GstCaps * caps,
ogg_packet *op = headers->data;
g_assert (op);
buffer = gst_buffer_new_and_alloc (op->bytes);
memcpy (GST_BUFFER_DATA (buffer), op->packet, op->bytes);
gst_buffer_fill (buffer, 0, op->packet, op->bytes);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
g_value_init (&value, GST_TYPE_BUFFER);
gst_value_take_buffer (&value, buffer);
......@@ -3272,7 +3273,7 @@ gst_ogg_demux_loop_forward (GstOggDemux * ogg)
goto done;
}
ogg->offset += GST_BUFFER_SIZE (buffer);
ogg->offset += gst_buffer_get_size (buffer);
if (G_UNLIKELY (ogg->newsegment)) {
gst_ogg_demux_send_event (ogg, ogg->newsegment);
......
......@@ -494,9 +494,8 @@ gst_ogg_mux_buffer_from_page (GstOggMux * mux, ogg_page * page, gboolean delta)
/* allocate space for header and body */
buffer = gst_buffer_new_and_alloc (page->header_len + page->body_len);
memcpy (GST_BUFFER_DATA (buffer), page->header, page->header_len);
memcpy (GST_BUFFER_DATA (buffer) + page->header_len,
page->body, page->body_len);
gst_buffer_fill (buffer, 0, page->header, page->header_len);
gst_buffer_fill (buffer, page->header_len, page->body, page->body_len);
/* Here we set granulepos as our OFFSET_END to give easy direct access to
* this value later. Before we push it, we reset this to OFFSET + SIZE
......@@ -519,7 +518,7 @@ gst_ogg_mux_push_buffer (GstOggMux * mux, GstBuffer * buffer)
/* fix up OFFSET and OFFSET_END again */
GST_BUFFER_OFFSET (buffer) = mux->offset;
mux->offset += GST_BUFFER_SIZE (buffer);
mux->offset += gst_buffer_get_size (buffer);
GST_BUFFER_OFFSET_END (buffer) = mux->offset;
/* Ensure we have monotonically increasing timestamps in the output. */
......@@ -805,9 +804,10 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux)
/* and we have one */
ogg_packet packet;
gboolean is_header;
gsize size;
packet.packet = GST_BUFFER_DATA (buf);
packet.bytes = GST_BUFFER_SIZE (buf);
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
......@@ -831,6 +831,8 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux)
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);
if (is_header) {
GST_DEBUG_OBJECT (ogg_mux,
"got header buffer in control state, ignoring");
......@@ -978,7 +980,8 @@ gst_ogg_mux_set_header_on_caps (GstCaps * caps, GList * buffers)
walk = walk->next;
/* mark buffer */
GST_LOG ("Setting IN_CAPS on buffer of length %d", GST_BUFFER_SIZE (buf));
GST_LOG ("Setting IN_CAPS on buffer of length %d",
gst_buffer_get_size (buf));
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
g_value_init (&value, GST_TYPE_BUFFER);
......@@ -1046,6 +1049,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
GstCaps *caps;
GstStructure *structure;
GstBuffer *hbuf;
gsize size;
pad = (GstOggPadData *) walk->data;
thepad = pad->collect.pad;
......@@ -1077,8 +1081,8 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
}
/* create a packet from the buffer */
packet.packet = GST_BUFFER_DATA (buf);
packet.bytes = GST_BUFFER_SIZE (buf);
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
if (packet.granulepos == -1)
packet.granulepos = 0;
......@@ -1090,6 +1094,8 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
/* swap the packet in */
ogg_stream_packetin (&pad->map.stream, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unref (buf);
GST_LOG_OBJECT (thepad, "flushing out BOS page");
......@@ -1142,12 +1148,13 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
GstBuffer *buf = GST_BUFFER (hwalk->data);
ogg_packet packet;
ogg_page page;
gsize size;
hwalk = hwalk->next;
/* create a packet from the buffer */
packet.packet = GST_BUFFER_DATA (buf);
packet.bytes = GST_BUFFER_SIZE (buf);
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
if (packet.granulepos == -1)
packet.granulepos = 0;
......@@ -1159,6 +1166,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
/* swap the packet in */
ogg_stream_packetin (&pad->map.stream, &packet);
gst_buffer_unmap (buf, packet.packet, size);
gst_buffer_unref (buf);
/* if last header, flush page */
......@@ -1315,6 +1323,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GstOggPadData *pad = ogg_mux->pulling;
gint64 duration;
gboolean force_flush;
gsize size;
GST_LOG_OBJECT (ogg_mux->pulling->collect.pad, "pulling from pad");
......@@ -1338,8 +1347,8 @@ 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_DATA (buf);
packet.bytes = GST_BUFFER_SIZE (buf);
packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
packet.bytes = size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
if (packet.granulepos == -1)
packet.granulepos = 0;
......@@ -1428,6 +1437,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);
pad->data_pushed = TRUE;
gp_time = GST_BUFFER_OFFSET (pad->buffer);
......
......@@ -286,15 +286,14 @@ gst_ogg_parse_dispose (GObject * object)
static GstFlowReturn
gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
{
guint size;
gsize size;
guint8 *data;
gchar *oggbuffer;
GstFlowReturn ret = GST_FLOW_OK;
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
GST_DEBUG_OBJECT (ogg, "submitting %u bytes", size);
GST_DEBUG_OBJECT (ogg, "submitting %" G_GSIZE_FORMAT " bytes", size);
if (G_UNLIKELY (size == 0))
goto done;
......@@ -314,6 +313,7 @@ gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
}
done:
gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
......@@ -368,8 +368,8 @@ gst_ogg_parse_buffer_from_page (ogg_page * page,
int size = page->header_len + page->body_len;
GstBuffer *buf = gst_buffer_new_and_alloc (size);
memcpy (GST_BUFFER_DATA (buf), page->header, page->header_len);
memcpy (GST_BUFFER_DATA (buf) + page->header_len, page->body, page->body_len);
gst_buffer_fill (buf, 0, page->header, page->header_len);
gst_buffer_fill (buf, page->header_len, page->body, page->body_len);
GST_BUFFER_TIMESTAMP (buf) = timestamp;
GST_BUFFER_OFFSET (buf) = offset;
......@@ -394,8 +394,9 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
ogg = GST_OGG_PARSE (GST_OBJECT_PARENT (pad));
GST_LOG_OBJECT (ogg, "Chain function received buffer of size %d",
GST_BUFFER_SIZE (buffer));
GST_LOG_OBJECT (ogg,
"Chain function received buffer of size %" G_GSIZE_FORMAT,
gst_buffer_get_size (buffer));
gst_ogg_parse_submit_buffer (ogg, buffer);
......
......@@ -303,19 +303,14 @@ static gboolean
tag_list_from_vorbiscomment_packet (ogg_packet * packet,
const guint8 * id_data, const guint id_data_length, GstTagList ** tags)
{
GstBuffer *buf = NULL;
gchar *encoder = NULL;
GstTagList *list;
gboolean ret = TRUE;
g_return_val_if_fail (tags != NULL, FALSE);
buf = gst_buffer_new ();
GST_BUFFER_DATA (buf) = (guint8 *) packet->packet;
GST_BUFFER_SIZE (buf) = packet->bytes;
list = gst_tag_list_from_vorbiscomment_buffer (buf, id_data, id_data_length,
&encoder);
list = gst_tag_list_from_vorbiscomment (packet->packet, packet->bytes,
id_data, id_data_length, &encoder);
if (!list) {
GST_WARNING ("failed to decode vorbis comments");
......@@ -335,8 +330,6 @@ exit:
gst_tag_list_free (*tags);
*tags = list;
gst_buffer_unref (buf);
return ret;
}
......
......@@ -725,32 +725,27 @@ gst_ogm_parse_comment_packet (GstOgmParse * ogm, GstBuffer * buf)
static void
gst_ogm_text_parse_strip_trailing_zeroes (GstOgmParse * ogm, GstBuffer * buf)
{
const guint8 *data;
guint size;
guint8 *data;
gsize size;
g_assert (gst_buffer_is_metadata_writable (buf));
g_assert (gst_buffer_is_writable (buf));
/* zeroes are not valid UTF-8 characters, so strip them from output */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
while (size > 0 && data[size - 1] == '\0') {
--size;
}
GST_BUFFER_SIZE (buf) = size;
gst_buffer_unmap (buf, data, size);
}
static GstFlowReturn
gst_ogm_parse_data_packet (GstOgmParse * ogm, GstBuffer * buf)
gst_ogm_parse_data_packet (GstOgmParse * ogm, GstBuffer * buf,
const guint8 * data, gsize size)
{
GstFlowReturn ret;
const guint8 *data;
GstBuffer *sbuf;
gboolean keyframe;
guint size, len, n, xsize = 0;
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
guint len, n, xsize = 0;
if ((data[0] & 0x01) != 0)
goto invalid_startcode;
......@@ -857,9 +852,10 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstOgmParse *ogm = GST_OGM_PARSE (GST_PAD_PARENT (pad));
guint8 *data = GST_BUFFER_DATA (buf);
guint size = GST_BUFFER_SIZE (buf);
guint8 *data;
gsize size;
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
if (size < 1)
goto buffer_too_small;
......@@ -875,11 +871,12 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buf)
break;
}
default:{
ret = gst_ogm_parse_data_packet (ogm, buf);
ret = gst_ogm_parse_data_packet (ogm, buf, data, size);
break;
}
}
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
if (ret != GST_FLOW_OK) {
......@@ -892,6 +889,7 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buf)
buffer_too_small:
{
GST_ELEMENT_ERROR (ogm, STREAM, DECODE, (NULL), ("buffer too small"));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
......
......@@ -1754,12 +1754,16 @@ gst_text_overlay_push_frame (GstTextOverlay * overlay, GstBuffer * video_frame)
gint width, height;
GstTextOverlayVAlign valign;
GstTextOverlayHAlign halign;
guint8 *data;
gsize size;
width = overlay->image_width;
height = overlay->image_height;
video_frame = gst_buffer_make_writable (video_frame);
data = gst_buffer_map (video_frame, &size, NULL, GST_MAP_WRITE);
if (overlay->use_vertical_render)
halign = GST_TEXT_OVERLAY_HALIGN_RIGHT;
else
......@@ -1820,24 +1824,24 @@ gst_text_overlay_push_frame (GstTextOverlay * overlay, GstBuffer * video_frame)
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
gst_text_overlay_shade_planar_Y (overlay,
GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
gst_text_overlay_shade_planar_Y (overlay, data,
xpos, xpos + overlay->image_width,
ypos, ypos + overlay->image_height);
break;
case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_UYVY:
gst_text_overlay_shade_packed_Y (overlay,
GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
gst_text_overlay_shade_packed_Y (overlay, data,
xpos, xpos + overlay->image_width,
ypos, ypos + overlay->image_height);
break;
case GST_VIDEO_FORMAT_xRGB:
gst_text_overlay_shade_xRGB (overlay,
GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
gst_text_overlay_shade_xRGB (overlay, data,
xpos, xpos + overlay->image_width,
ypos, ypos + overlay->image_height);
break;
case GST_VIDEO_FORMAT_BGRx:
gst_text_overlay_shade_BGRx (overlay,
GST_BUFFER_DATA (video_frame), xpos, xpos + overlay->image_width,
gst_text_overlay_shade_BGRx (overlay, data,
xpos, xpos + overlay->image_width,
ypos, ypos + overlay->image_height);
break;
default:
......@@ -1851,34 +1855,30 @@ gst_text_overlay_push_frame (GstTextOverlay * overlay, GstBuffer * video_frame)
if (overlay->text_image) {
switch (overlay->format) {
case GST_VIDEO_FORMAT_I420:
gst_text_overlay_blit_I420 (overlay,
GST_BUFFER_DATA (video_frame), xpos, ypos);
gst_text_overlay_blit_I420 (overlay, data, xpos, ypos);
break;
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
gst_text_overlay_blit_NV12_NV21 (overlay,
GST_BUFFER_DATA (video_frame), xpos, ypos);
gst_text_overlay_blit_NV12_NV21 (overlay, data, xpos, ypos);
break;
case GST_VIDEO_FORMAT_UYVY:
gst_text_overlay_blit_UYVY (overlay,
GST_BUFFER_DATA (video_frame), xpos, ypos);
gst_text_overlay_blit_UYVY (overlay, data, xpos, ypos);
break;
case GST_VIDEO_FORMAT_AYUV:
gst_text_overlay_blit_AYUV (overlay,
GST_BUFFER_DATA (video_frame), xpos, ypos);
gst_text_overlay_blit_AYUV (overlay, data, xpos, ypos);
break;
case GST_VIDEO_FORMAT_BGRx:
gst_text_overlay_blit_BGRx (overlay,
GST_BUFFER_DATA (video_frame), xpos, ypos);
gst_text_overlay_blit_BGRx (overlay, data, xpos, ypos);
break;
case GST_VIDEO_FORMAT_xRGB:
gst_text_overlay_blit_xRGB (overlay,
GST_BUFFER_DATA (video_frame), xpos, ypos);
gst_text_overlay_blit_xRGB (overlay, data, xpos, ypos);
break;
default:
g_assert_not_reached ();
}
}
gst_buffer_unmap (video_frame, data, size);
return gst_pad_push (overlay->srcpad, video_frame);
}
......@@ -2237,7 +2237,7 @@ gst_text_overlay_video_chain (GstPad * pad, GstBuffer * buffer)
/* if the buffer is only partially in the segment, fix up stamps */
if (clip_start != start || (stop != -1 && clip_stop != stop)) {
GST_DEBUG_OBJECT (overlay, "clipping buffer timestamp/duration to segment");
buffer = gst_buffer_make_metadata_writable (buffer);
buffer = gst_buffer_make_writable (buffer);
GST_BUFFER_TIMESTAMP (buffer) = clip_start;
if (stop != -1)
GST_BUFFER_DURATION (buffer) = clip_stop - clip_start;
......@@ -2365,11 +2365,13 @@ wait_for_text_buf:
/* Push the video frame */
ret = gst_pad_push (overlay->srcpad, buffer);
} else {
gchar *in_text;
gsize in_size;
gchar *in_text, *otext;
gsize in_size, osize;
in_text = (gchar *) GST_BUFFER_DATA (overlay->text_buffer);
in_size = GST_BUFFER_SIZE (overlay->text_buffer);
otext =
gst_buffer_map (overlay->text_buffer, &osize, NULL, GST_MAP_READ);
in_text = otext;
in_size = osize;
/* g_markup_escape_text() absolutely requires valid UTF8 input, it
* might crash otherwise. We don't fall back on GST_SUBTITLE_ENCODING
......@@ -2403,8 +2405,9 @@ wait_for_text_buf:
GST_DEBUG_OBJECT (overlay, "No text to render (empty buffer)");
gst_text_overlay_render_text (overlay, " ", 1);
}
gst_buffer_unmap (overlay->text_buffer, otext, osize);
if (in_text != (gchar *) GST_BUFFER_DATA (overlay->text_buffer))
if (in_text != otext)
g_free (in_text);
GST_OBJECT_UNLOCK (overlay);
......
......@@ -466,13 +466,15 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
GstFlowReturn ret;
GstBuffer *outbuf;
GstCaps *caps = NULL;
guint8 *data = GST_BUFFER_DATA (inbuf);
guint size = GST_BUFFER_SIZE (inbuf);
guint8 *data;
gsize size;
gint n;
gint xpos, ypos;
render = GST_TEXT_RENDER (gst_pad_get_parent (pad));
data = gst_buffer_map (inbuf, &size, NULL, GST_MAP_READ);
/* somehow pango barfs over "\0" buffers... */
while (size > 0 &&
(data[size - 1] == '\r' ||
......@@ -484,6 +486,7 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
GST_DEBUG ("rendering '%*s'", size, data);
pango_layout_set_markup (render->layout, (gchar *) data, size);