x11: use frame copy functions
This commit is contained in:
parent
1d9deae5be
commit
aa73f69f2d
@ -116,6 +116,7 @@
|
|||||||
#include <gst/gstinfo.h>
|
#include <gst/gstinfo.h>
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagesink);
|
GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagesink);
|
||||||
|
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
|
||||||
#define GST_CAT_DEFAULT gst_debug_ximagesink
|
#define GST_CAT_DEFAULT gst_debug_ximagesink
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -1122,6 +1123,9 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
|||||||
ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
|
ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
|
||||||
GST_VIDEO_SINK_WIDTH (ximagesink), GST_VIDEO_SINK_HEIGHT (ximagesink));
|
GST_VIDEO_SINK_WIDTH (ximagesink), GST_VIDEO_SINK_HEIGHT (ximagesink));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ximagesink->info = info;
|
||||||
|
|
||||||
/* Remember to draw borders for next frame */
|
/* Remember to draw borders for next frame */
|
||||||
ximagesink->draw_border = TRUE;
|
ximagesink->draw_border = TRUE;
|
||||||
|
|
||||||
@ -1287,8 +1291,7 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||||||
to_put = buf;
|
to_put = buf;
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
GstVideoFrame src, dest;
|
||||||
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... */
|
||||||
@ -1309,9 +1312,21 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||||||
if (gst_buffer_get_size (to_put) < gst_buffer_get_size (buf))
|
if (gst_buffer_get_size (to_put) < gst_buffer_get_size (buf))
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
data = gst_buffer_map (to_put, &size, NULL, GST_MAP_WRITE);
|
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, ximagesink,
|
||||||
gst_buffer_extract (buf, 0, data, size);
|
"slow copy into bufferpool buffer %p", to_put);
|
||||||
gst_buffer_unmap (to_put, data, size);
|
|
||||||
|
if (!gst_video_frame_map (&src, &ximagesink->info, buf, GST_MAP_READ))
|
||||||
|
goto invalid_buffer;
|
||||||
|
|
||||||
|
if (!gst_video_frame_map (&dest, &ximagesink->info, to_put, GST_MAP_WRITE)) {
|
||||||
|
gst_video_frame_unmap (&src);
|
||||||
|
goto invalid_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_video_frame_copy (&dest, &src);
|
||||||
|
|
||||||
|
gst_video_frame_unmap (&dest);
|
||||||
|
gst_video_frame_unmap (&src);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_ximagesink_ximage_put (ximagesink, to_put))
|
if (!gst_ximagesink_ximage_put (ximagesink, to_put))
|
||||||
@ -1347,6 +1362,13 @@ wrong_size:
|
|||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
invalid_buffer:
|
||||||
|
{
|
||||||
|
/* No Window available to put our image into */
|
||||||
|
GST_WARNING_OBJECT (ximagesink, "could map image");
|
||||||
|
res = GST_FLOW_OK;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
no_window:
|
no_window:
|
||||||
{
|
{
|
||||||
/* No Window available to put our image into */
|
/* No Window available to put our image into */
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
/* Helper functions */
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
#define GST_TYPE_XIMAGESINK \
|
#define GST_TYPE_XIMAGESINK \
|
||||||
(gst_ximagesink_get_type())
|
(gst_ximagesink_get_type())
|
||||||
@ -171,6 +174,8 @@ struct _GstXImageSink
|
|||||||
GThread *event_thread;
|
GThread *event_thread;
|
||||||
gboolean running;
|
gboolean running;
|
||||||
|
|
||||||
|
GstVideoInfo info;
|
||||||
|
|
||||||
/* Framerate numerator and denominator */
|
/* Framerate numerator and denominator */
|
||||||
gint fps_n;
|
gint fps_n;
|
||||||
gint fps_d;
|
gint fps_d;
|
||||||
|
@ -119,7 +119,6 @@
|
|||||||
#include <gst/interfaces/colorbalance.h>
|
#include <gst/interfaces/colorbalance.h>
|
||||||
#include <gst/interfaces/propertyprobe.h>
|
#include <gst/interfaces/propertyprobe.h>
|
||||||
/* Helper functions */
|
/* Helper functions */
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/video/gstmetavideo.h>
|
#include <gst/video/gstmetavideo.h>
|
||||||
|
|
||||||
/* Object header */
|
/* Object header */
|
||||||
@ -1656,6 +1655,8 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
|||||||
GST_VIDEO_SINK_HEIGHT (xvimagesink));
|
GST_VIDEO_SINK_HEIGHT (xvimagesink));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xvimagesink->info = info;
|
||||||
|
|
||||||
/* After a resize, we want to redraw the borders in case the new frame size
|
/* After a resize, we want to redraw the borders in case the new frame size
|
||||||
* doesn't cover the same area */
|
* doesn't cover the same area */
|
||||||
xvimagesink->redraw_border = TRUE;
|
xvimagesink->redraw_border = TRUE;
|
||||||
@ -1828,8 +1829,7 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||||||
to_put = buf;
|
to_put = buf;
|
||||||
res = GST_FLOW_OK;
|
res = GST_FLOW_OK;
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
GstVideoFrame src, dest;
|
||||||
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... */
|
||||||
@ -1853,9 +1853,18 @@ gst_xvimagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||||||
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
|
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
|
||||||
"slow copy into bufferpool buffer %p", to_put);
|
"slow copy into bufferpool buffer %p", to_put);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
if (!gst_video_frame_map (&src, &xvimagesink->info, buf, GST_MAP_READ))
|
||||||
gst_buffer_fill (to_put, 0, data, size);
|
goto invalid_buffer;
|
||||||
gst_buffer_unmap (buf, data, size);
|
|
||||||
|
if (!gst_video_frame_map (&dest, &xvimagesink->info, to_put, GST_MAP_WRITE)) {
|
||||||
|
gst_video_frame_unmap (&src);
|
||||||
|
goto invalid_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_video_frame_copy (&dest, &src);
|
||||||
|
|
||||||
|
gst_video_frame_unmap (&dest);
|
||||||
|
gst_video_frame_unmap (&src);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_xvimagesink_xvimage_put (xvimagesink, to_put))
|
if (!gst_xvimagesink_xvimage_put (xvimagesink, to_put))
|
||||||
@ -1891,6 +1900,13 @@ wrong_size:
|
|||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
invalid_buffer:
|
||||||
|
{
|
||||||
|
/* No Window available to put our image into */
|
||||||
|
GST_WARNING_OBJECT (xvimagesink, "could map image");
|
||||||
|
res = GST_FLOW_OK;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
no_window:
|
no_window:
|
||||||
{
|
{
|
||||||
/* No Window available to put our image into */
|
/* No Window available to put our image into */
|
||||||
|
@ -42,6 +42,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* Helper functions */
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
#define GST_TYPE_XVIMAGESINK \
|
#define GST_TYPE_XVIMAGESINK \
|
||||||
(gst_xvimagesink_get_type())
|
(gst_xvimagesink_get_type())
|
||||||
@ -213,6 +216,8 @@ struct _GstXvImageSink
|
|||||||
GThread *event_thread;
|
GThread *event_thread;
|
||||||
gboolean running;
|
gboolean running;
|
||||||
|
|
||||||
|
GstVideoInfo info;
|
||||||
|
|
||||||
/* Framerate numerator and denominator */
|
/* Framerate numerator and denominator */
|
||||||
gint fps_n;
|
gint fps_n;
|
||||||
gint fps_d;
|
gint fps_d;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user