From e569b8ba1eccd94bad02bbd15dacbdc95e267f91 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 10 Jun 2023 14:53:52 +0200 Subject: [PATCH] videotestsrc: Simplify ARGB to Bayer conversion Simplify the conversion to bayer pattern as suggested by Nicolas Dufresne. Part-of: --- .../gst/videotestsrc/videotestsrc.c | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/videotestsrc/videotestsrc.c b/subprojects/gst-plugins-base/gst/videotestsrc/videotestsrc.c index 791292c00b..21e52fe4c9 100644 --- a/subprojects/gst-plugins-base/gst/videotestsrc/videotestsrc.c +++ b/subprojects/gst-plugins-base/gst/videotestsrc/videotestsrc.c @@ -1688,23 +1688,11 @@ convert_hline_bayer (paintinfo * p, GstVideoFrame * frame, int y) gint width = GST_VIDEO_FRAME_WIDTH (frame); int x_inv = p->x_invert; int y_inv = p->y_invert; + int y_offset = 1 - ((y ^ y_inv) & 1); - if ((y ^ y_inv) & 1) { - for (i = 0; i < width; i++) { - if ((i ^ x_inv) & 1) { - R[i] = argb[4 * i + 1]; - } else { - R[i] = argb[4 * i + 2]; - } - } - } else { - for (i = 0; i < width; i++) { - if ((i ^ x_inv) & 1) { - R[i] = argb[4 * i + 2]; - } else { - R[i] = argb[4 * i + 3]; - } - } + for (i = 0; i < width; i++) { + int x_offset = 2 - ((i ^ x_inv) & 1); + R[i] = argb[4 * i + y_offset + x_offset]; } }