Esempio n. 1
0
void sc_report_handler::initialize()
{
#if 0 // actually, i do not know whether we have to reset these.
    suppress();
    force();
    set_actions(SC_INFO,    SC_DEFAULT_INFO_ACTIONS);
    set_actions(SC_WARNING, SC_DEFAULT_WARNING_ACTIONS);
    set_actions(SC_ERROR,   SC_DEFAULT_ERROR_ACTIONS);
    set_actions(SC_FATAL,   SC_DEFAULT_FATAL_ACTIONS);
#endif

    sev_call_count[SC_INFO]    = 0;
    sev_call_count[SC_WARNING] = 0;
    sev_call_count[SC_ERROR]   = 0;
    sev_call_count[SC_FATAL]   = 0;

    msg_def_items * items = messages;

    while ( items != &msg_terminator )
    {
        for ( int i = 0; i < items->count; ++i )
        {
            items->md[i].call_count = 0;
            items->md[i].sev_call_count[SC_INFO]    = 0;
            items->md[i].sev_call_count[SC_WARNING] = 0;
            items->md[i].sev_call_count[SC_ERROR]   = 0;
            items->md[i].sev_call_count[SC_FATAL]   = 0;
        }
        items = items->next;
    }

    // PROCESS ANY ENVIRONMENTAL OVERRIDES:

    const char* deprecation_warn = std::getenv("SC_DEPRECATION_WARNINGS");
    if ( (deprecation_warn!=0) && !strcmp(deprecation_warn,"DISABLE") )
    {
        set_actions("/IEEE_Std_1666/deprecated", SC_DO_NOTHING);
    }
}
Esempio n. 2
0
  void CANNY::apply_canny() {

  int *dest_1d,**tmp_2d,**p_2d,**q_2d,**m_2d,**nms,**delta,**tracked,*tmp2_1d;
  double **theta_2d;
  int i,j;
  int result;
  //int tmp = 0;
  unsigned char **aux;

    d_w = height;
    d_h = width;

    for(i=0;i<height;i++){
    for(j=0;j<width;j++){
      im_lineas[i][j]=0xff000000;
    }
 }

    aux=new unsigned char* [d_w];
    dest_1d= new int[d_h*d_w];
    tmp2_1d=new int [d_h*d_w];
    tmp_2d=new int* [d_w];
    p_2d=new int* [d_w];
    q_2d=new int* [d_w];
    m_2d=new int* [d_w];
    theta_2d=new double* [d_w];
    nms=new int* [d_w];
    delta=new int* [d_w];
    tracked=new int* [d_w];
    for(i=0;i<d_w;i++){
      aux[i]=new unsigned char[d_h];
      tmp_2d[i]=new int[d_h];
      p_2d[i]=new int[d_h];
      q_2d[i]=new int[d_h];
      m_2d[i]=new int[d_h];
      theta_2d[i]=new double[d_h];
      nms[i]=new int[d_h];
      delta[i]=new int[d_h];
      tracked[i]=new int[d_h]; 
    } 

    //Smooth the initial image
		cout<<tmp_2d<<" "<<height<<" "<<width<<" "<<kernel_size<<" "<<theta<<endl;
    SmoothImage(im_entrada,tmp_2d,height, width, kernel_size, theta);

    //Mask off so that we work with values between 0 and 255
    for(i=0;i<height;i++){
    for(j=0;j<width;j++){
      tmp_2d[i][j]=tmp_2d[i][j]&0x000000ff;
    }
 }
    
    //Apply the gradient detection
    for(i = 0; i < (d_w-1); i++){
      for(j = 0; j < (d_h-1); j++){
	p_2d[i][j] = (tmp_2d[i][j+1]-tmp_2d[i][j]+
		      tmp_2d[i+1][j+1]-tmp_2d[i+1][j])/2;
	q_2d[i][j] = (tmp_2d[i][j]-tmp_2d[i+1][j]+
		      tmp_2d[i][j+1]-tmp_2d[i+1][j+1])/2;
	m_2d[i][j] = (int)sqrt(pow((double)p_2d[i][j],2)+
				    pow((double)q_2d[i][j],2));
        if((q_2d[i][j]==0)&&(p_2d[i][j]==0)){
             theta_2d[i][j]=0;
        }else{
	theta_2d[i][j] =atan2((double)(q_2d[i][j]),(double)(p_2d[i][j]));
        }
      }
    }

    //Resize image
    d_w--;
    d_h--;
    //Apply the nonmaxima suppression

    //First calculate which sector each line appears in

    for( i = 0; i < d_w; i++){
      for( j = 0; j < d_h; j++){
	delta[i][j] = sector(theta_2d[i][j]);
      }
    }

    //Then apply non maximal suppression
    for( i = 0; i < (d_w-1); i++){ nms[i][0] = 0; nms[i][d_h-1] = 0; }
    for( j = 0; j < (d_h-1); j++){ nms[0][j] = 0; nms[d_w-1][j] = 0; }
    for( i = 1; i < (d_w-1); i++){
      for( j = 1; j < (d_h-1); j++){
	nms[i][j] = suppress(m_2d, delta[i][j], i, j,lowthresh);
      }
    }

    //Resize again!
    d_w = d_w - 2;
    d_h = d_h - 2;

    //Track the image
     apply_track(nms,tracked, d_w, d_h, lowthresh, highthresh);

    //Calculate the output array
    for( i = 0; i < d_w; i++){
      for( j = 0; j < d_h; j++){
	result = tracked[i][j];
        //if(result!=0)ShowMessage("Aki");
	result = (int) (result * scale);
        if(result>0){
	result = result + offset;
        }
	if(result > 255){result = 255;}
	if(result < 0){result = 0;}
	im_lineas[i][j] =0xff000000|result;
      }
    }

    //Change the sizes back
    d_w = d_w + 3;
    d_h = d_h + 3;

    for(i=0;i<d_w;i++){
      delete(aux[i]);
      delete(tmp_2d[i]);
      delete(p_2d[i]);
      delete(q_2d[i]);
      delete(m_2d[i]);
      delete(theta_2d[i]);
      delete(nms[i]);
      delete(delta[i]);
      delete(tracked[i]); 
    } 
      delete(aux);
      delete(tmp_2d);
      delete(p_2d);
      delete(q_2d);
      delete(m_2d);
      delete(theta_2d);
      delete(nms);
      delete(delta);
      delete(tracked); 
      delete(dest_1d);
      delete(tmp2_1d);
}
Esempio n. 3
0
int main(int argv ,char* argc)
{

    int i,j,k;
    const uchar*  data;					// pointer to the unaligned origin of image data
    int channels;
    char  name[50];

    IplImage *img = NULL;
    gets(name);
    img=cvLoadImage(name,1);				// load an image
    if(!img) {
        printf("cannot open image error");
        exit(1);
    }


// get the image data
    height = img->height;  				// image height in pixels
    width = img->width;   					// image width in pixels
    step = img->widthStep/sizeof(uchar); 			// size of aligned image row in bytes
    channels = img->nChannels;    				// Number of color channels (1,2,3,4)
    data = (uchar *)img->imageData;

    printf("Height=%d\nWidth=%d\n",height,width);

// display pixel value of each pixel
    /* for(i=0;i<height;i++)
     {
    	for(j=0;j<width;j++)
    		printf("%d ",data[i*width+j]);
    	printf("\n");
     }
    */
    /************************************************
        * Step 1: Apply a Gaussian blur
        * Step 2: Find edge Gradient strength and direction
        * Step 3: Trace along the edges
        * Step 4: Non-maximum Suppression
    **************************************************/



    int newPixel;						// Sum pixel values for gaussian


//scan  Gaussian Mask (5*5 matrix)
    int Gm[5][5]= {
        {2,4,5,4,2},
        {4,9,12,9,4},
        {5,12,15,12,5},
        {4,9,12,9,4},
        {2,4,5,4,2}
    };

//scan  Sobel operator (3x3 convolution masks) for estimating the Gradient in the x-direction
    int Gx[3][3]= {
        {-1,0,1},
        {-2,0,2},
        {-1,0,1}
    };

//scan  Sobel operator (3x3 convolution masks) for estimating the Gradient in the y-direction
    int Gy[3][3]= {
        {1,2,1},
        {0,0,0},
        {-1,-2,-1}
    };

// Convert the RGB image into Grayscale using Formula [Y = 0.3*R + 0.59*G + 0.11*B]
    for(i=0; i<height; i++) {
        for(j=0; j<width; j++) {
            Result[i][j]= (int)(0.3*(int)(data[i*step + j*channels +2])+0.59*(int)(data[i*step + j*channels +1])+0.11*(int)(data[i*step + j*channels +0]));
        }
    }


// Step:: 1  Apply a Gaussian blur


    int row,row1,col,col1;

    for (row=2; row<height-2; row++)
    {
        for (col=2; col<width-2; col++)
        {
            newPixel = 0;
            for (row1=-2; row1<=2; row1++)
            {
                for (col1=-2; col1<=2; col1++)
                    newPixel +=Result[row+row1][col+col1]*Gm[2+col1][2+row1];
            }
            Result[row][col]=newPixel/159;
        }
    }


// Step :: 2    Find edge Gradient strength and direction


    Direction = (int *)malloc(height*width*sizeof(int));
    Gradient = (int *)malloc(height*width*sizeof(int));

    int x,y;
    double Angle;

    for (row=1; row<height-1; row++)
    {
        for (col=1; col<width-1; col++)
        {
            x = 0;
            y = 0;
            /* Calculate the sum of the Sobel mask times the nine surrounding pixels in the x and y direction */
            for (row1=-1; row1<=1; row1++)
            {
                for (col1=-1; col1<=1; col1++)
                {
                    x+=Result[row+row1][col+col1]*Gx[1+col1][1+row1];
                    y+=Result[row+row1][col+col1]*Gy[1+col1][1+row1];
                }
            }

            Gradient[row*width+col] = (int)(sqrt(pow(x,2) + pow(y,2)));	// Calculate Gradient strength
            Angle = (atan2(x,y)/3.14159) * 180.0;		// Calculate actual direction of edge

            //printf("%d %d %lf\n",x,y,Gradient[row*width+col]);

            /* Convert actual edge direction to approximate value */
            if (((Angle<22.5)&&(Angle>-22.5)) || (Angle>157.5) || (Angle< -157.5))
                Angle = 0;
            if (((Angle > 22.5) && (Angle<67.5)) || ((Angle<-112.5) && (Angle>-157.5)))
                Angle = 45;
            if ( ( (Angle>67.5) && (Angle<112.5)) || ((Angle<-67.5) && (Angle>-112.5)))
                Angle = 90;
            if ( ( (Angle>112.5) && (Angle<157.5)) || ((Angle < -22.5) && (Angle > -67.5)))
                Angle = 135;

            Direction[row*width+col] = Angle;		// Store the approximate edge direction of each pixel in one array
        }
    }


//Step :: 3     Trace along the edges
    int flag;					// Stores whether or not the edge is at the edge of the possible image


    /* Trace along all the edges in the image */
    for (row=1; row<height-1; row++)
    {
        for (col=1; col<width-1; col++)
        {

            flag =0;
            if (Gradient[row*width+col] > upperThreshold) {
                /* Switch based on current pixel's edge direction */
                switch (Direction[row*width+col]) {
                case 0:
                    Edge(0,1,row,col,0);
                    break;
                case 45:
                    Edge(1,1,row,col,45);
                    break;
                case 90:
                    Edge(1,0,row,col,90);
                    break;
                case 135:
                    Edge(1,-1,row,col,135);
                    break;
                default :
                    Result[row][col]=0;
                    break;
                }
            }
            else {
                Result[row][col]=0;
            }
        }
    }



    /* Suppress any pixels not changed by the edge tracing */
    for (row=0; row<height; row++)
    {
        for (col=0; col<width; col++)
        {

            // If a pixel's grayValue is not black or white make it black
            if((Result[row][col]!= 255) && (Result[row][col]!= 0))
                Result[row][col]= 0 ;
        }
    }

    makeimage("output1.jpg");

// Step :: 4    Non-maximum Suppression


    for (row = 1; row < height-1; row++) {
        for (col = 1; col < width-1; col++) {
            if (Result[row][col] == 255) {		// Check to see if current pixel is an edge
                /* Switch based on current pixel's edge direction */
                switch (Direction[row*width+col]) {
                case 0:
                    suppress( 1, 0, row, col, 0);
                    break;
                case 45:
                    suppress( 1, -1, row, col, 45);
                    break;
                case 90:
                    suppress( 0, 1, row, col, 90);
                    break;
                case 135:
                    suppress( 1, 1, row, col, 135);
                    break;
                default :
                    break;
                }
            }
        }
    }


    makeimage("output2.jpg");

}// End of Main Function
Esempio n. 4
0
int
slave()
{
	int tries;
	long electiontime, refusetime, looktime, looptime, adjtime;
	u_short seq;
	long fastelection;
#define FASTTOUT 3
	struct in_addr cadr;
	struct timeval otime;
	struct sockaddr_in taddr;
	char tname[MAXHOSTNAMELEN];
	struct tsp *msg, to;
	struct timeval ntime, wait, tmptv;
	time_t tsp_time_sec;
	struct tsp *answer;
	int timeout();
	char olddate[32];
	char newdate[32];
	struct netinfo *ntp;
	struct hosttbl *htp;
	struct utmpx utx;


	old_slavenet = 0;
	seq = 0;
	refusetime = 0;
	adjtime = 0;

	(void)gettimeofday(&ntime, NULL);
	electiontime = ntime.tv_sec + delay2;
	fastelection = ntime.tv_sec + FASTTOUT;
	if (justquit)
		looktime = electiontime;
	else
		looktime = fastelection;
	looptime = fastelection;

	if (slavenet)
		xmit(TSP_SLAVEUP, 0, &slavenet->dest_addr);
	if (status & MASTER) {
		for (ntp = nettab; ntp != NULL; ntp = ntp->next) {
			if (ntp->status == MASTER)
				masterup(ntp);
		}
	}

loop:
	get_goodgroup(0);
	(void)gettimeofday(&ntime, NULL);
	if (ntime.tv_sec > electiontime) {
		if (trace)
			fprintf(fd, "election timer expired\n");
		longjmp(jmpenv, 1);
	}

	if (ntime.tv_sec >= looktime) {
		if (trace)
			fprintf(fd, "Looking for nets to master\n");

		if (Mflag && nignorednets > 0) {
			for (ntp = nettab; ntp != NULL; ntp = ntp->next) {
				if (ntp->status == IGNORE
				    || ntp->status == NOMASTER) {
					lookformaster(ntp);
					if (ntp->status == MASTER) {
						masterup(ntp);
					} else if (ntp->status == MASTER) {
						ntp->status = NOMASTER;
					}
				}
				if (ntp->status == MASTER
				    && --ntp->quit_count < 0)
					ntp->quit_count = 0;
			}
			makeslave(slavenet);	/* prune extras */
			setstatus();
		}
		(void)gettimeofday(&ntime, NULL);
		looktime = ntime.tv_sec + delay2;
	}
	if (ntime.tv_sec >= looptime) {
		if (trace)
			fprintf(fd, "Looking for loops\n");
		for (ntp = nettab; ntp != NULL; ntp = ntp->next) {
		    if (ntp->status == MASTER) {
			to.tsp_type = TSP_LOOP;
			to.tsp_vers = TSPVERSION;
			to.tsp_seq = sequence++;
			to.tsp_hopcnt = MAX_HOPCNT;
			(void)strcpy(to.tsp_name, hostname);
			bytenetorder(&to);
			if (sendto(sock, (char *)&to, sizeof(struct tsp), 0,
				   (struct sockaddr*)&ntp->dest_addr,
				   sizeof(ntp->dest_addr)) < 0) {
				trace_sendto_err(ntp->dest_addr.sin_addr);
			}
		    }
		}
		(void)gettimeofday(&ntime, NULL);
		looptime = ntime.tv_sec + delay2;
	}

	wait.tv_sec = min(electiontime,min(looktime,looptime)) - ntime.tv_sec;
	if (wait.tv_sec < 0)
		wait.tv_sec = 0;
	wait.tv_sec += FASTTOUT;
	wait.tv_usec = 0;
	msg = readmsg(TSP_ANY, ANYADDR, &wait, 0);

	if (msg != NULL) {
		/*
		 * filter stuff not for us
		 */
		switch (msg->tsp_type) {
		case TSP_SETDATE:
		case TSP_TRACEOFF:
		case TSP_TRACEON:
			/*
			 * XXX check to see they are from ourself
			 */
			break;

		case TSP_TEST:
		case TSP_MSITE:
			break;

		case TSP_MASTERUP:
			if (!fromnet) {
				if (trace) {
					fprintf(fd, "slave ignored: ");
					print(msg, &from);
				}
				goto loop;
			}
			break;

		default:
			if (!fromnet
			    || fromnet->status == IGNORE
			    || fromnet->status == NOMASTER) {
				if (trace) {
					fprintf(fd, "slave ignored: ");
					print(msg, &from);
				}
				goto loop;
			}
			break;
		}


		/*
		 * now process the message
		 */
		switch (msg->tsp_type) {

		case TSP_ADJTIME:
			if (fromnet != slavenet)
				break;
			if (!good_host_name(msg->tsp_name)) {
				syslog(LOG_NOTICE,
				   "attempted time adjustment by %s",
				       msg->tsp_name);
				suppress(&from, msg->tsp_name, fromnet);
				break;
			}
			/*
			 * Speed up loop detection in case we have a loop.
			 * Otherwise the clocks can race until the loop
			 * is found.
			 */
			(void)gettimeofday(&otime, NULL);
			if (adjtime < otime.tv_sec)
				looptime -= (looptime-otime.tv_sec)/2 + 1;

			setmaster(msg);
			if (seq != msg->tsp_seq) {
				seq = msg->tsp_seq;
				synch(tvtomsround(msg->tsp_time));
			}
			(void)gettimeofday(&ntime, NULL);
			electiontime = ntime.tv_sec + delay2;
			fastelection = ntime.tv_sec + FASTTOUT;
			adjtime = ntime.tv_sec + SAMPLEINTVL*2;
			break;

		case TSP_SETTIME:
			if (fromnet != slavenet)
				break;
			if (seq == msg->tsp_seq)
				break;
			seq = msg->tsp_seq;

			/* adjust time for residence on the queue */
			(void)gettimeofday(&otime, NULL);
			adj_msg_time(msg,&otime);
			/*
			 * the following line is necessary due to syslog
			 * calling ctime() which clobbers the static buffer
			 */
			(void)strcpy(olddate, date());
			tsp_time_sec = msg->tsp_time.tv_sec;
			(void)strcpy(newdate, ctime(&tsp_time_sec));

			if (!good_host_name(msg->tsp_name)) {
				syslog(LOG_NOTICE,
			    "attempted time setting by untrusted %s to %s",
				       msg->tsp_name, newdate);
				suppress(&from, msg->tsp_name, fromnet);
				break;
			}

			setmaster(msg);
 			tmptv.tv_sec = msg->tsp_time.tv_sec;
 			tmptv.tv_usec = msg->tsp_time.tv_usec;
			timevalsub(&ntime, &tmptv, &otime);
			if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) {
				/*
				 * do not change the clock if we can adjust it
				 */
				synch(tvtomsround(ntime));
			} else {
				utx.ut_type = OLD_TIME;
				gettimeofday(&utx.ut_tv, NULL);
				pututxline(&utx);
				(void)settimeofday(&tmptv, 0);
				utx.ut_type = NEW_TIME;
				gettimeofday(&utx.ut_tv, NULL);
				pututxline(&utx);
				syslog(LOG_NOTICE,
				       "date changed by %s from %s",
					msg->tsp_name, olddate);
				if (status & MASTER)
					spreadtime();
			}
			(void)gettimeofday(&ntime, NULL);
			electiontime = ntime.tv_sec + delay2;
			fastelection = ntime.tv_sec + FASTTOUT;

/* This patches a bad protocol bug.  Imagine a system with several networks,
 * where there are a pair of redundant gateways between a pair of networks,
 * each running timed.  Assume that we start with a third machine mastering
 * one of the networks, and one of the gateways mastering the other.
 * Imagine that the third machine goes away and the non-master gateway
 * decides to replace it.  If things are timed just 'right,' we will have
 * each gateway mastering one network for a little while.  If a SETTIME
 * message gets into the network at that time, perhaps from the newly
 * masterful gateway as it was taking control, the SETTIME will loop
 * forever.  Each time a gateway receives it on its slave side, it will
 * call spreadtime to forward it on its mastered network.  We are now in
 * a permanent loop, since the SETTIME msgs will keep any clock
 * in the network from advancing.  Normally, the 'LOOP' stuff will detect
 * and correct the situation.  However, with the clocks stopped, the
 * 'looptime' timer cannot expire.  While they are in this state, the
 * masters will try to saturate the network with SETTIME packets.
 */
			looptime = ntime.tv_sec + (looptime-otime.tv_sec)/2-1;
			break;

		case TSP_MASTERUP:
			if (slavenet && fromnet != slavenet)
				break;
			if (!good_host_name(msg->tsp_name)) {
				suppress(&from, msg->tsp_name, fromnet);
				if (electiontime > fastelection)
					electiontime = fastelection;
				break;
			}
			makeslave(fromnet);
			setmaster(msg);
			setstatus();
			answerdelay();
			xmit(TSP_SLAVEUP, 0, &from);
			(void)gettimeofday(&ntime, NULL);
			electiontime = ntime.tv_sec + delay2;
			fastelection = ntime.tv_sec + FASTTOUT;
			refusetime = 0;
			break;

		case TSP_MASTERREQ:
			if (fromnet->status != SLAVE)
				break;
			(void)gettimeofday(&ntime, NULL);
			electiontime = ntime.tv_sec + delay2;
			break;

		case TSP_SETDATE:
			tsp_time_sec = msg->tsp_time.tv_sec;
			(void)strcpy(newdate, ctime(&tsp_time_sec));
			schgdate(msg, newdate);
			break;

		case TSP_SETDATEREQ:
			if (fromnet->status != MASTER)
				break;
			tsp_time_sec = msg->tsp_time.tv_sec;
			(void)strcpy(newdate, ctime(&tsp_time_sec));
			htp = findhost(msg->tsp_name);
			if (0 == htp) {
				syslog(LOG_WARNING,
				       "DATEREQ from uncontrolled machine");
				break;
			}
			if (!htp->good) {
				syslog(LOG_WARNING,
				"attempted date change by untrusted %s to %s",
				       htp->name, newdate);
				spreadtime();
				break;
			}
			schgdate(msg, newdate);
			break;

		case TSP_TRACEON:
			traceon();
			break;

		case TSP_TRACEOFF:
			traceoff("Tracing ended at %s\n");
			break;

		case TSP_SLAVEUP:
			newslave(msg);
			break;

		case TSP_ELECTION:
			if (fromnet->status == SLAVE) {
				(void)gettimeofday(&ntime, NULL);
				electiontime = ntime.tv_sec + delay2;
				fastelection = ntime.tv_sec + FASTTOUT;
				seq = 0;
				if (!good_host_name(msg->tsp_name)) {
					syslog(LOG_NOTICE,
					       "suppress election of %s",
					       msg->tsp_name);
					to.tsp_type = TSP_QUIT;
					electiontime = fastelection;
				} else if (cadr.s_addr != from.sin_addr.s_addr
					   && ntime.tv_sec < refusetime) {
/* if the candidate has to repeat itself, the old code would refuse it
 * the second time.  That would prevent elections.
 */
					to.tsp_type = TSP_REFUSE;
				} else {
					cadr.s_addr = from.sin_addr.s_addr;
					to.tsp_type = TSP_ACCEPT;
					refusetime = ntime.tv_sec + 30;
				}
				taddr = from;
				(void)strcpy(tname, msg->tsp_name);
				(void)strcpy(to.tsp_name, hostname);
				answerdelay();
				if (!acksend(&to, &taddr, tname,
					     TSP_ACK, 0, 0))
					syslog(LOG_WARNING,
					     "no answer from candidate %s\n",
					       tname);

			} else {	/* fromnet->status == MASTER */
				htp = addmach(msg->tsp_name, &from,fromnet);
				to.tsp_type = TSP_QUIT;
				(void)strcpy(to.tsp_name, hostname);
				if (!acksend(&to, &htp->addr, htp->name,
					     TSP_ACK, 0, htp->noanswer)) {
					syslog(LOG_ERR,
					  "no reply from %s to ELECTION-QUIT",
					       htp->name);
					(void)remmach(htp);
				}
			}
			break;

		case TSP_CONFLICT:
			if (fromnet->status != MASTER)
				break;
			/*
			 * After a network partition, there can be
			 * more than one master: the first slave to
			 * come up will notify here the situation.
			 */
			(void)strcpy(to.tsp_name, hostname);

			/* The other master often gets into the same state,
			 * with boring results.
			 */
			ntp = fromnet;	/* (acksend() can leave fromnet=0 */
			for (tries = 0; tries < 3; tries++) {
				to.tsp_type = TSP_RESOLVE;
				answer = acksend(&to, &ntp->dest_addr,
						 ANYADDR, TSP_MASTERACK,
						 ntp, 0);
				if (answer == NULL)
					break;
				htp = addmach(answer->tsp_name,&from,ntp);
				to.tsp_type = TSP_QUIT;
				answer = acksend(&to, &htp->addr, htp->name,
						 TSP_ACK, 0, htp->noanswer);
				if (!answer) {
					syslog(LOG_WARNING,
				  "conflict error: no reply from %s to QUIT",
						htp->name);
					(void)remmach(htp);
				}
			}
			masterup(ntp);
			break;

		case TSP_MSITE:
			if (!slavenet)
				break;
			taddr = from;
			to.tsp_type = TSP_MSITEREQ;
			to.tsp_vers = TSPVERSION;
			to.tsp_seq = 0;
			(void)strcpy(to.tsp_name, hostname);
			answer = acksend(&to, &slavenet->dest_addr,
					 ANYADDR, TSP_ACK,
					 slavenet, 0);
			if (answer != NULL
			    && good_host_name(answer->tsp_name)) {
				setmaster(answer);
				to.tsp_type = TSP_ACK;
				(void)strcpy(to.tsp_name, answer->tsp_name);
				bytenetorder(&to);
				if (sendto(sock, (char *)&to,
					   sizeof(struct tsp), 0,
					   (struct sockaddr*)&taddr,
					   sizeof(taddr)) < 0) {
					trace_sendto_err(taddr.sin_addr);
				}
			}
			break;

		case TSP_MSITEREQ:
			break;

		case TSP_ACCEPT:
		case TSP_REFUSE:
		case TSP_RESOLVE:
			break;

		case TSP_QUIT:
			doquit(msg);		/* become a slave */
			break;

		case TSP_TEST:
			electiontime = 0;
			break;

		case TSP_LOOP:
			/* looking for loops of masters */
			if (!(status & MASTER))
				break;
			if (fromnet->status == SLAVE) {
			    if (!strcmp(msg->tsp_name, hostname)) {
				/*
				 * Someone forwarded our message back to
				 * us.  There must be a loop.  Tell the
				 * master of this network to quit.
				 *
				 * The other master often gets into
				 * the same state, with boring results.
				 */
				ntp = fromnet;
				for (tries = 0; tries < 3; tries++) {
				    to.tsp_type = TSP_RESOLVE;
				    answer = acksend(&to, &ntp->dest_addr,
						     ANYADDR, TSP_MASTERACK,
						     ntp,0);
				    if (answer == NULL)
					break;
				    taddr = from;
				    (void)strcpy(tname, answer->tsp_name);
				    to.tsp_type = TSP_QUIT;
				    (void)strcpy(to.tsp_name, hostname);
				    if (!acksend(&to, &taddr, tname,
						 TSP_ACK, 0, 1)) {
					syslog(LOG_ERR,
					"no reply from %s to slave LOOP-QUIT",
						 tname);
				    } else {
					electiontime = 0;
				    }
				}
				(void)gettimeofday(&ntime, NULL);
				looptime = ntime.tv_sec + FASTTOUT;
			    } else {
				if (msg->tsp_hopcnt-- < 1)
				    break;
				bytenetorder(msg);
				for (ntp = nettab; ntp != 0; ntp = ntp->next) {
				    if (ntp->status == MASTER
					&& 0 > sendto(sock, (char *)msg,
						      sizeof(struct tsp), 0,
					      (struct sockaddr*)&ntp->dest_addr,
						      sizeof(ntp->dest_addr)))
				    trace_sendto_err(ntp->dest_addr.sin_addr);
				}
			    }
			} else {	/* fromnet->status == MASTER */
			    /*
			     * We should not have received this from a net
			     * we are master on.  There must be two masters,
			     * unless the packet was really from us.
			     */
			    if (from.sin_addr.s_addr
				== fromnet->my_addr.s_addr) {
				if (trace)
				    fprintf(fd,"discarding forwarded LOOP\n");
				break;
			    }

			    /*
			     * The other master often gets into the same
			     * state, with boring results.
			     */
			    ntp = fromnet;
			    for (tries = 0; tries < 3; tries++) {
				to.tsp_type = TSP_RESOLVE;
				answer = acksend(&to, &ntp->dest_addr,
						 ANYADDR, TSP_MASTERACK,
						ntp,0);
				if (!answer)
					break;
				htp = addmach(answer->tsp_name,
					      &from,ntp);
				to.tsp_type = TSP_QUIT;
				(void)strcpy(to.tsp_name, hostname);
				if (!acksend(&to,&htp->addr,htp->name,
					     TSP_ACK, 0, htp->noanswer)) {
					syslog(LOG_ERR,
				    "no reply from %s to master LOOP-QUIT",
					       htp->name);
					(void)remmach(htp);
				}
			    }
			    (void)gettimeofday(&ntime, NULL);
			    looptime = ntime.tv_sec + FASTTOUT;
			}
			break;
		default:
			if (trace) {
				fprintf(fd, "garbage message: ");
				print(msg, &from);
			}
			break;
		}
	}
	goto loop;
}
Esempio n. 5
0
void
lookformaster(struct netinfo *ntp)
{
	struct tsp resp, conflict, *answer;
	struct timeval ntime;
	char mastername[MAXHOSTNAMELEN];
	struct sockaddr_in masteraddr;

	get_goodgroup(0);
	ntp->status = SLAVE;

	/* look for master */
	resp.tsp_type = TSP_MASTERREQ;
	(void)strcpy(resp.tsp_name, hostname);
	answer = acksend(&resp, &ntp->dest_addr, ANYADDR,
			 TSP_MASTERACK, ntp, 0);
	if (answer != NULL && !good_host_name(answer->tsp_name)) {
		suppress(&from, answer->tsp_name, ntp);
		ntp->status = NOMASTER;
		answer = NULL;
	}
	if (answer == NULL) {
		/*
		 * Various conditions can cause conflict: races between
		 * two just started timedaemons when no master is
		 * present, or timedaemons started during an election.
		 * A conservative approach is taken.  Give up and became a
		 * slave, postponing election of a master until first
		 * timer expires.
		 */
		ntime.tv_sec = ntime.tv_usec = 0;
		answer = readmsg(TSP_MASTERREQ, ANYADDR, &ntime, ntp);
		if (answer != NULL) {
			if (!good_host_name(answer->tsp_name)) {
				suppress(&from, answer->tsp_name, ntp);
				ntp->status = NOMASTER;
			}
			return;
		}

		ntime.tv_sec = ntime.tv_usec = 0;
		answer = readmsg(TSP_MASTERUP, ANYADDR, &ntime, ntp);
		if (answer != NULL) {
			if (!good_host_name(answer->tsp_name)) {
				suppress(&from, answer->tsp_name, ntp);
				ntp->status = NOMASTER;
			}
			return;
		}

		ntime.tv_sec = ntime.tv_usec = 0;
		answer = readmsg(TSP_ELECTION, ANYADDR, &ntime, ntp);
		if (answer != NULL) {
			if (!good_host_name(answer->tsp_name)) {
				suppress(&from, answer->tsp_name, ntp);
				ntp->status = NOMASTER;
			}
			return;
		}

		if (Mflag)
			ntp->status = MASTER;
		else
			ntp->status = NOMASTER;
		return;
	}

	ntp->status = SLAVE;
	(void)strcpy(mastername, answer->tsp_name);
	masteraddr = from;

	/*
	 * If network has been partitioned, there might be other
	 * masters; tell the one we have just acknowledged that
	 * it has to gain control over the others.
	 */
	ntime.tv_sec = 0;
	ntime.tv_usec = 300000;
	answer = readmsg(TSP_MASTERACK, ANYADDR, &ntime, ntp);
	/*
	 * checking also not to send CONFLICT to ack'ed master
	 * due to duplicated MASTERACKs
	 */
	if (answer != NULL &&
	    strcmp(answer->tsp_name, mastername) != 0) {
		conflict.tsp_type = TSP_CONFLICT;
		(void)strcpy(conflict.tsp_name, hostname);
		if (!acksend(&conflict, &masteraddr, mastername,
			     TSP_ACK, 0, 0)) {
			syslog(LOG_ERR,
			       "error on sending TSP_CONFLICT");
		}
	}
}
Esempio n. 6
0
cv::Mat	PM_type::nms(const cv::Mat &boxes, float overlap)
//% Non-maximum suppression.
//%   pick = nms(boxes, overlap) 
//% 
//%   Greedily select high-scoring detections and skip detections that are 
//%   significantly covered by a previously selected detection.
//%
//% Return value
//%   pick      Indices of locally maximal detections
//%
//% Arguments
//%   boxes     Detection bounding boxes (see pascal_test.m)
//%   overlap   Overlap threshold for suppression
//%             For a selected box Bi, all boxes Bj that are covered by 
//%             more than overlap are suppressed. Note that 'covered' is
//%             is |Bi \cap Bj| / |Bj|, not the PASCAL intersection over 
//%             union measure.
{
	if( boxes.empty() )
		return boxes;

	cv::Mat	x1 = boxes.col(0);
	cv::Mat	y1 = boxes.col(1);
	cv::Mat	x2 = boxes.col(2);
	cv::Mat	y2 = boxes.col(3);
	cv::Mat	s = boxes.col(boxes.cols - 1);

	cv::Mat	area = x2 - x1 + 1;
	area = area.mul(y2-y1+1);

	vector<int>	Ind( s.rows, 0 );
	cv::Mat	Idx(s.rows, 1, CV_32SC1, &Ind[0]);
	sortIdx( s, Idx, CV_SORT_EVERY_COLUMN+CV_SORT_ASCENDING );

	vector<int>	pick;
	while( !Ind.empty() ){
		int	last = Ind.size() - 1;
		int	i = Ind[last];
		pick.push_back(i);

		vector<int>	suppress( 1, last );
		for( int pos=0; pos<last; pos++ ){
			int		j = Ind[pos];
			float	xx1 = std::max(x1.at<float>(i), x1.at<float>(j));
			float	yy1 = std::max(y1.at<float>(i), y1.at<float>(j));
			float	xx2 = std::min(x2.at<float>(i), x2.at<float>(j));
			float	yy2 = std::min(y2.at<float>(i), y2.at<float>(j));
			float	w = xx2-xx1+1;
			float	h = yy2-yy1+1;
			if( w>0 && h>0 ){
				// compute overlap 
				float	area_intersection = w * h;
				float	o1 = area_intersection / area.at<float>(j);
				float	o2 = area_intersection / area.at<float>(i);
				float	o = std::max(o1,o2);
				if( o>overlap )
					suppress.push_back(pos);
			}
		}

		std::set<int>	supp( suppress.begin(), suppress.end() );
		vector<int>		Ind2;
		for( int i=0; i!=Ind.size(); i++ ){
			if( supp.find(i)==supp.end() )
				Ind2.push_back( Ind[i] );
		}
		Ind = Ind2;

	}

	cv::Mat	ret(pick.size(), boxes.cols, boxes.type());
	for( unsigned i=0; i<pick.size(); i++ )
		boxes.row( pick[i] ).copyTo( ret.row(i) );
	
	return ret;
}
Esempio n. 7
0
void CDmeTrack::RemoveAllClips()
{
	CSuppressAutoFixup suppress( this, SUPPRESS_OVERLAP_FIXUP | SUPPRESS_DIRTY_ORDERING );
	m_Clips.RemoveAll();
}
void
_finalize(js::FreeOp* fop, JSObject* obj)
{
    JS::AutoAssertGCCallback suppress(obj);
    ++ranFinalizer;
}
Esempio n. 9
0
size_t initSuppressions() {
	
	suppressBlockEnd("camera_0027", 1140, "}"); // '}' should be commented out!
	
	suppressBlockEnd("black_thing_0002", 1075, "on"); // missing '}' and accept/refuse
	
	suppressBlockEnd("chest_metal_0103", 626, "on"); // missing '}' and accept/refuse
	
	suppressBlockEnd("chest_metal_0104", 667, "on"); // missing '}' and accept/refuse
	
	suppressBlockEnd("goblin_base_0021", 617, "on"); // missing '}'
	
	suppressBlockEnd("goblin_base_0031", 974, "on"); // missing '}'
	
	suppressBlockEnd("lever_0028", 402, "}"); // extranous '}'
	
	// TODO(broken-scripts)
	// TODO move to external file
	
	suppress("akbaa_phase2", 13884, "play"); // missing sound files 'akbaa_strike1' to 'akbaa_strike3', should be 'akbaa_strike'
	suppress("akbaa_phase2", 19998, "play"); // sound number is sonetimes too high; missing 'akbaa_hail1', should be 'akbaa_hail'
	suppress("akbaa_phase2", 18549, "playanim"); // animation 'grunt' not loaded
	
	suppress("akbaa_tentacle", 2432, "on"); // unknown command 'on' (bad newline!)
	suppress("akbaa_tentacle", 3424, "on"); // unknown command 'on' (bad newline!)
	suppress("akbaa_tentacle", 3747, "dodamage"); // missing target parameter
	
	suppress("axe_2handed", 26, "settwohanded"); // obsolete command
	
	suppress("black_thing", 3703, "play"); // variable is never set
	
	suppress("camera_0072", 269, "goto"); // missing label 'dialogue7_2'
	
	suppress("camera_0076", 2139, ""); // missing accept/refuse/return/goto/gosub before end of script
	
	suppress("black_thing_0003", 4360, "setevent"); // unsupported event: "eat"
	suppress("black_thing_0003", 4388, "setevent"); // unsupported event: "no_more_eat"
	suppress("black_thing_0003", 4411, "setevent"); // unsupported event: "no_eat"
	suppress("black_thing_0003", 4709, "behvaior"); // unknown command 'behvaior', should be 'behavior'
	
	suppress("chest_metal_0011", 78, "inventory add"); // missing object: "graph/obj3d/interactive/items/magic/dragon_bone_powder/dragon_bone_powder.teo" (should be 'powder_dragon_bone/dragon_bone_powder'?)
	
	suppress("chest_metal_0012", 389, "inventory add"); // missing object: "graph/obj3d/interactive/items/magic/dragon_bone_powder/dragon_bone_powder.teo" (should be 'powder_dragon_bone/dragon_bone_powder'?)
	
	suppress("chest_metal_0020", 54, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	suppress("chest_metal_0020", 99, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	suppress("chest_metal_0020", 149, "inventory add"); // missing object: "graph/obj3d/interactive/items/magic/ring_darkaa/ring_darkaa.teo" (should be 'ring_daarka/ring_daarka'?)
	
	suppress("chest_metal_0023", 495, "unsetcontrolledzone"); // unknown zone 'zone_7_bis'
	
	suppress("chest_metal_0029", 224, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	suppress("chest_metal_0029", 317, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	suppress("chest_metal_0029", 461, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	suppress("chest_metal_0029", 557, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	suppress("chest_metal_0029", 650, "inventory add"); // missing object: "graph/obj3d/interactive/items/provisions/candle/candle.teo" (should be 'candle/candel'?)
	
	suppress("chest_metal_0045", 242, "inventory addfromscene"); // bad target ident: "magic\\potion_life\\potion_life"
	
	suppress("chest_metal_0095", 143, "inventory add"); // missing object: "graph/obj3d/interactive/items/armor/legging_leatherac/legging_leatherac.teo" (should be 'legging_leather_ac'?)
	
	suppress("chest_metal_0100", 629, "inventory add"); // missing object: "graph/obj3d/interactive/items/magic/dragon_bone_powder/dragon_bone_powder.teo" (should be 'powder_dragon_bone/dragon_bone_powder'?)
	suppress("chest_metal_0100", 693, "inventory add"); // missing object: "graph/obj3d/interactive/items/magic/dragon_bone_powder/dragon_bone_powder.teo" (should be 'powder_dragon_bone/dragon_bone_powder'?)
	
	suppress("chicken_base", 2037, "gosub"); // missing label 'save_behavior'
	suppress("chicken_base", 2410, "}"); // missing accept/refuse before end of event block
	
	suppress("corpse_0003", 399, "inventory addfromscene"); // bad target ident: "magic\\potion_life\\potion_life" (should be 'inventory add'?)
	
	suppress("corpse_0006", 172, "inventory add"); // missing object: "graph/obj3d/interactive/items/armor/helmet_leather/helmet_leather.teo"
	
	suppress("corpse_0084", 274, "inventory add"); // missing object: "graph/obj3d/interactive/items/weapons/chest_leather_ac/chest_leather_ac.teo"
	
	suppress("demon", 3571, "loadanim"); // missing animation 'demon_fight_left_start'
	suppress("demon", 3634, "loadanim"); // missing animation 'demon_fight_left_cycle'
	suppress("demon", 3698, "loadanim"); // missing animation 'demon_fight_left_strike'
	suppress("demon", 3762, "loadanim"); // missing animation 'demon_fight_right_start'
	suppress("demon", 3826, "loadanim"); // missing animation 'demon_fight_right_cycle'
	suppress("demon", 3891, "loadanim"); // missing animation 'demon_fight_right_strike'
	suppress("demon", 18479, "play"); // sound number is sometimes too high
	
	suppress("diamond", 139, "play"); // unknown flag -e (ignored) note: fix_inter/diamond_inwall/diamond.asl!
	
	suppress("dog", 19669, "play"); // sound number is sometimes too high
	
	suppress("dog_0011", 31, "playanim"); // animation 'action2' not loaded
	
	suppress("door_orbiplanax_chest", 371, "if"); // unknown operator '==1' (should be '== 1'), interpreted as constant true
	
	suppress("dragon_ice", 9029, "setevent"); // unsupported event 'agression', should be 'aggression'
	
	suppress("dragon_ice_0001", 93, "loadanim"); // missing animation: "dragon_talk_head"
	suppress("dragon_ice_0001", 3687, "playanim"); // animation 'action9' not loaded
	
	suppress("dragon's_lair_ice_wall", 41, "satangular"); // unknown command 'satangular', should be setangular
	
	suppress("dwarf_little_crusher_0001", 204, "?"); // 'playanim' only takes one parameter
	suppress("dwarf_little_crusher_0001", 228, "?"); // 'playanim' only takes one parameter
	
	suppress("dwarf_little_crusher_0002", 201, "?"); // 'playanim' only takes one parameter
	suppress("dwarf_little_crusher_0002", 225, "?"); // 'playanim' only takes one parameter
	
	suppress("dwarf_little_crusher_0003", 113, "?"); // 'playanim' only takes one parameter
	suppress("dwarf_little_crusher_0003", 137, "?"); // 'playanim' only takes one parameter
	
	suppress("emerald_inwall", 136, "play"); // unknown flag -e (ignored)
	
	suppress("fake_golden_snake", 185, "setinternalname"); // obsolete command (ignored)
	
	suppress("flour_bag", 41, "collison"); // unknown command 'collison', should be collision
	
	suppress("gem_inwall", 114, "play"); // unknown flag -e (ignored)
	
	suppress("goblin_base", 30010, "goto"); // missing label "main_alert"
	
	suppress("goblin_base_0009", 1455, "setevent"); // unsupported event: combine
	suppress("goblin_base_0009", 3864, "playanim"); // used -e flag without command
	
	suppress("goblin_base_0027", 8463, "wrong]"); // space instead of _ in localisation key
	
	suppress("goblin_base_0034", 771, "detach"); // object mug_full_0003 already destroyed
	
	suppress("goblin_base_0041", 3063, "if"); // unknown operator '==1' (should be '== 1'), interpreted as constant true
	
	suppress("goblin_base_0048", 632, "setevent"); // unsupported event: combine
	
	suppress("goblin_base_0046", 2924, "if"); // unknown operator '=>' (should be '>='?), interpreted as constant true
	
	suppress("gold_chunk_inwall", 144, "play"); // unknown flag -e (ignored)
	
	suppress("golden_snake", 156, "setinternalname"); // obsolete command
	
	suppress("hammer_club", 66, "settwohanded"); // obsolete command
	
	suppress("hanged_gob", 526, "playanim"); // animation 'action3' not loaded

	suppress("human_base", 5872, "loadanim"); // bad animation id: 'bae_ready', should be 'bare_ready'
	suppress("human_base", 13711, "loadanim"); // missing animation "child_get_hit", should be "child_hit"?
	suppress("human_base", 13751, "loadanim"); // missing animation "child_get_hit", should be "child_hit"?
	suppress("human_base", 39089, "teleport"); // variable dying_marker not set
	suppress("human_base", 45586, "goto"); // missing label "main_alert"
	
	suppress("human_base_0006", 83, "playanim"); // animation 'wait' not loaded yet
	
	suppress("human_base_0012", 1519, "goto"); // missing label 'stop'
	
	suppress("human_base_0016", 7142, "setcontrolledzone"); // unknown zone 'calpale_beer', should be 'calpal_beer'?
	suppress("human_base_0016", 1270, "inventory addfromscene"); // unknown target 'key_calpale_0003' already taken by player?
	
	suppress("human_base_0022", 10108, "behaviormoveto"); // unknown command 'behaviormoveto', should be 'behavior move_to'
	
	suppress("human_base_0025", 732, "detach"); // object mug_full_0002 already destroyed
	
	suppress("human_base_0041", 4279, "if"); // missing space between oprateor '==' and argument
	
	suppress("human_base_0051", 5396, "/"); // unknown command, should be '//' instead of '/ /'
	
	suppress("human_base_0051", 6083, "set"); // bad variable name: "waiting"
	
	suppress("human_base_0046", 679, "goto"); // missing label 'next_step02', should be 'next_step01'?
	
	suppress("human_base_0079", 239, "inventory add"); // missing object: "graph/obj3d/interactive/items/armor/chest_leatherac/chest_leatherac.teo" (should be 'chest_leather_ac'?)
	suppress("human_base_0079", 303, "inventory add"); // missing object: "graph/obj3d/interactive/items/armor/leggings_leatherac/leggings_leatherac.teo" (should be 'legging_leather_ac'?)
	
	suppress("human_base_0082", 24114, "on"); // unknown command 'on' (bad linebreak!)
	suppress("human_base_0082", 24141, "hide"); // unknown command 'hide' (bad linebreak!)
	
	suppress("human_base_0085", 426, "loadanim"); // missing animation 'human_noraml_sit_out', should be 'human_normal_sit_out'?
	
	suppress("human_base_0086", 189, "if"); // unknown operator '==1' (should be '== 1')
	suppress("human_base_0086", 787, "loadanim"); // missing animation 'human_noraml_sit_out', should be 'human_normal_sit_out'?
	
	suppress("human_base_0095", 722, "setcontrolledzone"); // unknown zone 'maria_shop'
	
	suppress("human_base_0099", 997, "errata"); // unknown command 'errata', should be 'goto errata'
	
	suppress("human_base_0114", 6541, "teleport"); // unknown target 'marker_0327'
	
	suppress("human_base_0118", 101, "collisions"); // unknown command 'collisions', should be 'collision'
	
	suppress("human_base_0119", 179, "collisions"); // unknown command 'collisions', should be 'collision'
	
	suppress("human_base_0120", 101, "collisions"); // unknown command 'collisions', should be 'collision'
	
	suppress("human_base_0121", 135, "collisions"); // unknown command 'collisions', should be 'collision'
	
	suppress("human_base_0122", 350, "collisions"); // unknown command 'collisions', should be 'collision'
	
	suppress("human_base_0135", 939, "detroy"); // unknown command 'detroy', should be 'destroy'
	
	suppress("human_base_0136", 995, "detroy"); // unknown command 'detroy', should be 'destroy'
	
	suppress("human_base_0137", 992, "detroy"); // unknown command 'detroy', should be 'destroy'
	
	suppress("human_base_0138", 2439, "setcontrolledzone"); // unknown zone 'shani_flee'
	
	suppress("human_base_0174", 136, "play"); // missing sound file 'loop_crypt1l', should be 'ambiance/loop_crypt1l'
	
	suppress("jail_wood_grid", 152, "set"); // bad variable name: "material"
	
	suppress("lamp_goblin2_0003", 737, "no"); // unknown command 'no' should be 'nop'?
	
	suppress("lava_event01_0004", 277, "action1"); // unknown command 'action1' (missing space in '200 playanim')
	
	suppress("light_door", 422, "set"); // bad variable name: "durability"
	
	suppress("light_door_0019", 105, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("light_door_0020", 230, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("light_door_0021", 234, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("light_door_0029", 88, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("light_door_0030", 162, "setevent"); // unsupported event: "npc_open"
	suppress("light_door_0030", 488, "setevent"); // unsupported event: "npc_open"
	suppress("light_door_0030", 717, "setevent"); // unsupported event: "npc_open"
	
	suppress("light_door_0100", 69, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("light_door_0102", 88, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("light_door_0106", 110, "setcontrolledzone"); // unknown zone 'city_entrance'
	
	suppress("light_door_0121", 88, "setspeakpitch"); // setspeakpitch only applies to NPCs
	
	suppress("lockpicks", 462, "play"); // missing sound file 'brokenweapon.wav', should be 'broken_weapon'
	
	suppress("long_sword_recovery", 591, "setequip"); // unknown flag '-s' (ignored)
	
	suppress("marker_0025", 288, "sendevent"); // unknown zone 'cooking' (should be 'cook_gary'?)
	
	suppress("marker_0247", 44, "setcontrolledzone"); // unknown zone 'level3_zone4'
	
	suppress("marker_0811", 536, "worldface"); // unknown command 'worldface', should be 'worldfade'
	
	suppress("metal_chunk_inwall", 143, "play"); // unknown flag -e (ignored)
	
	suppress("metal_grid_0008", 338, "}"); // missing accept/refuse before end of event block
	
	suppress("mithril_chunk_inwall", 144, "play"); // unknown flag -e (ignored)
	
	suppress("morning_glory", 971, "playanim"); // animation 'action1' not loaded
	
	suppress("orb_crypt", 76, "setsteal"); // setsteal only applies to items
	
	suppress("pig", 2409, "}"); // missing accept/refuse before end of event block
	
	suppress("player", 7725, "loadanim"); // bad animation id: "cast_hold"
	suppress("player", 8463, "loadanim"); // bad animation id: "lean_left_cycle"
	suppress("player", 8531, "loadanim"); // bad animation id: "lean_left_out"
	suppress("player", 8666, "loadanim"); // bad animation id: "lean_right_cycle"
	suppress("player", 8733, "loadanim"); // bad animation id: "lean_right_out"
	suppress("player", 9284, "loadanim"); // missing animation "human_death_cool"
	suppress("player", 9558, "loadanim"); // missing animation "human_talk_happyneutral_headonly"
	suppress("player", 18044, "play"); // missing sound file 'bell', should be 'arx_bell'
	
	suppress("porticullis_0039", 806, "setevent"); // unsupported event: "custom"
	
	suppress("porticullis_0049", 231, "?"); // missing '}' before end of script
	suppress("porticullis_0049", 231, ""); // missing accept / refuse / return before script end
	
	suppress("pressurepad_gob_0029", 74, "goto"); // missing label 'stress'
	
	suppress("public_notice_0011", 965, "magicoff"); // unknown command 'magicoff', should be 'magic off'
	
	suppress("rat_base", 17145, "play"); // sound number is sometimes too high
	
	suppress("rat_base_0059", 62, "behavior"); // unknown behavior 'firendly', should be 'friendly'
	suppress("rat_base_0059", 160, "behavior"); // unknown behavior 'firendly', should be 'friendly'
	
	suppress("ratman_base", 22834, "goto"); // missing label "main_alert"
	
	suppress("ratman_base_0024", 608, "goto"); // missing label 'test'
	
	suppress("ratman_base_0026", 712, "setevent"); // unsupported event: "detect_player"
	
	suppress("rock_akbaa", 135, "setinternalname"); // obsolete command 'setinternalname'
	
	suppress("ruby_inwall", 135, "play"); // unknown flag -e (ignored)
	
	suppress("sausagev", 12376, "inventory playeraddfromscene"); // unknown target 'note_0015'
	
	suppress("secret_door_council_2b", 609, "}"); // extraneous '}'
	
	suppress("shiny_orb", 103, "setinternalname"); // obsolete command
	
	suppress("snake_woman_base", 26358, "goto"); // missing label 'main_alert'
	
	suppress("snake_woman_base_0004", 1660, "goto"); // unreachable code after goto
	
	suppress("snake_woman_base_0007", 1138, "goto"); // missing label 'short'
	
	suppress("snake_woman_base_0008", 16149, "goto"); // missing label 'dialogue5_2'
	
	suppress("snake_woman_base_0010", 122, "collions"); // unknown command 'collions', should be 'collision'
	
	suppress("snake_woman_base_0015", 113, "setevent"); // unsupported event: "misc_reflection"
	
	suppress("snake_woman_base_0016", 138, "setevent"); // unsupported event: "misc_reflection"
	
	suppress("spider_base_0024", 660, "play"); // missing sound file 'spider_stress'
	suppress("spider_base_0024", 858, "play"); // missing sound file 'spider_stress'
	
	suppress("sword_2handed_meteor_enchant_0001", 48, "}"); // missing accept/refuse before end of event block
	
	suppress("sword_mx", 458, "halo"); // unknown flag -a (ignored)
	
	suppress("sylib", 832, "timer"); // unknown flag -t (ignored)
	
	suppress("timed_lever_0033", 1027, "-smf"); // command wrongly interpreted as event (script parser limitation)
	
	suppress("timed_lever_0052", 648, "-smf"); // command wrongly interpreted as event (script parser limitation)
	
	suppress("torch_rotating_0004", 68, "?"); // 'playanim' only takes one parameter
	suppress("torch_rotating_0004", 88, "?"); // 'playanim' only takes one parameter
	suppress("torch_rotating_0004", 89, "rotatingtorchdown"); // 'playanim' only takes one parameter
	
	suppress("torch_rotating_0005", 68, "?"); // 'playanim' only takes one parameter
	suppress("torch_rotating_0005", 88, "?"); // 'playanim' only takes one parameter
	suppress("torch_rotating_0005", 89, "rotatingtorchdown"); // 'playanim' only takes one parameter
	
	suppress("training_dummy", 174, "play"); // missing sound file "wooddoorhit", closest match is "door_wood_hit"
	
	suppress("troll_base", 5107, "loadanim"); // missing animation: "troll_fight_ready_toponly"
	suppress("troll_base", 5175, "loadanim"); // missing animation: "troll_fight_unready_toponly"
	suppress("troll_base", 19054, "goto"); // missing label "main_alert"
	
	suppress("undead_base_0039", 102, "}"); // missing accept/refuse before end of event block
	
	suppress("undead_base_0046", 110, "playanim"); // animation 'wait' not loaded yet
	
	suppress("wall_breakable", 523, "}"); // missing accept/refuse before end of event block
	
	suppress("wrat_base", 17152, "play"); // sound number is sometimes too high
	
	suppress("y_mx", 3106, "loadanim"); // bad animation id: 'bae_ready', should be 'bare_ready'
	
	class FakeCommand : public Command {
		
	public:
		
		explicit FakeCommand(const std::string & name) : Command(name) { }
		
		Result execute(Context & context) {
			ARX_UNUSED(context);
			return Success;
		}
		
	};
	
	/* 'playanim' only takes one parameter
	 * dwarf_little_crusher_0001:229
	 * dwarf_little_crusher_0002:226
	 * dwarf_little_crusher_0003:138
	 * need to use fake command so other commands on same line get executed!
	*/
	ScriptEvent::registerCommand(new FakeCommand("dwarflittlecrusherup"));
	
	return suppressionCount;
}
void MoreAccurateMotionWobbleSuppressorGpu::suppress(int idx, const Mat &frame, Mat &result)
{
    frameDevice_.upload(frame);
    suppress(idx, frameDevice_, resultDevice_);
    resultDevice_.download(result);
}
Esempio n. 11
0
static int print_results(ib_portid_t * portid, char *node_name,
			 ibnd_node_t * node, uint8_t * pc, int portnum,
			 int *header_printed, uint8_t *pce, uint16_t cap_mask)
{
	char buf[1024];
	char *str = buf;
	uint32_t val = 0;
	int i, n;

	for (n = 0, i = IB_PC_ERR_SYM_F; i <= IB_PC_VL15_DROPPED_F; i++) {
		if (suppress(i))
			continue;

		/* this is not a counter, skip it */
		if (i == IB_PC_COUNTER_SELECT2_F)
			continue;

		mad_decode_field(pc, i, (void *)&val);
		if (exceeds_threshold(i, val)) {
			n += snprintf(str + n, 1024 - n, " [%s == %u]",
				      mad_field_name(i), val);

			/* If there are PortXmitDiscards, get details (if supported) */
			if (i == IB_PC_XMT_DISCARDS_F && details) {
				n += query_and_dump(str + n, sizeof(buf) - n, portid,
						    node, node_name, portnum,
						    "PortXmitDiscardDetails",
						    IB_GSI_PORT_XMIT_DISCARD_DETAILS,
						    IB_PC_RCV_LOCAL_PHY_ERR_F,
						    IB_PC_RCV_ERR_LAST_F);
				/* If there are PortRcvErrors, get details (if supported) */
			} else if (i == IB_PC_ERR_RCV_F && details) {
				n += query_and_dump(str + n, sizeof(buf) - n, portid,
						    node, node_name, portnum,
						    "PortRcvErrorDetails",
						    IB_GSI_PORT_RCV_ERROR_DETAILS,
						    IB_PC_XMT_INACT_DISC_F,
						    IB_PC_XMT_DISC_LAST_F);
			}
		}
	}

	if (!suppress(IB_PC_XMT_WAIT_F)) {
		mad_decode_field(pc, IB_PC_XMT_WAIT_F, (void *)&val);
		if (exceeds_threshold(IB_PC_XMT_WAIT_F, val))
			n += snprintf(str + n, 1024 - n, " [%s == %u]",
				      mad_field_name(IB_PC_XMT_WAIT_F), val);
	}

	/* if we found errors. */
	if (n != 0) {
		if (data_counters) {
			uint8_t *pkt = pc;
			int start_field = IB_PC_XMT_BYTES_F;
			int end_field = IB_PC_RCV_PKTS_F;

			if (pce) {
				pkt = pce;
				start_field = IB_PC_EXT_XMT_BYTES_F;
				if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED)
					end_field = IB_PC_EXT_RCV_MPKTS_F;
				else
					end_field = IB_PC_EXT_RCV_PKTS_F;
			}

			for (i = start_field; i <= end_field; i++) {
				uint64_t val64 = 0;
				float val = 0;
				char *unit = "";
				mad_decode_field(pkt, i, (void *)&val64);
				if (val64) {
					int data = 0;
					if (i == IB_PC_EXT_XMT_BYTES_F ||
					    i == IB_PC_EXT_RCV_BYTES_F ||
					    i == IB_PC_XMT_BYTES_F ||
					    i == IB_PC_RCV_BYTES_F)
						data = 1;
					unit = conv_cnt_human_readable(val64,
								&val, data);
					n += snprintf(str + n, 1024 - n,
						" [%s == %" PRIu64
						" (%5.3f%s)]",
						mad_field_name(i), val64, val,
						unit);
				}
			}
		}

		if (!*header_printed) {
			if (node->type == IB_NODE_SWITCH)
				printf("Errors for 0x%" PRIx64 " \"%s\"\n",
					node->ports[0]->guid, node_name);
			else
				printf("Errors for \"%s\"\n", node_name);
			*header_printed = 1;
			summary.bad_nodes++;
		}

		if (portnum == 0xFF) {
			if (node->type == IB_NODE_SWITCH)
				printf("   GUID 0x%" PRIx64 " port ALL:%s\n",
				       node->ports[0]->guid, str);
		} else {
			printf("   GUID 0x%" PRIx64 " port %d:%s\n",
			       node->ports[portnum]->guid, portnum, str);
			if (port_config)
				print_port_config(node_name, node, portnum);
			summary.bad_ports++;
		}
	}
	return (n);
}
Esempio n. 12
0
/*
 * `election' candidates a host as master: it is called by a slave
 * which runs with the -M option set when its election timeout expires.
 * Note the conservative approach: if a new timed comes up, or another
 * candidate sends an election request, the candidature is withdrawn.
 */
int
election(struct netinfo *net)
{
	struct tsp *resp, msg;
	struct timeval then, wait;
	struct tsp *answer;
	struct hosttbl *htp;
	char loop_lim = 0;

/* This code can get totally confused if it gets slightly behind.  For
 *	example, if readmsg() has some QUIT messages waiting from the last
 *	round, we would send an ELECTION message, get the stale QUIT,
 *	and give up.  This results in network storms when several machines
 *	do it at once.
 */
	wait.tv_sec = 0;
	wait.tv_usec = 0;
	while (0 != readmsg(TSP_REFUSE, ANYADDR, &wait, net)) {
		if (trace)
			fprintf(fd, "election: discarded stale REFUSE\n");
	}
	while (0 != readmsg(TSP_QUIT, ANYADDR, &wait, net)) {
		if (trace)
			fprintf(fd, "election: discarded stale QUIT\n");
	}

again:
	syslog(LOG_INFO, "This machine is a candidate time master");
	if (trace)
		fprintf(fd, "This machine is a candidate time master\n");
	msg.tsp_type = TSP_ELECTION;
	msg.tsp_vers = TSPVERSION;
	(void)strcpy(msg.tsp_name, hostname);
	bytenetorder(&msg);
	if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0,
		   (struct sockaddr*)&net->dest_addr,
		   sizeof(struct sockaddr)) < 0) {
		trace_sendto_err(net->dest_addr.sin_addr);
		return(SLAVE);
	}

	(void)gettimeofday(&then, 0);
	then.tv_sec += 3;
	for (;;) {
		(void)gettimeofday(&wait, 0);
		timevalsub(&wait,&then,&wait);
		resp = readmsg(TSP_ANY, ANYADDR, &wait, net);
		if (!resp)
			return(MASTER);

		switch (resp->tsp_type) {

		case TSP_ACCEPT:
			(void)addmach(resp->tsp_name, &from,fromnet);
			break;

		case TSP_MASTERUP:
		case TSP_MASTERREQ:
			/*
			 * If another timedaemon is coming up at the same
			 * time, give up, and let it be the master.
			 */
			if (++loop_lim < 5
			    && !good_host_name(resp->tsp_name)) {
				(void)addmach(resp->tsp_name, &from,fromnet);
				suppress(&from, resp->tsp_name, net);
				goto again;
			}
			rmnetmachs(net);
			return(SLAVE);

		case TSP_QUIT:
		case TSP_REFUSE:
			/*
			 * Collision: change value of election timer
			 * using exponential backoff.
			 *
			 *  Fooey.
			 * An exponential backoff on a delay starting at
			 * 6 to 15 minutes for a process that takes
			 * milliseconds is silly.  It is particularly
			 * strange that the original code would increase
			 * the backoff without bound.
			 */
			rmnetmachs(net);
			return(SLAVE);

		case TSP_ELECTION:
			/* no master for another round */
			htp = addmach(resp->tsp_name,&from,fromnet);
			msg.tsp_type = TSP_REFUSE;
			(void)strcpy(msg.tsp_name, hostname);
			answer = acksend(&msg, &htp->addr, htp->name,
					 TSP_ACK, 0, htp->noanswer);
			if (!answer) {
				syslog(LOG_ERR, "error in election from %s",
				       htp->name);
			}
			break;

		case TSP_SLAVEUP:
			(void)addmach(resp->tsp_name, &from,fromnet);
			break;

		case TSP_SETDATE:
		case TSP_SETDATEREQ:
			break;

		default:
			if (trace) {
				fprintf(fd, "candidate: ");
				print(resp, &from);
			}
			break;
		}
	}
}
Esempio n. 13
0
void QgsEditFormConfig::writeXml( QDomNode& node ) const
{
  QDomDocument doc( node.ownerDocument() );

  QDomElement efField  = doc.createElement( "editform" );
  QDomText efText = doc.createTextNode( QgsProject::instance()->writePath( uiForm() ) );
  efField.appendChild( efText );
  node.appendChild( efField );

  QDomElement efiField  = doc.createElement( "editforminit" );
  if ( !initFunction().isEmpty() )
    efiField.appendChild( doc.createTextNode( initFunction() ) );
  node.appendChild( efiField );

  QDomElement eficsField  = doc.createElement( "editforminitcodesource" );
  eficsField.appendChild( doc.createTextNode( QString::number( initCodeSource() ) ) );
  node.appendChild( eficsField );

  QDomElement efifpField  = doc.createElement( "editforminitfilepath" );
  efifpField.appendChild( doc.createTextNode( QgsProject::instance()->writePath( initFilePath() ) ) );
  node.appendChild( efifpField );


  QDomElement eficField  = doc.createElement( "editforminitcode" );
  eficField.appendChild( doc.createCDATASection( initCode() ) );
  node.appendChild( eficField );

  QDomElement fFSuppElem  = doc.createElement( "featformsuppress" );
  QDomText fFSuppText = doc.createTextNode( QString::number( suppress() ) );
  fFSuppElem.appendChild( fFSuppText );
  node.appendChild( fFSuppElem );

  // tab display
  QDomElement editorLayoutElem  = doc.createElement( "editorlayout" );
  switch ( layout() )
  {
    case QgsEditFormConfig::UiFileLayout:
      editorLayoutElem.appendChild( doc.createTextNode( "uifilelayout" ) );
      break;

    case QgsEditFormConfig::TabLayout:
      editorLayoutElem.appendChild( doc.createTextNode( "tablayout" ) );
      break;

    case QgsEditFormConfig::GeneratedLayout:
    default:
      editorLayoutElem.appendChild( doc.createTextNode( "generatedlayout" ) );
      break;
  }

  node.appendChild( editorLayoutElem );

  // tabs and groups of edit form
  if ( tabs().size() > 0 )
  {
    QDomElement tabsElem = doc.createElement( "attributeEditorForm" );

    for ( QList< QgsAttributeEditorElement* >::const_iterator it = mAttributeEditorElements.constBegin(); it != mAttributeEditorElements.constEnd(); ++it )
    {
      QDomElement attributeEditorWidgetElem = ( *it )->toDomElement( doc );
      tabsElem.appendChild( attributeEditorWidgetElem );
    }

    node.appendChild( tabsElem );
  }

  //// TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS
  /// SEE QgsEditorWidgetFactory::writeConfig

  QDomElement widgetsElem = doc.createElement( "widgets" );

  QMap<QString, QgsEditorWidgetConfig >::ConstIterator configIt( mWidgetConfigs.constBegin() );

  while ( configIt != mWidgetConfigs.constEnd() )
  {
    if ( mFields.indexFromName( configIt.key() ) == -1 )
    {
      QDomElement widgetElem = doc.createElement( "widget" );
      widgetElem.setAttribute( "name", configIt.key() );

      QDomElement configElem = doc.createElement( "config" );
      widgetElem.appendChild( configElem );

      QgsEditorWidgetConfig::ConstIterator cfgIt( configIt.value().constBegin() );

      while ( cfgIt != configIt.value().constEnd() )
      {
        QDomElement optionElem = doc.createElement( "option" );
        optionElem.setAttribute( "key", cfgIt.key() );
        optionElem.setAttribute( "value", cfgIt.value().toString() );
        configElem.appendChild( optionElem );
        ++cfgIt;
      }

      widgetsElem.appendChild( widgetElem );
    }
    ++configIt;
  }

  node.appendChild( widgetsElem );

  //// END TODO
}
Esempio n. 14
0
 ScopedSuppress(void) { original = suppressed(); suppress(true); }
Esempio n. 15
0
sc_actions sc_report_handler::suppress()
{
    return suppress(0);
}
Esempio n. 16
0
 ~ScopedSuppress(void) { suppress(original); }
Esempio n. 17
0
int V4lGrabber::grab()
{
    char *fr = NULL;

    // debug_msg((sync_count % 2) ? "o" : "e");

    if (have_mmap) {
	fr = mem + (gb_buffers.offsets[(sync_count % 2) ? 1 : 0]);

	if (-1 == ioctl(fd_, VIDIOCSYNC, (sync_count % 2) ? &one : &zero) < 0) {
	    perror("ioctl VIDIOCSYNC");
	    printf("Syncerror SyncCount %d\n", sync_count);
	}
	else {
	    sync_count++;
	}
    }
    else {
	/* FIXME: read() */
    }

    switch (cformat_) {
    case CF_411:
    case CF_CIF:
/*		    
	if (have_422)         
	    packed422_to_planar411((char*)frame_,fr);
	else {
	   //  have_420P 
	   // vcvt_420p_411p(width_, height_, (char *)fr, frame_);  
	   // erwartet wird scheinbar 420P und nicht 411P  *wunder* 
	   memcpy((void *)frame_, (const void *)fr, (size_t)height_*width_*3/2);
	}
	break;						
	*/

	//  barz: bttv using packed422_to_planar411
	if (have_420P)
	    memcpy((void *) frame_, (const void *) fr,
		   (size_t) height_ * width_ * 3 / 2);
	else
	    packed422_to_planar411((char *) frame_, fr);
	break;

    case CF_422:
	if (have_422P)
	    memcpy((void *) frame_, (const void *) fr,
		   (size_t) height_ * width_ * 2);
	else if (have_422) {
	    packed422_to_planar422((char *) frame_, fr);
	}
	else {
	    //  have_420P 
	    vcvt_420p_422p(width_, height_, (char *) fr, frame_);
	}
	break;
    }

    // FIXED by barz 2006/9/19: not grab immediately after start
    if (sync_count > 1) {

	if (have_mmap) {
	    if (-1 ==
		ioctl(fd_, VIDIOCMCAPTURE,
		      (grab_count % 2) ? &gb_odd : &gb_even))
		perror("ioctl VIDIOMCAPTURE");
	    else
		grab_count++;
	}
    }

    suppress(frame_);
    saveblks(frame_);
    YuvFrame f(media_ts(), frame_, crvec_, outw_, outh_);
    return (target_->consume(&f));
}
Esempio n. 18
0
gboolean
cov_function_t::solve()
{
    int passes, changes;
    cov_arc_t *a;
    cov_block_t *b;

    /* For every block in the file,
       - if every exit/entrance arc has a known count, then set the block count
       - if the block count is known, and every exit/entrance arc but one has
	 a known execution count, then set the count of the remaining arc

       As arc counts are set, decrement the succ/pred count, but don't delete
       the arc, that way we can easily tell when all arcs are known, or only
       one arc is unknown.  */

    /* The order that the basic blocks are iterated through is important.
       Since the code that finds spanning trees starts with block 0, low numbered
       arcs are put on the spanning tree in preference to high numbered arcs.
       Hence, most instrumented arcs are at the end.  Graph solving works much
       faster if we propagate numbers from the end to the start.

       This takes an average of slightly more than 3 passes.  */

    solve_log.debug(" ---> %s\n", name_.data());

    /*
     * In the new gcc 3.3 file format we cannot expect to get arcs into
     * the entry block and out of the exit block.  So if we don't get any,
     * tweak the {in,out}_ninvalid_ count up to effective infinity to
     * ensure the solve algorithm doesn't accidentally use the lack of
     * counts.
     */
    assert(num_blocks() >= 2);
    if ((b = blocks_->nth(entry_block()))->in_arcs_.head() == 0)
    {
	assert(file_->format_version_ > 0);
	b->in_ninvalid_ = ~0U;
	solve_log.debug("entry block tweaked\n");
    }
    if ((b = blocks_->nth(exit_block()))->out_arcs_.head() == 0)
    {
	assert(file_->format_version_ > 0);
	b->out_ninvalid_ = ~0U;
	solve_log.debug("exit block tweaked\n");
    }

    changes = 1;
    passes = 0;
    while (changes)
    {
	passes++;
	changes = 0;

	solve_log.debug("pass %d\n", passes);

	for (ptrarray_iterator_t<cov_block_t> bitr = blocks_->last() ; *bitr ; --bitr)
	{
	    b = *bitr;
	    solve_log.debug("[%d]\n", b->bindex());

	    if (!b->count_valid_)
	    {
		solve_log.debug("[%d] out_ninvalid_=%u in_ninvalid_=%u\n",
			    b->bindex(), b->out_ninvalid_, b->in_ninvalid_);

		/*
		 * For blocks with calls we have to ignore the outbound total
		 * when calculating the block count, because of the possibility
		 * of calls to fork(), exit() or other functions which can
		 * return more or less frequently than they're called.  Given
		 * the existance of longjmp() all calls are potentially like
		 * that.
		 */
		if (b->out_ncalls_ == 0 && b->out_ninvalid_ == 0)
		{
		    b->set_count(cov_arc_t::total(b->out_arcs_));
		    changes++;
		    solve_log.debug("[%d] count=%llu\n", b->bindex(), (unsigned long long)b->count());
		}
		else if (b->in_ninvalid_ == 0)
		{
		    b->set_count(cov_arc_t::total(b->in_arcs_));
		    changes++;
		    solve_log.debug("[%d] count=%llu\n", b->bindex(), (unsigned long long)b->count());
		}
	    }

	    if (b->count_valid_)
	    {
		if (b->out_ninvalid_ == 1)
		{
		    /* Search for the invalid arc, and set its count.  */
		    if ((a = cov_arc_t::find_invalid(b->out_arcs_, FALSE)) == 0)
			return FALSE;   /* ERROR */
		    /* Calculate count for remaining arc by conservation.  */
		    /* One of the counts will be invalid, but it is zero,
		       so adding it in also doesn't hurt.  */
		    count_t out_total = cov_arc_t::total(b->out_arcs_);
		    if (b->count_ < out_total)
		    {
			solve_log.warning("Function %s cannot be solved because "
					  "the arc counts are inconsistent, suppressing\n",
					  name_.data());
			suppress(cov_suppressions.find(0, cov_suppression_t::UNSOLVABLE));
			return TRUE;
		    }
		    assert(b->count_ >= out_total);
		    a->set_count(b->count_ - out_total);
		    changes++;
		    solve_log.debug("[%d->%d] count=%llu\n",
			    a->from()->bindex(), a->to()->bindex(),
			    (unsigned long long)a->count());
		}
		if (b->in_ninvalid_ == 1)
		{
		    /* Search for the invalid arc, and set its count.  */
		    if ((a = cov_arc_t::find_invalid(b->in_arcs_, FALSE)) == 0)
			return FALSE;   /* ERROR */
		    /* Calculate count for remaining arc by conservation.  */
		    /* One of the counts will be invalid, but it is zero,
		       so adding it in also doesn't hurt.  */
		    count_t in_total = cov_arc_t::total(b->in_arcs_);
		    if (b->count_ < in_total)
		    {
			solve_log.warning("Function %s cannot be solved because "
					  "the arc counts are inconsistent, suppressing\n",
					  name_.data());
			suppress(cov_suppressions.find(0, cov_suppression_t::UNSOLVABLE));
			return TRUE;
		    }
		    assert(b->count_ >= in_total);
		    a->set_count(b->count_ - in_total);
		    changes++;
		    solve_log.debug("[%d->%d] count=%llu\n",
			    a->from()->bindex(), a->to()->bindex(),
			    (unsigned long long)a->count());
		}
	    }
	}
    }

    /*
     * If the graph has been correctly solved, every block will
     * have a valid count and all its inbound and outbounds arcs
     * will also have valid counts.
     */
    for (ptrarray_iterator_t<cov_block_t> bitr = blocks_->first() ; *bitr ; ++bitr)
    {
	b = *bitr;
	if (!b->count_valid_)
	    return FALSE;
	if (b->out_ninvalid_ > 0 && b->out_ninvalid_ < ~0U)
	    return FALSE;
	if (b->in_ninvalid_ > 0 && b->in_ninvalid_ < ~0U)
	    return FALSE;
	if (cov_arc_t::find_invalid(b->in_arcs_, TRUE) != 0)
	    return FALSE;
	if (cov_arc_t::find_invalid(b->out_arcs_, TRUE) != 0)
	    return FALSE;
    }

    solve_log.debug("Solved flow graph for %s in %d passes\n", name(), passes);

    return TRUE;
}
Esempio n. 19
0
void CDmeTrack::RemoveClip( int i )
{
	// NOTE: Removal shouldn't cause sort order or fixup to become invalid
	CSuppressAutoFixup suppress( this, SUPPRESS_OVERLAP_FIXUP | SUPPRESS_DIRTY_ORDERING );
	m_Clips.Remove( i );
}