예제 #1
0
static int
yv12_to_packed(const on2_image_t *dst, const on2_image_t *src, int *info) {
    void (*func)(unsigned char *dst, int scrnPitch,
                 YUV_BUFFER_CONFIG *buffConfig);
    YUV_BUFFER_CONFIG buf_cfg;

    (void)info;    
    SUPPORTED((src->fmt == IMG_FMT_YV12 || src->fmt == IMG_FMT_I420)
              && planar_img_is_aligned(src,
                                       1, 1,
                                       1, 2, 1, 1)
              && (src->stride[PLANE_U] == src->stride[PLANE_Y] / 2)
              && (src->stride[PLANE_V] == src->stride[PLANE_Y] / 2));
    
    switch(dst->fmt) {
    case IMG_FMT_UYVY:
    case IMG_FMT_YUY2:
        SUPPORTED(packed_img_is_aligned(dst, 4, 1,
                                        MAYBE_ALIGNED(4), MAYBE_ALIGNED(4)));
        break;
    case IMG_FMT_RGB555_LE:
    case IMG_FMT_RGB565_LE:
        SUPPORTED(planar_img_is_aligned(src,
                                        4, 1,
                                        MAYBE_ALIGNED(4), MAYBE_ALIGNED(4),
                                        MAYBE_ALIGNED(2), MAYBE_ALIGNED(2))
                  && packed_img_is_aligned(dst, 2, 2, 1, 1));
        break;
    case IMG_FMT_BGR24:
    case IMG_FMT_RGB32_LE:
        SUPPORTED(packed_img_is_aligned(dst, 2, 2,
                                        MAYBE_ALIGNED(4), MAYBE_ALIGNED(4)));
        break;
    default:
        return ON2_BLIT_ERR_UNSUPPORTED;
    }
    
    switch(dst->fmt) {
    case IMG_FMT_UYVY:      func = bcu00_c; break;
    case IMG_FMT_YUY2:      func = bcy00_c; break;
    case IMG_FMT_RGB555_LE: init_rgb(); func = bcs00_555_c; break;
    case IMG_FMT_RGB565_LE: init_rgb(); func = bcs00_565_c; break;
    case IMG_FMT_BGR24:     init_rgb(); func = bcf00_c; break;
    case IMG_FMT_RGB32_LE:  init_rgb(); func = bct00_c; break;
    }
    
    on2_image_to_yuv_buffer_config(&buf_cfg, src);
    func(dst->planes[PLANE_PACKED],
         dst->stride[PLANE_PACKED],
         &buf_cfg);
    return 0;
}
예제 #2
0
bool Image_TIFF::load_tiff(char * fname)
{
  tiff_handle = TIFFOpen(fname, "r");
  TIFFGetField(tiff_handle, TIFFTAG_IMAGEWIDTH, &_width);
  TIFFGetField(tiff_handle, TIFFTAG_IMAGELENGTH, &_height);
  _size = _width * _height;
  TIFFGetField(tiff_handle, TIFFTAG_BITSPERSAMPLE, &_depth);
  TIFFGetField(tiff_handle, TIFFTAG_SAMPLESPERPIXEL, &_comps);  
  TIFFGetField(tiff_handle, TIFFTAG_FILLORDER, &_order);
  TIFFGetField(tiff_handle, TIFFTAG_PLANARCONFIG, &_config);
  if (_comps <= 0 || _comps > 4) return false;
  if (_comps == 1) // gray scale data
    {
      init_gs();
      read_gs();
    }
  else if (_comps == 3)
    {
      init_rgb();
      read_rgb();
    }
  else
    {
      printf("..tiff found %d-samples per pixel (not supported) abort.\n", _comps);
      clear_gs();
      clear_rgb();
      return false;
    }
  printf("..libtiff loaded [%dx%d], depth(%d), comps(%d) image\n",_width, _height, _depth, _comps);
  return true;
}
예제 #3
0
파일: reflexion.c 프로젝트: mabm/raytracer
t_rgb		put_transparence(t_inter inter, t_scene *scene, t_vector pos_3d)
{
  t_cam		save;
  t_vector	t;
  t_inter      	color;
  float		scal;
  float		n;

  save.pos = scene->eye->pos;
  save.angle = scene->eye->pos;
  init_vec(&scene->eye->pos, inter.p.x, inter.p.y, inter.p.z);
  init_vec(&scene->eye->angle, 0, 0, 0);
  init_rgb(&color.rgb, 0, 0, 0);
  normalize_vec(&inter.n);
  normalize_vec(&pos_3d);
  n = 0.9;
  scal = get_scalaire(inter.n, pos_3d);
  scal = n * scal - sqrtf(1 + pow(n, 2) * (pow(scal, 2) - 1));
  t.x = n * pos_3d.x + scal * inter.n.x;
  t.y = n * pos_3d.y + scal * inter.n.y;
  t.z = n * pos_3d.z + scal * inter.n.z;
  color = get_pixel_color(t, scene);
  scene->eye->pos = save.pos;
  scene->eye->pos = save.angle;
  return (color.rgb);
}
예제 #4
0
파일: main.cpp 프로젝트: Sujai/db_samples
int main(void)
{
    int result = -1;
	int Red=0,Green=0,Blue=0;
    result = init_rgb();
    if (result > 0)
    {
      while (1)
      {
      int value = -1;
      value = read_rgb(&Red,&Green,&Blue);
      printf(" Red : %d , Green = %d , Blue = %d\n",Red,Green,Blue);
      usleep( 100 * 1000 ); 
      }
    }
}
예제 #5
0
파일: reflexion.c 프로젝트: mabm/raytracer
t_rgb		put_reflexion(t_inter inter, t_scene *scene, t_vector pos_3d)
{
  t_cam		save;
  t_vector	r;
  t_inter      	color;
  float		scal;

  save.pos = scene->eye->pos;
  save.angle = scene->eye->pos;
  init_vec(&scene->eye->pos, inter.p.x, inter.p.y, inter.p.z);
  init_vec(&scene->eye->angle, 0, 0, 0);
  init_rgb(&color.rgb, 0, 0, 0);
  normalize_vec(&inter.n);
  normalize_vec(&pos_3d);
  scal = get_scalaire(inter.n, pos_3d);
  r.x = ((-2.0 * inter.n.x) * scal) + pos_3d.x;
  r.y = ((-2.0 * inter.n.y) * scal) + pos_3d.y;
  r.z = ((-2.0 * inter.n.z) * scal) + pos_3d.z;
  color = get_pixel_color(r, scene);
  scene->eye->pos = save.pos;
  scene->eye->pos = save.angle;
  return (color.rgb);
}
예제 #6
0
void runFJob() {
  int  w, h[NJOBS], n;
  float x1, y1[NJOBS], x2, y2[NJOBS];

  float diff = ((1.0*jobHeight) / HEIGHT) * 0.01;
  x1 = 0.40; //left

  y1[0] = 0.20; //up
  for (int i = 1; i < NJOBS; i++)
    y1[i] = y1[i-1]+diff;//0.20828125;


  x2 = 0.41; //right


  y2[0] = 0.20 + diff;//down
  for (int i = 1; i < NJOBS; i++)
    y2[i] = y2[i-1]+diff;



  w  = WIDTH;  //  -
  for (int i = 0; i < NJOBS; i++)
    h[i] = jobHeight;//-   +




  n  = MAXITER;//  +


  init_rgb();

  printf ("x1=%f y1=%f x2=%f y2=%f w=%d h=%d n=%d file=%s\n",
      x1, y1[0], x2, y2[1], w, h[0], n, "file.ppm");



  nGlobItems[0] = 512;
  nGlobItems[1] = jobHeight < 512 ? jobHeight : 512;
  int nGlobItemsProfile[2] = {512,512};
  nItemsGroup[0] = 8;
  nItemsGroup[1] = (jobHeight % 8) == 0 ? 8 : (jobHeight % 4 == 0) ? 4 : (jobHeight % 2 == 0) ? 2 : 1;
  int nItemsGroupGPU[2];
  nItemsGroupGPU[0] = nItemsGroupGPU[1] = groupSize;

  //jobs for initial profiling
/*  float y1Prof=0.20,  y2Prof=0.21;
  int   wProf =1024,  hProf =1024,  nProf = 1048576;

  for (int i = 0; i < nPUs ; i++) {
    Job *job = createJob();
    setJobID(job, -1-i);
    setAllowPU(job, CL_DEVICE_TYPE_CPU);
    if (GPUs)
      setAllowPU(job, CL_DEVICE_TYPE_GPU);
    setJobCategory(job, 1);
    loadSourceFile(job, "mandel.cl");
    setStartingKernel(job, "calc_tile");

    setArgument(job, INPUT,  1 * sizeof(float), &x1);
    setArgument(job, INPUT,  1 * sizeof(float), &y2Prof);
    setArgument(job, INPUT,  1 * sizeof(float), &x2);
    setArgument(job, INPUT,  1 * sizeof(float), &y1Prof);
    setArgument(job, INPUT,  1 * sizeof(int), &wProf);
    setArgument(job, INPUT,  1 * sizeof(int), &hProf);
    setArgument(job, INPUT,  1 * sizeof(int), &nProf);
    setArgument(job, OUTPUT, wProf*hProf * sizeof(int), NULL);

    setDimensions(job, 2, nGlobItemsProfile, nItemsGroup);
    setResultCollector(job, defaultRCID);
    requestResultNotification(job);

    if (i == 0) {
      sleep(50);
//      printf("Type something to send the first PROFILING job.\n");
//      char asd[100];
//      scanf("%s",asd);
    }
    sendJobToExec(job, defaultSchedID);
  }

  printf("JM  (%i): Sent all PROFILING jobs.\n", myid);
  //jobs for actual work
*/sleep(50);
  for (int i = 0; i < NJOBS; i++) {

    job[i] = createJob();


    setJobID(job[i], i);

    setAllowPU(job[i], CL_DEVICE_TYPE_CPU);
    if (GPUs)
      setAllowPU(job[i], CL_DEVICE_TYPE_GPU);

    setJobCategory(job[i], 1);
    loadSourceFile(job[i], "mandel.cl");
    setStartingKernel(job[i], "calc_tile");


    setArgument(job[i], INPUT,  1 * sizeof(float), &x1);
    setArgument(job[i], INPUT,  1 * sizeof(float), &(y2[(NJOBS-1)-i]));
    setArgument(job[i], INPUT,  1 * sizeof(float), &x2);
    setArgument(job[i], INPUT,  1 * sizeof(float), &(y1[(NJOBS-1)-i]));
    setArgument(job[i], INPUT,  1 * sizeof(int), &w);
    setArgument(job[i], INPUT,  1 * sizeof(int), &(h[i]));
    setArgument(job[i], INPUT,  1 * sizeof(int), &n);
    setArgument(job[i], OUTPUT, w*(h[i]) * sizeof(int), NULL);

    setDimensions(job[i], 2, nGlobItems, nItemsGroup);
    setResultCollector(job[i], defaultRCID);
    requestResultNotification(job[i]);
  }

  pthread_mutex_lock(&end_mutex);
//  while(profilesReceived != nPUs)
//    pthread_cond_wait(&profile_over, &end_mutex);
  pthread_mutex_unlock(&end_mutex);
  //char asd[100];
  sleep(7);
  printf("\n\n\n#####PROFILING OVER#####\n");// Type something to send the first (real) job.\n");
  //      scanf("%s",asd);
  sleep(2);
  if (gettimeofday(&start, NULL)) {
    perror("gettimeofday");
    exit (EXIT_FAILURE);
  }

//  printf("JM: Sending now!\n");
  for (int i = 0; i < NJOBS; i++)
    sendJobToExec(job[i], defaultSchedID);


}