Exemplo n.º 1
0
int _adjustDestRect(Rect * rect, VideoDevice * vd)
{
    int outside = 0;
    if (rect->left<DEVICE_LEFT_EDGE){
        outside |= VS_LEFT_OUT;
        rect->left=DEVICE_LEFT_EDGE;
    }
    if (rect->top<DEVICE_TOP_EDGE){
        outside |= VS_TOP_OUT;
        rect->top=DEVICE_TOP_EDGE;
    }
    if (rect->right>vd->resX){
        outside |= VS_RIGHT_OUT;
        rect->right=vd->resX;
    }
    if (rect->bottom>vd->resY){
        outside |= VS_BOTTOM_OUT;
        rect->bottom=vd->resY;
    }

    ALIGNRIGHT8(rect->left);
    ALIGNRIGHT8(rect->top);
    ALIGNLEFT8(rect->right);
    ALIGNLEFT8(rect->bottom);
    
    //VS_MESSAGE("adjust win"WIN_FMT"\n", WIN_ARGS(rect));

    return outside;
}
Exemplo n.º 2
0
int _checkSource(SourceFmt * src)
{

    Rect * rect;
    if ((src->croprect.width & 0x7) || (src->croprect.height& 0x7))
        return -1;

    rect = &src->croprect.win;
    
    ALIGNRIGHT8(rect->left);
    ALIGNRIGHT8(rect->top);
    ALIGNLEFT8(rect->right);
    ALIGNLEFT8(rect->bottom);

    return 0;
}
void
_getVideoDeviceInfo (VideoDevice * vd)
{
  int fd;
  struct fb_var_screeninfo fb_var;

  if ((vd->fbidx != vd->main_fbidx) || (vd->mode_num == 0)) {
    fd = open (gFBDescs[vd->main_fbidx].devname, O_RDWR, 0);

    if (fd > 0) {

      VS_IOCTL (fd, FBIOGET_VSCREENINFO, error, &fb_var);
      vd->resX = ALIGNLEFT8(fb_var.xres);
      vd->resY = ALIGNLEFT8(fb_var.yres);
      VS_MESSAGE ("MAX resolution %dx%d\n", fb_var.xres, fb_var.yres);
    error:
      close (fd);
    }
  }
}
int
_initVideoDevice (VideoDevice * vd, int mode_idx)
{
  struct fb_var_screeninfo fb_var;
  int fd;

  if ((vd->fbidx == vd->main_fbidx) && (vd->mode_num)) {

    if ((mode_idx >= 0) && (mode_idx < vd->mode_num)) {
      vd->current_mode = mode_idx;
      vd->resX = ALIGNLEFT8(vd->modes[mode_idx].resx);
      vd->resY = ALIGNLEFT8(vd->modes[mode_idx].resy);
    } else {
      goto error;
    }
  }

  char *palpha;

  if ((palpha = getenv ("VSALPHA")) && (vd->main_fbidx != vd->fbidx))
    vd->setalpha = 1;
  else
    vd->setalpha = 0;

  fd = _getDevicefd (vd);

  VS_IOCTL (fd, FBIOGET_VSCREENINFO, error, &fb_var);

  vd->fbvar = fb_var;

  if ((vd->resX == 0) || (vd->resY == 0))
    goto error;

  return 0;
error:
  return -1;
}
void
_initVSIPUTask (VideoSurface * surf)
{
  VideoDevice *vd = SURFACE2DEVICE (surf);
  IPUTaskOne *t1 = &surf->itask;
  Rect *rect = &(surf->srcfmt.croprect.win), *desrect;

  VS_FLOW ("Fun %s in\n", __FUNCTION__);

  desrect = &(surf->adjustdesrect);

  if (surf->outside & VS_INVISIBLE) {
    surf->status = VS_STATUS_INVISIBLE;
    return;
  }
  surf->status = VS_STATUS_VISIBLE;

  INPUT_FORMAT (t1) = surf->srcfmt.fmt;
  INPUT_WIDTH (t1) = surf->srcfmt.croprect.width;
  INPUT_HEIGHT (t1) = surf->srcfmt.croprect.height;

  INPUT_CROP_X (t1) = rect->left;
  INPUT_CROP_Y (t1) = rect->top;
  INPUT_CROP_WIDTH (t1) = RECT_WIDTH (rect);
  INPUT_CROP_HEIGHT (t1) = RECT_HEIGHT (rect);
  if (surf->outside) {

    /* output outside of screen, need crop in input */
    int xx[4] = { 0, 0, 0, 0 };
    Rect *origrect = &surf->desfmt.rect;
    int x_len, y_len;


    if (surf->desfmt.rot <= ROTATION_180_CLOCKWISE) {
      x_len = RECT_WIDTH (rect);
      y_len = RECT_HEIGHT (rect);
    } else {
      y_len = RECT_WIDTH (rect);
      x_len = RECT_HEIGHT (rect);
    }

    if (surf->outside & VS_LEFT_OUT) {
      xx[0] =
          (DEVICE_LEFT_EDGE - origrect->left) * x_len / RECT_WIDTH (origrect);
      xx[0] = ALIGNLEFT8 (xx[0]);
    }
    if (surf->outside & VS_RIGHT_OUT) {
      xx[1] = (origrect->right - vd->resX) * x_len / RECT_WIDTH (origrect);
      xx[1] = ALIGNLEFT8 (xx[1]);
    }
    if (surf->outside & VS_TOP_OUT) {
      xx[2] =
          (DEVICE_TOP_EDGE - origrect->top) * y_len / RECT_HEIGHT (origrect);
      xx[2] = ALIGNLEFT8 (xx[2]);
    }
    if (surf->outside & VS_BOTTOM_OUT) {
      xx[3] = (origrect->bottom - vd->resY) * y_len / RECT_HEIGHT (origrect);
      xx[3] = ALIGNLEFT8 (xx[3]);
    }

    if (surf->desfmt.rot <= ROTATION_180_CLOCKWISE) {
      INPUT_CROP_WIDTH (t1) -= (xx[0] + xx[1]);
      INPUT_CROP_HEIGHT (t1) -= (xx[2] + xx[3]);
    } else {
      INPUT_CROP_WIDTH (t1) -= (xx[2] + xx[3]);
      INPUT_CROP_HEIGHT (t1) -= (xx[0] + xx[1]);
    }

    INPUT_CROP_X (t1) += xx[g_vstable[surf->desfmt.rot][0]];
    INPUT_CROP_Y (t1) += xx[g_vstable[surf->desfmt.rot][1]];



  }
  OUTPUT_FORMAT (t1) = vd->fmt;
  OUTPUT_WIDTH (t1) = vd->disp.right - vd->disp.left;
  OUTPUT_HEIGHT (t1) = vd->disp.bottom - vd->disp.top;
  OUTPUT_CROP_X (t1) = desrect->left - vd->disp.left;
  OUTPUT_CROP_Y (t1) = desrect->top - vd->disp.top;
  OUTPUT_CROP_WIDTH (t1) = desrect->right - desrect->left;
  OUTPUT_CROP_HEIGHT (t1) = desrect->bottom - desrect->top;
  OUTPUT_ROTATION (t1) = surf->desfmt.rot;
  if ((INPUT_CROP_WIDTH (t1) < 16) || (INPUT_CROP_HEIGHT (t1) < 16)
      || (OUTPUT_CROP_WIDTH (t1) < 16) || (OUTPUT_CROP_HEIGHT (t1) < 16)) {
    surf->status = VS_STATUS_INVISIBLE;
  }


}
Exemplo n.º 6
0
void
_initVSIPUTask(VideoSurface * surf)
{
    VS_FLOW("Fun %s in\n", __FUNCTION__);

    VideoDevice * vd = SURFACE2DEVICE(surf);
    ipu_lib_input_param_t * input = &surf->itask.input;

    Rect * rect = &(surf->srcfmt.croprect.win), *desrect;
    
    desrect = &(surf->adjustdesrect);
   
    input->fmt = surf->srcfmt.fmt;
    input->width = surf->srcfmt.croprect.width;
    input->height = surf->srcfmt.croprect.height;

    if (surf->outside==0){
        input->input_crop_win.pos.x = rect->left;
        input->input_crop_win.pos.y = rect->top;
        input->input_crop_win.win_w = RECT_WIDTH(rect);
        input->input_crop_win.win_h = RECT_HEIGHT(rect);
    }else{
        /* output outside of screen, need crop in input */
        int xl=0, xr=0, xt=0, xb=0;
        Rect * origrect = &surf->desfmt.rect;
        if (surf->outside&VS_LEFT_OUT){
            xl = (DEVICE_LEFT_EDGE-origrect->left)*RECT_WIDTH(rect)/RECT_WIDTH(origrect);
            ALIGNLEFT8(xl);
        }
        if (surf->outside&VS_RIGHT_OUT){
            xr = (origrect->right-vd->resX)*RECT_WIDTH(rect)/RECT_WIDTH(origrect);
            ALIGNLEFT8(xr);
        }
        if (surf->outside&VS_TOP_OUT){
            xt = (DEVICE_TOP_EDGE-origrect->top)*RECT_HEIGHT(rect)/RECT_HEIGHT(origrect);
            ALIGNLEFT8(xt);
        }
        if (surf->outside&VS_BOTTOM_OUT){
            xb = (origrect->bottom-vd->resY)*RECT_HEIGHT(rect)/RECT_HEIGHT(origrect);
            ALIGNLEFT8(xb);
        }
        
        input->input_crop_win.pos.x = rect->left+xl;
        input->input_crop_win.pos.y = rect->top+xt;
        input->input_crop_win.win_w = RECT_WIDTH(rect)-xl-xr;
        input->input_crop_win.win_h = RECT_HEIGHT(rect)-xt-xb;
        
    }

    input->user_def_paddr[0] = input->user_def_paddr[1] = 0;
    
    ipu_lib_output_param_t * output = &surf->itask.output;
    
    output->fmt = vd->fmt;
    output->width = vd->disp.right-vd->disp.left;
    output->height = vd->disp.bottom-vd->disp.top;
    output->output_win.pos.x = desrect->left-vd->disp.left;
    output->output_win.pos.y = desrect->top-vd->disp.top;
    output->output_win.win_w = desrect->right-desrect->left;
    output->output_win.win_h = desrect->bottom-desrect->top;
    output->user_def_paddr[0] = output->user_def_paddr[1] = 0;
    output->rot = surf->desfmt.rot;

}