gst_plugins_base/gst/videotestsrc/videotestsrc.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    23 
    23 
    24 /* non-GST-specific stuff */
    24 /* non-GST-specific stuff */
    25 
    25 
    26 #include "gstvideotestsrc.h"
    26 #include "gstvideotestsrc.h"
    27 #include "videotestsrc.h"
    27 #include "videotestsrc.h"
    28 #include <liboil/liboil.h>
    28 #include <gst/liboil.h>
    29 
    29 
    30 #ifdef __SYMBIAN32__
       
    31 #include <liboil/globals.h>
       
    32 #endif
       
    33 
    30 
    34 #include <string.h>
    31 #include <string.h>
    35 #include <stdlib.h>
    32 #include <stdlib.h>
    36 #include <math.h>
    33 #include <math.h>
    37 
    34 
   210   COLOR_POS_Q,
   207   COLOR_POS_Q,
   211   COLOR_SUPER_BLACK,
   208   COLOR_SUPER_BLACK,
   212   COLOR_DARK_GREY
   209   COLOR_DARK_GREY
   213 };
   210 };
   214 
   211 
   215 static const struct vts_color_struct_rgb vts_colors_rgb[] = {
   212 static const struct vts_color_struct vts_colors[] = {
   216   {255, 255, 255},
   213   /* 100% white */
   217   {255, 255, 0},
   214   {255, 128, 128, 255, 255, 255, 255},
   218   {0, 255, 255},
   215   /* yellow */
   219   {0, 255, 0},
   216   {226, 0, 155, 255, 255, 0, 255},
   220   {255, 0, 255},
   217   /* cyan */
   221   {255, 0, 0},
   218   {179, 170, 0, 0, 255, 255, 255},
   222   {0, 0, 255},
   219   /* green */
   223   {0, 0, 0},
   220   {150, 46, 21, 0, 255, 0, 255},
   224   {0, 0, 128},                  /* -I ? */
   221   /* magenta */
   225   {0, 128, 255},                /* +Q ? */
   222   {105, 212, 235, 255, 0, 255, 255},
   226   {0, 0, 0},
   223   /* red */
   227   {19, 19, 19},
   224   {76, 85, 255, 255, 0, 0, 255},
       
   225   /* blue */
       
   226   {29, 255, 107, 0, 0, 255, 255},
       
   227   /* black */
       
   228   {16, 128, 128, 0, 0, 0, 255},
       
   229   /* -I */
       
   230   {16, 198, 21, 0, 0, 128, 255},
       
   231   /* +Q */
       
   232   {16, 235, 198, 0, 128, 255, 255},
       
   233   /* superblack */
       
   234   {0, 128, 128, 0, 0, 0, 255},
       
   235   /* 5% grey */
       
   236   {32, 128, 128, 32, 32, 32, 255},
   228 };
   237 };
   229 
   238 
   230 static const struct vts_color_struct_rgb vts_colors_rgb_75[] = {
   239 
   231   {191, 191, 191},
   240 #if 0
   232   {191, 191, 0},
   241 
   233   {0, 191, 191},
   242 /*                        wht  yel  cya  grn  mag  red  blu  blk   -I    Q, superblack, dark grey */
   234   {0, 191, 0},
   243 static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 16, 0, 32 };
   235   {191, 0, 191},
   244 static int u_colors[] =
   236   {191, 0, 0},
   245     { 128, 0, 170, 46, 212, 85, 255, 128, 198, 235, 128, 128 };
   237   {0, 0, 191},
   246 static int v_colors[] =
   238   {0, 0, 0},
   247     { 128, 155, 0, 21, 235, 255, 107, 128, 21, 198, 128, 128 };
   239   {0, 0, 128},                  /* -I ? */
   248 
   240   {0, 128, 255},                /* +Q ? */
   249 /*                        wht  yel  cya  grn  mag  red  blu  blk   -I    Q  superblack, dark grey */
   241   {0, 0, 0},
   250 static int r_colors[] = { 255, 255, 0, 0, 255, 255, 0, 0, 0, 0, 0, 32 };
   242   {19, 19, 19},
   251 static int g_colors[] = { 255, 255, 255, 255, 0, 0, 0, 0, 0, 128, 0, 32 };
   243 };
   252 static int b_colors[] = { 255, 0, 255, 0, 255, 0, 255, 0, 128, 255, 0, 32 };
   244 
   253 #endif
   245 static const struct vts_color_struct_yuv vts_colors_bt709_ycbcr_100[] = {
   254 
   246   {235, 128, 128},
       
   247   {219, 16, 138},
       
   248   {188, 154, 16},
       
   249   {173, 42, 26},
       
   250   {78, 214, 230},
       
   251   {63, 102, 240},
       
   252   {32, 240, 118},
       
   253   {16, 128, 128},
       
   254   {16, 198, 21},                /* -I ? */
       
   255   {16, 235, 198},               /* +Q ? */
       
   256   {0, 128, 128},
       
   257   {32, 128, 128},
       
   258 };
       
   259 
       
   260 static const struct vts_color_struct_yuv vts_colors_bt709_ycbcr_75[] = {
       
   261   {180, 128, 128},
       
   262   {168, 44, 136},
       
   263   {145, 147, 44},
       
   264   {133, 63, 52},
       
   265   {63, 193, 204},
       
   266   {51, 109, 212},
       
   267   {28, 212, 120},
       
   268   {16, 128, 128},
       
   269   {16, 198, 21},                /* -I ? */
       
   270   {16, 235, 198},               /* +Q ? */
       
   271   {0, 128, 128},
       
   272   {32, 128, 128},
       
   273 };
       
   274 
       
   275 static const struct vts_color_struct_yuv vts_colors_bt601_ycbcr_100[] = {
       
   276   {235, 128, 128},
       
   277   {210, 16, 146},
       
   278   {170, 166, 16},
       
   279   {145, 54, 34},
       
   280   {106, 202, 222},
       
   281   {81, 90, 240},
       
   282   {41, 240, 110},
       
   283   {16, 128, 128},
       
   284   {16, 198, 21},                /* -I ? */
       
   285   {16, 235, 198},               /* +Q ? */
       
   286   {-0, 128, 128},
       
   287   {32, 128, 128},
       
   288 };
       
   289 
       
   290 static const struct vts_color_struct_yuv vts_colors_bt601_ycbcr_75[] = {
       
   291   {180, 128, 128},
       
   292   {162, 44, 142},
       
   293   {131, 156, 44},
       
   294   {112, 72, 58},
       
   295   {84, 184, 198},
       
   296   {65, 100, 212},
       
   297   {35, 212, 114},
       
   298   {16, 128, 128},
       
   299   {16, 198, 21},                /* -I ? */
       
   300   {16, 235, 198},               /* +Q ? */
       
   301   {-0, 128, 128},
       
   302   {32, 128, 128},
       
   303 };
       
   304 
       
   305 static const struct vts_color_struct_gray vts_colors_gray_100[] = {
       
   306   {235 << 8},
       
   307   {210 << 8},
       
   308   {170 << 8},
       
   309   {145 << 8},
       
   310   {106 << 8},
       
   311   {81 << 8},
       
   312   {41 << 8},
       
   313   {16 << 8},
       
   314   {16 << 8},
       
   315   {16 << 8},
       
   316   {-0 << 8},
       
   317   {32 << 8},
       
   318 };
       
   319 
       
   320 static const struct vts_color_struct_gray vts_colors_gray_75[] = {
       
   321   {180 << 8},
       
   322   {162 << 8},
       
   323   {131 << 8},
       
   324   {112 << 8},
       
   325   {84 << 8},
       
   326   {65 << 8},
       
   327   {35 << 8},
       
   328   {16 << 8},
       
   329   {16 << 8},
       
   330   {16 << 8},
       
   331   {-0 << 8},
       
   332   {32 << 8},
       
   333 };
       
   334 
   255 
   335 static void paint_setup_I420 (paintinfo * p, unsigned char *dest);
   256 static void paint_setup_I420 (paintinfo * p, unsigned char *dest);
   336 static void paint_setup_YV12 (paintinfo * p, unsigned char *dest);
   257 static void paint_setup_YV12 (paintinfo * p, unsigned char *dest);
   337 static void paint_setup_YUY2 (paintinfo * p, unsigned char *dest);
   258 static void paint_setup_YUY2 (paintinfo * p, unsigned char *dest);
   338 static void paint_setup_UYVY (paintinfo * p, unsigned char *dest);
   259 static void paint_setup_UYVY (paintinfo * p, unsigned char *dest);
   339 static void paint_setup_YVYU (paintinfo * p, unsigned char *dest);
   260 static void paint_setup_YVYU (paintinfo * p, unsigned char *dest);
   340 static void paint_setup_IYU2 (paintinfo * p, unsigned char *dest);
   261 static void paint_setup_IYU2 (paintinfo * p, unsigned char *dest);
   341 static void paint_setup_Y41B (paintinfo * p, unsigned char *dest);
   262 static void paint_setup_Y41B (paintinfo * p, unsigned char *dest);
   342 static void paint_setup_Y42B (paintinfo * p, unsigned char *dest);
   263 static void paint_setup_Y42B (paintinfo * p, unsigned char *dest);
   343 static void paint_setup_Y444 (paintinfo * p, unsigned char *dest);
       
   344 static void paint_setup_Y800 (paintinfo * p, unsigned char *dest);
   264 static void paint_setup_Y800 (paintinfo * p, unsigned char *dest);
   345 static void paint_setup_AYUV (paintinfo * p, unsigned char *dest);
   265 static void paint_setup_AYUV (paintinfo * p, unsigned char *dest);
   346 static void paint_setup_v308 (paintinfo * p, unsigned char *dest);
       
   347 static void paint_setup_NV12 (paintinfo * p, unsigned char *dest);
       
   348 static void paint_setup_NV21 (paintinfo * p, unsigned char *dest);
       
   349 static void paint_setup_v410 (paintinfo * p, unsigned char *dest);
       
   350 static void paint_setup_v216 (paintinfo * p, unsigned char *dest);
       
   351 static void paint_setup_v210 (paintinfo * p, unsigned char *dest);
       
   352 
   266 
   353 #if 0
   267 #if 0
   354 static void paint_setup_IMC1 (paintinfo * p, unsigned char *dest);
   268 static void paint_setup_IMC1 (paintinfo * p, unsigned char *dest);
   355 static void paint_setup_IMC2 (paintinfo * p, unsigned char *dest);
   269 static void paint_setup_IMC2 (paintinfo * p, unsigned char *dest);
   356 static void paint_setup_IMC3 (paintinfo * p, unsigned char *dest);
   270 static void paint_setup_IMC3 (paintinfo * p, unsigned char *dest);
   372 static void paint_setup_xRGB1555 (paintinfo * p, unsigned char *dest);
   286 static void paint_setup_xRGB1555 (paintinfo * p, unsigned char *dest);
   373 
   287 
   374 static void paint_setup_bayer (paintinfo * p, unsigned char *dest);
   288 static void paint_setup_bayer (paintinfo * p, unsigned char *dest);
   375 
   289 
   376 static void paint_hline_I420 (paintinfo * p, int x, int y, int w);
   290 static void paint_hline_I420 (paintinfo * p, int x, int y, int w);
   377 static void paint_hline_NV12_NV21 (paintinfo * p, int x, int y, int w);
       
   378 static void paint_hline_YUY2 (paintinfo * p, int x, int y, int w);
   291 static void paint_hline_YUY2 (paintinfo * p, int x, int y, int w);
   379 static void paint_hline_IYU2 (paintinfo * p, int x, int y, int w);
   292 static void paint_hline_IYU2 (paintinfo * p, int x, int y, int w);
   380 static void paint_hline_Y41B (paintinfo * p, int x, int y, int w);
   293 static void paint_hline_Y41B (paintinfo * p, int x, int y, int w);
   381 static void paint_hline_Y42B (paintinfo * p, int x, int y, int w);
   294 static void paint_hline_Y42B (paintinfo * p, int x, int y, int w);
   382 static void paint_hline_Y444 (paintinfo * p, int x, int y, int w);
       
   383 static void paint_hline_Y800 (paintinfo * p, int x, int y, int w);
   295 static void paint_hline_Y800 (paintinfo * p, int x, int y, int w);
   384 static void paint_hline_v308 (paintinfo * p, int x, int y, int w);
       
   385 static void paint_hline_AYUV (paintinfo * p, int x, int y, int w);
   296 static void paint_hline_AYUV (paintinfo * p, int x, int y, int w);
   386 static void paint_hline_v410 (paintinfo * p, int x, int y, int w);
       
   387 static void paint_hline_v216 (paintinfo * p, int x, int y, int w);
       
   388 static void paint_hline_v210 (paintinfo * p, int x, int y, int w);
       
   389 
   297 
   390 #if 0
   298 #if 0
   391 static void paint_hline_IMC1 (paintinfo * p, int x, int y, int w);
   299 static void paint_hline_IMC1 (paintinfo * p, int x, int y, int w);
   392 #endif
   300 #endif
   393 static void paint_hline_YUV9 (paintinfo * p, int x, int y, int w);
   301 static void paint_hline_YUV9 (paintinfo * p, int x, int y, int w);
   395 static void paint_hline_str3 (paintinfo * p, int x, int y, int w);
   303 static void paint_hline_str3 (paintinfo * p, int x, int y, int w);
   396 static void paint_hline_RGB565 (paintinfo * p, int x, int y, int w);
   304 static void paint_hline_RGB565 (paintinfo * p, int x, int y, int w);
   397 static void paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w);
   305 static void paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w);
   398 
   306 
   399 static void paint_hline_bayer (paintinfo * p, int x, int y, int w);
   307 static void paint_hline_bayer (paintinfo * p, int x, int y, int w);
   400 
       
   401 static void paint_setup_GRAY8 (paintinfo * p, unsigned char *dest);
       
   402 static void paint_setup_GRAY16 (paintinfo * p, unsigned char *dest);
       
   403 static void paint_hline_GRAY8 (paintinfo * p, int x, int y, int w);
       
   404 static void paint_hline_GRAY16 (paintinfo * p, int x, int y, int w);
       
   405 
   308 
   406 struct fourcc_list_struct fourcc_list[] = {
   309 struct fourcc_list_struct fourcc_list[] = {
   407 /* packed */
   310 /* packed */
   408   {VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, paint_hline_YUY2},
   311   {VTS_YUV, "YUY2", "YUY2", 16, paint_setup_YUY2, paint_hline_YUY2},
   409   {VTS_YUV, "UYVY", "UYVY", 16, paint_setup_UYVY, paint_hline_YUY2},
   312   {VTS_YUV, "UYVY", "UYVY", 16, paint_setup_UYVY, paint_hline_YUY2},
   410   {VTS_YUV, "Y422", "Y422", 16, paint_setup_UYVY, paint_hline_YUY2},
   313   {VTS_YUV, "Y422", "Y422", 16, paint_setup_UYVY, paint_hline_YUY2},
   411   {VTS_YUV, "UYNV", "UYNV", 16, paint_setup_UYVY, paint_hline_YUY2},    /* FIXME: UYNV? */
   314   {VTS_YUV, "UYNV", "UYNV", 16, paint_setup_UYVY, paint_hline_YUY2},    /* FIXME: UYNV? */
   412   {VTS_YUV, "YVYU", "YVYU", 16, paint_setup_YVYU, paint_hline_YUY2},
   315   {VTS_YUV, "YVYU", "YVYU", 16, paint_setup_YVYU, paint_hline_YUY2},
   413   {VTS_YUV, "v308", "v308", 24, paint_setup_v308, paint_hline_v308},
       
   414   {VTS_YUV, "AYUV", "AYUV", 32, paint_setup_AYUV, paint_hline_AYUV},
   316   {VTS_YUV, "AYUV", "AYUV", 32, paint_setup_AYUV, paint_hline_AYUV},
   415   {VTS_YUV, "v410", "v410", 32, paint_setup_v410, paint_hline_v410},
       
   416   {VTS_YUV, "v210", "v210", 21, paint_setup_v210, paint_hline_v210},
       
   417   {VTS_YUV, "v216", "v216", 32, paint_setup_v216, paint_hline_v216},
       
   418 
   317 
   419   /* interlaced */
   318   /* interlaced */
   420   /*{ VTS_YUV,  "IUYV", "IUY2", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
   319   /*{ VTS_YUV,  "IUYV", "IUY2", 16, paint_setup_YVYU, paint_hline_YUY2 }, */
   421 
   320 
   422   /* inverted */
   321   /* inverted */
   444   /* YV12 */
   343   /* YV12 */
   445   {VTS_YUV, "YV12", "YV12", 12, paint_setup_YV12, paint_hline_I420},
   344   {VTS_YUV, "YV12", "YV12", 12, paint_setup_YV12, paint_hline_I420},
   446   /* I420 */
   345   /* I420 */
   447   {VTS_YUV, "I420", "I420", 12, paint_setup_I420, paint_hline_I420},
   346   {VTS_YUV, "I420", "I420", 12, paint_setup_I420, paint_hline_I420},
   448   /* NV12 */
   347   /* NV12 */
   449   {VTS_YUV, "NV12", "NV12", 12, paint_setup_NV12, paint_hline_NV12_NV21},
       
   450   /* NV21 */
   348   /* NV21 */
   451   {VTS_YUV, "NV21", "NV21", 12, paint_setup_NV21, paint_hline_NV12_NV21},
       
   452 #if 0
   349 #if 0
   453   /* IMC1 */
   350   /* IMC1 */
   454   {VTS_YUV, "IMC1", "IMC1", 16, paint_setup_IMC1, paint_hline_IMC1},
   351   {VTS_YUV, "IMC1", "IMC1", 16, paint_setup_IMC1, paint_hline_IMC1},
   455   /* IMC2 */
   352   /* IMC2 */
   456   {VTS_YUV, "IMC2", "IMC2", 12, paint_setup_IMC2, paint_hline_IMC1},
   353   {VTS_YUV, "IMC2", "IMC2", 12, paint_setup_IMC2, paint_hline_IMC1},
   462   /* CLPL */
   359   /* CLPL */
   463   /* Y41B */
   360   /* Y41B */
   464   {VTS_YUV, "Y41B", "Y41B", 12, paint_setup_Y41B, paint_hline_Y41B},
   361   {VTS_YUV, "Y41B", "Y41B", 12, paint_setup_Y41B, paint_hline_Y41B},
   465   /* Y42B */
   362   /* Y42B */
   466   {VTS_YUV, "Y42B", "Y42B", 16, paint_setup_Y42B, paint_hline_Y42B},
   363   {VTS_YUV, "Y42B", "Y42B", 16, paint_setup_Y42B, paint_hline_Y42B},
   467   /* Y444 */
       
   468   {VTS_YUV, "Y444", "Y444", 24, paint_setup_Y444, paint_hline_Y444},
       
   469   /* Y800 grayscale */
   364   /* Y800 grayscale */
   470   {VTS_YUV, "Y800", "Y800", 8, paint_setup_Y800, paint_hline_Y800},
   365   {VTS_YUV, "Y800", "Y800", 8, paint_setup_Y800, paint_hline_Y800},
   471 
       
   472   /* Not exactly YUV but it's the same as above */
       
   473   {VTS_GRAY, "GRAY8", "GRAY8", 8, paint_setup_GRAY8, paint_hline_GRAY8},
       
   474   {VTS_GRAY, "GRAY16", "GRAY16", 16, paint_setup_GRAY16, paint_hline_GRAY16},
       
   475 
   366 
   476   {VTS_RGB, "RGB ", "xRGB8888", 32, paint_setup_xRGB8888, paint_hline_str4, 24,
   367   {VTS_RGB, "RGB ", "xRGB8888", 32, paint_setup_xRGB8888, paint_hline_str4, 24,
   477       0x00ff0000, 0x0000ff00, 0x000000ff},
   368       0x00ff0000, 0x0000ff00, 0x000000ff},
   478   {VTS_RGB, "RGB ", "xBGR8888", 32, paint_setup_xBGR8888, paint_hline_str4, 24,
   369   {VTS_RGB, "RGB ", "xBGR8888", 32, paint_setup_xBGR8888, paint_hline_str4, 24,
   479       0x000000ff, 0x0000ff00, 0x00ff0000},
   370       0x000000ff, 0x0000ff00, 0x00ff0000},
   499         15,
   390         15,
   500       0x00007c00, 0x000003e0, 0x0000001f},
   391       0x00007c00, 0x000003e0, 0x0000001f},
   501 
   392 
   502   {VTS_BAYER, "BAY8", "Bayer", 8, paint_setup_bayer, paint_hline_bayer}
   393   {VTS_BAYER, "BAY8", "Bayer", 8, paint_setup_bayer, paint_hline_bayer}
   503 };
   394 };
   504 
       
   505 int n_fourccs = G_N_ELEMENTS (fourcc_list);
   395 int n_fourccs = G_N_ELEMENTS (fourcc_list);
   506 
   396 
   507 struct fourcc_list_struct *
   397 struct fourcc_list_struct *
   508 paintinfo_find_by_structure (const GstStructure * structure)
   398 paintinfo_find_by_structure (const GstStructure * structure)
   509 {
   399 {
   511   const char *media_type = gst_structure_get_name (structure);
   401   const char *media_type = gst_structure_get_name (structure);
   512   int ret;
   402   int ret;
   513 
   403 
   514   g_return_val_if_fail (structure, NULL);
   404   g_return_val_if_fail (structure, NULL);
   515 
   405 
   516   if (strcmp (media_type, "video/x-raw-gray") == 0) {
   406   if (strcmp (media_type, "video/x-raw-yuv") == 0) {
   517     gint bpp, depth, endianness = 0;
       
   518 
       
   519     ret = gst_structure_get_int (structure, "bpp", &bpp) &&
       
   520         gst_structure_get_int (structure, "depth", &depth);
       
   521     if (!ret || bpp != depth || (depth != 8 && depth != 16))
       
   522       return NULL;
       
   523 
       
   524     ret = gst_structure_get_int (structure, "endianness", &endianness);
       
   525     if ((!ret || endianness != G_BYTE_ORDER) && bpp == 16)
       
   526       return NULL;
       
   527 
       
   528     for (i = 0; i < n_fourccs; i++) {
       
   529       if (fourcc_list[i].type == VTS_GRAY && fourcc_list[i].bitspp == bpp) {
       
   530         return fourcc_list + i;
       
   531       }
       
   532     }
       
   533   } else if (strcmp (media_type, "video/x-raw-yuv") == 0) {
       
   534     char *s;
   407     char *s;
   535     int fourcc;
   408     int fourcc;
   536     guint32 format;
   409     guint32 format;
   537 
   410 
   538     ret = gst_structure_get_fourcc (structure, "format", &format);
   411     ret = gst_structure_get_fourcc (structure, "format", &format);
   664       if (format->depth == 32 && format->alpha_mask > 0) {
   537       if (format->depth == 32 && format->alpha_mask > 0) {
   665         gst_structure_set (structure, "alpha_mask", G_TYPE_INT,
   538         gst_structure_set (structure, "alpha_mask", G_TYPE_INT,
   666             format->alpha_mask, NULL);
   539             format->alpha_mask, NULL);
   667       }
   540       }
   668       break;
   541       break;
   669     case VTS_GRAY:
       
   670       structure = gst_structure_new ("video/x-raw-gray",
       
   671           "bpp", G_TYPE_INT, format->bitspp, "depth", G_TYPE_INT,
       
   672           format->bitspp, NULL);
       
   673       if (format->bitspp == 16)
       
   674         gst_structure_set (structure, "endianness", G_TYPE_INT, G_BYTE_ORDER,
       
   675             NULL);
       
   676       break;
       
   677     case VTS_YUV:
   542     case VTS_YUV:
   678       structure = gst_structure_new ("video/x-raw-yuv",
   543       structure = gst_structure_new ("video/x-raw-yuv",
   679           "format", GST_TYPE_FOURCC, fourcc, NULL);
   544           "format", GST_TYPE_FOURCC, fourcc, NULL);
   680       break;
   545       break;
   681     case VTS_BAYER:
   546     case VTS_BAYER:
   717   int j;
   582   int j;
   718   paintinfo pi = { NULL, };
   583   paintinfo pi = { NULL, };
   719   paintinfo *p = &pi;
   584   paintinfo *p = &pi;
   720   struct fourcc_list_struct *fourcc;
   585   struct fourcc_list_struct *fourcc;
   721 
   586 
   722   p->rgb_colors = vts_colors_rgb;
       
   723   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
   724     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
   725   } else {
       
   726     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
   727   }
       
   728   p->gray_colors = vts_colors_gray_100;
       
   729   p->width = w;
   587   p->width = w;
   730   p->height = h;
   588   p->height = h;
   731   fourcc = v->fourcc;
   589   fourcc = v->fourcc;
   732   if (fourcc == NULL)
   590   if (fourcc == NULL)
   733     return;
   591     return;
   741   /* color bars */
   599   /* color bars */
   742   for (i = 0; i < 7; i++) {
   600   for (i = 0; i < 7; i++) {
   743     int x1 = i * w / 7;
   601     int x1 = i * w / 7;
   744     int x2 = (i + 1) * w / 7;
   602     int x2 = (i + 1) * w / 7;
   745 
   603 
   746     p->yuv_color = p->yuv_colors + i;
   604     p->color = vts_colors + i;
   747     p->rgb_color = p->rgb_colors + i;
       
   748     p->gray_color = p->gray_colors + i;
       
   749     for (j = 0; j < y1; j++) {
   605     for (j = 0; j < y1; j++) {
   750       p->paint_hline (p, x1, j, (x2 - x1));
   606       p->paint_hline (p, x1, j, (x2 - x1));
   751     }
   607     }
   752   }
   608   }
   753 
   609 
   760     if (i & 1) {
   616     if (i & 1) {
   761       k = 7;
   617       k = 7;
   762     } else {
   618     } else {
   763       k = 6 - i;
   619       k = 6 - i;
   764     }
   620     }
   765     p->yuv_color = p->yuv_colors + k;
   621     p->color = vts_colors + k;
   766     p->rgb_color = p->rgb_colors + k;
       
   767     p->gray_color = p->gray_colors + k;
       
   768     for (j = y1; j < y2; j++) {
   622     for (j = y1; j < y2; j++) {
   769       p->paint_hline (p, x1, j, (x2 - x1));
   623       p->paint_hline (p, x1, j, (x2 - x1));
   770     }
   624     }
   771   }
   625   }
   772 
   626 
   781     } else if (i == 1) {
   635     } else if (i == 1) {
   782       k = 0;
   636       k = 0;
   783     } else
   637     } else
   784       k = 9;
   638       k = 9;
   785 
   639 
   786     p->yuv_color = p->yuv_colors + k;
   640     p->color = vts_colors + k;
   787     p->rgb_color = p->rgb_colors + k;
       
   788     p->gray_color = p->gray_colors + k;
       
   789     for (j = y2; j < h; j++) {
   641     for (j = y2; j < h; j++) {
   790       p->paint_hline (p, x1, j, (x2 - x1));
   642       p->paint_hline (p, x1, j, (x2 - x1));
   791     }
   643     }
   792   }
   644   }
   793 
   645 
   802     } else if (i == 1) {
   654     } else if (i == 1) {
   803       k = COLOR_BLACK;
   655       k = COLOR_BLACK;
   804     } else
   656     } else
   805       k = COLOR_DARK_GREY;
   657       k = COLOR_DARK_GREY;
   806 
   658 
   807     p->yuv_color = p->yuv_colors + k;
   659     p->color = vts_colors + k;
   808     p->rgb_color = p->rgb_colors + k;
       
   809     p->gray_color = p->gray_colors + k;
       
   810     for (j = y2; j < h; j++) {
   660     for (j = y2; j < h; j++) {
   811       p->paint_hline (p, x1, j, (x2 - x1));
   661       p->paint_hline (p, x1, j, (x2 - x1));
   812     }
   662     }
   813   }
   663   }
   814 
   664 
   815   {
   665   {
   816     int x1 = w * 3 / 4;
   666     int x1 = w * 3 / 4;
   817     struct vts_color_struct_rgb rgb_color;
   667     struct vts_color_struct color;
   818     struct vts_color_struct_yuv yuv_color;
   668 
   819     struct vts_color_struct_gray gray_color;
   669     color = vts_colors[COLOR_BLACK];
   820 
   670     p->color = &color;
   821     rgb_color = p->rgb_colors[COLOR_BLACK];
       
   822     yuv_color = p->yuv_colors[COLOR_BLACK];
       
   823     gray_color = p->gray_colors[COLOR_BLACK];
       
   824     p->rgb_color = &rgb_color;
       
   825     p->yuv_color = &yuv_color;
       
   826     p->gray_color = &gray_color;
       
   827 
   671 
   828     for (i = x1; i < w; i++) {
   672     for (i = x1; i < w; i++) {
   829       for (j = y2; j < h; j++) {
   673       for (j = y2; j < h; j++) {
   830         /* FIXME not strictly correct */
   674         /* FIXME not strictly correct */
   831         int y = random_char ();
   675         color.Y = random_char ();
   832         yuv_color.Y = y;
   676         color.R = color.Y;
   833         rgb_color.R = y;
   677         color.G = color.Y;
   834         rgb_color.G = y;
   678         color.B = color.Y;
   835         rgb_color.B = y;
       
   836         gray_color.G = (y << 8) | random_char ();
       
   837         p->paint_hline (p, i, j, 1);
   679         p->paint_hline (p, i, j, 1);
   838       }
   680       }
   839     }
   681     }
   840 
   682 
   841   }
   683   }
   842 }
   684 }
   843 
   685 
   844 void
   686 void
   845 gst_video_test_src_smpte75 (GstVideoTestSrc * v, unsigned char *dest, int w,
   687 gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
   846     int h)
       
   847 {
   688 {
   848   int i;
   689   int i;
   849   int j;
   690   int j;
   850   paintinfo pi = { NULL, };
   691   paintinfo pi = { NULL, };
   851   paintinfo *p = &pi;
   692   paintinfo *p = &pi;
   852   struct fourcc_list_struct *fourcc;
   693   struct fourcc_list_struct *fourcc;
   853 
   694   struct vts_color_struct color;
   854   p->rgb_colors = vts_colors_rgb_75;
   695 
   855   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
   856     p->yuv_colors = vts_colors_bt601_ycbcr_75;
       
   857   } else {
       
   858     p->yuv_colors = vts_colors_bt709_ycbcr_75;
       
   859   }
       
   860   p->gray_colors = vts_colors_gray_75;
       
   861   p->width = w;
   696   p->width = w;
   862   p->height = h;
   697   p->height = h;
   863   fourcc = v->fourcc;
   698   fourcc = v->fourcc;
   864   if (fourcc == NULL)
   699   if (fourcc == NULL)
   865     return;
   700     return;
   866 
   701 
   867   fourcc->paint_setup (p, dest);
   702   fourcc->paint_setup (p, dest);
   868   p->paint_hline = fourcc->paint_hline;
   703   p->paint_hline = fourcc->paint_hline;
   869 
   704 
   870   /* color bars */
   705   color = vts_colors[COLOR_BLACK];
   871   for (i = 0; i < 7; i++) {
   706   p->color = &color;
   872     int x1 = i * w / 7;
   707 
   873     int x2 = (i + 1) * w / 7;
   708   for (i = 0; i < w; i++) {
   874 
       
   875     p->yuv_color = p->yuv_colors + i;
       
   876     p->rgb_color = p->rgb_colors + i;
       
   877     p->gray_color = p->gray_colors + i;
       
   878     for (j = 0; j < h; j++) {
   709     for (j = 0; j < h; j++) {
   879       p->paint_hline (p, x1, j, (x2 - x1));
   710       /* FIXME not strictly correct */
   880     }
   711       color.Y = random_char ();
   881   }
   712       color.R = color.Y;
   882 }
   713       color.G = color.Y;
   883 
   714       color.B = color.Y;
   884 void
   715       p->paint_hline (p, i, j, 1);
   885 gst_video_test_src_snow (GstVideoTestSrc * v, unsigned char *dest, int w, int h)
   716     }
       
   717   }
       
   718 }
       
   719 
       
   720 static void
       
   721 gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
       
   722     int h, const struct vts_color_struct *color)
   886 {
   723 {
   887   int i;
   724   int i;
   888   int j;
       
   889   paintinfo pi = { NULL, };
   725   paintinfo pi = { NULL, };
   890   paintinfo *p = &pi;
   726   paintinfo *p = &pi;
   891   struct fourcc_list_struct *fourcc;
   727   struct fourcc_list_struct *fourcc;
   892   struct vts_color_struct_rgb rgb_color;
   728 
   893   struct vts_color_struct_yuv yuv_color;
       
   894   struct vts_color_struct_gray gray_color;
       
   895 
       
   896   p->rgb_colors = vts_colors_rgb;
       
   897   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
   898     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
   899   } else {
       
   900     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
   901   }
       
   902   p->gray_colors = vts_colors_gray_100;
       
   903   p->width = w;
   729   p->width = w;
   904   p->height = h;
   730   p->height = h;
   905   fourcc = v->fourcc;
   731   fourcc = v->fourcc;
   906   if (fourcc == NULL)
   732   if (fourcc == NULL)
   907     return;
   733     return;
   908 
   734 
   909   fourcc->paint_setup (p, dest);
   735   fourcc->paint_setup (p, dest);
   910   p->paint_hline = fourcc->paint_hline;
   736   p->paint_hline = fourcc->paint_hline;
   911 
   737 
   912   rgb_color = p->rgb_colors[COLOR_BLACK];
   738   p->color = color;
   913   yuv_color = p->yuv_colors[COLOR_BLACK];
   739 
   914   gray_color = p->gray_colors[COLOR_BLACK];
   740   for (i = 0; i < h; i++) {
   915   p->rgb_color = &rgb_color;
   741     p->paint_hline (p, 0, i, w);
   916   p->yuv_color = &yuv_color;
   742   }
   917   p->gray_color = &gray_color;
   743 }
   918 
   744 
   919   for (i = 0; i < w; i++) {
   745 void
   920     for (j = 0; j < h; j++) {
   746 gst_video_test_src_black (GstVideoTestSrc * v, guchar * dest, int w, int h)
   921       /* FIXME not strictly correct */
   747 {
   922       int y = random_char ();
   748   gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_BLACK);
   923       yuv_color.Y = y;
   749 }
   924       rgb_color.R = y;
   750 
   925       rgb_color.G = y;
   751 void
   926       rgb_color.B = y;
   752 gst_video_test_src_white (GstVideoTestSrc * v, guchar * dest, int w, int h)
   927       gray_color.G = (y << 8) | random_char ();
   753 {
   928       p->paint_hline (p, i, j, 1);
   754   gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_WHITE);
   929     }
   755 }
   930   }
   756 
   931 }
   757 void
   932 
   758 gst_video_test_src_red (GstVideoTestSrc * v, guchar * dest, int w, int h)
   933 static void
   759 {
   934 gst_video_test_src_unicolor (GstVideoTestSrc * v, unsigned char *dest, int w,
   760   gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_RED);
   935     int h, int color_index)
   761 }
   936 {
   762 
   937   int i;
   763 void
       
   764 gst_video_test_src_green (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   765 {
       
   766   gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_GREEN);
       
   767 }
       
   768 
       
   769 void
       
   770 gst_video_test_src_blue (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   771 {
       
   772   gst_video_test_src_unicolor (v, dest, w, h, vts_colors + COLOR_BLUE);
       
   773 }
       
   774 
       
   775 void
       
   776 gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   777 {
       
   778   int x, y;
   938   paintinfo pi = { NULL, };
   779   paintinfo pi = { NULL, };
   939   paintinfo *p = &pi;
   780   paintinfo *p = &pi;
   940   struct fourcc_list_struct *fourcc;
   781   struct fourcc_list_struct *fourcc;
   941 
   782 
   942   p->rgb_colors = vts_colors_rgb;
       
   943   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
   944     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
   945   } else {
       
   946     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
   947   }
       
   948   p->gray_colors = vts_colors_gray_100;
       
   949   p->width = w;
   783   p->width = w;
   950   p->height = h;
   784   p->height = h;
   951   fourcc = v->fourcc;
   785   fourcc = v->fourcc;
   952   if (fourcc == NULL)
   786   if (fourcc == NULL)
   953     return;
   787     return;
   954 
   788 
   955   fourcc->paint_setup (p, dest);
   789   fourcc->paint_setup (p, dest);
   956   p->paint_hline = fourcc->paint_hline;
   790   p->paint_hline = fourcc->paint_hline;
   957 
   791 
   958   p->rgb_color = p->rgb_colors + color_index;
   792   for (y = 0; y < h; y++) {
   959   p->yuv_color = p->yuv_colors + color_index;
   793     p->color = vts_colors + COLOR_GREEN;
   960   p->gray_color = p->gray_colors + color_index;
   794     p->paint_hline (p, 0, y, w);
   961 
   795     for (x = (y % 2); x < w; x += 2) {
   962   for (i = 0; i < h; i++) {
   796       p->color = vts_colors + COLOR_RED;
   963     p->paint_hline (p, 0, i, w);
   797       p->paint_hline (p, x, y, 1);
       
   798     }
   964   }
   799   }
   965 }
   800 }
   966 
   801 
   967 void
   802 void
   968 gst_video_test_src_black (GstVideoTestSrc * v, guchar * dest, int w, int h)
   803 gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h)
   969 {
       
   970   gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLACK);
       
   971 }
       
   972 
       
   973 void
       
   974 gst_video_test_src_white (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   975 {
       
   976   gst_video_test_src_unicolor (v, dest, w, h, COLOR_WHITE);
       
   977 }
       
   978 
       
   979 void
       
   980 gst_video_test_src_red (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   981 {
       
   982   gst_video_test_src_unicolor (v, dest, w, h, COLOR_RED);
       
   983 }
       
   984 
       
   985 void
       
   986 gst_video_test_src_green (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   987 {
       
   988   gst_video_test_src_unicolor (v, dest, w, h, COLOR_GREEN);
       
   989 }
       
   990 
       
   991 void
       
   992 gst_video_test_src_blue (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   993 {
       
   994   gst_video_test_src_unicolor (v, dest, w, h, COLOR_BLUE);
       
   995 }
       
   996 
       
   997 void
       
   998 gst_video_test_src_checkers1 (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
   999 {
   804 {
  1000   int x, y;
   805   int x, y;
  1001   paintinfo pi = { NULL, };
   806   paintinfo pi = { NULL, };
  1002   paintinfo *p = &pi;
   807   paintinfo *p = &pi;
  1003   struct fourcc_list_struct *fourcc;
   808   struct fourcc_list_struct *fourcc;
  1004 
   809 
  1005   p->rgb_colors = vts_colors_rgb;
       
  1006   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
  1007     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
  1008   } else {
       
  1009     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
  1010   }
       
  1011   p->gray_colors = vts_colors_gray_100;
       
  1012   p->width = w;
   810   p->width = w;
  1013   p->height = h;
   811   p->height = h;
  1014   fourcc = v->fourcc;
   812   fourcc = v->fourcc;
  1015   if (fourcc == NULL)
   813   if (fourcc == NULL)
  1016     return;
   814     return;
  1017 
   815 
  1018   fourcc->paint_setup (p, dest);
   816   fourcc->paint_setup (p, dest);
  1019   p->paint_hline = fourcc->paint_hline;
   817   p->paint_hline = fourcc->paint_hline;
  1020 
   818 
       
   819   p->color = vts_colors + COLOR_GREEN;
  1021   for (y = 0; y < h; y++) {
   820   for (y = 0; y < h; y++) {
  1022     p->rgb_color = p->rgb_colors + COLOR_GREEN;
       
  1023     p->yuv_color = p->yuv_colors + COLOR_GREEN;
       
  1024     p->gray_color = p->gray_colors + COLOR_GREEN;
       
  1025     p->paint_hline (p, 0, y, w);
   821     p->paint_hline (p, 0, y, w);
  1026     for (x = (y % 2); x < w; x += 2) {
   822   }
  1027       p->rgb_color = p->rgb_colors + COLOR_RED;
   823 
  1028       p->yuv_color = p->yuv_colors + COLOR_RED;
   824   for (y = 0; y < h; y += 2) {
  1029       p->gray_color = p->gray_colors + COLOR_RED;
   825     for (x = ((y % 4) == 0) ? 0 : 2; x < w; x += 4) {
  1030       p->paint_hline (p, x, y, 1);
   826       guint len = (x < (w - 1)) ? 2 : (w - x);
       
   827 
       
   828       p->color = vts_colors + COLOR_RED;
       
   829       p->paint_hline (p, x, y + 0, len);
       
   830       if (G_LIKELY ((y + 1) < h)) {
       
   831         p->paint_hline (p, x, y + 1, len);
       
   832       }
  1031     }
   833     }
  1032   }
   834   }
  1033 }
   835 }
  1034 
   836 
  1035 void
   837 void
  1036 gst_video_test_src_checkers2 (GstVideoTestSrc * v, guchar * dest, int w, int h)
   838 gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h)
  1037 {
   839 {
  1038   int x, y;
   840   int x, y;
  1039   paintinfo pi = { NULL, };
   841   paintinfo pi = { NULL, };
  1040   paintinfo *p = &pi;
   842   paintinfo *p = &pi;
  1041   struct fourcc_list_struct *fourcc;
   843   struct fourcc_list_struct *fourcc;
  1042 
   844 
  1043   p->rgb_colors = vts_colors_rgb;
       
  1044   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
  1045     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
  1046   } else {
       
  1047     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
  1048   }
       
  1049   p->gray_colors = vts_colors_gray_100;
       
  1050   p->width = w;
   845   p->width = w;
  1051   p->height = h;
   846   p->height = h;
  1052   fourcc = v->fourcc;
   847   fourcc = v->fourcc;
  1053   if (fourcc == NULL)
   848   if (fourcc == NULL)
  1054     return;
   849     return;
  1055 
   850 
  1056   fourcc->paint_setup (p, dest);
   851   fourcc->paint_setup (p, dest);
  1057   p->paint_hline = fourcc->paint_hline;
   852   p->paint_hline = fourcc->paint_hline;
  1058 
   853 
  1059   p->rgb_color = p->rgb_colors + COLOR_GREEN;
   854   p->color = vts_colors + COLOR_GREEN;
  1060   p->yuv_color = p->yuv_colors + COLOR_GREEN;
       
  1061   p->gray_color = p->gray_colors + COLOR_GREEN;
       
  1062   for (y = 0; y < h; y++) {
       
  1063     p->paint_hline (p, 0, y, w);
       
  1064   }
       
  1065 
       
  1066   for (y = 0; y < h; y += 2) {
       
  1067     for (x = ((y % 4) == 0) ? 0 : 2; x < w; x += 4) {
       
  1068       guint len = (x < (w - 1)) ? 2 : (w - x);
       
  1069 
       
  1070       p->rgb_color = p->rgb_colors + COLOR_RED;
       
  1071       p->yuv_color = p->yuv_colors + COLOR_RED;
       
  1072       p->gray_color = p->gray_colors + COLOR_RED;
       
  1073       p->paint_hline (p, x, y + 0, len);
       
  1074       if (G_LIKELY ((y + 1) < h)) {
       
  1075         p->paint_hline (p, x, y + 1, len);
       
  1076       }
       
  1077     }
       
  1078   }
       
  1079 }
       
  1080 
       
  1081 void
       
  1082 gst_video_test_src_checkers4 (GstVideoTestSrc * v, guchar * dest, int w, int h)
       
  1083 {
       
  1084   int x, y;
       
  1085   paintinfo pi = { NULL, };
       
  1086   paintinfo *p = &pi;
       
  1087   struct fourcc_list_struct *fourcc;
       
  1088 
       
  1089   p->rgb_colors = vts_colors_rgb;
       
  1090   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
  1091     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
  1092   } else {
       
  1093     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
  1094   }
       
  1095   p->gray_colors = vts_colors_gray_100;
       
  1096   p->width = w;
       
  1097   p->height = h;
       
  1098   fourcc = v->fourcc;
       
  1099   if (fourcc == NULL)
       
  1100     return;
       
  1101 
       
  1102   fourcc->paint_setup (p, dest);
       
  1103   p->paint_hline = fourcc->paint_hline;
       
  1104 
       
  1105   p->rgb_color = p->rgb_colors + COLOR_GREEN;
       
  1106   p->yuv_color = p->yuv_colors + COLOR_GREEN;
       
  1107   p->gray_color = p->gray_colors + COLOR_GREEN;
       
  1108   for (y = 0; y < h; y++) {
   855   for (y = 0; y < h; y++) {
  1109     p->paint_hline (p, 0, y, w);
   856     p->paint_hline (p, 0, y, w);
  1110   }
   857   }
  1111 
   858 
  1112   for (y = 0; y < h; y += 4) {
   859   for (y = 0; y < h; y += 4) {
  1113     for (x = ((y % 8) == 0) ? 0 : 4; x < w; x += 8) {
   860     for (x = ((y % 8) == 0) ? 0 : 4; x < w; x += 8) {
  1114       guint len = (x < (w - 3)) ? 4 : (w - x);
   861       guint len = (x < (w - 3)) ? 4 : (w - x);
  1115 
   862 
  1116       p->rgb_color = p->rgb_colors + COLOR_RED;
   863       p->color = vts_colors + COLOR_RED;
  1117       p->yuv_color = p->yuv_colors + COLOR_RED;
       
  1118       p->gray_color = p->gray_colors + COLOR_RED;
       
  1119       p->paint_hline (p, x, y + 0, len);
   864       p->paint_hline (p, x, y + 0, len);
  1120       if (G_LIKELY ((y + 1) < h)) {
   865       if (G_LIKELY ((y + 1) < h)) {
  1121         p->paint_hline (p, x, y + 1, len);
   866         p->paint_hline (p, x, y + 1, len);
  1122         if (G_LIKELY ((y + 2) < h)) {
   867         if (G_LIKELY ((y + 2) < h)) {
  1123           p->paint_hline (p, x, y + 2, len);
   868           p->paint_hline (p, x, y + 2, len);
  1136   int x, y;
   881   int x, y;
  1137   paintinfo pi = { NULL, };
   882   paintinfo pi = { NULL, };
  1138   paintinfo *p = &pi;
   883   paintinfo *p = &pi;
  1139   struct fourcc_list_struct *fourcc;
   884   struct fourcc_list_struct *fourcc;
  1140 
   885 
  1141   p->rgb_colors = vts_colors_rgb;
       
  1142   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
  1143     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
  1144   } else {
       
  1145     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
  1146   }
       
  1147   p->gray_colors = vts_colors_gray_100;
       
  1148   p->width = w;
   886   p->width = w;
  1149   p->height = h;
   887   p->height = h;
  1150   fourcc = v->fourcc;
   888   fourcc = v->fourcc;
  1151   if (fourcc == NULL)
   889   if (fourcc == NULL)
  1152     return;
   890     return;
  1153 
   891 
  1154   fourcc->paint_setup (p, dest);
   892   fourcc->paint_setup (p, dest);
  1155   p->paint_hline = fourcc->paint_hline;
   893   p->paint_hline = fourcc->paint_hline;
  1156 
   894 
  1157   p->rgb_color = p->rgb_colors + COLOR_GREEN;
   895   p->color = vts_colors + COLOR_GREEN;
  1158   p->yuv_color = p->yuv_colors + COLOR_GREEN;
       
  1159   p->gray_color = p->gray_colors + COLOR_GREEN;
       
  1160   for (y = 0; y < h; y++) {
   896   for (y = 0; y < h; y++) {
  1161     for (x = 0; x < w; x += 8) {
   897     p->paint_hline (p, 0, y, w);
  1162       int len = MIN (8, w - x);
   898   }
  1163 
   899 
  1164       if ((x ^ y) & (1 << 4)) {
   900   for (y = 0; y < h; y += 8) {
  1165         p->rgb_color = p->rgb_colors + COLOR_GREEN;
   901     for (x = ((GST_ROUND_UP_8 (y) % 16) == 0) ? 0 : 8; x < w; x += 16) {
  1166         p->yuv_color = p->yuv_colors + COLOR_GREEN;
   902       guint len = (x < (w - 7)) ? 8 : (w - x);
  1167         p->gray_color = p->gray_colors + COLOR_GREEN;
   903 
  1168       } else {
   904       p->color = vts_colors + COLOR_RED;
  1169         p->rgb_color = p->rgb_colors + COLOR_RED;
   905       p->paint_hline (p, x, y + 0, len);
  1170         p->yuv_color = p->yuv_colors + COLOR_RED;
   906       if (G_LIKELY ((y + 1) < h)) {
  1171         p->gray_color = p->gray_colors + COLOR_RED;
   907         p->paint_hline (p, x, y + 1, len);
       
   908         if (G_LIKELY ((y + 2) < h)) {
       
   909           p->paint_hline (p, x, y + 2, len);
       
   910           if (G_LIKELY ((y + 3) < h)) {
       
   911             p->paint_hline (p, x, y + 3, len);
       
   912             if (G_LIKELY ((y + 4) < h)) {
       
   913               p->paint_hline (p, x, y + 4, len);
       
   914               if (G_LIKELY ((y + 5) < h)) {
       
   915                 p->paint_hline (p, x, y + 5, len);
       
   916                 if (G_LIKELY ((y + 6) < h)) {
       
   917                   p->paint_hline (p, x, y + 6, len);
       
   918                   if (G_LIKELY ((y + 7) < h)) {
       
   919                     p->paint_hline (p, x, y + 7, len);
       
   920                   }
       
   921                 }
       
   922               }
       
   923             }
       
   924           }
       
   925         }
  1172       }
   926       }
  1173       p->paint_hline (p, x, y, len);
   927     }
  1174     }
   928   }
  1175   }
   929 }
  1176 }
   930 
  1177 
   931 #undef SCALE_AMPLITUDE
  1178 void
   932 void
  1179 gst_video_test_src_zoneplate (GstVideoTestSrc * v, unsigned char *dest,
   933 gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
  1180     int w, int h)
   934     int w, int h)
  1181 {
   935 {
  1182   int i;
   936   int i;
  1183   int j;
   937   int j;
  1184   paintinfo pi = { NULL, };
   938   paintinfo pi = { NULL, };
  1185   paintinfo *p = &pi;
   939   paintinfo *p = &pi;
  1186   struct fourcc_list_struct *fourcc;
   940   struct fourcc_list_struct *fourcc;
  1187   struct vts_color_struct_rgb rgb_color;
   941   struct vts_color_struct color;
  1188   struct vts_color_struct_yuv yuv_color;
       
  1189   struct vts_color_struct_gray gray_color;
       
  1190   static uint8_t sine_array[256];
   942   static uint8_t sine_array[256];
  1191   static int sine_array_inited = FALSE;
   943   static int sine_array_inited = FALSE;
  1192 
   944   double freq[8];
  1193   static int t = 0;             /* time - increment phase vs time by 1 for each generated frame */
   945 
  1194   /* this may not fit with the correct gstreamer notion of time, so maybe FIXME? */
   946 #ifdef SCALE_AMPLITUDE
  1195 
   947   double ampl[8];
  1196   int xreset = -(w / 2) - v->xoffset;   /* starting values for x^2 and y^2, centering the ellipse */
   948 #endif
  1197   int yreset = -(h / 2) - v->yoffset;
   949   int d;
  1198 
       
  1199   int x, y;
       
  1200   int accum_kx;
       
  1201   int accum_kxt;
       
  1202   int accum_ky;
       
  1203   int accum_kyt;
       
  1204   int accum_kxy;
       
  1205   int kt;
       
  1206   int kt2;
       
  1207   int ky2;
       
  1208   int delta_kxt = v->kxt * t;
       
  1209   int delta_kxy;
       
  1210   int scale_kxy = 0xffff / (w / 2);
       
  1211   int scale_kx2 = 0xffff / w;
       
  1212 
   950 
  1213   if (!sine_array_inited) {
   951   if (!sine_array_inited) {
  1214     int black = 16;
       
  1215     int white = 235;
       
  1216     int range = white - black;
       
  1217     for (i = 0; i < 256; i++) {
   952     for (i = 0; i < 256; i++) {
  1218       sine_array[i] =
   953       sine_array[i] =
  1219           floor (range * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5 + black);
   954           floor (255 * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5);
  1220     }
   955     }
  1221     sine_array_inited = TRUE;
   956     sine_array_inited = TRUE;
  1222   }
   957   }
  1223 
   958 
  1224   p->rgb_colors = vts_colors_rgb;
       
  1225   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
  1226     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
  1227   } else {
       
  1228     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
  1229   }
       
  1230   p->gray_colors = vts_colors_gray_100;
       
  1231   p->width = w;
   959   p->width = w;
  1232   p->height = h;
   960   p->height = h;
  1233   fourcc = v->fourcc;
   961   fourcc = v->fourcc;
  1234   if (fourcc == NULL)
   962   if (fourcc == NULL)
  1235     return;
   963     return;
  1236 
   964 
  1237   fourcc->paint_setup (p, dest);
   965   fourcc->paint_setup (p, dest);
  1238   p->paint_hline = fourcc->paint_hline;
   966   p->paint_hline = fourcc->paint_hline;
  1239 
   967 
  1240   rgb_color = p->rgb_colors[COLOR_BLACK];
   968   color = vts_colors[COLOR_BLACK];
  1241   yuv_color = p->yuv_colors[COLOR_BLACK];
   969   p->color = &color;
  1242   gray_color = p->gray_colors[COLOR_BLACK];
       
  1243   p->rgb_color = &rgb_color;
       
  1244   p->yuv_color = &yuv_color;
       
  1245   p->gray_color = &gray_color;
       
  1246 
       
  1247   /* Zoneplate equation:
       
  1248    *
       
  1249    * phase = k0 + kx*x + ky*y + kt*t
       
  1250    *       + kxt*x*t + kyt*y*t + kxy*x*y
       
  1251    *       + kx2*x*x + ky2*y*y + Kt2*t*t
       
  1252    */
       
  1253 
       
  1254 #if 0
       
  1255   for (j = 0, y = yreset; j < h; j++, y++) {
       
  1256     for (i = 0, x = xreset; i < w; i++, x++) {
       
  1257 
       
  1258       //zero order
       
  1259       int phase = v->k0;
       
  1260 
       
  1261       //first order
       
  1262       phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t);
       
  1263 
       
  1264       //cross term
       
  1265       //phase = phase + (v->kxt * i * t) + (v->kyt * j * t);
       
  1266       //phase = phase + (v->kxy * x * y) / (w/2);
       
  1267 
       
  1268       /*second order */
       
  1269       /*normalise x/y terms to rate of change of phase at the picture edge */
       
  1270       phase =
       
  1271           phase + ((v->kx2 * x * x) / w) + ((v->ky2 * y * y) / h) +
       
  1272           ((v->kt2 * t * t) >> 1);
       
  1273 
       
  1274       color.Y = sine_array[phase & 0xff];
       
  1275 
       
  1276       color.R = color.Y;
       
  1277       color.G = color.Y;
       
  1278       color.B = color.Y;
       
  1279       p->paint_hline (p, i, j, 1);
       
  1280     }
       
  1281   }
       
  1282 #endif
       
  1283 
       
  1284   /* optimised version, with original code shown in comments */
       
  1285   accum_ky = 0;
       
  1286   accum_kyt = 0;
       
  1287   kt = v->kt * t;
       
  1288   kt2 = v->kt2 * t * t;
       
  1289   for (j = 0, y = yreset; j < h; j++, y++) {
       
  1290     accum_kx = 0;
       
  1291     accum_kxt = 0;
       
  1292     accum_ky += v->ky;
       
  1293     accum_kyt += v->kyt * t;
       
  1294     delta_kxy = v->kxy * y * scale_kxy;
       
  1295     accum_kxy = delta_kxy * xreset;
       
  1296     ky2 = (v->ky2 * y * y) / h;
       
  1297     for (i = 0, x = xreset; i < w; i++, x++) {
       
  1298 
       
  1299       //zero order
       
  1300       int phase = v->k0;
       
  1301 
       
  1302       //first order
       
  1303       accum_kx += v->kx;
       
  1304       //phase = phase + (v->kx * i) + (v->ky * j) + (v->kt * t);
       
  1305       phase = phase + accum_kx + accum_ky + kt;
       
  1306 
       
  1307       //cross term
       
  1308       accum_kxt += delta_kxt;
       
  1309       accum_kxy += delta_kxy;
       
  1310       //phase = phase + (v->kxt * i * t) + (v->kyt * j * t);
       
  1311       phase = phase + accum_kxt + accum_kyt;
       
  1312 
       
  1313       //phase = phase + (v->kxy * x * y) / (w/2);
       
  1314       //phase = phase + accum_kxy / (w/2) ;
       
  1315       phase = phase + (accum_kxy >> 16);
       
  1316 
       
  1317       /*second order */
       
  1318       /*normalise x/y terms to rate of change of phase at the picture edge */
       
  1319       //phase = phase + ((v->kx2 * x * x)/w) + ((v->ky2 * y * y)/h) + ((v->kt2 * t * t)>>1);
       
  1320       phase = phase + ((v->kx2 * x * x * scale_kx2) >> 16) + ky2 + (kt2 >> 1);
       
  1321 
       
  1322       yuv_color.Y = sine_array[phase & 0xff];
       
  1323 
       
  1324       rgb_color.R = yuv_color.Y;
       
  1325       rgb_color.G = yuv_color.Y;
       
  1326       rgb_color.B = yuv_color.Y;
       
  1327 
       
  1328       gray_color.G = yuv_color.Y << 8;
       
  1329       p->paint_hline (p, i, j, 1);
       
  1330     }
       
  1331   }
       
  1332 
       
  1333   t++;
       
  1334 }
       
  1335 
       
  1336 #undef SCALE_AMPLITUDE
       
  1337 void
       
  1338 gst_video_test_src_circular (GstVideoTestSrc * v, unsigned char *dest,
       
  1339     int w, int h)
       
  1340 {
       
  1341   int i;
       
  1342   int j;
       
  1343   paintinfo pi = { NULL, };
       
  1344   paintinfo *p = &pi;
       
  1345   struct fourcc_list_struct *fourcc;
       
  1346   struct vts_color_struct_rgb rgb_color;
       
  1347   struct vts_color_struct_yuv yuv_color;
       
  1348   struct vts_color_struct_gray gray_color;
       
  1349   static uint8_t sine_array[256];
       
  1350   static int sine_array_inited = FALSE;
       
  1351   double freq[8];
       
  1352 
       
  1353 #ifdef SCALE_AMPLITUDE
       
  1354   double ampl[8];
       
  1355 #endif
       
  1356   int d;
       
  1357 
       
  1358   if (!sine_array_inited) {
       
  1359     for (i = 0; i < 256; i++) {
       
  1360       sine_array[i] =
       
  1361           floor (255 * (0.5 + 0.5 * sin (i * 2 * M_PI / 256)) + 0.5);
       
  1362     }
       
  1363     sine_array_inited = TRUE;
       
  1364   }
       
  1365 
       
  1366   p->rgb_colors = vts_colors_rgb;
       
  1367   if (v->color_spec == GST_VIDEO_TEST_SRC_BT601) {
       
  1368     p->yuv_colors = vts_colors_bt601_ycbcr_100;
       
  1369   } else {
       
  1370     p->yuv_colors = vts_colors_bt709_ycbcr_100;
       
  1371   }
       
  1372   p->gray_colors = vts_colors_gray_100;
       
  1373   p->width = w;
       
  1374   p->height = h;
       
  1375   fourcc = v->fourcc;
       
  1376   if (fourcc == NULL)
       
  1377     return;
       
  1378 
       
  1379   fourcc->paint_setup (p, dest);
       
  1380   p->paint_hline = fourcc->paint_hline;
       
  1381 
       
  1382   rgb_color = p->rgb_colors[COLOR_BLACK];
       
  1383   yuv_color = p->yuv_colors[COLOR_BLACK];
       
  1384   gray_color = p->gray_colors[COLOR_BLACK];
       
  1385   p->rgb_color = &rgb_color;
       
  1386   p->yuv_color = &yuv_color;
       
  1387   p->gray_color = &gray_color;
       
  1388 
   970 
  1389   for (i = 1; i < 8; i++) {
   971   for (i = 1; i < 8; i++) {
  1390     freq[i] = 200 * pow (2.0, -(i - 1) / 4.0);
   972     freq[i] = 200 * pow (2.0, -(i - 1) / 4.0);
  1391 #ifdef SCALE_AMPLITUDE
   973 #ifdef SCALE_AMPLITUDE
  1392     {
   974     {
  1406       dist =
   988       dist =
  1407           sqrt ((2 * i - w) * (2 * i - w) + (2 * j - h) * (2 * j -
   989           sqrt ((2 * i - w) * (2 * i - w) + (2 * j - h) * (2 * j -
  1408               h)) / (2 * w);
   990               h)) / (2 * w);
  1409       seg = floor (dist * 16);
   991       seg = floor (dist * 16);
  1410       if (seg == 0 || seg >= 8) {
   992       if (seg == 0 || seg >= 8) {
  1411         yuv_color.Y = 255;
   993         color.Y = 255;
  1412         gray_color.G = 65535;
       
  1413       } else {
   994       } else {
  1414 #ifdef SCALE_AMPLITUDE
   995 #ifdef SCALE_AMPLITUDE
  1415         double a;
   996         double a;
  1416 #endif
   997 #endif
  1417         d = floor (256 * dist * freq[seg] + 0.5);
   998         d = floor (256 * dist * freq[seg] + 0.5);
  1418 #ifdef SCALE_AMPLITUDE
   999 #ifdef SCALE_AMPLITUDE
  1419         a = ampl[seg];
  1000         a = ampl[seg];
  1420         if (a < 0)
  1001         if (a < 0)
  1421           a = 0;
  1002           a = 0;
  1422         yuv_color.Y = 128 + a * (sine_array[d & 0xff] - 128);
  1003         color.Y = 128 + a * (sine_array[d & 0xff] - 128);
  1423         gray_color.G = 128 + a * (sine_array[d & 0xff] - 128);
       
  1424 #else
  1004 #else
  1425         yuv_color.Y = sine_array[d & 0xff];
  1005         color.Y = sine_array[d & 0xff];
  1426         gray_color.G = sine_array[d & 0xff];
       
  1427 #endif
  1006 #endif
  1428       }
  1007       }
  1429       rgb_color.R = yuv_color.Y;
  1008       color.R = color.Y;
  1430       rgb_color.G = yuv_color.Y;
  1009       color.G = color.Y;
  1431       rgb_color.B = yuv_color.Y;
  1010       color.B = color.Y;
  1432       p->paint_hline (p, i, j, 1);
  1011       p->paint_hline (p, i, j, 1);
  1433     }
  1012     }
  1434   }
  1013   }
  1435 }
  1014 }
  1436 
  1015 
  1445   p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
  1024   p->vstride = GST_ROUND_UP_8 (p->ystride) / 2;
  1446   p->endptr = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
  1025   p->endptr = p->vp + p->vstride * GST_ROUND_UP_2 (p->height) / 2;
  1447 }
  1026 }
  1448 
  1027 
  1449 static void
  1028 static void
  1450 paint_setup_NV12 (paintinfo * p, unsigned char *dest)
       
  1451 {
       
  1452   p->yp = dest;
       
  1453   p->ystride = GST_ROUND_UP_4 (p->width);
       
  1454   p->up = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
       
  1455   p->vp = p->up + 1;
       
  1456   p->ustride = p->ystride;
       
  1457   p->vstride = p->ystride;
       
  1458   p->endptr = p->up + (p->ystride * GST_ROUND_UP_2 (p->height)) / 2;
       
  1459 }
       
  1460 
       
  1461 static void
       
  1462 paint_setup_NV21 (paintinfo * p, unsigned char *dest)
       
  1463 {
       
  1464   p->yp = dest;
       
  1465   p->ystride = GST_ROUND_UP_4 (p->width);
       
  1466   p->vp = p->yp + p->ystride * GST_ROUND_UP_2 (p->height);
       
  1467   p->up = p->vp + 1;
       
  1468   p->ustride = p->ystride;
       
  1469   p->vstride = p->ystride;
       
  1470   p->endptr = p->vp + (p->ystride * GST_ROUND_UP_2 (p->height)) / 2;
       
  1471 }
       
  1472 
       
  1473 static void
       
  1474 paint_hline_I420 (paintinfo * p, int x, int y, int w)
  1029 paint_hline_I420 (paintinfo * p, int x, int y, int w)
  1475 {
  1030 {
  1476   int x1 = x / 2;
  1031   int x1 = x / 2;
  1477   int x2 = (x + w) / 2;
  1032   int x2 = (x + w) / 2;
  1478   int offset = y * p->ystride;
  1033   int offset = y * p->ystride;
  1479   int offset1 = (y / 2) * p->ustride;
  1034   int offset1 = (y / 2) * p->ustride;
  1480 
  1035 
  1481   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
  1036   oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
  1482   oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
  1037   oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
  1483   oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
  1038   oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
  1484 }
       
  1485 
       
  1486 static void
       
  1487 paint_hline_NV12_NV21 (paintinfo * p, int x, int y, int w)
       
  1488 {
       
  1489   int x1 = x / 2;
       
  1490   int x2 = (x + w) / 2;
       
  1491   int offset = y * p->ystride;
       
  1492   int offsetuv = (y / 2) * p->ustride + (x & ~0x01);
       
  1493   int uvlength = x2 - x1 + 1;
       
  1494 
       
  1495   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
       
  1496   if (uvlength) {
       
  1497     oil_splat_u8 (p->up + offsetuv, 2, &p->yuv_color->U, uvlength);
       
  1498     oil_splat_u8 (p->vp + offsetuv, 2, &p->yuv_color->V, uvlength);
       
  1499   }
       
  1500 }
  1039 }
  1501 
  1040 
  1502 static void
  1041 static void
  1503 paint_setup_YV12 (paintinfo * p, unsigned char *dest)
  1042 paint_setup_YV12 (paintinfo * p, unsigned char *dest)
  1504 {
  1043 {
  1510   p->ustride = GST_ROUND_UP_8 (p->ystride) / 2;
  1049   p->ustride = GST_ROUND_UP_8 (p->ystride) / 2;
  1511   p->endptr = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
  1050   p->endptr = p->up + p->ustride * GST_ROUND_UP_2 (p->height) / 2;
  1512 }
  1051 }
  1513 
  1052 
  1514 static void
  1053 static void
  1515 paint_setup_v308 (paintinfo * p, unsigned char *dest)
       
  1516 {
       
  1517   p->yp = dest;
       
  1518   p->up = dest + 1;
       
  1519   p->vp = dest + 2;
       
  1520   p->ystride = GST_ROUND_UP_4 (p->width * 3);
       
  1521   p->endptr = dest + p->ystride * p->height;
       
  1522 }
       
  1523 
       
  1524 static void
       
  1525 paint_setup_AYUV (paintinfo * p, unsigned char *dest)
  1054 paint_setup_AYUV (paintinfo * p, unsigned char *dest)
  1526 {
  1055 {
  1527   p->ap = dest;
  1056   p->ap = dest;
  1528   p->yp = dest + 1;
  1057   p->yp = dest + 1;
  1529   p->up = dest + 2;
  1058   p->up = dest + 2;
  1531   p->ystride = p->width * 4;
  1060   p->ystride = p->width * 4;
  1532   p->endptr = dest + p->ystride * p->height;
  1061   p->endptr = dest + p->ystride * p->height;
  1533 }
  1062 }
  1534 
  1063 
  1535 static void
  1064 static void
  1536 paint_setup_v410 (paintinfo * p, unsigned char *dest)
       
  1537 {
       
  1538   p->yp = dest + 0;
       
  1539   p->up = dest + 0;
       
  1540   p->vp = dest + 0;
       
  1541   p->ystride = p->width * 4;
       
  1542   p->endptr = dest + p->ystride * p->height;
       
  1543 }
       
  1544 
       
  1545 static void
       
  1546 paint_setup_v216 (paintinfo * p, unsigned char *dest)
       
  1547 {
       
  1548   p->ap = dest;
       
  1549   p->yp = dest + 2;
       
  1550   p->up = dest + 0;
       
  1551   p->vp = dest + 4;
       
  1552   p->ystride = p->width * 4;
       
  1553   p->endptr = dest + p->ystride * p->height;
       
  1554 }
       
  1555 
       
  1556 static void
       
  1557 paint_setup_v210 (paintinfo * p, unsigned char *dest)
       
  1558 {
       
  1559   p->ap = dest;
       
  1560   p->yp = dest + 0;
       
  1561   p->up = dest + 0;
       
  1562   p->vp = dest + 0;
       
  1563   p->ystride = ((p->width + 47) / 48) * 128;    /* no, really. */
       
  1564   p->endptr = dest + p->ystride * p->height;
       
  1565 }
       
  1566 
       
  1567 static void
       
  1568 paint_setup_YUY2 (paintinfo * p, unsigned char *dest)
  1065 paint_setup_YUY2 (paintinfo * p, unsigned char *dest)
  1569 {
  1066 {
  1570   p->yp = dest;
  1067   p->yp = dest;
  1571   p->up = dest + 1;
  1068   p->up = dest + 1;
  1572   p->vp = dest + 3;
  1069   p->vp = dest + 3;
  1593   p->ystride = GST_ROUND_UP_2 (p->width) * 2;
  1090   p->ystride = GST_ROUND_UP_2 (p->width) * 2;
  1594   p->endptr = dest + p->ystride * p->height;
  1091   p->endptr = dest + p->ystride * p->height;
  1595 }
  1092 }
  1596 
  1093 
  1597 static void
  1094 static void
  1598 paint_hline_v308 (paintinfo * p, int x, int y, int w)
  1095 paint_hline_AYUV (paintinfo * p, int x, int y, int w)
  1599 {
  1096 {
  1600   int offset;
  1097   int offset;
  1601 
  1098 
  1602   offset = (y * p->ystride) + (x * 3);
       
  1603   oil_splat_u8 (p->yp + offset, 3, &p->yuv_color->Y, w);
       
  1604   oil_splat_u8 (p->up + offset, 3, &p->yuv_color->U, w);
       
  1605   oil_splat_u8 (p->vp + offset, 3, &p->yuv_color->V, w);
       
  1606 }
       
  1607 
       
  1608 static void
       
  1609 paint_hline_AYUV (paintinfo * p, int x, int y, int w)
       
  1610 {
       
  1611   int offset;
       
  1612   guint8 alpha = 255;
       
  1613 
       
  1614   offset = (y * p->ystride) + (x * 4);
  1099   offset = (y * p->ystride) + (x * 4);
  1615   oil_splat_u8 (p->yp + offset, 4, &p->yuv_color->Y, w);
  1100   oil_splat_u8 (p->yp + offset, 4, &p->color->Y, w);
  1616   oil_splat_u8 (p->up + offset, 4, &p->yuv_color->U, w);
  1101   oil_splat_u8 (p->up + offset, 4, &p->color->U, w);
  1617   oil_splat_u8 (p->vp + offset, 4, &p->yuv_color->V, w);
  1102   oil_splat_u8 (p->vp + offset, 4, &p->color->V, w);
  1618   oil_splat_u8 (p->ap + offset, 4, &alpha, w);
  1103   oil_splat_u8 (p->ap + offset, 4, &p->color->A, w);
  1619 }
       
  1620 
       
  1621 #define TO_16(x) (((x)<<8) | (x))
       
  1622 #define TO_10(x) (((x)<<2) | ((x)>>6))
       
  1623 
       
  1624 static void
       
  1625 paint_hline_v216 (paintinfo * p, int x, int y, int w)
       
  1626 {
       
  1627   int x1 = x / 2;
       
  1628   int x2 = (x + w) / 2;
       
  1629   uint16_t Y, U, V;
       
  1630   int i;
       
  1631   int offset;
       
  1632 
       
  1633   offset = y * p->ystride;
       
  1634   Y = TO_16 (p->yuv_color->Y);
       
  1635   U = TO_16 (p->yuv_color->U);
       
  1636   V = TO_16 (p->yuv_color->V);
       
  1637   for (i = x; i < x + w; i++) {
       
  1638     GST_WRITE_UINT16_LE (p->yp + offset + i * 4, Y);
       
  1639   }
       
  1640   for (i = x1; i < x2; i++) {
       
  1641     GST_WRITE_UINT16_LE (p->up + offset + i * 8, U);
       
  1642     GST_WRITE_UINT16_LE (p->vp + offset + i * 8, V);
       
  1643   }
       
  1644 }
       
  1645 
       
  1646 static void
       
  1647 paint_hline_v410 (paintinfo * p, int x, int y, int w)
       
  1648 {
       
  1649   uint32_t a;
       
  1650   uint8_t *data;
       
  1651   int i;
       
  1652 
       
  1653   a = (TO_10 (p->yuv_color->U) << 22) |
       
  1654       (TO_10 (p->yuv_color->Y) << 12) | (TO_10 (p->yuv_color->V) << 2);
       
  1655 
       
  1656   data = p->yp + y * p->ystride + x * 4;
       
  1657   for (i = 0; i < w; i++) {
       
  1658     GST_WRITE_UINT32_LE (data, a);
       
  1659   }
       
  1660 }
       
  1661 
       
  1662 static void
       
  1663 paint_hline_v210 (paintinfo * p, int x, int y, int w)
       
  1664 {
       
  1665   uint32_t a0, a1, a2, a3;
       
  1666   uint8_t *data;
       
  1667   int i;
       
  1668 
       
  1669   /* FIXME this is kinda gross.  it only handles x values in
       
  1670      multiples of 6 */
       
  1671 
       
  1672   a0 = TO_10 (p->yuv_color->U) | (TO_10 (p->yuv_color->Y) << 10)
       
  1673       | (TO_10 (p->yuv_color->V) << 20);
       
  1674   a1 = TO_10 (p->yuv_color->Y) | (TO_10 (p->yuv_color->U) << 10)
       
  1675       | (TO_10 (p->yuv_color->Y) << 20);
       
  1676   a2 = TO_10 (p->yuv_color->V) | (TO_10 (p->yuv_color->Y) << 10)
       
  1677       | (TO_10 (p->yuv_color->U) << 20);
       
  1678   a3 = TO_10 (p->yuv_color->Y) | (TO_10 (p->yuv_color->V) << 10)
       
  1679       | (TO_10 (p->yuv_color->Y) << 20);
       
  1680 
       
  1681   data = p->yp + y * p->ystride;
       
  1682   for (i = x / 6; i < (x + w) / 6; i++) {
       
  1683     GST_WRITE_UINT32_LE (data + i * 16 + 0, a0);
       
  1684     GST_WRITE_UINT32_LE (data + i * 16 + 4, a1);
       
  1685     GST_WRITE_UINT32_LE (data + i * 16 + 8, a2);
       
  1686     GST_WRITE_UINT32_LE (data + i * 16 + 12, a3);
       
  1687   }
       
  1688 }
  1104 }
  1689 
  1105 
  1690 static void
  1106 static void
  1691 paint_hline_YUY2 (paintinfo * p, int x, int y, int w)
  1107 paint_hline_YUY2 (paintinfo * p, int x, int y, int w)
  1692 {
  1108 {
  1693   int x1 = x / 2;
  1109   int x1 = x / 2;
  1694   int x2 = (x + w) / 2;
  1110   int x2 = (x + w) / 2;
  1695   int offset;
  1111   int offset;
  1696 
  1112 
  1697   offset = y * p->ystride;
  1113   offset = y * p->ystride;
  1698   oil_splat_u8 (p->yp + offset + x * 2, 2, &p->yuv_color->Y, w);
  1114   oil_splat_u8 (p->yp + offset + x * 2, 2, &p->color->Y, w);
  1699   oil_splat_u8 (p->up + offset + x1 * 4, 4, &p->yuv_color->U, x2 - x1);
  1115   oil_splat_u8 (p->up + offset + x1 * 4, 4, &p->color->U, x2 - x1);
  1700   oil_splat_u8 (p->vp + offset + x1 * 4, 4, &p->yuv_color->V, x2 - x1);
  1116   oil_splat_u8 (p->vp + offset + x1 * 4, 4, &p->color->V, x2 - x1);
  1701 }
  1117 }
  1702 
  1118 
  1703 static void
  1119 static void
  1704 paint_setup_IYU2 (paintinfo * p, unsigned char *dest)
  1120 paint_setup_IYU2 (paintinfo * p, unsigned char *dest)
  1705 {
  1121 {
  1715 paint_hline_IYU2 (paintinfo * p, int x, int y, int w)
  1131 paint_hline_IYU2 (paintinfo * p, int x, int y, int w)
  1716 {
  1132 {
  1717   int offset;
  1133   int offset;
  1718 
  1134 
  1719   offset = y * p->ystride;
  1135   offset = y * p->ystride;
  1720   oil_splat_u8 (p->yp + offset + x * 3, 3, &p->yuv_color->Y, w);
  1136   oil_splat_u8 (p->yp + offset + x * 3, 3, &p->color->Y, w);
  1721   oil_splat_u8 (p->up + offset + x * 3, 3, &p->yuv_color->U, w);
  1137   oil_splat_u8 (p->up + offset + x * 3, 3, &p->color->U, w);
  1722   oil_splat_u8 (p->vp + offset + x * 3, 3, &p->yuv_color->V, w);
  1138   oil_splat_u8 (p->vp + offset + x * 3, 3, &p->color->V, w);
  1723 }
  1139 }
  1724 
  1140 
  1725 static void
  1141 static void
  1726 paint_setup_Y41B (paintinfo * p, unsigned char *dest)
  1142 paint_setup_Y41B (paintinfo * p, unsigned char *dest)
  1727 {
  1143 {
  1740   int x1 = x / 4;
  1156   int x1 = x / 4;
  1741   int x2 = (x + w) / 4;
  1157   int x2 = (x + w) / 4;
  1742   int offset = y * p->ystride;
  1158   int offset = y * p->ystride;
  1743   int offset1 = y * p->ustride;
  1159   int offset1 = y * p->ustride;
  1744 
  1160 
  1745   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
  1161   oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
  1746   oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
  1162   oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
  1747   oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
  1163   oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
  1748 }
  1164 }
  1749 
  1165 
  1750 static void
  1166 static void
  1751 paint_setup_Y42B (paintinfo * p, unsigned char *dest)
  1167 paint_setup_Y42B (paintinfo * p, unsigned char *dest)
  1752 {
  1168 {
  1765   int x1 = x / 2;
  1181   int x1 = x / 2;
  1766   int x2 = (x + w) / 2;
  1182   int x2 = (x + w) / 2;
  1767   int offset = y * p->ystride;
  1183   int offset = y * p->ystride;
  1768   int offset1 = y * p->ustride;
  1184   int offset1 = y * p->ustride;
  1769 
  1185 
  1770   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
  1186   oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
  1771   oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
  1187   oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
  1772   oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
  1188   oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
  1773 }
       
  1774 
       
  1775 static void
       
  1776 paint_setup_Y444 (paintinfo * p, unsigned char *dest)
       
  1777 {
       
  1778   p->yp = dest;
       
  1779   p->ystride = GST_ROUND_UP_4 (p->width);
       
  1780   p->up = p->yp + p->ystride * p->height;
       
  1781   p->vp = p->up + p->ystride * p->height;
       
  1782   p->endptr = p->vp + p->ystride * p->height;
       
  1783 }
       
  1784 
       
  1785 static void
       
  1786 paint_hline_Y444 (paintinfo * p, int x, int y, int w)
       
  1787 {
       
  1788   int offset = y * p->ystride;
       
  1789 
       
  1790   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
       
  1791   oil_splat_u8_ns (p->up + offset + x, &p->yuv_color->U, w);
       
  1792   oil_splat_u8_ns (p->vp + offset + x, &p->yuv_color->V, w);
       
  1793 }
  1189 }
  1794 
  1190 
  1795 static void
  1191 static void
  1796 paint_setup_Y800 (paintinfo * p, unsigned char *dest)
  1192 paint_setup_Y800 (paintinfo * p, unsigned char *dest)
  1797 {
  1193 {
  1804 static void
  1200 static void
  1805 paint_hline_Y800 (paintinfo * p, int x, int y, int w)
  1201 paint_hline_Y800 (paintinfo * p, int x, int y, int w)
  1806 {
  1202 {
  1807   int offset = y * p->ystride;
  1203   int offset = y * p->ystride;
  1808 
  1204 
  1809   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
  1205   oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
  1810 }
  1206 }
  1811 
  1207 
  1812 #if 0
  1208 #if 0
  1813 static void
  1209 static void
  1814 paint_setup_IMC1 (paintinfo * p, unsigned char *dest)
  1210 paint_setup_IMC1 (paintinfo * p, unsigned char *dest)
  1848   int x1 = x / 2;
  1244   int x1 = x / 2;
  1849   int x2 = (x + w) / 2;
  1245   int x2 = (x + w) / 2;
  1850   int offset = y * p->width;
  1246   int offset = y * p->width;
  1851   int offset1 = (y / 2) * p->width;
  1247   int offset1 = (y / 2) * p->width;
  1852 
  1248 
  1853   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
  1249   oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
  1854   oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
  1250   oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
  1855   oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
  1251   oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
  1856 }
  1252 }
  1857 #endif
  1253 #endif
  1858 
  1254 
  1859 static void
  1255 static void
  1860 paint_setup_YVU9 (paintinfo * p, unsigned char *dest)
  1256 paint_setup_YVU9 (paintinfo * p, unsigned char *dest)
  1891   int x1 = x / 4;
  1287   int x1 = x / 4;
  1892   int x2 = (x + w) / 4;
  1288   int x2 = (x + w) / 4;
  1893   int offset = y * p->ystride;
  1289   int offset = y * p->ystride;
  1894   int offset1 = (y / 4) * p->ustride;
  1290   int offset1 = (y / 4) * p->ustride;
  1895 
  1291 
  1896   oil_splat_u8_ns (p->yp + offset + x, &p->yuv_color->Y, w);
  1292   oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
  1897   oil_splat_u8_ns (p->up + offset1 + x1, &p->yuv_color->U, x2 - x1);
  1293   oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
  1898   oil_splat_u8_ns (p->vp + offset1 + x1, &p->yuv_color->V, x2 - x1);
  1294   oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
  1899 }
  1295 }
  1900 
  1296 
  1901 static void
  1297 static void
  1902 paint_setup_ARGB8888 (paintinfo * p, unsigned char *dest)
  1298 paint_setup_ARGB8888 (paintinfo * p, unsigned char *dest)
  1903 {
  1299 {
  1988 
  1384 
  1989 static void
  1385 static void
  1990 paint_hline_str4 (paintinfo * p, int x, int y, int w)
  1386 paint_hline_str4 (paintinfo * p, int x, int y, int w)
  1991 {
  1387 {
  1992   int offset = y * p->ystride;
  1388   int offset = y * p->ystride;
  1993   guint8 alpha = 255;
  1389 
  1994 
  1390   oil_splat_u8 (p->yp + offset + x * 4, 4, &p->color->R, w);
  1995   oil_splat_u8 (p->yp + offset + x * 4, 4, &p->rgb_color->R, w);
  1391   oil_splat_u8 (p->up + offset + x * 4, 4, &p->color->G, w);
  1996   oil_splat_u8 (p->up + offset + x * 4, 4, &p->rgb_color->G, w);
  1392   oil_splat_u8 (p->vp + offset + x * 4, 4, &p->color->B, w);
  1997   oil_splat_u8 (p->vp + offset + x * 4, 4, &p->rgb_color->B, w);
       
  1998 
  1393 
  1999   if (p->ap != NULL) {
  1394   if (p->ap != NULL) {
  2000     oil_splat_u8 (p->ap + offset + (x * 4), 4, &alpha, w);
  1395     oil_splat_u8 (p->ap + offset + (x * 4), 4, &p->color->A, w);
  2001   }
  1396   }
  2002 }
  1397 }
  2003 
  1398 
  2004 static void
  1399 static void
  2005 paint_hline_str3 (paintinfo * p, int x, int y, int w)
  1400 paint_hline_str3 (paintinfo * p, int x, int y, int w)
  2006 {
  1401 {
  2007   int offset = y * p->ystride;
  1402   int offset = y * p->ystride;
  2008 
  1403 
  2009   oil_splat_u8 (p->yp + offset + x * 3, 3, &p->rgb_color->R, w);
  1404   oil_splat_u8 (p->yp + offset + x * 3, 3, &p->color->R, w);
  2010   oil_splat_u8 (p->up + offset + x * 3, 3, &p->rgb_color->G, w);
  1405   oil_splat_u8 (p->up + offset + x * 3, 3, &p->color->G, w);
  2011   oil_splat_u8 (p->vp + offset + x * 3, 3, &p->rgb_color->B, w);
  1406   oil_splat_u8 (p->vp + offset + x * 3, 3, &p->color->B, w);
  2012 }
  1407 }
  2013 
  1408 
  2014 static void
  1409 static void
  2015 paint_setup_RGB565 (paintinfo * p, unsigned char *dest)
  1410 paint_setup_RGB565 (paintinfo * p, unsigned char *dest)
  2016 {
  1411 {
  2023 paint_hline_RGB565 (paintinfo * p, int x, int y, int w)
  1418 paint_hline_RGB565 (paintinfo * p, int x, int y, int w)
  2024 {
  1419 {
  2025   int offset = y * p->ystride;
  1420   int offset = y * p->ystride;
  2026   uint8_t a, b;
  1421   uint8_t a, b;
  2027 
  1422 
  2028   a = (p->rgb_color->R & 0xf8) | (p->rgb_color->G >> 5);
  1423   a = (p->color->R & 0xf8) | (p->color->G >> 5);
  2029   b = ((p->rgb_color->G << 3) & 0xe0) | (p->rgb_color->B >> 3);
  1424   b = ((p->color->G << 3) & 0xe0) | (p->color->B >> 3);
  2030 
  1425 
  2031 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
  1426 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
  2032   oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
  1427   oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
  2033   oil_splat_u8 (p->yp + offset + x * 2 + 1, 2, &a, w);
  1428   oil_splat_u8 (p->yp + offset + x * 2 + 1, 2, &a, w);
  2034 #else
  1429 #else
  2049 paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w)
  1444 paint_hline_xRGB1555 (paintinfo * p, int x, int y, int w)
  2050 {
  1445 {
  2051   int offset = y * p->ystride;
  1446   int offset = y * p->ystride;
  2052   uint8_t a, b;
  1447   uint8_t a, b;
  2053 
  1448 
  2054   a = ((p->rgb_color->R >> 1) & 0x7c) | (p->rgb_color->G >> 6);
  1449   a = ((p->color->R >> 1) & 0x7c) | (p->color->G >> 6);
  2055   b = ((p->rgb_color->G << 2) & 0xe0) | (p->rgb_color->B >> 3);
  1450   b = ((p->color->G << 2) & 0xe0) | (p->color->B >> 3);
  2056 
  1451 
  2057 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
  1452 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
  2058   oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
  1453   oil_splat_u8 (p->yp + offset + x * 2 + 0, 2, &b, w);
  2059   oil_splat_u8 (p->yp + offset + x * 2 + 1, 2, &a, w);
  1454   oil_splat_u8 (p->yp + offset + x * 2 + 1, 2, &a, w);
  2060 #else
  1455 #else
  2080   int i;
  1475   int i;
  2081 
  1476 
  2082   if (y & 1) {
  1477   if (y & 1) {
  2083     for (i = x; i < x + w; i++) {
  1478     for (i = x; i < x + w; i++) {
  2084       if (i & 1) {
  1479       if (i & 1) {
  2085         dest[i] = p->rgb_color->G;
  1480         dest[i] = p->color->G;
  2086       } else {
  1481       } else {
  2087         dest[i] = p->rgb_color->B;
  1482         dest[i] = p->color->B;
  2088       }
  1483       }
  2089     }
  1484     }
  2090   } else {
  1485   } else {
  2091     for (i = x; i < x + w; i++) {
  1486     for (i = x; i < x + w; i++) {
  2092       if (i & 1) {
  1487       if (i & 1) {
  2093         dest[i] = p->rgb_color->R;
  1488         dest[i] = p->color->R;
  2094       } else {
  1489       } else {
  2095         dest[i] = p->rgb_color->G;
  1490         dest[i] = p->color->G;
  2096       }
  1491       }
  2097     }
  1492     }
  2098   }
  1493   }
  2099 }
  1494 }
  2100 
       
  2101 static void
       
  2102 paint_setup_GRAY8 (paintinfo * p, unsigned char *dest)
       
  2103 {
       
  2104   p->yp = dest;
       
  2105   p->ystride = GST_ROUND_UP_4 (p->width);
       
  2106   p->endptr = dest + p->ystride * p->height;
       
  2107 }
       
  2108 
       
  2109 static void
       
  2110 paint_hline_GRAY8 (paintinfo * p, int x, int y, int w)
       
  2111 {
       
  2112   int offset = y * p->ystride;
       
  2113   guint8 color = p->gray_color->G >> 8;
       
  2114 
       
  2115   oil_splat_u8_ns (p->yp + offset + x, &color, w);
       
  2116 }
       
  2117 
       
  2118 static void
       
  2119 paint_setup_GRAY16 (paintinfo * p, unsigned char *dest)
       
  2120 {
       
  2121   p->yp = dest;
       
  2122   p->ystride = GST_ROUND_UP_4 (p->width * 2);
       
  2123   p->endptr = dest + p->ystride * p->height;
       
  2124 }
       
  2125 
       
  2126 static void
       
  2127 paint_hline_GRAY16 (paintinfo * p, int x, int y, int w)
       
  2128 {
       
  2129   int offset = y * p->ystride;
       
  2130 
       
  2131   oil_splat_u16_ns ((guint16 *) (p->yp + offset + 2 * x), &p->gray_color->G, w);
       
  2132 }