Пример #1
0
static mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename)
{
    mf_t *mf = talloc_zero(talloc_ctx, mf_t);
    mf->log = log;
    mf_add(mf, filename);
    return mf;
}
Пример #2
0
int16_t addtest(void)
{
	float a;
	float b;
	float target;
	float result;
	minifloat mfa;
	minifloat mfb;
	minifloat mf;

	int16_t index = 0;
	int16_t indexa;
	int16_t indexb;

	float amplitude;
	
	_Q16 tempQ16;
	
	// Q16 divide test
	for(indexa = 0; indexa < count; indexa++)
	{
		for(indexb = 0; indexb < count; indexb++)
		{
			a = floatvals[indexa];
			b = floatvals[indexb];
			if(b != 0)
			{
				target = a + b;

				amplitude = sqrt( (a*a)  + (b*b) );

				// Check if valid test
				if(1 == 0)
					results[index] = 10;
				else
				{	
					mfa = ftomf(a);
					mfb = ftomf(b);
		
					mf = mf_add(mfa, mfb);
					
					result = mftof(mf);
		
					results[index] = compare_offset(target, result, amplitude * 0.05);
					if(results[index] != 1) 
						errorcount++;;
				}
			}
			else
				results[index] = 3;

			index++;
		}
	}

	return errorcount;
}
Пример #3
0
int16_t Q16addtest(void)
{
	float a;
	float b;
	float target;
	float result;
	minifloat mfa;
	minifloat mfb;
	minifloat mf;

	int16_t index = 0;
	int16_t indexa;
	int16_t indexb;

	float amplitude;
	
	_Q16 tempQ16;
	
	// Q16 divide test
	for(indexa = 0; indexa < count; indexa++)
	{
		for(indexb = 0; indexb < count; indexb++)
		{
			a = floatvals[indexa];
			b = floatvals[indexb];
			if(b != 0)
			{
				target = a + b;

				amplitude = sqrt( (a*a)  + (b*b) );

				// Check if valid test
				if(target > 32767)
					results[index] = 2;
				else if (target < -32767)
					results[index] = 2;
				else if ((target > 0) && (target < (256.0 / 65536) ))
					results[index] = 2;
				else if ((target < 0) && (target > -(256.0 / 65536)))
					results[index] = 2;
				else
				{	
					a *= 0x10000;
					tempQ16 = (int32_t) a;	
					mfa = Q16tomf(tempQ16);
		
					b *= 0x10000;
					tempQ16 = (int32_t) b;
					mfb = Q16tomf(tempQ16);
		
					mf = mf_add(mfa, mfb);
					tempQ16 = mftoQ16(mf);
		
					result = (float) tempQ16;
					result /= 0x10000;
		
					results[index] = compare_offset(target, result, amplitude * 0.05);
					if(results[index] != 1) 
						errorcount++;;
				}
			}
			else
				results[index] = 3;

			index++;
		}
	}

	return errorcount;
}
Пример #4
0
static mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename)
{
    int error_count = 0;
    int count = 0;

    mf_t *mf = talloc_zero(talloc_ctx, mf_t);
    mf->log = log;

    if (filename[0] == '@') {
        FILE *lst_f = fopen(filename + 1, "r");
        if (lst_f) {
            char *fname = talloc_size(mf, 512);
            while (fgets(fname, 512, lst_f)) {
                /* remove spaces from end of fname */
                char *t = fname + strlen(fname) - 1;
                while (t > fname && mp_isspace(*t))
                    *(t--) = 0;
                if (!mp_path_exists(fname)) {
                    mp_verbose(log, "file not found: '%s'\n", fname);
                } else {
                    mf_add(mf, fname);
                }
            }
            fclose(lst_f);

            mp_info(log, "number of files: %d\n", mf->nr_of_files);
            goto exit_mf;
        }
        mp_info(log, "%s is not indirect filelist\n", filename + 1);
    }

    if (strchr(filename, ',')) {
        mp_info(log, "filelist: %s\n", filename);
        bstr bfilename = bstr0(filename);

        while (bfilename.len) {
            bstr bfname;
            bstr_split_tok(bfilename, ",", &bfname, &bfilename);
            char *fname2 = bstrdup0(mf, bfname);

            if (!mp_path_exists(fname2))
                mp_verbose(log, "file not found: '%s'\n", fname2);
            else {
                mf_add(mf, fname2);
            }
            talloc_free(fname2);
        }
        mp_info(log, "number of files: %d\n", mf->nr_of_files);

        goto exit_mf;
    }

    char *fname = talloc_size(mf, strlen(filename) + 32);

    if (!strchr(filename, '%')) {
        strcpy(fname, filename);
        if (!strchr(filename, '*'))
            strcat(fname, "*");

        mp_info(log, "search expr: %s\n", fname);

        glob_t gg;
        if (glob(fname, 0, NULL, &gg)) {
            talloc_free(mf);
            return NULL;
        }

        for (int i = 0; i < gg.gl_pathc; i++) {
            if (mp_path_isdir(gg.gl_pathv[i]))
                continue;
            mf_add(mf, gg.gl_pathv[i]);
        }
        mp_info(log, "number of files: %d\n", mf->nr_of_files);
        globfree(&gg);
        goto exit_mf;
    }

    mp_info(log, "search expr: %s\n", filename);

    while (error_count < 5) {
        sprintf(fname, filename, count++);
        if (!mp_path_exists(fname)) {
            error_count++;
            mp_verbose(log, "file not found: '%s'\n", fname);
        } else {
            mf_add(mf, fname);
        }
    }

    mp_info(log, "number of files: %d\n", mf->nr_of_files);

exit_mf:
    return mf;
}