mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-27 23:44:47 +00:00
vaapioverlay: unroll the recursive call
Recursive functions are elegant but dangerous since they might overflow the stack. It is better to turn them into a list tranversal if possible, as this case.
This commit is contained in:
parent
d0e14ec308
commit
889fac3823
1 changed files with 28 additions and 32 deletions
|
@ -374,9 +374,7 @@ gst_vaapi_overlay_surface_next (gpointer data)
|
|||
generator = (GstVaapiOverlaySurfaceGenerator *) data;
|
||||
|
||||
/* at the end of the generator? */
|
||||
if (!generator->current)
|
||||
return NULL;
|
||||
|
||||
while (generator->current) {
|
||||
/* get the current video aggregator sinkpad */
|
||||
vagg_pad = GST_VIDEO_AGGREGATOR_PAD (generator->current->data);
|
||||
|
||||
|
@ -397,15 +395,10 @@ gst_vaapi_overlay_surface_next (gpointer data)
|
|||
|
||||
/* Current sinkpad may have reached EOS */
|
||||
if (!inframe || !inbuf)
|
||||
return gst_vaapi_overlay_surface_next (generator);
|
||||
continue;
|
||||
|
||||
inbuf_meta = gst_buffer_get_vaapi_video_meta (inbuf);
|
||||
|
||||
if (!inbuf_meta) {
|
||||
gst_buffer_unref (inbuf);
|
||||
return blend_surface;
|
||||
}
|
||||
|
||||
if (inbuf_meta) {
|
||||
blend_surface->surface = gst_vaapi_video_meta_get_surface (inbuf_meta);
|
||||
blend_surface->crop = gst_vaapi_video_meta_get_render_rect (inbuf_meta);
|
||||
blend_surface->target.x = pad->xpos;
|
||||
|
@ -413,12 +406,15 @@ gst_vaapi_overlay_surface_next (gpointer data)
|
|||
blend_surface->target.width = GST_VIDEO_FRAME_WIDTH (inframe);
|
||||
blend_surface->target.height = GST_VIDEO_FRAME_HEIGHT (inframe);
|
||||
blend_surface->alpha = pad->alpha;
|
||||
}
|
||||
|
||||
gst_buffer_unref (inbuf);
|
||||
|
||||
return blend_surface;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_vaapi_overlay_aggregate_frames (GstVideoAggregator * vagg,
|
||||
GstBuffer * outbuf)
|
||||
|
|
Loading…
Reference in a new issue