tools/buffers: Remove duplicate code 79/277179/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 30 Jun 2022 10:22:43 +0000 (19:22 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 7 Jul 2022 10:07:14 +0000 (19:07 +0900)
Change-Id: Id64cc0f159cb57d01f515b2708094612e7f6997e

tools/buffers.c

index ea88179..91dcab7 100644 (file)
@@ -195,40 +195,41 @@ struct color_yuv {
 #define MAKE_RGB24(rgb, r, g, b) \
        { .value = MAKE_RGBA(rgb, r, g, b, 0) }
 
+const struct color_yuv colors_yuv_top[] = {
+       MAKE_YUV_601(191, 192, 192),    /* grey */
+       MAKE_YUV_601(192, 192, 0),      /* yellow */
+       MAKE_YUV_601(0, 192, 192),      /* cyan */
+       MAKE_YUV_601(0, 192, 0),        /* green */
+       MAKE_YUV_601(192, 0, 192),      /* magenta */
+       MAKE_YUV_601(192, 0, 0),        /* red */
+       MAKE_YUV_601(0, 0, 192),        /* blue */
+};
+const struct color_yuv colors_yuv_middle[] = {
+       MAKE_YUV_601(0, 0, 192),        /* blue */
+       MAKE_YUV_601(19, 19, 19),       /* black */
+       MAKE_YUV_601(192, 0, 192),      /* magenta */
+       MAKE_YUV_601(19, 19, 19),       /* black */
+       MAKE_YUV_601(0, 192, 192),      /* cyan */
+       MAKE_YUV_601(19, 19, 19),       /* black */
+       MAKE_YUV_601(192, 192, 192),    /* grey */
+};
+const struct color_yuv colors_yuv_bottom[] = {
+       MAKE_YUV_601(0, 33, 76),        /* in-phase */
+       MAKE_YUV_601(255, 255, 255),    /* super white */
+       MAKE_YUV_601(50, 0, 106),       /* quadrature */
+       MAKE_YUV_601(19, 19, 19),       /* black */
+       MAKE_YUV_601(9, 9, 9),          /* 3.5% */
+       MAKE_YUV_601(19, 19, 19),       /* 7.5% */
+       MAKE_YUV_601(29, 29, 29),       /* 11.5% */
+       MAKE_YUV_601(19, 19, 19),       /* black */
+};
+
 static void
 fill_smpte_yuv_planar(const struct yuv_info *yuv,
                                          unsigned char *y_mem, unsigned char *u_mem,
                                          unsigned char *v_mem, unsigned int width,
                                          unsigned int height, unsigned int stride)
 {
-       const struct color_yuv colors_top[] = {
-               MAKE_YUV_601(191, 192, 192),    /* grey */
-               MAKE_YUV_601(192, 192, 0),      /* yellow */
-               MAKE_YUV_601(0, 192, 192),      /* cyan */
-               MAKE_YUV_601(0, 192, 0),        /* green */
-               MAKE_YUV_601(192, 0, 192),      /* magenta */
-               MAKE_YUV_601(192, 0, 0),        /* red */
-               MAKE_YUV_601(0, 0, 192),        /* blue */
-       };
-       const struct color_yuv colors_middle[] = {
-               MAKE_YUV_601(0, 0, 192),        /* blue */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(192, 0, 192),      /* magenta */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(0, 192, 192),      /* cyan */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(192, 192, 192),    /* grey */
-       };
-       const struct color_yuv colors_bottom[] = {
-               MAKE_YUV_601(0, 33, 76),        /* in-phase */
-               MAKE_YUV_601(255, 255, 255),    /* super white */
-               MAKE_YUV_601(50, 0, 106),       /* quadrature */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(9, 9, 9),          /* 3.5% */
-               MAKE_YUV_601(19, 19, 19),       /* 7.5% */
-               MAKE_YUV_601(29, 29, 29),       /* 11.5% */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-       };
        unsigned int cs = yuv->chroma_stride;
        unsigned int xsub = yuv->xsub;
        unsigned int ysub = yuv->ysub;
@@ -238,27 +239,27 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv,
        /* Luma */
        for (y = 0; y < height * 6 / 9; ++y) {
                for (x = 0; x < width; ++x)
-                       y_mem[x] = colors_top[x * 7 / width].y;
+                       y_mem[x] = colors_yuv_top[x * 7 / width].y;
                y_mem += stride;
        }
 
        for (; y < height * 7 / 9; ++y) {
                for (x = 0; x < width; ++x)
-                       y_mem[x] = colors_middle[x * 7 / width].y;
+                       y_mem[x] = colors_yuv_middle[x * 7 / width].y;
                y_mem += stride;
        }
 
        for (; y < height; ++y) {
                for (x = 0; x < width * 5 / 7; ++x)
-                       y_mem[x] = colors_bottom[x * 4 / (width * 5 / 7)].y;
+                       y_mem[x] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].y;
                for (; x < width * 6 / 7; ++x)
-                       y_mem[x] = colors_bottom[(x - width * 5 / 7) * 3
+                       y_mem[x] = colors_yuv_bottom[(x - width * 5 / 7) * 3
                                                                         / (width / 7) + 4].y;
                for (; x < width; ++x) {
                        if (rand_r(&rand_seed) % 2)
-                               y_mem[x] = colors_bottom[1].y;
+                               y_mem[x] = colors_yuv_bottom[1].y;
                        else
-                               y_mem[x] = colors_bottom[7].y;
+                               y_mem[x] = colors_yuv_bottom[7].y;
                }
                y_mem += stride;
        }
@@ -266,8 +267,8 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv,
        /* Chroma */
        for (y = 0; y < height / ysub * 6 / 9; ++y) {
                for (x = 0; x < width; x += xsub) {
-                       u_mem[x * cs / xsub] = colors_top[x * 7 / width].u;
-                       v_mem[x * cs / xsub] = colors_top[x * 7 / width].v;
+                       u_mem[x * cs / xsub] = colors_yuv_top[x * 7 / width].u;
+                       v_mem[x * cs / xsub] = colors_yuv_top[x * 7 / width].v;
                }
                u_mem += stride * cs / xsub;
                v_mem += stride * cs / xsub;
@@ -275,8 +276,8 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv,
 
        for (; y < height / ysub * 7 / 9; ++y) {
                for (x = 0; x < width; x += xsub) {
-                       u_mem[x * cs / xsub] = colors_middle[x * 7 / width].u;
-                       v_mem[x * cs / xsub] = colors_middle[x * 7 / width].v;
+                       u_mem[x * cs / xsub] = colors_yuv_middle[x * 7 / width].u;
+                       v_mem[x * cs / xsub] = colors_yuv_middle[x * 7 / width].v;
                }
                u_mem += stride * cs / xsub;
                v_mem += stride * cs / xsub;
@@ -285,23 +286,23 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv,
        for (; y < height / ysub; ++y) {
                for (x = 0; x < width * 5 / 7; x += xsub) {
                        u_mem[x * cs / xsub] =
-                               colors_bottom[x * 4 / (width * 5 / 7)].u;
+                               colors_yuv_bottom[x * 4 / (width * 5 / 7)].u;
                        v_mem[x * cs / xsub] =
-                               colors_bottom[x * 4 / (width * 5 / 7)].v;
+                               colors_yuv_bottom[x * 4 / (width * 5 / 7)].v;
                }
                for (; x < width * 6 / 7; x += xsub) {
-                       u_mem[x * cs / xsub] = colors_bottom[(x - width * 5 / 7) *
+                       u_mem[x * cs / xsub] = colors_yuv_bottom[(x - width * 5 / 7) *
                                                                                                 3 / (width / 7) + 4].u;
-                       v_mem[x * cs / xsub] = colors_bottom[(x - width * 5 / 7) *
+                       v_mem[x * cs / xsub] = colors_yuv_bottom[(x - width * 5 / 7) *
                                                                                                 3 / (width / 7) + 4].v;
                }
                for (; x < width; x += xsub) {
                        if (rand_r(&rand_seed) % 2) {
-                               u_mem[x * cs / xsub] = colors_bottom[1].u;
-                               v_mem[x * cs / xsub] = colors_bottom[1].v;
+                               u_mem[x * cs / xsub] = colors_yuv_bottom[1].u;
+                               v_mem[x * cs / xsub] = colors_yuv_bottom[1].v;
                        } else {
-                               u_mem[x * cs / xsub] = colors_bottom[7].u;
-                               v_mem[x * cs / xsub] = colors_bottom[7].v;
+                               u_mem[x * cs / xsub] = colors_yuv_bottom[7].u;
+                               v_mem[x * cs / xsub] = colors_yuv_bottom[7].v;
                        }
                }
                u_mem += stride * cs / xsub;
@@ -314,34 +315,6 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem,
                                          unsigned int width, unsigned int height,
                                          unsigned int stride)
 {
-       const struct color_yuv colors_top[] = {
-               MAKE_YUV_601(191, 192, 192),    /* grey */
-               MAKE_YUV_601(192, 192, 0),      /* yellow */
-               MAKE_YUV_601(0, 192, 192),      /* cyan */
-               MAKE_YUV_601(0, 192, 0),        /* green */
-               MAKE_YUV_601(192, 0, 192),      /* magenta */
-               MAKE_YUV_601(192, 0, 0),        /* red */
-               MAKE_YUV_601(0, 0, 192),        /* blue */
-       };
-       const struct color_yuv colors_middle[] = {
-               MAKE_YUV_601(0, 0, 192),        /* blue */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(192, 0, 192),      /* magenta */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(0, 192, 192),      /* cyan */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(192, 192, 192),    /* grey */
-       };
-       const struct color_yuv colors_bottom[] = {
-               MAKE_YUV_601(0, 33, 76),        /* in-phase */
-               MAKE_YUV_601(255, 255, 255),    /* super white */
-               MAKE_YUV_601(50, 0, 106),       /* quadrature */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-               MAKE_YUV_601(9, 9, 9),          /* 3.5% */
-               MAKE_YUV_601(19, 19, 19),       /* 7.5% */
-               MAKE_YUV_601(29, 29, 29),       /* 11.5% */
-               MAKE_YUV_601(19, 19, 19),       /* black */
-       };
        unsigned char *y_mem = (yuv->order & YUV_YC) ? mem : mem + 1;
        unsigned char *c_mem = (yuv->order & YUV_CY) ? mem : mem + 1;
        unsigned int u = (yuv->order & YUV_YCrCb) ? 2 : 0;
@@ -355,58 +328,58 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem,
        /* Luma */
        for (y = 0; y < height * 6 / 9; ++y) {
                for (x = 0; x < width; ++x)
-                       y_mem[2 * x] = colors_top[x * 7 / width].y;
+                       y_mem[2 * x] = colors_yuv_top[x * 7 / width].y;
                y_mem += stride;
        }
 
        for (; y < height * 7 / 9; ++y) {
                for (x = 0; x < width; ++x)
-                       y_mem[2 * x] = colors_middle[x * 7 / width].y;
+                       y_mem[2 * x] = colors_yuv_middle[x * 7 / width].y;
                y_mem += stride;
        }
 
        for (; y < height; ++y) {
                for (x = 0; x < width * 5 / 7; ++x)
-                       y_mem[2 * x] = colors_bottom[x * 4 / (width * 5 / 7)].y;
+                       y_mem[2 * x] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].y;
                for (; x < width * 6 / 7; ++x)
-                       y_mem[2 * x] = colors_bottom[(x - width * 5 / 7) * 3
+                       y_mem[2 * x] = colors_yuv_bottom[(x - width * 5 / 7) * 3
                                                                                 / (width / 7) + 4].y;
                for (; x < width; ++x)
-                       y_mem[2 * x] = colors_bottom[7].y;
+                       y_mem[2 * x] = colors_yuv_bottom[7].y;
                y_mem += stride;
        }
 
        /* Chroma */
        for (y = 0; y < height * 6 / 9; ++y) {
                for (x = 0; x < width; x += 2) {
-                       c_mem[2 * x + u] = colors_top[x * 7 / width].u;
-                       c_mem[2 * x + v] = colors_top[x * 7 / width].v;
+                       c_mem[2 * x + u] = colors_yuv_top[x * 7 / width].u;
+                       c_mem[2 * x + v] = colors_yuv_top[x * 7 / width].v;
                }
                c_mem += stride;
        }
 
        for (; y < height * 7 / 9; ++y) {
                for (x = 0; x < width; x += 2) {
-                       c_mem[2 * x + u] = colors_middle[x * 7 / width].u;
-                       c_mem[2 * x + v] = colors_middle[x * 7 / width].v;
+                       c_mem[2 * x + u] = colors_yuv_middle[x * 7 / width].u;
+                       c_mem[2 * x + v] = colors_yuv_middle[x * 7 / width].v;
                }
                c_mem += stride;
        }
 
        for (; y < height; ++y) {
                for (x = 0; x < width * 5 / 7; x += 2) {
-                       c_mem[2 * x + u] = colors_bottom[x * 4 / (width * 5 / 7)].u;
-                       c_mem[2 * x + v] = colors_bottom[x * 4 / (width * 5 / 7)].v;
+                       c_mem[2 * x + u] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].u;
+                       c_mem[2 * x + v] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].v;
                }
                for (; x < width * 6 / 7; x += 2) {
-                       c_mem[2 * x + u] = colors_bottom[(x - width * 5 / 7) *
+                       c_mem[2 * x + u] = colors_yuv_bottom[(x - width * 5 / 7) *
                                                                                         3 / (width / 7) + 4].u;
-                       c_mem[2 * x + v] = colors_bottom[(x - width * 5 / 7) *
+                       c_mem[2 * x + v] = colors_yuv_bottom[(x - width * 5 / 7) *
                                                                                         3 / (width / 7) + 4].v;
                }
                for (; x < width; x += 2) {
-                       c_mem[2 * x + u] = colors_bottom[7].u;
-                       c_mem[2 * x + v] = colors_bottom[7].v;
+                       c_mem[2 * x + u] = colors_yuv_bottom[7].u;
+                       c_mem[2 * x + v] = colors_yuv_bottom[7].v;
                }
                c_mem += stride;
        }
@@ -416,7 +389,7 @@ static void
 fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem,
                                 unsigned int width, unsigned int height, unsigned int stride)
 {
-       const uint16_t colors_top[] = {
+       const uint16_t colors_rgb16_top[] = {
                MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE),     /* grey */
                MAKE_RGBA(rgb, 192, 192, 0, ALPHA_VALUE),       /* yellow */
                MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE),       /* cyan */
@@ -425,7 +398,7 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBA(rgb, 192, 0, 0, ALPHA_VALUE),         /* red */
                MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE),         /* blue */
        };
-       const uint16_t colors_middle[] = {
+       const uint16_t colors_rgb16_middle[] = {
                MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE),         /* blue */
                MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE),        /* black */
                MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE),       /* magenta */
@@ -434,7 +407,7 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE),        /* black */
                MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE),     /* grey */
        };
-       const uint16_t colors_bottom[] = {
+       const uint16_t colors_rgb16_bottom[] = {
                MAKE_RGBA(rgb, 0, 33, 76, ALPHA_VALUE),         /* in-phase */
                MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE),     /* super white */
                MAKE_RGBA(rgb, 50, 0, 106, ALPHA_VALUE),        /* quadrature */
@@ -444,6 +417,7 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBA(rgb, 29, 29, 29, ALPHA_VALUE),        /* 11.5% */
                MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE),        /* black */
        };
+
        unsigned int x;
        unsigned int y;
 
@@ -452,26 +426,26 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem,
 
        for (y = 0; y < height * 6 / 9; ++y) {
                for (x = 0; x < width; ++x)
-                       ((uint16_t *)mem)[x] = colors_top[x * 7 / width];
+                       ((uint16_t *)mem)[x] = colors_rgb16_top[x * 7 / width];
                mem += stride;
        }
 
        for (; y < height * 7 / 9; ++y) {
                for (x = 0; x < width; ++x)
-                       ((uint16_t *)mem)[x] = colors_middle[x * 7 / width];
+                       ((uint16_t *)mem)[x] = colors_rgb16_middle[x * 7 / width];
                mem += stride;
        }
 
        for (; y < height; ++y) {
                for (x = 0; x < width * 5 / 7; ++x)
                        ((uint16_t *)mem)[x] =
-                               colors_bottom[x * 4 / (width * 5 / 7)];
+                               colors_rgb16_bottom[x * 4 / (width * 5 / 7)];
                for (; x < width * 6 / 7; ++x)
                        ((uint16_t *)mem)[x] =
-                               colors_bottom[(x - width * 5 / 7) * 3
+                               colors_rgb16_bottom[(x - width * 5 / 7) * 3
                                                          / (width / 7) + 4];
                for (; x < width; ++x)
-                       ((uint16_t *)mem)[x] = colors_bottom[7];
+                       ((uint16_t *)mem)[x] = colors_rgb16_bottom[7];
                mem += stride;
        }
 }
@@ -480,7 +454,7 @@ static void
 fill_smpte_rgb24(const struct rgb_info *rgb, void *mem,
                                 unsigned int width, unsigned int height, unsigned int stride)
 {
-       const struct color_rgb24 colors_top[] = {
+       const struct color_rgb24 colors_rgb24_top[] = {
                MAKE_RGB24(rgb, 192, 192, 192), /* grey */
                MAKE_RGB24(rgb, 192, 192, 0),   /* yellow */
                MAKE_RGB24(rgb, 0, 192, 192),   /* cyan */
@@ -489,7 +463,7 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem,
                MAKE_RGB24(rgb, 192, 0, 0),     /* red */
                MAKE_RGB24(rgb, 0, 0, 192),     /* blue */
        };
-       const struct color_rgb24 colors_middle[] = {
+       const struct color_rgb24 colors_rgb24_middle[] = {
                MAKE_RGB24(rgb, 0, 0, 192),     /* blue */
                MAKE_RGB24(rgb, 19, 19, 19),    /* black */
                MAKE_RGB24(rgb, 192, 0, 192),   /* magenta */
@@ -498,7 +472,7 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem,
                MAKE_RGB24(rgb, 19, 19, 19),    /* black */
                MAKE_RGB24(rgb, 192, 192, 192), /* grey */
        };
-       const struct color_rgb24 colors_bottom[] = {
+       const struct color_rgb24 colors_rgb24_bottom[] = {
                MAKE_RGB24(rgb, 0, 33, 76),     /* in-phase */
                MAKE_RGB24(rgb, 255, 255, 255), /* super white */
                MAKE_RGB24(rgb, 50, 0, 106),    /* quadrature */
@@ -508,6 +482,7 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem,
                MAKE_RGB24(rgb, 29, 29, 29),    /* 11.5% */
                MAKE_RGB24(rgb, 19, 19, 19),    /* black */
        };
+
        unsigned int x;
        unsigned int y;
 
@@ -517,36 +492,36 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem,
        for (y = 0; y < height * 6 / 9; ++y) {
                for (x = 0; x < width; ++x)
                        ((struct color_rgb24 *)mem)[x] =
-                               colors_top[x * 7 / width];
+                               colors_rgb24_top[x * 7 / width];
                mem += stride;
        }
 
        for (; y < height * 7 / 9; ++y) {
                for (x = 0; x < width; ++x)
                        ((struct color_rgb24 *)mem)[x] =
-                               colors_middle[x * 7 / width];
+                               colors_rgb24_middle[x * 7 / width];
                mem += stride;
        }
 
        for (; y < height; ++y) {
                for (x = 0; x < width * 5 / 7; ++x)
                        ((struct color_rgb24 *)mem)[x] =
-                               colors_bottom[x * 4 / (width * 5 / 7)];
+                               colors_rgb24_bottom[x * 4 / (width * 5 / 7)];
                for (; x < width * 6 / 7; ++x)
                        ((struct color_rgb24 *)mem)[x] =
-                               colors_bottom[(x - width * 5 / 7) * 3
+                               colors_rgb24_bottom[(x - width * 5 / 7) * 3
                                                          / (width / 7) + 4];
                for (; x < width; ++x)
-                       ((struct color_rgb24 *)mem)[x] = colors_bottom[7];
+                       ((struct color_rgb24 *)mem)[x] = colors_rgb24_bottom[7];
                mem += stride;
        }
 }
 
 static void
 fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem,
-                                unsigned int width, unsigned int height, unsigned int stride)
+                                unsigned int width, unsigned int height, unsigned int stride, bool alpha)
 {
-       const uint32_t colors_top[] = {
+       const uint32_t colors_rgba32_top[] = {
                MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE),     /* grey */
                MAKE_RGBA(rgb, 192, 192, 0, ALPHA_VALUE),       /* yellow */
                MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE),       /* cyan */
@@ -555,7 +530,7 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBA(rgb, 192, 0, 0, ALPHA_VALUE),         /* red */
                MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE),         /* blue */
        };
-       const uint32_t colors_middle[] = {
+       const uint32_t colors_rgba32_middle[] = {
                MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE),         /* blue */
                MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE),        /* black */
                MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE),       /* magenta */
@@ -564,7 +539,7 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE),        /* black */
                MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE),     /* grey */
        };
