2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 /* non-GST-specific stuff */
26 #include "gstvideotestsrc.h"
27 #include "videotestsrc.h"
28 #include "gstvideotestsrcorc.h"
36 #define M_PI 3.14159265358979323846
42 static unsigned int state;
46 return (state >> 16) & 0xff;
50 oil_splat_u8 (guint8 * dest, int stride, const guint8 * value, int n)
53 for (i = 0; i < n; i++) {
61 random_chars (unsigned char *dest, int nbytes)
64 static unsigned int state;
66 for (i = 0; i < nbytes; i++) {
69 dest[i] = (state >> 16);
76 paint_rect_random (unsigned char *dest, int stride, int x, int y, int w, int h)
78 unsigned char *d = dest + stride * y + x;
81 for (i = 0; i < h; i++) {
90 paint_rect (unsigned char *dest, int stride, int x, int y, int w, int h,
93 unsigned char *d = dest + stride * y + x;
96 for (i = 0; i < h; i++) {
97 gst_orc_splat_u8 (d, &color, w);
105 paint_rect_s2 (unsigned char *dest, int stride, int x, int y, int w, int h,
108 unsigned char *d = dest + stride * y + x * 2;
112 for (i = 0; i < h; i++) {
114 for (j = 0; j < w; j++) {
125 paint_rect2 (unsigned char *dest, int stride, int x, int y, int w, int h,
128 unsigned char *d = dest + stride * y + x * 2;
132 for (i = 0; i < h; i++) {
134 for (j = 0; j < w; j++) {
145 paint_rect3 (unsigned char *dest, int stride, int x, int y, int w, int h,
148 unsigned char *d = dest + stride * y + x * 3;
152 for (i = 0; i < h; i++) {
154 for (j = 0; j < w; j++) {
166 paint_rect4 (unsigned char *dest, int stride, int x, int y, int w, int h,
169 unsigned char *d = dest + stride * y + x * 4;
173 for (i = 0; i < h; i++) {
175 for (j = 0; j < w; j++) {
188 paint_rect_s4 (unsigned char *dest, int stride, int x, int y, int w, int h,
191 unsigned char *d = dest + stride * y + x * 4;
195 for (i = 0; i < h; i++) {
197 for (j = 0; j < w; j++) {
222 static const struct vts_color_struct vts_colors_bt709_ycbcr_100[] = {
223 {235, 128, 128, 255, 255, 255, 255, (235 << 8)},
224 {219, 16, 138, 255, 255, 255, 0, (219 << 8)},
225 {188, 154, 16, 255, 0, 255, 255, (188 < 8)},
226 {173, 42, 26, 255, 0, 255, 0, (173 << 8)},
227 {78, 214, 230, 255, 255, 0, 255, (78 << 8)},
228 {63, 102, 240, 255, 255, 0, 0, (64 << 8)},
229 {32, 240, 118, 255, 0, 0, 255, (32 << 8)},
230 {16, 128, 128, 255, 0, 0, 0, (16 << 8)},
231 {16, 198, 21, 255, 0, 0, 128, (16 << 8)}, /* -I ? */
232 {16, 235, 198, 255, 0, 128, 255, (16 << 8)}, /* +Q ? */
233 {0, 128, 128, 255, 0, 0, 0, 0},
234 {32, 128, 128, 255, 19, 19, 19, (32 << 8)},
237 static const struct vts_color_struct vts_colors_bt709_ycbcr_75[] = {
238 {180, 128, 128, 255, 191, 191, 191, (180 << 8)},
239 {168, 44, 136, 255, 191, 191, 0, (168 << 8)},
240 {145, 147, 44, 255, 0, 191, 191, (145 << 8)},
241 {133, 63, 52, 255, 0, 191, 0, (133 << 8)},
242 {63, 193, 204, 255, 191, 0, 191, (63 << 8)},
243 {51, 109, 212, 255, 191, 0, 0, (51 << 8)},
244 {28, 212, 120, 255, 0, 0, 191, (28 << 8)},
245 {16, 128, 128, 255, 0, 0, 0, (16 << 8)},
246 {16, 198, 21, 255, 0, 0, 128, (16 << 8)}, /* -I ? */
247 {16, 235, 198, 255, 0, 128, 255, (16 << 8)}, /* +Q ? */
248 {0, 128, 128, 255, 0, 0, 0, 0},
249 {32, 128, 128, 255, 19, 19, 19, (32 << 8)},
252 static const struct vts_color_struct vts_colors_bt601_ycbcr_100[] = {
253 {235, 128, 128, 255, 255, 255, 255, (235 << 8)},
254 {210, 16, 146, 255, 255, 255, 0, (219 << 8)},
255 {170, 166, 16, 255, 0, 255, 255, (188 < 8)},
256 {145, 54, 34, 255, 0, 255, 0, (173 << 8)},
257 {106, 202, 222, 255, 255, 0, 255, (78 << 8)},
258 {81, 90, 240, 255, 255, 0, 0, (64 << 8)},
259 {41, 240, 110, 255, 0, 0, 255, (32 << 8)},
260 {16, 128, 128, 255, 0, 0, 0, (16 << 8)},
261 {16, 198, 21, 255, 0, 0, 128, (16 << 8)}, /* -I ? */
262 {16, 235, 198, 255, 0, 128, 255, (16 << 8)}, /* +Q ? */
263 {-0, 128, 128, 255, 0, 0, 0, 0},
264 {32, 128, 128, 255, 19, 19, 19, (32 << 8)},
267 static const struct vts_color_struct vts_colors_bt601_ycbcr_75[] = {
268 {180, 128, 128, 255, 191, 191, 191, (180 << 8)},
269 {162, 44, 142, 255, 191, 191, 0, (168 << 8)},
270 {131, 156, 44, 255, 0, 191, 191, (145 << 8)},
271 {112, 72, 58, 255, 0, 191, 0, (133 << 8)},
272 {84, 184, 198, 255, 191, 0, 191, (63 << 8)},
273 {65, 100, 212, 255, 191, 0, 0, (51 << 8)},
274 {35, 212, 114, 255, 0, 0, 191, (28 << 8)},
275 {16, 128, 128, 255, 0, 0, 0, (16 << 8)},
276 {16, 198, 21, 255, 0, 0, 128, (16 << 8)}, /* -I ? */
277 {16, 235, 198, 255, 0, 128, 255, (16 << 8)}, /* +Q ? */
278 {-0, 128, 128, 255, 0, 0, 0, 0},
279 {32, 128, 128, 255, 19, 19, 19, (32 << 8)},
283 static void paint_setup_I420 (paintinfo * p, unsigned char *dest);
284 static void paint_setup_YV12 (paintinfo * p, unsigned char *dest);
285 static void paint_setup_YUY2 (paintinfo * p, unsigned char *dest);
286 static void paint_setup_UYVY (paintinfo * p, unsigned char *dest);
287 static void paint_setup_YVYU (paintinfo * p, unsigned char *dest);
288 static void paint_setup_IYU2 (paintinfo * p, unsigned char *dest);
289 static void paint_setup_Y41B (paintinfo * p, unsigned char *dest);
290 static void paint_setup_Y42B (paintinfo * p, unsigned char *dest);
291 static void paint_setup_Y444 (paintinfo * p, unsigned char *dest);
292 static void paint_setup_Y800 (paintinfo * p, unsigned char *dest);
293 static void paint_setup_AYUV (paintinfo * p, unsigned char *dest);
294 static void paint_setup_v308 (paintinfo * p, unsigned char *dest);
295 static void paint_setup_NV12 (paintinfo * p, unsigned char *dest);
296 static void paint_setup_NV21 (paintinfo * p, unsigned char *dest);
297 static void paint_setup_v410 (paintinfo * p, unsigned char *dest);
298 static void paint_setup_v216 (paintinfo * p, unsigned char *dest);
299 static void paint_setup_v210 (paintinfo * p, unsigned char *dest);
302 static void paint_setup_IMC1 (paintinfo * p, unsigned char *dest);
303 static void paint_setup_IMC2 (paintinfo * p, unsigned char *dest);
304 static void paint_setup_IMC3 (paintinfo * p, unsigned char *dest);
305 static void paint_setup_IMC4 (paintinfo * p, unsigned char *dest);
307 static void paint_setup_YUV9 (paintinfo * p, unsigned char *dest);
308 static void paint_setup_YVU9 (paintinfo * p, unsigned char *dest);
309 static void paint_setup_ARGB8888 (paintinfo * p, unsigned char *dest);
310 static void paint_setup_ABGR8888 (paintinfo * p, unsigned char *dest);
311 static void paint_setup_RGBA8888 (paintinfo * p, unsigned char *dest);
312 static void paint_setup_BGRA8888 (paintinfo * p, unsigned char *dest);
313 static void paint_setup_xRGB8888 (paintinfo * p, unsigned char *dest);
314 static void paint_setup_xBGR8888 (paintinfo * p, unsigned char *dest);
315 static void paint_setup_RGBx8888 (paintinfo * p, unsigned char *dest);
316 static void paint_setup_BGRx8888 (paintinfo * p, unsigned char *dest);
317 static void paint_setup_RGB888 (paintinfo * p, unsigned char *dest);
318 static void paint_setup_BGR888 (paintinfo * p, unsigned char *dest);
319 static void paint_setup_RGB565 (paintinfo * p, unsigned char *dest);
320 static void paint_setup_xRGB1555 (paintinfo * p, unsigned char *dest);
322 static void paint_setup_bayer (paintinfo * p, unsigned char *dest);
324 static void paint_hline_I420 (paintinfo * p, int x, int y, int w);
325 static void paint_hline_NV12 (paintinfo * p, int x, int y, int w);
326 static void paint_hline_NV21 (paintinfo * p, int x, int y, int w);
327 static void paint_hline_YUY2 (paintinfo * p, int x, int y, int w);
328 static void paint_hline_IYU2 (paintinfo * p, int x, int y, int w);
329 static void paint_hline_Y41B (paintinfo * p, int x, int y, int w);
330 static void paint_hline_Y42B (paintinfo * p, int x, int y, int w);
331 static void paint_hline_Y444 (paintinfo * p, int x, int y, int w);
332 static void paint_hline_Y800 (paintinfo * p, int x, int y, int w);
333 static void paint_hline_v308 (paintinfo * p, int x, int y, int w);
334 static void paint_hline_AYUV (paintinfo * p, int x, int y, int w);
335 static void paint_hline_v410 (paintinfo * p, int x, int y, int w);
336 static void paint_hline_v216 (paintinfo * p, int x, int y, int w);
337 static void paint_hline_v210 (paintinfo * p, int x, int y, int w);
340 static void paint_hline_IMC1 (paintinfo * p, int x, int y, int w);
342 static void paint_hline_YUV9 (paintinfo * p, int x, int y, int w);
343 static void paint_hline_str4 (paintinfo * p, int x, int y, int w);
344 static void paint_hline_str3 (paintinfo * p, int x, int y, int w);
345 static void paint_hline_RGB565 (paintinfo * p, int x, int y, int w);
346 static void paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w);
348 static void paint_hline_bayer (paintinfo * p, int x, int y, int w);
350 static void paint_setup_GRAY8 (paintinfo * p, unsigned char *dest);
351 static void paint_setup_GRAY16 (paintinfo * p, unsigned char *dest);
352 static void paint_hline_GRAY8 (paintinfo * p, int x, int y, int w);
353 static void paint_hline_GRAY16 (paintinfo * p, int x, int y, int w);
355 struct fourcc_list_struct fourcc_list[] = {
357 {VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, paint_hline_YUY2},
358 {VTS_YUV, "UYVY", "UYVY", 16, paint_setup_UYVY, paint_hline_YUY2},
359 {VTS_YUV, "Y422", "Y422", 16, paint_setup_UYVY, paint_hline_YUY2},
360 {VTS_YUV, "UYNV", "UYNV", 16, paint_setup_UYVY, paint_hline_YUY2}, /* FIXME: UYNV? */
361 {VTS_YUV, "YVYU", "YVYU", 16, paint_setup_YVYU, paint_hline_YUY2},
362 {VTS_YUV, "v308", "v308", 24, paint_setup_v308, paint_hline_v308},
363 {VTS_YUV, "AYUV", "AYUV", 32, paint_setup_AYUV, paint_hline_AYUV},
364 {VTS_YUV, "v410", "v410", 32, paint_setup_v410, paint_hline_v410},
365 {VTS_YUV, "v210", "v210", 21, paint_setup_v210, paint_hline_v210},
366 {VTS_YUV, "v216", "v216", 32, paint_setup_v216, paint_hline_v216},
369 /*{ VTS_YUV, "IUYV", "IUY2", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
372 /*{ VTS_YUV, "cyuv", "cyuv", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
374 /*{ VTS_YUV, "Y41P", "Y41P", 12, paint_setup_YVYU, paint_hline_YUY2 }, */
377 /*{ VTS_YUV, "IY41", "IY41", 12, paint_setup_YVYU, paint_hline_YUY2 }, */
379 /*{ VTS_YUV, "Y211", "Y211", 8, paint_setup_YVYU, paint_hline_YUY2 }, */
381 /*{ VTS_YUV, "Y41T", "Y41T", 12, paint_setup_YVYU, paint_hline_YUY2 }, */
382 /*{ VTS_YUV, "Y42P", "Y42P", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
383 /*{ VTS_YUV, "CLJR", "CLJR", 8, paint_setup_YVYU, paint_hline_YUY2 }, */
384 /*{ VTS_YUV, "IYU1", "IYU1", 12, paint_setup_YVYU, paint_hline_YUY2 }, */
385 {VTS_YUV, "IYU2", "IYU2", 24, paint_setup_IYU2, paint_hline_IYU2},
389 {VTS_YUV, "YVU9", "YVU9", 9, paint_setup_YVU9, paint_hline_YUV9},
391 {VTS_YUV, "YUV9", "YUV9", 9, paint_setup_YUV9, paint_hline_YUV9},
394 {VTS_YUV, "YV12", "YV12", 12, paint_setup_YV12, paint_hline_I420},
396 {VTS_YUV, "I420", "I420", 12, paint_setup_I420, paint_hline_I420},
398 {VTS_YUV, "NV12", "NV12", 12, paint_setup_NV12, paint_hline_NV12},
400 {VTS_YUV, "NV21", "NV21", 12, paint_setup_NV21, paint_hline_NV21},
403 {VTS_YUV, "IMC1", "IMC1", 16, paint_setup_IMC1, paint_hline_IMC1},
405 {VTS_YUV, "IMC2", "IMC2", 12, paint_setup_IMC2, paint_hline_IMC1},
407 {VTS_YUV, "IMC3", "IMC3", 16, paint_setup_IMC3, paint_hline_IMC1},
409 {VTS_YUV, "IMC4", "IMC4", 12, paint_setup_IMC4, paint_hline_IMC1},
413 {VTS_YUV, "Y41B", "Y41B", 12, paint_setup_Y41B, paint_hline_Y41B},
415 {VTS_YUV, "Y42B", "Y42B", 16, paint_setup_Y42B, paint_hline_Y42B},
417 {VTS_YUV, "Y444", "Y444", 24, paint_setup_Y444, paint_hline_Y444},
419 {VTS_YUV, "Y800", "Y800", 8, paint_setup_Y800, paint_hline_Y800},
421 /* Not exactly YUV but it's the same as above */
422 {VTS_GRAY, "GRAY8", "GRAY8", 8, paint_setup_GRAY8, paint_hline_GRAY8},
423 {VTS_GRAY, "GRAY16", "GRAY16", 16, paint_setup_GRAY16, paint_hline_GRAY16},
425 {VTS_RGB, "RGB ", "xRGB8888", 32, paint_setup_xRGB8888, paint_hline_str4, 24,
426 0x00ff0000, 0x0000ff00, 0x000000ff},
427 {VTS_RGB, "RGB ", "xBGR8888", 32, paint_setup_xBGR8888, paint_hline_str4, 24,
428 0x000000ff, 0x0000ff00, 0x00ff0000},
429 {VTS_RGB, "RGB ", "RGBx8888", 32, paint_setup_RGBx8888, paint_hline_str4, 24,
430 0xff000000, 0x00ff0000, 0x0000ff00},
431 {VTS_RGB, "RGB ", "BGRx8888", 32, paint_setup_BGRx8888, paint_hline_str4, 24,
432 0x0000ff00, 0x00ff0000, 0xff000000},
433 {VTS_RGB, "RGB ", "ARGB8888", 32, paint_setup_ARGB8888, paint_hline_str4, 32,
434 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000},
435 {VTS_RGB, "RGB ", "ABGR8888", 32, paint_setup_ABGR8888, paint_hline_str4, 32,
436 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000},
437 {VTS_RGB, "RGB ", "RGBA8888", 32, paint_setup_RGBA8888, paint_hline_str4, 32,
438 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff},
439 {VTS_RGB, "RGB ", "BGRA8888", 32, paint_setup_BGRA8888, paint_hline_str4, 32,
440 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff},
441 {VTS_RGB, "RGB ", "RGB888", 24, paint_setup_RGB888, paint_hline_str3, 24,
442 0x00ff0000, 0x0000ff00, 0x000000ff},
443 {VTS_RGB, "RGB ", "BGR888", 24, paint_setup_BGR888, paint_hline_str3, 24,
444 0x000000ff, 0x0000ff00, 0x00ff0000},
445 {VTS_RGB, "RGB ", "RGB565", 16, paint_setup_RGB565, paint_hline_RGB565, 16,
446 0x0000f800, 0x000007e0, 0x0000001f},
447 {VTS_RGB, "RGB ", "xRGB1555", 16, paint_setup_xRGB1555, paint_hline_xRGB1555,
449 0x00007c00, 0x000003e0, 0x0000001f},
451 {VTS_BAYER, "BAY8", "Bayer", 8, paint_setup_bayer, paint_hline_bayer}
454 int n_fourccs = G_N_ELEMENTS (fourcc_list);
456 struct fourcc_list_struct *
457 paintinfo_find_by_structure (const GstStructure * structure)
460 const char *media_type = gst_structure_get_name (structure);
463 g_return_val_if_fail (structure, NULL);
465 if (strcmp (media_type, "video/x-raw-gray") == 0) {
466 gint bpp, depth, endianness = 0;
468 ret = gst_structure_get_int (structure, "bpp", &bpp) &&
469 gst_structure_get_int (structure, "depth", &depth);
470 if (!ret || bpp != depth || (depth != 8 && depth != 16))
473 ret = gst_structure_get_int (structure, "endianness", &endianness);
474 if ((!ret || endianness != G_BYTE_ORDER) && bpp == 16)
477 for (i = 0; i < n_fourccs; i++) {
478 if (fourcc_list[i].type == VTS_GRAY && fourcc_list[i].bitspp == bpp) {
479 return fourcc_list + i;
482 } else if (strcmp (media_type, "video/x-raw-yuv") == 0) {
487 ret = gst_structure_get_fourcc (structure, "format", &format);
490 for (i = 0; i < n_fourccs; i++) {
491 s = fourcc_list[i].fourcc;
492 /* g_print("testing %" GST_FOURCC_FORMAT " and %s\n", GST_FOURCC_ARGS(format), s); */
493 fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
494 if (fourcc_list[i].type == VTS_YUV && fourcc == format) {
495 return fourcc_list + i;
498 } else if (strcmp (media_type, "video/x-raw-rgb") == 0) {
506 ret = gst_structure_get_int (structure, "red_mask", &red_mask);
507 ret &= gst_structure_get_int (structure, "green_mask", &green_mask);
508 ret &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
509 ret &= gst_structure_get_int (structure, "depth", &depth);
510 ret &= gst_structure_get_int (structure, "bpp", &bpp);
513 ret &= gst_structure_get_int (structure, "alpha_mask", &alpha_mask);
514 ret &= (alpha_mask != 0);
520 GST_WARNING ("incomplete caps structure: %" GST_PTR_FORMAT, structure);
524 for (i = 0; i < n_fourccs; i++) {
525 if (fourcc_list[i].type == VTS_RGB &&
526 fourcc_list[i].red_mask == red_mask &&
527 fourcc_list[i].green_mask == green_mask &&
528 fourcc_list[i].blue_mask == blue_mask &&
529 (alpha_mask == 0 || fourcc_list[i].alpha_mask == alpha_mask) &&
530 fourcc_list[i].depth == depth && fourcc_list[i].bitspp == bpp) {
531 return fourcc_list + i;
535 } else if (strcmp (media_type, "video/x-raw-bayer") == 0) {
536 for (i = 0; i < n_fourccs; i++) {
537 if (fourcc_list[i].type == VTS_BAYER) {
538 return fourcc_list + i;
544 g_critical ("format not found for media type %s", media_type);
549 struct fourcc_list_struct *
550 paintrect_find_fourcc (int find_fourcc)
554 for (i = 0; i < n_fourccs; i++) {
558 s = fourcc_list[i].fourcc;
559 fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
560 if (find_fourcc == fourcc) {
561 /* If YUV format, it's good */
562 if (!fourcc_list[i].type == VTS_YUV) {
563 return fourcc_list + i;
566 return fourcc_list + i;
572 struct fourcc_list_struct *
573 paintrect_find_name (const char *name)
577 for (i = 0; i < n_fourccs; i++) {
578 if (strcmp (name, fourcc_list[i].name) == 0) {
579 return fourcc_list + i;
587 paint_get_structure (struct fourcc_list_struct * format)
589 GstStructure *structure = NULL;
593 g_return_val_if_fail (format, NULL);
596 GST_MAKE_FOURCC (format->fourcc[0], format->fourcc[1], format->fourcc[2],
599 switch (format->type) {
601 if (format->bitspp == 16) {
602 endianness = G_BYTE_ORDER;
604 endianness = G_BIG_ENDIAN;
606 structure = gst_structure_new ("video/x-raw-rgb",
607 "bpp", G_TYPE_INT, format->bitspp,
608 "endianness", G_TYPE_INT, endianness,
609 "depth", G_TYPE_INT, format->depth,
610 "red_mask", G_TYPE_INT, format->red_mask,
611 "green_mask", G_TYPE_INT, format->green_mask,
612 "blue_mask", G_TYPE_INT, format->blue_mask, NULL);
613 if (format->depth == 32 && format->alpha_mask > 0) {
614 gst_structure_set (structure, "alpha_mask", G_TYPE_INT,
615 format->alpha_mask, NULL);
619 structure = gst_structure_new ("video/x-raw-gray",
620 "bpp", G_TYPE_INT, format->bitspp, "depth", G_TYPE_INT,
621 format->bitspp, NULL);
622 if (format->bitspp == 16)
623 gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER,
628 GValue value_list = { 0 };
629 GValue value = { 0 };
631 structure = gst_structure_new ("video/x-raw-yuv",
632 "format", GST_TYPE_FOURCC, fourcc, NULL);
634 if (fourcc != GST_STR_FOURCC ("Y800")) {
635 g_value_init (&value_list, GST_TYPE_LIST);
637 g_value_init (&value, G_TYPE_STRING);
638 g_value_set_static_string (&value, "sdtv");
639 gst_value_list_append_value (&value_list, &value);
641 g_value_set_static_string (&value, "hdtv");
642 gst_value_list_append_value (&value_list, &value);
644 gst_structure_set_value (structure, "color-matrix", &value_list);
645 g_value_reset (&value_list);
647 if (fourcc != GST_STR_FOURCC ("AYUV") &&
648 fourcc != GST_STR_FOURCC ("v308") &&
649 fourcc != GST_STR_FOURCC ("v410") &&
650 fourcc != GST_STR_FOURCC ("Y444")) {
651 g_value_set_static_string (&value, "mpeg2");
652 gst_value_list_append_value (&value_list, &value);
654 g_value_set_static_string (&value, "jpeg");
655 gst_value_list_append_value (&value_list, &value);
657 gst_structure_set_value (structure, "chroma-site", &value_list);
659 g_value_unset (&value_list);
664 structure = gst_structure_new ("video/x-raw-bayer", NULL);
667 g_assert_not_reached ();
673 /* returns the size in bytes for one video frame of the given dimensions
674 * given the fourcc in GstVideoTestSrc */
676 gst_video_test_src_get_size (GstVideoTestSrc * v, int w, int h)
678 paintinfo pi = { NULL, };
680 struct fourcc_list_struct *fourcc;
688 fourcc->paint_setup (p, NULL);
690 return (unsigned long) p->endptr;
694 #define ONE_HALF (1 << (SCALEBITS - 1))
695 #define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
697 #define RGB_TO_Y(r, g, b) \
698 ((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
699 FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
701 #define RGB_TO_U(r1, g1, b1, shift)\
702 (((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
703 FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
705 #define RGB_TO_V(r1, g1, b1, shift)\
706 (((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
707 FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
709 #define RGB_TO_Y_CCIR(r, g, b) \
710 ((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
711 FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
713 #define RGB_TO_U_CCIR(r1, g1, b1, shift)\
714 (((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
715 FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
717 #define RGB_TO_V_CCIR(r1, g1, b1, shift)\
718 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
719 FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
721 #define RGB_TO_Y_CCIR_709(r, g, b) \
722 ((FIX(0.212600*219.0/255.0) * (r) + FIX(0.715200*219.0/255.0) * (g) + \
723 FIX(0.072200*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
725 #define RGB_TO_U_CCIR_709(r1, g1, b1, shift)\
726 (((- FIX(0.114572*224.0/255.0) * r1 - FIX(0.385427*224.0/255.0) * g1 + \
727 FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
729 #define RGB_TO_V_CCIR_709(r1, g1, b1, shift)\
730 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.454153*224.0/255.0) * g1 - \
731 FIX(0.045847*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
734 videotestsrc_setup_paintinfo (GstVideoTestSrc * v, paintinfo * p, int w, int h)
738 if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
739 p->colors = vts_colors_bt601_ycbcr_100;
741 p->colors = vts_colors_bt709_ycbcr_100;
746 p->paint_hline = v->fourcc->paint_hline;
748 a = (v->foreground_color >> 24) & 0xff;
749 r = (v->foreground_color >> 16) & 0xff;
750 g = (v->foreground_color >> 8) & 0xff;
751 b = (v->foreground_color >> 0) & 0xff;
752 p->foreground_color.A = a;
753 p->foreground_color.R = r;
754 p->foreground_color.G = g;
755 p->foreground_color.B = b;
756 if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
757 p->foreground_color.Y = RGB_TO_Y_CCIR (r, g, b);
758 p->foreground_color.U = RGB_TO_U_CCIR (r, g, b, 0);
759 p->foreground_color.V = RGB_TO_V_CCIR (r, g, b, 0);
761 p->foreground_color.Y = RGB_TO_Y_CCIR_709 (r, g, b);
762 p->foreground_color.U = RGB_TO_U_CCIR_709 (r, g, b, 0);
763 p->foreground_color.V = RGB_TO_V_CCIR_709 (r, g, b, 0);
765 p->foreground_color.gray = RGB_TO_Y (r, g, b);
767 a = (v->background_color >> 24) & 0xff;
768 r = (v->background_color >> 16) & 0xff;
769 g = (v->background_color >> 8) & 0xff;
770 b = (v->background_color >> 0) & 0xff;
771 p->background_color.A = a;
772 p->background_color.R = r;
773 p->background_color.G = g;
774 p->background_color.B = b;
775 if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
776 p->background_color.Y = RGB_TO_Y_CCIR (r, g, b);
777 p->background_color.U = RGB_TO_U_CCIR (r, g, b, 0);
778 p->background_color.V = RGB_TO_V_CCIR (r, g, b, 0);
780 p->background_color.Y = RGB_TO_Y_CCIR_709 (r, g, b);
781 p->background_color.U = RGB_TO_U_CCIR_709 (r, g, b, 0);
782 p->background_color.V = RGB_TO_V_CCIR_709 (r, g, b, 0);
784 p->background_color.gray = RGB_TO_Y (r, g, b);
789 videotestsrc_blend_color (struct vts_color_struct *dest,
790 struct vts_color_struct *a, struct vts_color_struct *b, int x)
792 #define BLEND1(a,b,x) ((a)*(x) + (b)*(255-(x)))
793 #define DIV255(x) (((x) + (((x)+128)>>8) + 128)>>8)
794 #define BLEND(a,b,x) DIV255(BLEND1(a,b,x))
795 dest->Y = BLEND (a->Y, b->Y, x);
796 dest->U = BLEND (a->U, b->U, x);
797 dest->V = BLEND (a->V, b->V, x);
798 dest->R = BLEND (a->R, b->R, x);
799 dest->G = BLEND (a->G, b->G, x);
800 dest->B = BLEND (a->B, b->B, x);
801 dest->gray = BLEND (a->gray, b->gray, x);
807 gst_video_test_src_smpte (GstVideoTestSrc * v, unsigned char *dest, int w,
813 paintinfo pi = { NULL, };
815 struct fourcc_list_struct *fourcc;
817 videotestsrc_setup_paintinfo (v, p, w, h);
822 fourcc->paint_setup (p, dest);
828 for (i = 0; i < 7; i++) {
830 int x2 = (i + 1) * w / 7;
832 p->color = p->colors + i;
833 for (j = 0; j < y1; j++) {
834 p->paint_hline (p, x1, j, (x2 - x1));
838 /* inverse blue bars */
839 for (i = 0; i < 7; i++) {
841 int x2 = (i + 1) * w / 7;
849 p->color = p->colors + k;
850 for (j = y1; j < y2; j++) {
851 p->paint_hline (p, x1, j, (x2 - x1));
855 /* -I, white, Q regions */
856 for (i = 0; i < 3; i++) {
858 int x2 = (i + 1) * w / 6;
868 p->color = p->colors + k;
869 for (j = y2; j < h; j++) {
870 p->paint_hline (p, x1, j, (x2 - x1));
874 /* superblack, black, dark grey */
875 for (i = 0; i < 3; i++) {
876 int x1 = w / 2 + i * w / 12;
877 int x2 = w / 2 + (i + 1) * w / 12;
881 k = COLOR_SUPER_BLACK;
887 p->color = p->colors + k;
888 for (j = y2; j < h; j++) {
889 p->paint_hline (p, x1, j, (x2 - x1));
895 struct vts_color_struct color;
897 color = p->colors[COLOR_BLACK];
900 for (i = x1; i < w; i++) {
901 for (j = y2; j < h; j++) {
902 int y = random_char ();
903 videotestsrc_blend_color (&color, &p->foreground_color,
904 &p->background_color, y);
905 p->paint_hline (p, i, j, 1);
913 gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
918 paintinfo pi = { NULL, };
920 struct fourcc_list_struct *fourcc;
922 videotestsrc_setup_paintinfo (v, p, w, h);
927 fourcc->paint_setup (p, dest);
930 for (i = 0; i < 7; i++) {
932 int x2 = (i + 1) * w / 7;
934 p->color = p->colors + i;
935 for (j = 0; j < h; j++) {
936 p->paint_hline (p, x1, j, (x2 - x1));
942 gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
946 paintinfo pi = { NULL, };
948 struct fourcc_list_struct *fourcc;
949 struct vts_color_struct color;
951 videotestsrc_setup_paintinfo (v, p, w, h);
956 fourcc->paint_setup (p, dest);
958 color = p->colors[COLOR_BLACK];
961 for (i = 0; i < w; i++) {
962 for (j = 0; j < h; j++) {
963 int y = random_char ();
964 videotestsrc_blend_color (&color, &p->foreground_color,
965 &p->background_color, y);
966 p->paint_hline (p, i, j, 1);
972 gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
973 int h, int color_index)
976 paintinfo pi = { NULL, };
978 struct fourcc_list_struct *fourcc;
980 videotestsrc_setup_paintinfo (v, p, w, h);
985 fourcc->paint_setup (p, dest);
987 p->color = p->colors + color_index;
988 if (color_index == COLOR_BLACK) {
989 p->color = &p->background_color;
991 if (color_index == COLOR_WHITE) {
992 p->color = &p->foreground_color;
995 for (i = 0; i < h; i++) {
996 p->paint_hline (p, 0, i, w);
1001 gst_video_test_src_black (GstVideoTestSrc * v, guchar * dest, int w, int h)
1003 gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLACK);
1007 gst_video_test_src_white (GstVideoTestSrc * v, guchar * dest, int w, int h)
1009 gst_video_test_src_unicolor (v, dest, w, h, COLOR_WHITE);
1013 gst_video_test_src_red (GstVideoTestSrc * v, guchar * dest, int w, int h)
1015 gst_video_test_src_unicolor (v, dest, w, h, COLOR_RED);
1019 gst_video_test_src_green (GstVideoTestSrc * v, guchar * dest, int w, int h)
1021 gst_video_test_src_unicolor (v, dest, w, h, COLOR_GREEN);
1025 gst_video_test_src_blue (GstVideoTestSrc * v, guchar * dest, int w, int h)
1027 gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLUE);
1031 gst_video_test_src_solid (GstVideoTestSrc * v, unsigned char *dest, int w,
1035 paintinfo pi = { NULL, };
1037 struct fourcc_list_struct *fourcc;
1039 videotestsrc_setup_paintinfo (v, p, w, h);
1045 fourcc->paint_setup (p, dest);
1047 p->color = &p->foreground_color;
1049 for (i = 0; i < h; i++) {
1050 p->paint_hline (p, 0, i, w);
1055 gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
1058 paintinfo pi = { NULL, };
1060 struct fourcc_list_struct *fourcc;
1062 videotestsrc_setup_paintinfo (v, p, w, h);
1068 fourcc->paint_setup (p, dest);
1070 for (y = 0; y < h; y++) {
1071 p->color = p->colors + COLOR_GREEN;
1072 p->paint_hline (p, 0, y, w);
1073 for (x = (y % 2); x < w; x += 2) {
1074 p->color = p->colors + COLOR_RED;
1075 p->paint_hline (p, x, y, 1);
1081 gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h)
1084 paintinfo pi = { NULL, };
1086 struct fourcc_list_struct *fourcc;
1088 videotestsrc_setup_paintinfo (v, p, w, h);
1093 fourcc->paint_setup (p, dest);
1095 p->color = p->colors + COLOR_GREEN;
1096 for (y = 0; y < h; y++) {
1097 p->paint_hline (p, 0, y, w);
1100 for (y = 0; y < h; y += 2) {
1101 for (x = ((y % 4) == 0) ? 0 : 2; x < w; x += 4) {
1102 guint len = (x < (w - 1)) ? 2 : (w - x);
1104 p->color = p->colors + COLOR_RED;
1105 p->paint_hline (p, x, y + 0, len);
1106 if (G_LIKELY ((y + 1) < h)) {
1107 p->paint_hline (p, x, y + 1, len);
1114 gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h)
1117 paintinfo pi = { NULL, };
1119 struct fourcc_list_struct *fourcc;
1121 videotestsrc_setup_paintinfo (v, p, w, h);
1126 fourcc->paint_setup (p, dest);
1128 p->color = p->colors + COLOR_GREEN;
1129 for (y = 0; y < h; y++) {
1130 p->paint_hline (p, 0, y, w);
1133 for (y = 0; y < h; y += 4) {
1134 for (x = ((y % 8) == 0) ? 0 : 4; x < w; x += 8) {
1135 guint len = (x < (w - 3)) ? 4 : (w - x);
1137 p->color = p->colors + COLOR_RED;
1138 p->paint_hline (p, x, y + 0, len);
1139 if (G_LIKELY ((y + 1) < h)) {
1140 p->paint_hline (p, x, y + 1, len);
1141 if (G_LIKELY ((y + 2) < h)) {
1142 p->paint_hline (p, x, y + 2, len);
1143 if (G_LIKELY ((y + 3) < h)) {
1144 p->paint_hline (p, x, y + 3, len);
1153 gst_video_test_src_checkers8 (GstVideoTestSrc * v, guchar * dest, int w, int h)
1156 paintinfo pi = { NULL, };
1158 struct fourcc_list_struct *fourcc;
1160 videotestsrc_setup_paintinfo (v, p, w, h);
1165 fourcc->paint_setup (p, dest);
1167 p->color = p->colors + COLOR_GREEN;
1168 for (y = 0; y < h; y++) {
1169 for (x = 0; x < w; x += 8) {
1170 int len = MIN (8, w - x);
1172 if ((x ^ y) & (1 << 3)) {
1173 p->color = p->colors + COLOR_GREEN;
1175 p->color = p->colors + COLOR_RED;
1177 p->paint_hline (p, x, y, len);
1183 gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
1188 paintinfo pi = { NULL, };
1190 struct fourcc_list_struct *fourcc;
1191 struct vts_color_struct color;
1192 static guint8 sine_array[256];
1193 static int sine_array_inited = FALSE;
1194 int t = v->zoneplate_t;
1195 int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */
1196 int yreset = -(h / 2) - v->yoffset;
1207 int delta_kxt = v->kxt * t;
1209 int scale_kxy = 0xffff / (w / 2);
1210 int scale_kx2 = 0xffff / w;
1212 if (!sine_array_inited) {
1215 int range = white - black;
1216 for (i = 0; i < 256; i++) {
1218 floor (range * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5 + black);
1220 sine_array_inited = TRUE;
1223 videotestsrc_setup_paintinfo (v, p, w, h);
1228 fourcc->paint_setup (p, dest);
1230 color = p->colors[COLOR_BLACK];
1233 /* Zoneplate equation:
1235 * phase = k0 + kx*x + ky*y + kt*t
1236 * + kxt*x*t + kyt*y*t + kxy*x*y
1237 * + kx2*x*x + ky2*y*y + Kt2*t*t
1241 for (j = 0, y = yreset; j < h; j++, y++) {
1242 for (i = 0, x = xreset; i < w; i++, x++) {
1248 phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t);
1251 /* phase = phase + (v->kxt * i * t) + (v->kyt * j * t); */
1252 /* phase = phase + (v->kxy * x * y) / (w/2); */
1255 /*normalise x/y terms to rate of change of phase at the picture edge */
1257 phase + ((v->kx2 * x * x) / w) + ((v->ky2 * y * y) / h) +
1258 ((v->kt2 * t * t) >> 1);
1260 color.Y = sine_array[phase & 0xff];
1265 p->paint_hline (p, i, j, 1);
1270 /* optimised version, with original code shown in comments */
1274 kt2 = v->kt2 * t * t;
1275 for (j = 0, y = yreset; j < h; j++, y++) {
1279 accum_kyt += v->kyt * t;
1280 delta_kxy = v->kxy * y * scale_kxy;
1281 accum_kxy = delta_kxy * xreset;
1282 ky2 = (v->ky2 * y * y) / h;
1283 for (i = 0, x = xreset; i < w; i++, x++) {
1290 /* phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t); */
1291 phase = phase + accum_kx + accum_ky + kt;
1294 accum_kxt += delta_kxt;
1295 accum_kxy += delta_kxy;
1296 /* phase = phase + (v->kxt * i * t) + (v->kyt * j * t); */
1297 phase = phase + accum_kxt + accum_kyt;
1299 /* phase = phase + (v->kxy * x * y) / (w/2); */
1300 /* phase = phase + accum_kxy / (w/2); */
1301 phase = phase + (accum_kxy >> 16);
1304 /*normalise x/y terms to rate of change of phase at the picture edge */
1305 /*phase = phase + ((v->kx2 * x * x)/w) + ((v->ky2 * y * y)/h) + ((v->kt2 * t * t)>>1); */
1306 phase = phase + ((v->kx2 * x * x * scale_kx2) >> 16) + ky2 + (kt2 >> 1);
1308 videotestsrc_blend_color (&color, &p->foreground_color,
1309 &p->background_color, sine_array[phase & 0xff]);
1311 p->paint_hline (p, i, j, 1);
1319 gst_video_test_src_chromazoneplate (GstVideoTestSrc * v, unsigned char *dest,
1324 paintinfo pi = { NULL, };
1326 struct fourcc_list_struct *fourcc;
1327 struct vts_color_struct color;
1328 static guint8 sine_array[256];
1329 static int sine_array_inited = FALSE;
1330 int t = v->zoneplate_t;
1332 int xreset = -(w / 2) - v->xoffset; /* starting values for x^2 and y^2, centering the ellipse */
1333 int yreset = -(h / 2) - v->yoffset;
1344 int delta_kxt = v->kxt * t;
1346 int scale_kxy = 0xffff / (w / 2);
1347 int scale_kx2 = 0xffff / w;
1349 if (!sine_array_inited) {
1352 int range = white - black;
1353 for (i = 0; i < 256; i++) {
1355 floor (range * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5 + black);
1357 sine_array_inited = TRUE;
1360 videotestsrc_setup_paintinfo (v, p, w, h);
1365 fourcc->paint_setup (p, dest);
1367 color = p->colors[COLOR_BLACK];
1370 /* Zoneplate equation:
1372 * phase = k0 + kx*x + ky*y + kt*t
1373 * + kxt*x*t + kyt*y*t + kxy*x*y
1374 * + kx2*x*x + ky2*y*y + Kt2*t*t
1377 /* optimised version, with original code shown in comments */
1381 kt2 = v->kt2 * t * t;
1382 for (j = 0, y = yreset; j < h; j++, y++) {
1386 accum_kyt += v->kyt * t;
1387 delta_kxy = v->kxy * y * scale_kxy;
1388 accum_kxy = delta_kxy * xreset;
1389 ky2 = (v->ky2 * y * y) / h;
1390 for (i = 0, x = xreset; i < w; i++, x++) {
1397 /* phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t); */
1398 phase = phase + accum_kx + accum_ky + kt;
1401 accum_kxt += delta_kxt;
1402 accum_kxy += delta_kxy;
1403 /* phase = phase + (v->kxt * i * t) + (v->kyt * j * t); */
1404 phase = phase + accum_kxt + accum_kyt;
1406 /* phase = phase + (v->kxy * x * y) / (w/2); */
1407 /* phase = phase + accum_kxy / (w/2); */
1408 phase = phase + (accum_kxy >> 16);
1411 /*normalise x/y terms to rate of change of phase at the picture edge */
1412 /*phase = phase + ((v->kx2 * x * x)/w) + ((v->ky2 * y * y)/h) + ((v->kt2 * t * t)>>1); */
1413 phase = phase + ((v->kx2 * x * x * scale_kx2) >> 16) + ky2 + (kt2 >> 1);
1416 color.U = sine_array[phase & 0xff];
1417 color.V = sine_array[phase & 0xff];
1423 color.gray = color.Y << 8;
1424 p->paint_hline (p, i, j, 1);
1431 #undef SCALE_AMPLITUDE
1433 gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
1438 paintinfo pi = { NULL, };
1440 struct fourcc_list_struct *fourcc;
1441 struct vts_color_struct color;
1442 static guint8 sine_array[256];
1443 static int sine_array_inited = FALSE;
1446 #ifdef SCALE_AMPLITUDE
1451 if (!sine_array_inited) {
1452 for (i = 0; i < 256; i++) {
1454 floor (255 * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5);
1456 sine_array_inited = TRUE;
1459 videotestsrc_setup_paintinfo (v, p, w, h);
1464 fourcc->paint_setup (p, dest);
1466 color = p->colors[COLOR_BLACK];
1469 for (i = 1; i < 8; i++) {
1470 freq[i] = 200 * pow (2.0, -(i - 1) / 4.0);
1471 #ifdef SCALE_AMPLITUDE
1475 x = 2 * M_PI * freq[i] / w;
1476 ampl[i] = sin (x) / x;
1481 for (i = 0; i < w; i++) {
1482 for (j = 0; j < h; j++) {
1487 sqrt ((2 * i - w) * (2 * i - w) + (2 * j - h) * (2 * j -
1489 seg = floor (dist * 16);
1490 if (seg == 0 || seg >= 8) {
1491 color = p->foreground_color;
1493 #ifdef SCALE_AMPLITUDE
1496 d = floor (256 * dist * freq[seg] + 0.5);
1497 #ifdef SCALE_AMPLITUDE
1501 videotestsrc_blend_color (&color, &p->foreground_color,
1502 &p->background_color, 128 + a * (sine_array[d & 0xff] - 128));
1504 videotestsrc_blend_color (&color, &p->foreground_color,
1505 &p->background_color, sine_array[d & 0xff]);
1508 p->paint_hline (p, i, j, 1);
1514 gst_video_test_src_gamut (GstVideoTestSrc * v, guchar * dest, int w, int h)
1517 paintinfo pi = { NULL, };
1519 struct fourcc_list_struct *fourcc;
1520 struct vts_color_struct yuv_primary;
1521 struct vts_color_struct yuv_secondary;
1523 videotestsrc_setup_paintinfo (v, p, w, h);
1528 fourcc->paint_setup (p, dest);
1530 for (y = 0; y < h; y++) {
1531 int region = (y * 4) / h;
1535 yuv_primary = p->colors[COLOR_BLACK];
1536 yuv_secondary = p->colors[COLOR_BLACK];
1537 yuv_secondary.Y = 0;
1540 yuv_primary = p->colors[COLOR_WHITE];
1541 yuv_secondary = p->colors[COLOR_WHITE];
1542 yuv_secondary.Y = 255;
1545 yuv_primary = p->colors[COLOR_RED];
1546 yuv_secondary = p->colors[COLOR_RED];
1547 yuv_secondary.V = 255;
1550 yuv_primary = p->colors[COLOR_BLUE];
1551 yuv_secondary = p->colors[COLOR_BLUE];
1552 yuv_secondary.U = 255;
1556 for (x = 0; x < w; x += 8) {
1557 int len = MIN (8, w - x);
1559 if ((x ^ y) & (1 << 4)) {
1560 p->color = &yuv_primary;
1562 p->color = &yuv_secondary;
1564 p->paint_hline (p, x, y, len);
1570 gst_video_test_src_ball (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
1573 paintinfo pi = { NULL, };
1575 struct fourcc_list_struct *fourcc;
1576 int t = v->zoneplate_t;
1580 videotestsrc_setup_paintinfo (v, p, w, h);
1585 fourcc->paint_setup (p, dest);
1587 x = radius + (0.5 + 0.5 * sin (2 * M_PI * t / 200)) * (w - 2 * radius);
1588 y = radius + (0.5 + 0.5 * sin (2 * M_PI * sqrt (2) * t / 200)) * (h -
1591 for (i = 0; i < h; i++) {
1592 if (i < y - radius || i > y + radius) {
1593 p->color = &p->foreground_color;
1594 p->paint_hline (p, 0, i, w);
1596 int r = rint (sqrt (radius * radius - (i - y) * (i - y)));
1600 p->color = &p->foreground_color;
1602 x2 = MAX (0, x - r);
1603 p->paint_hline (p, x1, i, x2 - x1);
1605 x1 = MAX (0, x - r);
1606 x2 = MIN (w, x + r + 1);
1607 for (j = x1; j < x2; j++) {
1608 double rr = radius - sqrt ((j - x) * (j - x) + (i - y) * (i - y));
1609 struct vts_color_struct yuv;
1613 p->color = &p->foreground_color;
1614 } else if (rr > 1) {
1615 p->color = &p->background_color;
1617 #define BLEND(a,b,x) (rint((a)*(1-x) + (b)*(x)))
1618 yuv.Y = BLEND (p->foreground_color.Y, p->background_color.Y, rr);
1619 yuv.U = BLEND (p->foreground_color.U, p->background_color.U, rr);
1620 yuv.V = BLEND (p->foreground_color.V, p->background_color.V, rr);
1621 yuv.R = BLEND (p->foreground_color.R, p->background_color.R, rr);
1622 yuv.G = BLEND (p->foreground_color.G, p->background_color.G, rr);
1623 yuv.B = BLEND (p->foreground_color.B, p->background_color.B, rr);
1625 BLEND (p->foreground_color.gray, p->background_color.gray, rr);
1629 p->paint_hline (p, j, i, 1);
1632 p->color = &p->foreground_color;
1633 x1 = MIN (w, x + r + 1);
1635 p->paint_hline (p, x1, i, x2 - x1);
1643 paint_setup_I420 (paintinfo * p, unsigned char *dest)
1646 p->ystride = GST_ROUND_UP_4 (p->width);
1647 p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
1648 p->ustride = GST_ROUND_UP_8 (p->width) / 2;
1649 p->vp = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
1650 p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
1651 p->endptr = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
1655 paint_setup_NV12 (paintinfo * p, unsigned char *dest)
1658 p->ystride = GST_ROUND_UP_4 (p->width);
1659 p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
1661 p->ustride = p->ystride;
1662 p->vstride = p->ystride;
1663 p->endptr = p->up + (p->ystride * GST_ROUND_UP_2 (p->height)) / 2;
1667 paint_setup_NV21 (paintinfo * p, unsigned char *dest)
1670 p->ystride = GST_ROUND_UP_4 (p->width);
1671 p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
1673 p->ustride = p->ystride;
1674 p->vstride = p->ystride;
1675 p->endptr = p->vp + (p->ystride * GST_ROUND_UP_2 (p->height)) / 2;
1679 paint_hline_I420 (paintinfo * p, int x, int y, int w)
1682 int w1 = (x + w) / 2 - x1;
1683 int offset = y * p->ystride;
1684 int offset1 = (y / 2) * p->ustride;
1686 if (x + w == p->width && p->width % 2 != 0)
1688 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
1689 gst_orc_splat_u8 (p->up + offset1 + x1, p->color->U, w1);
1690 gst_orc_splat_u8 (p->vp + offset1 + x1, p->color->V, w1);
1694 paint_hline_NV12 (paintinfo * p, int x, int y, int w)
1697 int x2 = (x + w) / 2;
1698 int offset = y * p->ystride;
1699 int offsetuv = (y / 2) * p->ustride + (x & ~0x01);
1700 int uvlength = x2 - x1 + 1;
1703 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
1704 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1705 value = (p->color->U << 0) | (p->color->V << 8);
1707 value = (p->color->U << 8) | (p->color->V << 0);
1711 gst_orc_splat_u16 (p->up + offsetuv, value, uvlength);
1716 paint_hline_NV21 (paintinfo * p, int x, int y, int w)
1719 int x2 = (x + w) / 2;
1720 int offset = y * p->ystride;
1721 int offsetuv = (y / 2) * p->ustride + (x & ~0x01);
1722 int uvlength = x2 - x1 + 1;
1725 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
1726 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1727 value = (p->color->U << 8) | (p->color->V << 0);
1729 value = (p->color->U << 0) | (p->color->V << 8);
1733 gst_orc_splat_u16 (p->vp + offsetuv, value, uvlength);
1738 paint_setup_YV12 (paintinfo * p, unsigned char *dest)
1741 p->ystride = GST_ROUND_UP_4 (p->width);
1742 p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
1743 p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
1744 p->up = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
1745 p->ustride = GST_ROUND_UP_8 (p->ystride) / 2;
1746 p->endptr = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
1750 paint_setup_v308 (paintinfo * p, unsigned char *dest)
1755 p->ystride = GST_ROUND_UP_4 (p->width * 3);
1756 p->endptr = dest + p->ystride * p->height;
1760 paint_setup_AYUV (paintinfo * p, unsigned char *dest)
1766 p->ystride = p->width * 4;
1767 p->endptr = dest + p->ystride * p->height;
1771 paint_setup_v410 (paintinfo * p, unsigned char *dest)
1776 p->ystride = p->width * 4;
1777 p->endptr = dest + p->ystride * p->height;
1781 paint_setup_v216 (paintinfo * p, unsigned char *dest)
1787 p->ystride = p->width * 4;
1788 p->endptr = dest + p->ystride * p->height;
1792 paint_setup_v210 (paintinfo * p, unsigned char *dest)
1798 p->ystride = ((p->width + 47) / 48) * 128; /* no, really. */
1799 p->endptr = dest + p->ystride * p->height;
1803 paint_setup_YUY2 (paintinfo * p, unsigned char *dest)
1808 p->ystride = GST_ROUND_UP_2 (p->width) * 2;
1809 p->endptr = dest + p->ystride * p->height;
1813 paint_setup_UYVY (paintinfo * p, unsigned char *dest)
1818 p->ystride = GST_ROUND_UP_2 (p->width) * 2;
1819 p->endptr = dest + p->ystride * p->height;
1823 paint_setup_YVYU (paintinfo * p, unsigned char *dest)
1828 p->ystride = GST_ROUND_UP_2 (p->width) * 2;
1829 p->endptr = dest + p->ystride * p->height;
1833 paint_hline_v308 (paintinfo * p, int x, int y, int w)
1838 offset = (y * p->ystride) + (x * 3);
1839 for (i = 0; i < w; i++) {
1840 p->yp[offset + 3 * i] = p->color->Y;
1841 p->up[offset + 3 * i] = p->color->U;
1842 p->vp[offset + 3 * i] = p->color->V;
1847 paint_hline_AYUV (paintinfo * p, int x, int y, int w)
1852 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1853 value = (p->color->A << 0) | (p->color->Y << 8) |
1854 (p->color->U << 16) | (p->color->V << 24);
1856 value = (p->color->A << 24) | (p->color->Y << 16) |
1857 (p->color->U << 8) | (p->color->V << 0);
1860 offset = (y * p->ystride) + (x * 4);
1861 gst_orc_splat_u32 (p->ap + offset, value, w);
1864 #define TO_16(x) (((x)<<8) | (x))
1865 #define TO_10(x) (((x)<<2) | ((x)>>6))
1868 paint_hline_v216 (paintinfo * p, int x, int y, int w)
1871 int x2 = (x + w) / 2;
1876 offset = y * p->ystride;
1877 Y = TO_16 (p->color->Y);
1878 U = TO_16 (p->color->U);
1879 V = TO_16 (p->color->V);
1880 for (i = x; i < x + w; i++) {
1881 GST_WRITE_UINT16_LE (p->yp + offset + i * 4, Y);
1883 for (i = x1; i < x2; i++) {
1884 GST_WRITE_UINT16_LE (p->up + offset + i * 8, U);
1885 GST_WRITE_UINT16_LE (p->vp + offset + i * 8, V);
1890 paint_hline_v410 (paintinfo * p, int x, int y, int w)
1896 a = (TO_10 (p->color->U) << 22) |
1897 (TO_10 (p->color->Y) << 12) | (TO_10 (p->color->V) << 2);
1899 data = p->yp + y * p->ystride + x * 4;
1900 for (i = 0; i < w; i++) {
1901 GST_WRITE_UINT32_LE (data, a);
1906 paint_hline_v210 (paintinfo * p, int x, int y, int w)
1908 guint32 a0, a1, a2, a3;
1912 /* FIXME this is kinda gross. it only handles x values in
1915 a0 = TO_10 (p->color->U) | (TO_10 (p->color->Y) << 10)
1916 | (TO_10 (p->color->V) << 20);
1917 a1 = TO_10 (p->color->Y) | (TO_10 (p->color->U) << 10)
1918 | (TO_10 (p->color->Y) << 20);
1919 a2 = TO_10 (p->color->V) | (TO_10 (p->color->Y) << 10)
1920 | (TO_10 (p->color->U) << 20);
1921 a3 = TO_10 (p->color->Y) | (TO_10 (p->color->V) << 10)
1922 | (TO_10 (p->color->Y) << 20);
1924 data = p->yp + y * p->ystride;
1925 for (i = x / 6; i < (x + w) / 6; i++) {
1926 GST_WRITE_UINT32_LE (data + i * 16 + 0, a0);
1927 GST_WRITE_UINT32_LE (data + i * 16 + 4, a1);
1928 GST_WRITE_UINT32_LE (data + i * 16 + 8, a2);
1929 GST_WRITE_UINT32_LE (data + i * 16 + 12, a3);
1934 paint_hline_YUY2 (paintinfo * p, int x, int y, int w)
1937 int w1 = (x + w) / 2 - x1;
1938 int offset = y * p->ystride;
1940 if (x + w == p->width && p->width % 2 != 0)
1942 oil_splat_u8 (p->yp + offset + x * 2, 2, &p->color->Y, w);
1943 oil_splat_u8 (p->up + offset + x1 * 4, 4, &p->color->U, w1);
1944 oil_splat_u8 (p->vp + offset + x1 * 4, 4, &p->color->V, w1);
1948 paint_setup_IYU2 (paintinfo * p, unsigned char *dest)
1954 p->ystride = GST_ROUND_UP_4 (p->width * 3);
1955 p->endptr = dest + p->ystride * p->height;
1959 paint_hline_IYU2 (paintinfo * p, int x, int y, int w)
1963 offset = y * p->ystride;
1964 oil_splat_u8 (p->yp + offset + x * 3, 3, &p->color->Y, w);
1965 oil_splat_u8 (p->up + offset + x * 3, 3, &p->color->U, w);
1966 oil_splat_u8 (p->vp + offset + x * 3, 3, &p->color->V, w);
1970 paint_setup_Y41B (paintinfo * p, unsigned char *dest)
1973 p->ystride = GST_ROUND_UP_4 (p->width);
1974 p->up = p->yp + p->ystride * p->height;
1975 p->ustride = GST_ROUND_UP_16 (p->width) / 4;
1976 p->vp = p->up + p->ustride * p->height;
1977 p->vstride = GST_ROUND_UP_16 (p->width) / 4;
1978 p->endptr = p->vp + p->vstride * p->height;
1982 paint_hline_Y41B (paintinfo * p, int x, int y, int w)
1985 int w1 = (x + w) / 4 - x1;
1986 int offset = y * p->ystride;
1987 int offset1 = y * p->ustride;
1989 if (x + w == p->width && p->width % 4 != 0)
1991 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
1992 gst_orc_splat_u8 (p->up + offset1 + x1, p->color->U, w1);
1993 gst_orc_splat_u8 (p->vp + offset1 + x1, p->color->V, w1);
1997 paint_setup_Y42B (paintinfo * p, unsigned char *dest)
2000 p->ystride = GST_ROUND_UP_4 (p->width);
2001 p->up = p->yp + p->ystride * p->height;
2002 p->ustride = GST_ROUND_UP_8 (p->width) / 2;
2003 p->vp = p->up + p->ustride * p->height;
2004 p->vstride = GST_ROUND_UP_8 (p->width) / 2;
2005 p->endptr = p->vp + p->vstride * p->height;
2009 paint_hline_Y42B (paintinfo * p, int x, int y, int w)
2012 int w1 = (x + w) / 2 - x1;
2013 int offset = y * p->ystride;
2014 int offset1 = y * p->ustride;
2016 if (x + w == p->width && p->width % 2 != 0)
2018 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
2019 gst_orc_splat_u8 (p->up + offset1 + x1, p->color->U, w1);
2020 gst_orc_splat_u8 (p->vp + offset1 + x1, p->color->V, w1);
2024 paint_setup_Y444 (paintinfo * p, unsigned char *dest)
2027 p->ystride = GST_ROUND_UP_4 (p->width);
2028 p->up = p->yp + p->ystride * p->height;
2029 p->vp = p->up + p->ystride * p->height;
2030 p->endptr = p->vp + p->ystride * p->height;
2034 paint_hline_Y444 (paintinfo * p, int x, int y, int w)
2036 int offset = y * p->ystride;
2038 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
2039 gst_orc_splat_u8 (p->up + offset + x, p->color->U, w);
2040 gst_orc_splat_u8 (p->vp + offset + x, p->color->V, w);
2044 paint_setup_Y800 (paintinfo * p, unsigned char *dest)
2048 p->ystride = GST_ROUND_UP_4 (p->width);
2049 p->endptr = dest + p->ystride * p->height;
2053 paint_hline_Y800 (paintinfo * p, int x, int y, int w)
2055 int offset = y * p->ystride;
2057 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
2062 paint_setup_IMC1 (paintinfo * p, unsigned char *dest)
2065 p->up = dest + p->width * p->height;
2066 p->vp = dest + p->width * p->height + p->width * p->height / 2;
2070 paint_setup_IMC2 (paintinfo * p, unsigned char *dest)
2073 p->vp = dest + p->width * p->height;
2074 p->up = dest + p->width * p->height + p->width / 2;
2078 paint_setup_IMC3 (paintinfo * p, unsigned char *dest)
2081 p->up = dest + p->width * p->height + p->width * p->height / 2;
2082 p->vp = dest + p->width * p->height;
2086 paint_setup_IMC4 (paintinfo * p, unsigned char *dest)
2089 p->vp = dest + p->width * p->height + p->width / 2;
2090 p->up = dest + p->width * p->height;
2094 paint_hline_IMC1 (paintinfo * p, int x, int y, int w)
2097 int x2 = (x + w) / 2;
2098 int offset = y * p->width;
2099 int offset1 = (y / 2) * p->width;
2101 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
2102 gst_orc_splat_u8 (p->up + offset1 + x1, p->color->U, x2 - x1);
2103 gst_orc_splat_u8 (p->vp + offset1 + x1, p->color->V, x2 - x1);
2108 paint_setup_YVU9 (paintinfo * p, unsigned char *dest)
2110 int h = GST_ROUND_UP_4 (p->height);
2113 p->ystride = GST_ROUND_UP_4 (p->width);
2114 p->vp = p->yp + p->ystride * h;
2115 p->vstride = GST_ROUND_UP_4 (p->ystride / 4);
2116 p->up = p->vp + p->vstride * h / 4;
2117 p->ustride = GST_ROUND_UP_4 (p->ystride / 4);
2118 p->endptr = p->up + p->ustride * h / 4;
2122 paint_setup_YUV9 (paintinfo * p, unsigned char *dest)
2125 int h = GST_ROUND_UP_4 (p->height);
2128 p->ystride = GST_ROUND_UP_4 (p->width);
2129 p->up = p->yp + p->ystride * h;
2130 p->ustride = GST_ROUND_UP_4 (p->ystride / 4);
2131 p->vp = p->up + p->ustride * h / 4;
2132 p->vstride = GST_ROUND_UP_4 (p->ystride / 4);
2133 p->endptr = p->vp + p->vstride * h / 4;
2137 paint_hline_YUV9 (paintinfo * p, int x, int y, int w)
2140 int w1 = (x + w) / 4 - x1;
2141 int offset = y * p->ystride;
2142 int offset1 = (y / 4) * p->ustride;
2144 if (x + w == p->width && p->width % 4 != 0)
2146 gst_orc_splat_u8 (p->yp + offset + x, p->color->Y, w);
2147 gst_orc_splat_u8 (p->up + offset1 + x1, p->color->U, w1);
2148 gst_orc_splat_u8 (p->vp + offset1 + x1, p->color->V, w1);
2152 paint_setup_ARGB8888 (paintinfo * p, unsigned char *dest)
2154 paint_setup_xRGB8888 (p, dest);
2159 paint_setup_ABGR8888 (paintinfo * p, unsigned char *dest)
2161 paint_setup_xBGR8888 (p, dest);
2166 paint_setup_RGBA8888 (paintinfo * p, unsigned char *dest)
2168 paint_setup_RGBx8888 (p, dest);
2173 paint_setup_BGRA8888 (paintinfo * p, unsigned char *dest)
2175 paint_setup_BGRx8888 (p, dest);
2180 paint_setup_xRGB8888 (paintinfo * p, unsigned char *dest)
2185 p->ystride = p->width * 4;
2186 p->endptr = p->dest + p->ystride * p->height;
2190 paint_setup_xBGR8888 (paintinfo * p, unsigned char *dest)
2195 p->ystride = p->width * 4;
2196 p->endptr = p->dest + p->ystride * p->height;
2200 paint_setup_RGBx8888 (paintinfo * p, unsigned char *dest)
2205 p->ystride = p->width * 4;
2206 p->endptr = p->dest + p->ystride * p->height;
2210 paint_setup_BGRx8888 (paintinfo * p, unsigned char *dest)
2215 p->ystride = p->width * 4;
2216 p->endptr = p->dest + p->ystride * p->height;
2220 paint_setup_RGB888 (paintinfo * p, unsigned char *dest)
2225 p->ystride = GST_ROUND_UP_4 (p->width * 3);
2226 p->endptr = p->dest + p->ystride * p->height;
2230 paint_setup_BGR888 (paintinfo * p, unsigned char *dest)
2235 p->ystride = GST_ROUND_UP_4 (p->width * 3);
2236 p->endptr = p->dest + p->ystride * p->height;
2240 paint_hline_str4 (paintinfo * p, int x, int y, int w)
2242 int offset = y * p->ystride;
2244 oil_splat_u8 (p->yp + offset + x * 4, 4, &p->color->R, w);
2245 oil_splat_u8 (p->up + offset + x * 4, 4, &p->color->G, w);
2246 oil_splat_u8 (p->vp + offset + x * 4, 4, &p->color->B, w);
2248 if (p->ap != NULL) {
2249 oil_splat_u8 (p->ap + offset + (x * 4), 4, &p->color->A, w);
2254 paint_hline_str3 (paintinfo * p, int x, int y, int w)
2256 int offset = y * p->ystride;
2258 oil_splat_u8 (p->yp + offset + x * 3, 3, &p->color->R, w);
2259 oil_splat_u8 (p->up + offset + x * 3, 3, &p->color->G, w);
2260 oil_splat_u8 (p->vp + offset + x * 3, 3, &p->color->B, w);
2264 paint_setup_RGB565 (paintinfo * p, unsigned char *dest)
2267 p->ystride = GST_ROUND_UP_4 (p->width * 2);
2268 p->endptr = p->dest + p->ystride * p->height;
2272 paint_hline_RGB565 (paintinfo * p, int x, int y, int w)
2274 int offset = y * p->ystride;
2277 value = ((p->color->R & 0xf8) << 8) |
2278 ((p->color->G & 0xfc) << 3) | ((p->color->B & 0xf8) >> 3);
2280 gst_orc_splat_u16 (p->yp + offset + x * 2 + 0, value, w);
2284 paint_setup_xRGB1555 (paintinfo * p, unsigned char *dest)
2287 p->ystride = GST_ROUND_UP_4 (p->width * 2);
2288 p->endptr = p->dest + p->ystride * p->height;
2292 paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w)
2294 int offset = y * p->ystride;
2297 a = ((p->color->R >> 1) & 0x7c) | (p->color->G >> 6);
2298 b = ((p->color->G << 2) & 0xe0) | (p->color->B >> 3);
2300 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
2301 oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
2302 oil_splat_u8 (p->yp + offset + x * 2 + 1, 2, &a, w);
2304 oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &a, w);
2305 oil_splat_u8 (p->yp + offset + x * 2 + 1, 2, &b, w);
2311 paint_setup_bayer (paintinfo * p, unsigned char *dest)
2314 p->ystride = GST_ROUND_UP_4 (p->width);
2315 p->endptr = p->dest + p->ystride * p->height;
2319 paint_hline_bayer (paintinfo * p, int x, int y, int w)
2321 int offset = y * p->ystride;
2322 guint8 *dest = p->yp + offset;
2326 for (i = x; i < x + w; i++) {
2328 dest[i] = p->color->G;
2330 dest[i] = p->color->B;
2334 for (i = x; i < x + w; i++) {
2336 dest[i] = p->color->R;
2338 dest[i] = p->color->G;
2345 paint_setup_GRAY8 (paintinfo * p, unsigned char *dest)
2348 p->ystride = GST_ROUND_UP_4 (p->width);
2349 p->endptr = dest + p->ystride * p->height;
2353 paint_hline_GRAY8 (paintinfo * p, int x, int y, int w)
2355 int offset = y * p->ystride;
2356 guint8 color = p->color->gray >> 8;
2358 gst_orc_splat_u8 (p->yp + offset + x, color, w);
2362 paint_setup_GRAY16 (paintinfo * p, unsigned char *dest)
2365 p->ystride = GST_ROUND_UP_4 (p->width * 2);
2366 p->endptr = dest + p->ystride * p->height;
2370 paint_hline_GRAY16 (paintinfo * p, int x, int y, int w)
2372 int offset = y * p->ystride;
2374 gst_orc_splat_u16 (p->yp + offset + 2 * x, p->color->gray, w);