From: Wim Taymans Date: Mon, 28 Mar 2011 19:05:31 +0000 (+0200) Subject: plugins: port to new memory API X-Git-Tag: RELEASE-0.11.1~624 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea65d34cefba6370b71db4b4525c6959c381f1b9;p=platform%2Fupstream%2Fgst-plugins-good.git plugins: port to new memory API --- diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c index e9c29d5..70c9a32 100644 --- a/gst/alpha/gstalpha.c +++ b/gst/alpha/gstalpha.c @@ -174,7 +174,7 @@ static GstStaticCaps gst_alpha_alpha_caps = static gboolean gst_alpha_start (GstBaseTransform * trans); static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans, - GstCaps * caps, guint * size); + GstCaps * caps, gsize * size); static GstCaps *gst_alpha_transform_caps (GstBaseTransform * btrans, GstPadDirection direction, GstCaps * caps); static gboolean gst_alpha_set_caps (GstBaseTransform * btrans, @@ -458,7 +458,7 @@ gst_alpha_get_property (GObject * object, guint prop_id, GValue * value, static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans, - GstCaps * caps, guint * size) + GstCaps * caps, gsize * size) { GstVideoFormat format; gint width, height; @@ -2597,6 +2597,8 @@ gst_alpha_transform (GstBaseTransform * btrans, GstBuffer * in, GstBuffer * out) { GstAlpha *alpha = GST_ALPHA (btrans); gint width, height; + guint8 *indata, *outdata; + gsize insize, outsize; GST_ALPHA_LOCK (alpha); @@ -2609,8 +2611,13 @@ gst_alpha_transform (GstBaseTransform * btrans, GstBuffer * in, GstBuffer * out) width = alpha->width; height = alpha->height; - alpha->process (GST_BUFFER_DATA (in), - GST_BUFFER_DATA (out), width, height, alpha); + indata = gst_buffer_map (in, &insize, NULL, GST_MAP_READ); + outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE); + + alpha->process (indata, outdata, width, height, alpha); + + gst_buffer_unmap (out, outdata, outsize); + gst_buffer_unmap (in, indata, insize); GST_ALPHA_UNLOCK (alpha); diff --git a/gst/alpha/gstalphacolor.c b/gst/alpha/gstalphacolor.c index 2c9eb4a..f4e25eb 100644 --- a/gst/alpha/gstalphacolor.c +++ b/gst/alpha/gstalphacolor.c @@ -638,12 +638,8 @@ static GstFlowReturn gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf) { GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans); - - if (G_UNLIKELY (GST_BUFFER_SIZE (inbuf) != 4 * alpha->width * alpha->height)) { - GST_ERROR_OBJECT (alpha, "Invalid buffer size (was %u, expected %u)", - GST_BUFFER_SIZE (inbuf), alpha->width * alpha->height); - return GST_FLOW_ERROR; - } + guint8 *data; + gsize size; if (gst_base_transform_is_passthrough (btrans)) return GST_FLOW_OK; @@ -653,9 +649,19 @@ gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf) return GST_FLOW_NOT_NEGOTIATED; } + data = gst_buffer_map (inbuf, &size, NULL, GST_MAP_READWRITE); + + if (G_UNLIKELY (size != 4 * alpha->width * alpha->height)) { + GST_ERROR_OBJECT (alpha, "Invalid buffer size (was %u, expected %u)", + size, alpha->width * alpha->height); + gst_buffer_unmap (inbuf, data, size); + return GST_FLOW_ERROR; + } + /* Transform in place */ - alpha->process (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf), - alpha->matrix); + alpha->process (data, size, alpha->matrix); + + gst_buffer_unmap (inbuf, data, size); return GST_FLOW_OK; } diff --git a/gst/apetag/gstapedemux.c b/gst/apetag/gstapedemux.c index accebee..c57d988 100644 --- a/gst/apetag/gstapedemux.c +++ b/gst/apetag/gstapedemux.c @@ -333,17 +333,25 @@ static gboolean gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer, gboolean start_tag, guint * tag_size) { - if (memcmp (GST_BUFFER_DATA (buffer), "APETAGEX", 8) != 0) { + guint8 *data; + gsize size; + + data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); + + if (memcmp (data, "APETAGEX", 8) != 0) { GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file", (start_tag) ? "start" : "end"); + gst_buffer_unmap (buffer, data, size); return FALSE; } - *tag_size = GST_READ_UINT32_LE (GST_BUFFER_DATA (buffer) + 12); + *tag_size = GST_READ_UINT32_LE (data + 12); /* size is without header, so add 32 to account for that */ *tag_size += 32; + gst_buffer_unmap (buffer, data, size); + return TRUE; } diff --git a/gst/videofilter/gstgamma.c b/gst/videofilter/gstgamma.c index 86663b6..167680e 100644 --- a/gst/videofilter/gstgamma.c +++ b/gst/videofilter/gstgamma.c @@ -434,7 +434,7 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) { GstGamma *gamma = GST_GAMMA (base); guint8 *data; - guint size; + gsize size; if (!gamma->process) goto not_negotiated; @@ -442,8 +442,7 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) if (base->passthrough) goto done; - data = GST_BUFFER_DATA (outbuf); - size = GST_BUFFER_SIZE (outbuf); + data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE); if (size != gamma->size) goto wrong_size; @@ -452,6 +451,8 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) gamma->process (gamma, data); GST_OBJECT_UNLOCK (gamma); + gst_buffer_unmap (outbuf, data, size); + done: return GST_FLOW_OK; @@ -460,6 +461,7 @@ wrong_size: { GST_ELEMENT_ERROR (gamma, STREAM, FORMAT, (NULL), ("Invalid buffer size %d, expected %d", size, gamma->size)); + gst_buffer_unmap (outbuf, data, size); return GST_FLOW_ERROR; } not_negotiated: diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c index 968e259..3be943c 100644 --- a/gst/videofilter/gstvideobalance.c +++ b/gst/videofilter/gstvideobalance.c @@ -488,7 +488,7 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) { GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base); guint8 *data; - guint size; + gsize size; if (!videobalance->process) goto not_negotiated; @@ -497,8 +497,7 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) if (base->passthrough) goto done; - data = GST_BUFFER_DATA (outbuf); - size = GST_BUFFER_SIZE (outbuf); + data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE); if (size != videobalance->size) goto wrong_size; @@ -507,6 +506,8 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) videobalance->process (videobalance, data); GST_OBJECT_UNLOCK (videobalance); + gst_buffer_unmap (outbuf, data, size); + done: return GST_FLOW_OK; @@ -516,6 +517,7 @@ wrong_size: GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT, (NULL), ("Invalid buffer size %d, expected %d", size, videobalance->size)); + gst_buffer_unmap (outbuf, data, size); return GST_FLOW_ERROR; } not_negotiated: diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c index a08d64f..f3612df 100644 --- a/gst/videofilter/gstvideoflip.c +++ b/gst/videofilter/gstvideoflip.c @@ -191,7 +191,7 @@ gst_video_flip_transform_caps (GstBaseTransform * trans, static gboolean gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, - guint * size) + gsize * size) { GstVideoFormat format; gint width, height; @@ -903,13 +903,14 @@ gst_video_flip_transform (GstBaseTransform * trans, GstBuffer * in, { GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans); guint8 *dest; - const guint8 *src; + guint8 *src; + gsize srcsize, destsize; if (G_UNLIKELY (videoflip->process == NULL)) goto not_negotiated; - src = GST_BUFFER_DATA (in); - dest = GST_BUFFER_DATA (out); + src = gst_buffer_map (in, &srcsize, NULL, GST_MAP_READ); + dest = gst_buffer_map (out, &destsize, NULL, GST_MAP_WRITE); GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)", videoflip->from_width, videoflip->from_height, videoflip->to_width, @@ -919,6 +920,9 @@ gst_video_flip_transform (GstBaseTransform * trans, GstBuffer * in, videoflip->process (videoflip, dest, src); GST_OBJECT_UNLOCK (videoflip); + gst_buffer_unmap (in, src, srcsize); + gst_buffer_unmap (out, dest, destsize); + return GST_FLOW_OK; not_negotiated: