From 96decaf7efda9c31309aae4a2593bad1bd9c5108 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 12 Mar 2021 20:57:13 +0100 Subject: [PATCH] videotestsrc: Keep tmpline unchanged in_convert_tmpline This will allow us to repeatedly call it to render subsequent lines. Part-of: --- gst/videotestsrc/videotestsrc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index d127564..7457ab5 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -256,11 +256,21 @@ videotestsrc_convert_tmpline (paintinfo * p, GstVideoFrame * frame, int j) int height = frame->info.height; int n_lines = p->n_lines; int offset = p->offset; + guint8 *tmpline = p->tmpline, *tmpline2 = p->tmpline2; + /* `tmpline2` is only used here and when the shift amount `x` is + * non-zero, which only applies when `horizontal-speed` is set. + * + * Instead of copying the rotated line back to `tmpline` for + * `p->convert_tmpline` to use, swap the pointers briefly. Besides + * being cheaper, this also lets us reuse the painted `tmpline` for + * subsequent lines. + */ if (x != 0) { - memcpy (p->tmpline2, p->tmpline, width * 4); - memcpy (p->tmpline, p->tmpline2 + x * 4, (width - x) * 4); - memcpy (p->tmpline + (width - x) * 4, p->tmpline2, x * 4); + memcpy (tmpline2, tmpline + x * 4, (width - x) * 4); + memcpy (tmpline2 + (width - x) * 4, tmpline, x * 4); + p->tmpline = tmpline2; + p->tmpline2 = tmpline; } for (i = width; i < width + 5; i++) { @@ -278,6 +288,11 @@ videotestsrc_convert_tmpline (paintinfo * p, GstVideoFrame * frame, int j) p->convert_tmpline (p, frame, j); } } + + if (x != 0) { + p->tmpline = tmpline; + p->tmpline2 = tmpline2; + } } #define BLEND1(a,b,x) ((a)*(x) + (b)*(255-(x))) -- 2.7.4