mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
plugins: port to new memory API
This commit is contained in:
parent
8f22a09dc4
commit
ea65d34cef
6 changed files with 53 additions and 24 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue