예제 #1
0
파일: btraced.c 프로젝트: xaos-project/XaoS
static void
dosymmetries (int x1, int x2, int y1, int y2, int xsym, int cx1, int cx2)
{
    if (cx1 != x1) {
        register int y;
        register cpixel_t *xx1, *xx2;
        for (y = y1; y <= y2; y++) {
            xx1 = p_add ((cpixel_t *) cimage.currlines[y], x1);
            xx2 = p_add ((cpixel_t *) cimage.currlines[y], 2 * xsym - x1);
            while (xx1 < xx2) {
                p_copy (xx1, 0, xx2, 0);
                p_inc (xx1, 1);
                p_inc (xx2, -1);
            }
        }
    }
    if (cx2 != x2) {
        register int y;
        register cpixel_t *xx1, *xx2;
        for (y = y1; y <= y2; y++) {
            xx1 = p_add ((cpixel_t *) cimage.currlines[y], x2);
            xx2 = p_add ((cpixel_t *) cimage.currlines[y], 2 * xsym - x2);
            while (xx1 > xx2) {
                p_copy (xx1, 0, xx2, 0);
                p_inc (xx1, -1);
                p_inc (xx2, 1);
            }
        }
    }
}
int
affx::TsvFileDiff::diffHeaders(affx::TsvFile& tsv1, affx::TsvFile& tsv2)
{
  int start_diff_cnt=m_diff_cnt;
  std::string key1,val1,key2,val2;

  // do the diff in three passes.

  // 1 = changed values
  tsv1.headersBegin();
  while (tsv1.headersNext(key1,val1)==affx::TSV_OK) {
    if (tsv2.getHeader(key1,val2)==affx::TSV_OK) {
      if (val1==val2) {
        if (m_opt_print_same) {
          if (p_inc()) {
            printf(" #%%%s=%s\n",key1.c_str(),val1.c_str());
          }
        }
      }
      else { // !=
        m_diff_cnt++;
        if (p_inc()) {
          printf("-#%%%s=%s\n",key1.c_str(),val1.c_str());
          printf("+#%%%s=%s\n",key1.c_str(),val2.c_str());
        }
      }
    }
  }

  // 2 = headers in tsv1 not in tsv2
  tsv1.headersBegin();
  while (tsv1.headersNext(key1,val1)==affx::TSV_OK) {
    if (tsv2.getHeader(key1,val2)!=affx::TSV_OK) {
      m_diff_cnt++;
      if (p_inc()) {
        printf("-#%%%s=%s\n",key1.c_str(),val1.c_str());
      }
    }
  }
  // 3 = headers in tsv2 not in tsv1
  tsv2.headersBegin();
  while (tsv2.headersNext(key2,val2)==affx::TSV_OK) {
    if (tsv1.getHeader(key2,val1)!=affx::TSV_OK) {
      m_diff_cnt++;
      if (p_inc()) {
        printf("+#%%%s=%s\n",key2.c_str(),val2.c_str());
      }
    }
  }
  //
  return m_diff_cnt-start_diff_cnt;
}
예제 #3
0
파일: lib_getch.c 프로젝트: aunali1/exopc
static inline int fifo_peek(void)
{
	int ch = SP->_fifo[peek];
	T(("peeking at %d", peek));
	
	p_inc();
	return ch;
}
예제 #4
0
static NCURSES_INLINE int
fifo_peek(SCREEN *sp)
{
    int ch = (peek >= 0) ? sp->_fifo[peek] : ERR;
    TR(TRACE_IEVENT, ("peeking at %d", peek));

    p_inc();
    return ch;
}
예제 #5
0
파일: btraced.c 프로젝트: xaos-project/XaoS
static void
bfill (void *dat, struct taskinfo *task, int r1, int r2)
{
    int y;
    cpixel_t *pos, *end;
    unsigned char *data;
    r1 += ystart + 1;
    r2 += ystart + 1;
    for (y = r1; y < r2; y++) {
        pos = p_add ((cpixel_t *) cimage.currlines[y], xstart + 1);
        end = p_add ((cpixel_t *) cimage.currlines[y], xend);
        data = calculated + xstart + y * CALCWIDTH + 1;
        for (; pos < end; p_inc (pos, 1), data++) {
            if (!*data)
                p_copy (pos, 0, pos, -1);
        }
    }
}
예제 #6
0
파일: paletted.c 프로젝트: Azizou/XaoS
static void cpalette(void *data, struct taskinfo *task, int r1, int r2)
{
    pixel8_t *src, *srcend;
    cppixel_t dest;
    struct filter *f = (struct filter *) data;
    struct palettedata *s = (struct palettedata *) f->data;
    int i;
    unsigned int *table = s->table;
    for (i = r1; i < r2; i++) {
	src = f->childimage->currlines[i];
	srcend = src + f->image->width;
	dest = (cppixel_t) f->image->currlines[i];
	while (src < srcend) {
	    p_set(dest, table[*src]);
	    src++;
	    p_inc(dest, 1);
	}
    }
}
int
affx::TsvFileDiff::diffData(affx::TsvFile& tsv1, affx::TsvFile& tsv2)
{
  int start_diff_cnt=m_diff_cnt;
  std::string val1,val2;
    
  //
  open_residuals(m_residuals_filename,tsv1,tsv2);

  //
  tsv1.rewind();
  tsv2.rewind();

  //
  tsv1.nextLine();
  tsv2.nextLine();

  //
  while ((!tsv1.eof())||(!tsv2.eof())) {
    //
    int tsv1_clvl=tsv1.lineLevel();
    int tsv2_clvl=tsv2.lineLevel();
    //
    while (((tsv1_clvl>tsv2_clvl)||tsv2.eof())&&(!tsv1.eof())) {
      if (p_inc()) {
        p_linenums(tsv1,tsv2);
        printf("-");
        p_line(tsv1);
      }
      m_diff_cnt+=tsv1.getColumnCount(tsv1_clvl);
      tsv1.nextLine();
      tsv1_clvl=tsv1.lineLevel();
    }
    //
    while (((tsv2_clvl>tsv1_clvl)||tsv1.eof())&&(!tsv2.eof())) {
      if (p_inc()) {
        p_linenums(tsv1,tsv2);
        printf("+");
        p_line(tsv2);
      }
      m_diff_cnt+=tsv2.getColumnCount(tsv2_clvl);
      tsv2.nextLine();
      tsv2_clvl=tsv2.lineLevel();
    }
    //
    if ((tsv1_clvl>=0)&&(tsv2_clvl>=0)) {
      int tsv1_cidx_max=tsv1.getColumnCount(tsv1_clvl);
      int tsv2_cidx_max=tsv2.getColumnCount(tsv2_clvl);
      //
      int cidx_max;
      if (tsv1_cidx_max<tsv2_cidx_max) {
        cidx_max=tsv2_cidx_max;
      } else {
        cidx_max=tsv1_cidx_max;
      }
      
      // count diffs on the line
      int line_diff_cnt=0;
      double d1,d2;
      for (int cidx=0;cidx<cidx_max;cidx++) {
        tsv1.get(tsv1_clvl,cidx,val1);
        tsv2.get(tsv2_clvl,cidx,val2);
        // the same?
        if (val1==val2) {
          // record the base value
          if (m_residuals_tsv!=NULL) {
            // numeric?
            if (tsv1.get(tsv1_clvl,cidx,d1)==affx::TSV_OK) {
              // put a zero
              m_residuals_tsv->set(tsv1_clvl,cidx,"0");
            } else {
              // put the value
              m_residuals_tsv->set(tsv1_clvl,cidx,val1);
            }
          }
        }
        // Not string equal -- check for numeric diff
        else if ((tsv1.get(tsv1_clvl,cidx,d1)==affx::TSV_OK) &&
                 (tsv2.get(tsv2_clvl,cidx,d2)==affx::TSV_OK)) {
          double d_diff=d1-d2;
          // output the result...
          if (m_residuals_tsv!=NULL) {
            m_residuals_tsv->set(tsv1_clvl,cidx,d_diff);
          }
          // if small, it isnt a diff
          if (!((m_opt_max_diff>0.0) && (fabs(d_diff)<=m_opt_max_diff))) {
            // too big -- mark it down as a diff.
            m_diff_cnt++;
            line_diff_cnt++;
            //
          }
        }
        // normal text diff
        else {
          if (m_residuals_tsv!=NULL) {
            m_residuals_tsv->set(tsv1_clvl,cidx,"'"+val1+"'/'"+val2+"'");
          }
        }
      }
      
      // output the result line
      if (m_residuals_tsv!=NULL) {
        m_residuals_tsv->writeLevel(tsv1_clvl);
      }

      // print unchanged lines?
      if ((m_opt_print_same || (line_diff_cnt!=0)) &&
          (p_inc())) {
        //
        if (line_diff_cnt==0) {
          p_linenums(tsv1,tsv2);
          printf(" ");
          p_line(tsv1);
        }
        else if (m_opt_print_format==TsvFileDiff::FMT_1) {
          p_diff_1line(tsv1,tsv2);
        } 
        else if (m_opt_print_format==TsvFileDiff::FMT_2) {
          p_diff_2line(tsv1,tsv2);
        }
        else {
          Err::errAbort("Bad format");
        }
      }
    }
    
    //
    tsv1.nextLine();
    tsv2.nextLine();
  }
  
  close_residuals();
  
  return m_diff_cnt-start_diff_cnt;
}
예제 #8
0
파일: edged.c 프로젝트: Jheengut/gmerlin
static void
do_edge (void *data, struct taskinfo *task, int r1, int r2)
{
  struct filter *f = (struct filter *) data;
  int y;
  unsigned int *pixels = f->image->palette->pixels;
  register unsigned int black = f->image->palette->pixels[0];
  register cpixel_t *output, *end;
  register spixel_t *up, *down, *input;
  for (y = r1; y < r2; y++)
    {
      output = p_add (((cpixel_t *) f->image->currlines[y]), 1);
      input = ((spixel_t *) f->childimage->currlines[y]) + 1;
      if (y != 0)
	up = ((spixel_t *) f->childimage->currlines[y - 1]) + 2;
      else
	up = ((spixel_t *) f->childimage->currlines[y]) + 2;
      if (y != f->image->height - 1)
	down = ((spixel_t *) f->childimage->currlines[y + 1]) + 2;
      else
	down = ((spixel_t *) f->childimage->currlines[y]) + 2;
      end =
	p_add (((cpixel_t *) f->image->currlines[y]), f->image->width - 1);
      p_setp (output, -1, 0);
      p_setp (output, f->image->width - 2, 0);
      while (output < end)
	{
	  if (input[1] != input[0] || input[0] != up[0]
	      || input[0] != down[0])
	    {
	      if (output < end - 2)
		{
		  p_set (output, pixels[input[0]]);
		  p_setp (output, 1, pixels[input[1]]);
		  p_setp (output, 2, pixels[input[2]]);
		  p_inc (output, 3);
		  input += 3;
		  up += 3;
		  down += 3;
		  while (output < end - 1
			 && (input[0] != up[-1] || input[0] != down[-1]))
		    {
		      p_set (output, pixels[input[0]]);
		      p_setp (output, 1, pixels[input[1]]);
		      p_inc (output, 2);
		      input += 2;
		      up += 2;
		      down += 2;
		    }
		  if (output < end
		      && (input[-1] != input[0] || up[-2] != input[0]
			  || down[-2] != input[0]))
		    {
		      p_set (output, pixels[input[0]]);
		      p_inc (output, 1);
		      input++;
		      up++;
		      down++;
		    }
		}
	      else
		p_set (output, pixels[*input]), p_inc (output, 1), input++,
		  up++, down++;
	    }
	  else
	    p_set (output, black), p_inc (output, 1), input++, up++, down++;
	}
    }
}
예제 #9
0
파일: btraced.c 프로젝트: xaos-project/XaoS
     static void tracecolor (int xstart, int ystart, int xend, int yend, register int x, register int y)
{
    int dir = RIGHT, fill = 0;
    register unsigned char *calc;
    int peri = 0;
    cpixeldata_t c = (cpixeldata_t) calculatepixel (x, y, 0);
    cpixeldata_t w = (cpixeldata_t) 0;
    cpixeldata_t inset = (cpixeldata_t) cpalette.pixels[0];
    putpixel (x, y, c);
    calc = calculated + x + y * CALCWIDTH;
    *calc = (unsigned char) 1;
    while (x > xstart && getpixel (x - 1, y) == c)
        x--, calc--;
    *calc = (unsigned char) 2;
    if (c == inset)
        peri = 1;
    do {
        if (!fill && !*calc) {
            *calc = (unsigned char) 1;
            putpixel (x, y, c);
        }
        switch (dir) {
            case RIGHT:
                if (y > ystart) {
                    if (!*(calc - CALCWIDTH)) {
                        w = (cpixeldata_t) calculatepixel (x, y - 1, peri);
                        putpixel (x, y - 1, w);
                        *(calc - CALCWIDTH) = (unsigned char) 1;
                    } else
                        w = getpixel (x, y - 1);
                    if (w == c) {
                        dir = UP;
                        calc -= CALCWIDTH;
                        y--;
                        break;
                    }
                }

                if (x < xend) {
                    if (!*(calc + 1)) {
                        w = (cpixeldata_t) calculatepixel (x + 1, y, peri);
                        putpixel (x + 1, y, w);
                        *(calc + 1) = (unsigned char) 1;
                    } else
                        w = getpixel (x + 1, y);
                    if (w == c) {
                        calc++;
                        x++;
                        break;
                    }
                }

                if (y < yend) {
                    if (!*(calc + CALCWIDTH)) {
                        w = (cpixeldata_t) calculatepixel (x, y + 1, peri);
                        putpixel (x, y + 1, w);
                        *(calc + CALCWIDTH) = (unsigned char) 1;
                    } else
                        w = getpixel (x, y + 1);
                    if (w == c) {
                        dir = DOWN;
                        calc += CALCWIDTH;
                        y++;
                        break;
                    }
                }

                if (*calc == (unsigned char) 2) {
                    *calc = (unsigned char) 1;
                    return;
                }

                dir = LEFT;
                x--;
                calc--;
                break;

            case LEFT:
                if (y < yend) {
                    if (!*(calc + CALCWIDTH)) {
                        w = (cpixeldata_t) calculatepixel (x, y + 1, peri);
                        putpixel (x, y + 1, w);
                        *(calc + CALCWIDTH) = (unsigned char) 1;
                    } else
                        w = getpixel (x, y + 1);
                    if (w == c) {
                        dir = DOWN;
                        calc += CALCWIDTH;
                        y++;
                        break;
                    }
                }

                if (x > xstart) {
                    if (!*(calc - 1)) {
                        w = (cpixeldata_t) calculatepixel (x - 1, y, peri);
                        putpixel (x - 1, y, w);
                        *(calc - 1) = (unsigned char) 1;
                    } else
                        w = getpixel (x - 1, y);
                    if (w == c) {
                        calc--;
                        x--;
                        break;
                    }
                }

                if (y > ystart) {
                    if (!*(calc - CALCWIDTH)) {
                        w = (cpixeldata_t) calculatepixel (x, y - 1, peri);
                        putpixel (x, y - 1, w);
                        *(calc - CALCWIDTH) = (unsigned char) 1;
                    } else
                        w = getpixel (x, y - 1);
                    if (w == c) {
                        dir = UP;
                        calc -= CALCWIDTH;
                        y--;
                        break;
                    }
                }


                dir = RIGHT;
                x++;
                calc++;
                break;

            case UP:
                if (fill) {
                    unsigned char *calc1;
                    cpixel_t *pixel1;
                    calc1 = calc + 1;
                    pixel1 = p_add ((cpixel_t *) cimage.currlines[y], x + 1);
                    while (pixel1 <= p_add ((cpixel_t *) cimage.currlines[y], xend)) {
                        if (!*calc1)
                            *calc1 = (unsigned char) 1, p_set (pixel1, c);
                        else if (p_get (pixel1) != c)
                            break;
                        p_inc (pixel1, 1);
                        calc1++;
                    }
                }
                if (x > xstart) {
                    if (!*(calc - 1)) {
                        w = (cpixeldata_t) calculatepixel (x - 1, y, peri);
                        putpixel (x - 1, y, w);
                        *(calc - 1) = (unsigned char) 1;
                    }
                    w = getpixel (x - 1, y);
                    if (w == c) {
                        dir = LEFT;
                        calc--;
                        x--;
                        break;
                    }
                }

                if (y > ystart) {
                    if (!*(calc - CALCWIDTH)) {
                        w = (cpixeldata_t) calculatepixel (x, y - 1, peri);
                        putpixel (x, y - 1, w);
                        *(calc - CALCWIDTH) = (unsigned char) 1;
                    }
                    w = getpixel (x, y - 1);
                    if (w == c) {
                        calc -= CALCWIDTH;
                        y--;
                        break;
                    }
                }

                if (x < xend) {
                    if (!*(calc + 1)) {
                        w = (cpixeldata_t) calculatepixel (x + 1, y, peri);
                        putpixel (x + 1, y, w);
                        *(calc + 1) = (unsigned char) 1;
                    } else
                        w = getpixel (x + 1, y);
                    if (w == c) {
                        dir = RIGHT;
                        calc++;
                        x++;
                        break;
                    }
                }

                dir = DOWN;
                y++;
                calc += CALCWIDTH;
                break;
            case DOWN:
                if (x < xend) {
                    if (!*(calc + 1)) {
                        w = (cpixeldata_t) calculatepixel (x + 1, y, peri);
                        putpixel (x + 1, y, w);
                        *(calc + 1) = (unsigned char) 1;
                    } else
                        w = getpixel (x + 1, y);
                    if (w == c) {
                        dir = RIGHT;
                        calc++;
                        x++;
                        break;
                    }
                }

                if (y < yend) {
                    if (!*(calc + CALCWIDTH)) {
                        w = (cpixeldata_t) calculatepixel (x, y + 1, peri);
                        putpixel (x, y + 1, w);
                        *(calc + CALCWIDTH) = (unsigned char) 1;
                    } else
                        w = getpixel (x, y + 1);
                    if (w == c) {
                        dir = DOWN;
                        calc += CALCWIDTH;
                        y++;
                        break;
                    }
                }

                if (x > xstart) {
                    if (!*(calc - 1)) {
                        w = (cpixeldata_t) calculatepixel (x - 1, y, peri);
                        putpixel (x - 1, y, w);
                        *(calc - 1) = (unsigned char) 1;
                    } else
                        w = getpixel (x - 1, y);
                    if (w == c) {
                        dir = LEFT;
                        calc--;
                        x--;
                        break;
                    }
                }

                dir = UP;
                calc -= CALCWIDTH;
                y--;
                break;

        }
        if (*calc == (unsigned char) 2) {
            if (fill) {
                *calc = (unsigned char) 1;
                return;
            }
            fill = 1;
            dir = RIGHT;
        }
    }
    while (1);
}