plugins: port to new memory API

This commit is contained in:
Wim Taymans 2011-03-28 21:05:31 +02:00
parent 8f22a09dc4
commit ea65d34cef
6 changed files with 53 additions and 24 deletions

View file

@ -174,7 +174,7 @@ static GstStaticCaps gst_alpha_alpha_caps =
static gboolean gst_alpha_start (GstBaseTransform * trans); static gboolean gst_alpha_start (GstBaseTransform * trans);
static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans, 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, static GstCaps *gst_alpha_transform_caps (GstBaseTransform * btrans,
GstPadDirection direction, GstCaps * caps); GstPadDirection direction, GstCaps * caps);
static gboolean gst_alpha_set_caps (GstBaseTransform * btrans, 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 static gboolean
gst_alpha_get_unit_size (GstBaseTransform * btrans, gst_alpha_get_unit_size (GstBaseTransform * btrans,
GstCaps * caps, guint * size) GstCaps * caps, gsize * size)
{ {
GstVideoFormat format; GstVideoFormat format;
gint width, height; gint width, height;
@ -2597,6 +2597,8 @@ gst_alpha_transform (GstBaseTransform * btrans, GstBuffer * in, GstBuffer * out)
{ {
GstAlpha *alpha = GST_ALPHA (btrans); GstAlpha *alpha = GST_ALPHA (btrans);
gint width, height; gint width, height;
guint8 *indata, *outdata;
gsize insize, outsize;
GST_ALPHA_LOCK (alpha); GST_ALPHA_LOCK (alpha);
@ -2609,8 +2611,13 @@ gst_alpha_transform (GstBaseTransform * btrans, GstBuffer * in, GstBuffer * out)
width = alpha->width; width = alpha->width;
height = alpha->height; height = alpha->height;
alpha->process (GST_BUFFER_DATA (in), indata = gst_buffer_map (in, &insize, NULL, GST_MAP_READ);
GST_BUFFER_DATA (out), width, height, alpha); 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); GST_ALPHA_UNLOCK (alpha);

View file

@ -638,12 +638,8 @@ static GstFlowReturn
gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf) gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
{ {
GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans); GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
guint8 *data;
if (G_UNLIKELY (GST_BUFFER_SIZE (inbuf) != 4 * alpha->width * alpha->height)) { gsize size;
GST_ERROR_OBJECT (alpha, "Invalid buffer size (was %u, expected %u)",
GST_BUFFER_SIZE (inbuf), alpha->width * alpha->height);
return GST_FLOW_ERROR;
}
if (gst_base_transform_is_passthrough (btrans)) if (gst_base_transform_is_passthrough (btrans))
return GST_FLOW_OK; return GST_FLOW_OK;
@ -653,9 +649,19 @@ gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
return GST_FLOW_NOT_NEGOTIATED; 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 */ /* Transform in place */
alpha->process (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf), alpha->process (data, size, alpha->matrix);
alpha->matrix);
gst_buffer_unmap (inbuf, data, size);
return GST_FLOW_OK; return GST_FLOW_OK;
} }

View file

@ -333,17 +333,25 @@ static gboolean
gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer, gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
gboolean start_tag, guint * tag_size) 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", GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file",
(start_tag) ? "start" : "end"); (start_tag) ? "start" : "end");
gst_buffer_unmap (buffer, data, size);
return FALSE; 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 */ /* size is without header, so add 32 to account for that */
*tag_size += 32; *tag_size += 32;
gst_buffer_unmap (buffer, data, size);
return TRUE; return TRUE;
} }

View file

@ -434,7 +434,7 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
{ {
GstGamma *gamma = GST_GAMMA (base); GstGamma *gamma = GST_GAMMA (base);
guint8 *data; guint8 *data;
guint size; gsize size;
if (!gamma->process) if (!gamma->process)
goto not_negotiated; goto not_negotiated;
@ -442,8 +442,7 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
if (base->passthrough) if (base->passthrough)
goto done; goto done;
data = GST_BUFFER_DATA (outbuf); data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
size = GST_BUFFER_SIZE (outbuf);
if (size != gamma->size) if (size != gamma->size)
goto wrong_size; goto wrong_size;
@ -452,6 +451,8 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
gamma->process (gamma, data); gamma->process (gamma, data);
GST_OBJECT_UNLOCK (gamma); GST_OBJECT_UNLOCK (gamma);
gst_buffer_unmap (outbuf, data, size);
done: done:
return GST_FLOW_OK; return GST_FLOW_OK;
@ -460,6 +461,7 @@ wrong_size:
{ {
GST_ELEMENT_ERROR (gamma, STREAM, FORMAT, GST_ELEMENT_ERROR (gamma, STREAM, FORMAT,
(NULL), ("Invalid buffer size %d, expected %d", size, gamma->size)); (NULL), ("Invalid buffer size %d, expected %d", size, gamma->size));
gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
not_negotiated: not_negotiated:

View file

@ -488,7 +488,7 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
{ {
GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base); GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base);
guint8 *data; guint8 *data;
guint size; gsize size;
if (!videobalance->process) if (!videobalance->process)
goto not_negotiated; goto not_negotiated;
@ -497,8 +497,7 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
if (base->passthrough) if (base->passthrough)
goto done; goto done;
data = GST_BUFFER_DATA (outbuf); data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
size = GST_BUFFER_SIZE (outbuf);
if (size != videobalance->size) if (size != videobalance->size)
goto wrong_size; goto wrong_size;
@ -507,6 +506,8 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
videobalance->process (videobalance, data); videobalance->process (videobalance, data);
GST_OBJECT_UNLOCK (videobalance); GST_OBJECT_UNLOCK (videobalance);
gst_buffer_unmap (outbuf, data, size);
done: done:
return GST_FLOW_OK; return GST_FLOW_OK;
@ -516,6 +517,7 @@ wrong_size:
GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT, GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT,
(NULL), ("Invalid buffer size %d, expected %d", size, (NULL), ("Invalid buffer size %d, expected %d", size,
videobalance->size)); videobalance->size));
gst_buffer_unmap (outbuf, data, size);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
not_negotiated: not_negotiated:

View file

@ -191,7 +191,7 @@ gst_video_flip_transform_caps (GstBaseTransform * trans,
static gboolean static gboolean
gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
guint * size) gsize * size)
{ {
GstVideoFormat format; GstVideoFormat format;
gint width, height; gint width, height;
@ -903,13 +903,14 @@ gst_video_flip_transform (GstBaseTransform * trans, GstBuffer * in,
{ {
GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans); GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
guint8 *dest; guint8 *dest;
const guint8 *src; guint8 *src;
gsize srcsize, destsize;
if (G_UNLIKELY (videoflip->process == NULL)) if (G_UNLIKELY (videoflip->process == NULL))
goto not_negotiated; goto not_negotiated;
src = GST_BUFFER_DATA (in); src = gst_buffer_map (in, &srcsize, NULL, GST_MAP_READ);
dest = GST_BUFFER_DATA (out); dest = gst_buffer_map (out, &destsize, NULL, GST_MAP_WRITE);
GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)", GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)",
videoflip->from_width, videoflip->from_height, videoflip->to_width, 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); videoflip->process (videoflip, dest, src);
GST_OBJECT_UNLOCK (videoflip); GST_OBJECT_UNLOCK (videoflip);
gst_buffer_unmap (in, src, srcsize);
gst_buffer_unmap (out, dest, destsize);
return GST_FLOW_OK; return GST_FLOW_OK;
not_negotiated: not_negotiated: