Ejemplo n.º 1
0
// Compute one line of output
inline void
doLine(Pixel *l0, Pixel *l1, Pixel *l2, Pixel *out, unsigned width, unsigned xderiv) {
  if(xderiv)
    doLineX(l0, l1, l2, out, width);
  else
    doLineY(l0, l1, l2, out, width);
}
Ejemplo n.º 2
0
static unsigned 
update(int H, int W, Pixel *src, Pixel *dst, float *dst_32f,
        unsigned lines, unsigned xderiv) {
  if( !img ) {
    img = malloc(H * W * sizeof(Pixel));
  }

  unsigned i, j;
  for( i = 0; i < lines; i++ ) {
    int at = (lineAt + i) * W;
    int src_at = i * W;
    for( j = 0; j < W; j++ )
      img[at+j] = src[src_at+j];
  }

  unsigned produced = 0;
  for( i = 0; i < lines; i++ ) {
    int at = lineAt + i;
    // at = 0 begin (zero lines)
    if( at == 1 ) {
      // first line
      memset(dst, 0, sizeof(Pixel) * W);
      memset(dst_32f, 0, sizeof(float) * W);
      dst += W;
      dst_32f += W;
      produced++;
    }
    else if( at > 1 ) {
      Pixel *img_cur = img + at * W;
      if( xderiv ) {
        doLineX( img_cur - W, img_cur, img_cur + W, dst, W );
        doLineX_32f( img_cur - W, img_cur, img_cur + W, dst_32f, W );
      }
      else {
        doLineY( img_cur - W, img_cur, img_cur + W, dst, W );
        doLineY_32f( img_cur - W, img_cur, img_cur + W, dst_32f, W );
      }
      dst += W;
      dst_32f += W;
      produced++;
    }

    if( at == H - 1 ) {
      // end (two lines)
      memset(dst, 0, sizeof(Pixel) * W);
      memset(dst_32f, 0, sizeof(float) * W);
      dst += W;
      dst_32f += W;
      produced++;
    }
  }
  return produced;
}