-       const uint32_t colors_bottom[] = {
+       const uint32_t colors_rgba32_bottom[] = {
                MAKE_RGBA(rgb, 0, 33, 76, ALPHA_VALUE),         /* in-phase */
                MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE),     /* super white */
                MAKE_RGBA(rgb, 50, 0, 106, ALPHA_VALUE),        /* quadrature */
@@ -574,43 +549,8 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBA(rgb, 29, 29, 29, ALPHA_VALUE),        /* 11.5% */
                MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE),        /* black */
        };
-       unsigned int x;
-       unsigned int y;
 
-       if (width < 8)
-               return;
-
-       for (y = 0; y < height * 6 / 9; ++y) {
-               for (x = 0; x < width; ++x)
-                       ((uint32_t *)mem)[x] = colors_top[x * 7 / width];
-               mem += stride;
-       }
-
-       for (; y < height * 7 / 9; ++y) {
-               for (x = 0; x < width; ++x)
-                       ((uint32_t *)mem)[x] = colors_middle[x * 7 / width];
-               mem += stride;
-       }
-
-       for (; y < height; ++y) {
-               for (x = 0; x < width * 5 / 7; ++x)
-                       ((uint32_t *)mem)[x] =
-                               colors_bottom[x * 4 / (width * 5 / 7)];
-               for (; x < width * 6 / 7; ++x)
-                       ((uint32_t *)mem)[x] =
-                               colors_bottom[(x - width * 5 / 7) * 3
-                                                         / (width / 7) + 4];
-               for (; x < width; ++x)
-                       ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE) : MAKE_RGBA(rgb, 0, 0, 0, ALPHA_VALUE);
-               mem += stride;
-       }
-}
-
-static void
-fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem,
-                                                                unsigned int width, unsigned int height, unsigned int stride)
-{
-       const uint32_t colors_top[] = {
+       const uint32_t colors_rgbx32_top[] = {
                MAKE_RGBX(rgb, 192, 192, 192),  /* grey */
                MAKE_RGBX(rgb, 192, 192, 0),    /* yellow */
                MAKE_RGBX(rgb, 0, 192, 192),    /* cyan */
@@ -619,7 +559,7 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBX(rgb, 192, 0, 0),              /* red */
                MAKE_RGBX(rgb, 0, 0, 192),              /* blue */
        };
-       const uint32_t colors_middle[] = {
+       const uint32_t colors_rgbx32_middle[] = {
                MAKE_RGBX(rgb, 0, 0, 192),              /* blue */
                MAKE_RGBX(rgb, 19, 19, 19),     /* black */
                MAKE_RGBX(rgb, 192, 0, 192),    /* magenta */
@@ -628,7 +568,7 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBX(rgb, 19, 19, 19),     /* black */
                MAKE_RGBX(rgb, 192, 192, 192),  /* grey */
        };
-       const uint32_t colors_bottom[] = {
+       const uint32_t colors_rgbx32_bottom[] = {
                MAKE_RGBX(rgb, 0, 33, 76),              /* in-phase */
                MAKE_RGBX(rgb, 255, 255, 255),  /* super white */
                MAKE_RGBX(rgb, 50, 0, 106),     /* quadrature */
@@ -638,9 +578,24 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem,
                MAKE_RGBX(rgb, 29, 29, 29),     /* 11.5% */
                MAKE_RGBX(rgb, 19, 19, 19),     /* black */
        };
+
+       const uint32_t *colors_top;
+       const uint32_t *colors_middle;
+       const uint32_t *colors_bottom;
+
        unsigned int x;
        unsigned int y;
 
+       if (alpha) {
+               colors_top = colors_rgba32_top;
+               colors_middle = colors_rgba32_middle;
+               colors_bottom = colors_rgba32_bottom;
+       } else {
+               colors_top = colors_rgbx32_top;
+               colors_middle = colors_rgbx32_middle;
+               colors_bottom = colors_rgbx32_bottom;
+       }
+
        if (width < 8)
                return;
 
@@ -664,8 +619,12 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem,
                        ((uint32_t *)mem)[x] =
                                colors_bottom[(x - width * 5 / 7) * 3
                                                          / (width / 7) + 4];
-               for (; x < width; ++x)
-                       ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBX(rgb, 255, 255, 255) : MAKE_RGBX(rgb, 0, 0, 0);
+               for (; x < width; ++x) {
+                       if (alpha)
+                               ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE) : MAKE_RGBA(rgb, 0, 0, 0, ALPHA_VALUE);
+                       else
+                               ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBX(rgb, 255, 255, 255) : MAKE_RGBX(rgb, 0, 0, 0);
+               }
                mem += stride;
        }
 }
@@ -742,10 +701,10 @@ fill_smpte(const struct format_info *info, void *planes[3], unsigned int width,
        case TBM_FORMAT_BGRA1010102:
        case TBM_FORMAT_BGRX1010102:
                return fill_smpte_rgb32(&info->rgb, planes[0],
-                                                               width, height, stride);
+                                                               width, height, stride, true);
        case TBM_FORMAT_XRGB8888:
-               return fill_smpte_rgb32_dont_care_alpha(&info->rgb, planes[0],
-                                                                                               width, height, stride);
+               return fill_smpte_rgb32(&info->rgb, planes[0],
+                                                               width, height, stride, false);
        }
 }