Beispiel #1
0
void maxfilt_centered_double_inplace( double *a, int len, int support )
{   static double **U = NULL;
    static size_t maxUbytes = 0;
    size_t maxU,maxR;
    unsigned int    iUf,iUb,iRf,iRb;
    static double *R = NULL;
    static size_t maxRbytes = 0;
    double *e;
    int off = support;
    int c = support/2+1;
    double this,last;
    assert(support > 2);

    U = request_storage_pow2items(U,&maxUbytes,sizeof(double*), 2*support , "maxfilt_centered_double_inplace");
    maxU = maxUbytes / sizeof(double*) - 1;
    iUf = maxU/2-1;
    iUb = maxU/2;
    R = request_storage_pow2items(R,&maxRbytes,sizeof(double), 2*(off-c), "maxfilt_centered_double_inplace");
    maxR = maxRbytes / sizeof(double) - 1;
    iRf=-1;
    iRb=0;

    //The middle (support entirely in interval)
    last = *a;
    for( e=a+1; e < a+len; e++ )
    {   this = *e;
        if( e-a >= c )
            pushf(R) = isempty(U) ? last : *peekf(U);
        if( e-a >= off  )
            e[-off] = popb(R);
        //progress("iRf:%5d\tiUf:%5d\tiUb:%5d\tsz:%5d\n",iRf,iUf,iUb,iUf-iUb+1);
        if( this > last )
        {   while( !isempty(U) )
            {   if( this <= *peekb(U) )
                {   if( e-off == peekf(U) )
                        popf_noassign(U);
                    break;
                }
                if( !isempty(U) )
                    popb_noassign(U);
            }
        } else
        {   pushb(U)  = e-1;
            if( (e-off) == peekf(U) )
                popf_noassign(U);
        }
        last = this;
    }
    //The end
    for( ; e <= a+len+c; e++ )
    {   pushf(R) = isempty(U) ? e[-1] : *peekf(U);
        e[-off] = popb(R);

        pushb(U)  = e-1;
        if( (e-off) == peekf(U) )
            popf_noassign(U);
    }
}
Beispiel #2
0
Datei: sig.c Projekt: aosm/boot
void
parseFile(FILE *file)
{
    char *line, c;
    int len, lineNumber;
    
    line = malloc(MAXLINE+1);
    lineNumber = 1;
    
    skipWhitespace(file);
    
    while (!feof(file)) {
	c = peekf(file);
	if (c == '#' || c == '/') {
	    len = getLineThru(file, line, '\n', MAXLINE);
	    if (c == '#')
		fprintf(ofile, line);
	} else {
	    len = getLineThru(file, line, ';', MAXLINE);
	    parseLine(line);
	}
	skipWhitespace(file);
    }
    free(line);
}