mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 18:35:35 +00:00
VDPAU: Refactor the error path to a common output, and fix a leak.
Don't leak the input buffer on errors. Add some debug statements.
This commit is contained in:
parent
8ded28b126
commit
0d94e5a656
1 changed files with 24 additions and 16 deletions
|
@ -74,16 +74,19 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstVdpDevice *device;
|
GstVdpDevice *device;
|
||||||
VdpVideoSurface surface;
|
VdpVideoSurface surface;
|
||||||
GstBuffer *outbuf = NULL;
|
GstBuffer *outbuf = NULL;
|
||||||
|
GstFlowReturn result = GST_FLOW_ERROR;
|
||||||
|
|
||||||
video_yuv = GST_VDP_VIDEO_YUV (GST_OBJECT_PARENT (pad));
|
video_yuv = GST_VDP_VIDEO_YUV (GST_OBJECT_PARENT (pad));
|
||||||
device = GST_VDP_VIDEO_BUFFER (buffer)->device;
|
device = GST_VDP_VIDEO_BUFFER (buffer)->device;
|
||||||
surface = GST_VDP_VIDEO_BUFFER (buffer)->surface;
|
surface = GST_VDP_VIDEO_BUFFER (buffer)->surface;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (video_yuv, "Received buffer format %" GST_FOURCC_FORMAT,
|
||||||
|
GST_FOURCC_ARGS (video_yuv->format));
|
||||||
|
|
||||||
switch (video_yuv->format) {
|
switch (video_yuv->format) {
|
||||||
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
|
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
|
||||||
{
|
{
|
||||||
gint size;
|
gint size;
|
||||||
GstFlowReturn result;
|
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
guint8 *data[3];
|
guint8 *data[3];
|
||||||
guint32 stride[3];
|
guint32 stride[3];
|
||||||
|
@ -94,8 +97,10 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
result =
|
result =
|
||||||
gst_pad_alloc_buffer_and_set_caps (video_yuv->src,
|
gst_pad_alloc_buffer_and_set_caps (video_yuv->src,
|
||||||
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (video_yuv->src), &outbuf);
|
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (video_yuv->src), &outbuf);
|
||||||
if (G_UNLIKELY (result != GST_FLOW_OK))
|
if (G_UNLIKELY (result != GST_FLOW_OK)) {
|
||||||
return result;
|
GST_DEBUG_OBJECT (video_yuv, "Pad alloc_buffer returned %d", result);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
data[0] = GST_BUFFER_DATA (outbuf) +
|
data[0] = GST_BUFFER_DATA (outbuf) +
|
||||||
gst_video_format_get_component_offset (GST_VIDEO_FORMAT_YV12,
|
gst_video_format_get_component_offset (GST_VIDEO_FORMAT_YV12,
|
||||||
|
@ -122,14 +127,13 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
("Couldn't get data from vdpau"),
|
("Couldn't get data from vdpau"),
|
||||||
("Error returned from vdpau was: %s",
|
("Error returned from vdpau was: %s",
|
||||||
device->vdp_get_error_string (status)));
|
device->vdp_get_error_string (status)));
|
||||||
goto error;
|
goto done;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
||||||
{
|
{
|
||||||
gint size;
|
gint size;
|
||||||
GstFlowReturn result;
|
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
guint8 *data[3];
|
guint8 *data[3];
|
||||||
guint32 stride[3];
|
guint32 stride[3];
|
||||||
|
@ -140,8 +144,10 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
result =
|
result =
|
||||||
gst_pad_alloc_buffer_and_set_caps (video_yuv->src,
|
gst_pad_alloc_buffer_and_set_caps (video_yuv->src,
|
||||||
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (video_yuv->src), &outbuf);
|
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (video_yuv->src), &outbuf);
|
||||||
if (G_UNLIKELY (result != GST_FLOW_OK))
|
if (G_UNLIKELY (result != GST_FLOW_OK)) {
|
||||||
return result;
|
GST_DEBUG_OBJECT (video_yuv, "Pad alloc_buffer returned %d", result);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
data[0] = GST_BUFFER_DATA (outbuf) +
|
data[0] = GST_BUFFER_DATA (outbuf) +
|
||||||
gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420,
|
gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420,
|
||||||
|
@ -168,14 +174,13 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
("Couldn't get data from vdpau"),
|
("Couldn't get data from vdpau"),
|
||||||
("Error returned from vdpau was: %s",
|
("Error returned from vdpau was: %s",
|
||||||
device->vdp_get_error_string (status)));
|
device->vdp_get_error_string (status)));
|
||||||
goto error;
|
goto done;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
|
case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
|
||||||
{
|
{
|
||||||
gint size;
|
gint size;
|
||||||
GstFlowReturn result;
|
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
guint8 *data[2];
|
guint8 *data[2];
|
||||||
guint32 stride[2];
|
guint32 stride[2];
|
||||||
|
@ -186,9 +191,10 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
result =
|
result =
|
||||||
gst_pad_alloc_buffer_and_set_caps (video_yuv->src,
|
gst_pad_alloc_buffer_and_set_caps (video_yuv->src,
|
||||||
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (video_yuv->src), &outbuf);
|
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (video_yuv->src), &outbuf);
|
||||||
if (G_UNLIKELY (result != GST_FLOW_OK))
|
if (G_UNLIKELY (result != GST_FLOW_OK)) {
|
||||||
return result;
|
GST_DEBUG_OBJECT (video_yuv, "Pad alloc_buffer returned %d", result);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
data[0] = GST_BUFFER_DATA (outbuf);
|
data[0] = GST_BUFFER_DATA (outbuf);
|
||||||
data[1] = GST_BUFFER_DATA (outbuf) + video_yuv->width * video_yuv->height;
|
data[1] = GST_BUFFER_DATA (outbuf) + video_yuv->width * video_yuv->height;
|
||||||
|
@ -204,7 +210,7 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
("Couldn't get data from vdpau"),
|
("Couldn't get data from vdpau"),
|
||||||
("Error returned from vdpau was: %s",
|
("Error returned from vdpau was: %s",
|
||||||
device->vdp_get_error_string (status)));
|
device->vdp_get_error_string (status)));
|
||||||
goto error;
|
goto done;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -217,9 +223,11 @@ gst_vdp_video_yuv_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
gst_buffer_copy_metadata (outbuf, buffer, GST_BUFFER_COPY_TIMESTAMPS);
|
gst_buffer_copy_metadata (outbuf, buffer, GST_BUFFER_COPY_TIMESTAMPS);
|
||||||
return gst_pad_push (video_yuv->src, outbuf);
|
return gst_pad_push (video_yuv->src, outbuf);
|
||||||
|
|
||||||
error:
|
done:
|
||||||
gst_buffer_unref (outbuf);
|
if (outbuf)
|
||||||
return GST_FLOW_ERROR;
|
gst_buffer_unref (outbuf);
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
|
|
Loading…
Reference in a new issue