mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
kate: avoid rendering when we know there is nothing to render
https://bugzilla.gnome.org/show_bug.cgi?id=660528
This commit is contained in:
parent
12bb47343d
commit
fa3d661083
1 changed files with 48 additions and 34 deletions
|
@ -725,6 +725,7 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
|
||||||
GstFlowReturn rflow = GST_FLOW_OK;
|
GstFlowReturn rflow = GST_FLOW_OK;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
int ret;
|
int ret;
|
||||||
|
kate_float t;
|
||||||
|
|
||||||
GST_KATE_TIGER_MUTEX_LOCK (tiger);
|
GST_KATE_TIGER_MUTEX_LOCK (tiger);
|
||||||
|
|
||||||
|
@ -743,45 +744,58 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
|
||||||
g_cond_broadcast (tiger->cond);
|
g_cond_broadcast (tiger->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw on it */
|
/* Update first with a dummy buffer pointer we cannot write to. If there is nothing
|
||||||
|
to draw, we will not have to make it writeable */
|
||||||
|
ptr = GST_BUFFER_DATA (buf);
|
||||||
|
ret =
|
||||||
|
tiger_renderer_set_buffer (tiger->tr, ptr, tiger->video_width,
|
||||||
|
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
|
||||||
|
if (G_UNLIKELY (ret < 0)) {
|
||||||
|
GST_WARNING_OBJECT (tiger,
|
||||||
|
"Tiger renderer failed to set buffer to video frame: %d", ret);
|
||||||
|
goto pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update the renderer at the time of the video frame */
|
||||||
|
t = gst_kate_tiger_get_time (tiger);
|
||||||
|
GST_LOG_OBJECT (tiger, "Video segment calc: last stop %ld, time %.3f",
|
||||||
|
(long) tiger->video_segment.last_stop, t);
|
||||||
|
ret = tiger_renderer_update (tiger->tr, t, 1);
|
||||||
|
if (G_UNLIKELY (ret < 0)) {
|
||||||
|
GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %d", ret);
|
||||||
|
goto pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if there nothing to draw, we can just push the video buffer as is */
|
||||||
|
if (ret > 0)
|
||||||
|
goto pass;
|
||||||
|
|
||||||
|
/* there is something to draw, so first make the buffer writable */
|
||||||
buf = gst_buffer_make_writable (buf);
|
buf = gst_buffer_make_writable (buf);
|
||||||
if (G_UNLIKELY (!buf)) {
|
if (G_UNLIKELY (!buf)) {
|
||||||
GST_WARNING_OBJECT (tiger, "Failed to make video buffer writable");
|
GST_WARNING_OBJECT (tiger, "Failed to make video buffer writable");
|
||||||
} else {
|
goto pass;
|
||||||
ptr = GST_BUFFER_DATA (buf);
|
|
||||||
if (!ptr) {
|
|
||||||
GST_WARNING_OBJECT (tiger,
|
|
||||||
"Failed to get a pointer to video buffer data");
|
|
||||||
} else {
|
|
||||||
ret =
|
|
||||||
tiger_renderer_set_buffer (tiger->tr, ptr, tiger->video_width,
|
|
||||||
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
|
|
||||||
if (G_UNLIKELY (ret < 0)) {
|
|
||||||
GST_WARNING_OBJECT (tiger,
|
|
||||||
"Tiger renderer failed to set buffer to video frame: %d", ret);
|
|
||||||
} else {
|
|
||||||
kate_float t = gst_kate_tiger_get_time (tiger);
|
|
||||||
GST_LOG_OBJECT (tiger, "Video segment calc: last stop %ld, time %.3f",
|
|
||||||
(long) tiger->video_segment.last_stop, t);
|
|
||||||
|
|
||||||
ret = tiger_renderer_update (tiger->tr, t, 1);
|
|
||||||
if (G_UNLIKELY (ret < 0)) {
|
|
||||||
GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %d",
|
|
||||||
ret);
|
|
||||||
} else {
|
|
||||||
ret = tiger_renderer_render (tiger->tr);
|
|
||||||
if (G_UNLIKELY (ret < 0)) {
|
|
||||||
GST_WARNING_OBJECT (tiger,
|
|
||||||
"Tiger renderer failed to render to video frame: %d", ret);
|
|
||||||
} else {
|
|
||||||
GST_LOG_OBJECT (tiger,
|
|
||||||
"Tiger renderer rendered on video frame at %f", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* and setup that buffer before rendering */
|
||||||
|
ptr = GST_BUFFER_DATA (buf);
|
||||||
|
ret =
|
||||||
|
tiger_renderer_set_buffer (tiger->tr, ptr, tiger->video_width,
|
||||||
|
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
|
||||||
|
if (G_UNLIKELY (ret < 0)) {
|
||||||
|
GST_WARNING_OBJECT (tiger,
|
||||||
|
"Tiger renderer failed to set buffer to video frame: %d", ret);
|
||||||
|
goto pass;
|
||||||
|
}
|
||||||
|
ret = tiger_renderer_render (tiger->tr);
|
||||||
|
if (G_UNLIKELY (ret < 0)) {
|
||||||
|
GST_WARNING_OBJECT (tiger,
|
||||||
|
"Tiger renderer failed to render to video frame: %d", ret);
|
||||||
|
} else {
|
||||||
|
GST_LOG_OBJECT (tiger, "Tiger renderer rendered on video frame at %f", t);
|
||||||
|
}
|
||||||
|
|
||||||
|
pass:
|
||||||
GST_KATE_TIGER_MUTEX_UNLOCK (tiger);
|
GST_KATE_TIGER_MUTEX_UNLOCK (tiger);
|
||||||
|
|
||||||
rflow = gst_pad_push (tiger->srcpad, buf);
|
rflow = gst_pad_push (tiger->srcpad, buf);
|
||||||
|
|
Loading…
Reference in a new issue