예제 #1
0
static void
color_transform (CogFrame * frame, void *_dest, int component, int j)
{
  uint8_t *dest = _dest;
  uint8_t *src_y;
  uint8_t *src_u;
  uint8_t *src_v;
  uint8_t *table;
  int i;

  table = COG_OFFSET (frame->virt_priv2, component * 0x1000000);

  src_y = cog_virt_frame_get_line (frame->virt_frame1, 0, j);
  src_u = cog_virt_frame_get_line (frame->virt_frame1, 1, j);
  src_v = cog_virt_frame_get_line (frame->virt_frame1, 2, j);

  for (i = 0; i < frame->width; i++) {
    dest[i] = table[(src_y[i] << 16) | (src_u[i] << 8) | (src_v[i])];
  }
}
예제 #2
0
static guint8 *
get_color_transform_table (void)
{
  static guint8 *color_transform_table = NULL;

#if 1
  if (!color_transform_table) {
    ColorMatrix bt601_to_rgb;
    ColorMatrix bt601_to_yuv;
    ColorMatrix bt601_rgb_to_XYZ;
    ColorMatrix dell_XYZ_to_rgb;
    guint8 *table_y;
    guint8 *table_u;
    guint8 *table_v;
    int y, u, v;

    videomixer_color_matrix_build_yuv_to_rgb_601 (&bt601_to_rgb);
    videomixer_color_matrix_build_rgb_to_yuv_601 (&bt601_to_yuv);
    videomixer_color_matrix_build_rgb_to_XYZ_601 (&bt601_rgb_to_XYZ);
    videomixer_color_matrix_build_XYZ_to_rgb_dell (&dell_XYZ_to_rgb);

    color_transform_table = g_malloc (0x1000000 * 3);

    table_y = COG_OFFSET (color_transform_table, 0 * 0x1000000);
    table_u = COG_OFFSET (color_transform_table, 1 * 0x1000000);
    table_v = COG_OFFSET (color_transform_table, 2 * 0x1000000);

    for (y = 0; y < 256; y++) {
      for (u = 0; u < 256; u++) {
        for (v = 0; v < 256; v++) {
          Color c;

          c.v[0] = y;
          c.v[1] = u;
          c.v[2] = v;
          videomixer_color_matrix_apply (&bt601_to_rgb, &c, &c);
          color_gamut_clamp (&c, &c);
          color_transfer_function_apply (&c, &c);
          videomixer_color_matrix_apply (&bt601_rgb_to_XYZ, &c, &c);
          videomixer_color_matrix_apply (&dell_XYZ_to_rgb, &c, &c);
          color_transfer_function_unapply (&c, &c);
          color_gamut_clamp (&c, &c);
          videomixer_color_matrix_apply (&bt601_to_yuv, &c, &c);

          table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]);
          table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]);
          table_v[(y << 16) | (u << 8) | (v)] = rint (c.v[2]);
        }
      }
    }
  }
#endif
#if 0
  if (!color_transform_table) {
    ColorMatrix bt709_to_bt601;
    guint8 *table_y;
    guint8 *table_u;
    guint8 *table_v;
    int y, u, v;

    videomixer_color_matrix_build_bt709_to_bt601 (&bt709_to_bt601);

    color_transform_table = g_malloc (0x1000000 * 3);

    table_y = COG_OFFSET (color_transform_table, 0 * 0x1000000);
    table_u = COG_OFFSET (color_transform_table, 1 * 0x1000000);
    table_v = COG_OFFSET (color_transform_table, 2 * 0x1000000);

    for (y = 0; y < 256; y++) {
      for (u = 0; u < 256; u++) {
        for (v = 0; v < 256; v++) {
          Color c;

          c.v[0] = y;
          c.v[1] = u;
          c.v[2] = v;
          videomixer_color_matrix_apply (&bt709_to_bt601, &c, &c);

          table_y[(y << 16) | (u << 8) | (v)] = rint (c.v[0]);
          table_u[(y << 16) | (u << 8) | (v)] = rint (c.v[1]);
          table_v[(y << 16) | (u << 8) | (v)] = rint (c.v[2]);
        }
      }
    }
  }
#endif

  return color_transform_table;
}