xvimagesink: make the show_frame function prettier
This commit is contained in:
parent
1ae67927cc
commit
1999e73759
@ -1806,8 +1806,7 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
GstXvImageSink *xvimagesink;
|
GstXvImageSink *xvimagesink;
|
||||||
GstMetaXvImage *meta;
|
GstMetaXvImage *meta;
|
||||||
GstBuffer *temp;
|
GstBuffer *to_put;
|
||||||
gboolean unref;
|
|
||||||
|
|
||||||
xvimagesink = GST_XVIMAGESINK (vsink);
|
xvimagesink = GST_XVIMAGESINK (vsink);
|
||||||
|
|
||||||
@ -1816,47 +1815,44 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||||||
if (meta) {
|
if (meta) {
|
||||||
/* If this buffer has been allocated using our buffer management we simply
|
/* If this buffer has been allocated using our buffer management we simply
|
||||||
put the ximage which is in the PRIVATE pointer */
|
put the ximage which is in the PRIVATE pointer */
|
||||||
GST_LOG_OBJECT (xvimagesink, "buffer from our pool, writing directly");
|
GST_LOG_OBJECT (xvimagesink, "buffer %p from our pool, writing directly",
|
||||||
|
buf);
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
unref = FALSE;
|
to_put = buf;
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
/* Else we have to copy the data into our private image, */
|
/* Else we have to copy the data into our private image, */
|
||||||
/* if we have one... */
|
/* if we have one... */
|
||||||
GST_LOG_OBJECT (xvimagesink, "buffer not from our pool, copying");
|
GST_LOG_OBJECT (xvimagesink, "buffer %p not from our pool, copying", buf);
|
||||||
|
|
||||||
/* we should have a pool, configured in setcaps */
|
/* we should have a pool, configured in setcaps */
|
||||||
if (xvimagesink->pool == NULL)
|
if (xvimagesink->pool == NULL)
|
||||||
goto no_pool;
|
goto no_pool;
|
||||||
|
|
||||||
/* take a buffer form our pool */
|
/* take a buffer form our pool */
|
||||||
res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &temp, NULL);
|
res = gst_buffer_pool_acquire_buffer (xvimagesink->pool, &to_put, NULL);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
goto no_buffer;
|
goto no_buffer;
|
||||||
|
|
||||||
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
|
if (gst_buffer_get_size (to_put) < gst_buffer_get_size (buf))
|
||||||
"slow copy into bufferpool buffer %p", temp);
|
|
||||||
|
|
||||||
unref = TRUE;
|
|
||||||
|
|
||||||
if (gst_buffer_get_size (temp) < gst_buffer_get_size (buf))
|
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
data = gst_buffer_map (temp, &size, NULL, GST_MAP_WRITE);
|
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
|
||||||
gst_buffer_extract (buf, 0, data, size);
|
"slow copy into bufferpool buffer %p", to_put);
|
||||||
gst_buffer_unmap (temp, data, size);
|
|
||||||
|
|
||||||
buf = temp;
|
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||||
|
gst_buffer_fill (to_put, 0, data, size);
|
||||||
|
gst_buffer_unmap (buf, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_xvimagesink_xvimage_put (xvimagesink, buf))
|
if (!gst_xvimagesink_xvimage_put (xvimagesink, to_put))
|
||||||
goto no_window;
|
goto no_window;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (unref)
|
if (to_put != buf)
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (to_put);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@ -1879,7 +1875,7 @@ wrong_size:
|
|||||||
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE,
|
||||||
("Failed to create output image buffer"),
|
("Failed to create output image buffer"),
|
||||||
("XServer allocated buffer size did not match input buffer %"
|
("XServer allocated buffer size did not match input buffer %"
|
||||||
G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (temp),
|
G_GSIZE_FORMAT " - %" G_GSIZE_FORMAT, gst_buffer_get_size (to_put),
|
||||||
gst_buffer_get_size (buf)));
|
gst_buffer_get_size (buf)));
|
||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
@ -2123,7 +2119,7 @@ reuse_last_caps:
|
|||||||
if (xvimage) {
|
if (xvimage) {
|
||||||
/* Make sure the buffer is cleared of any previously used flags */
|
/* Make sure the buffer is cleared of any previously used flags */
|
||||||
GST_MINI_OBJECT_CAST (xvimage)->flags = 0;
|
GST_MINI_OBJECT_CAST (xvimage)->flags = 0;
|
||||||
gst_buffer_set_caps (GST_BUFFER_CAST (xvimage), intersection);
|
gst_buffer_set_caps (xvimage, intersection);
|
||||||
}
|
}
|
||||||
|
|
||||||
*buf = xvimage;
|
*buf = xvimage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user