Exemplo n.º 1
0
DCTFFTW::DCTFFTW(int _sizex, int _sizey, HINSTANCE hinstFFTW3, int _dctmode) 

{
		fftwf_free_addr = (fftwf_free_proc) GetProcAddress(hinstFFTW3, "fftwf_free"); 
		fftwf_malloc_addr = (fftwf_malloc_proc)GetProcAddress(hinstFFTW3, "fftwf_malloc"); 
		fftwf_destroy_plan_addr = (fftwf_destroy_plan_proc) GetProcAddress(hinstFFTW3, "fftwf_destroy_plan");
		fftwf_plan_r2r_2d_addr = (fftwf_plan_r2r_2d_proc) GetProcAddress(hinstFFTW3, "fftwf_plan_r2r_2d");
		fftwf_execute_r2r_addr = (fftwf_execute_r2r_proc) GetProcAddress(hinstFFTW3, "fftwf_execute_r2r");

		sizex = _sizex;
		sizey = _sizey;
		dctmode = _dctmode;

		int size2d = sizey*sizex;

		int cursize = 1;
		dctshift = 0;
		while (cursize < size2d) 
		{
			dctshift++;
			cursize = (cursize<<1);
		}
		
		dctshift0 = dctshift + 2;

		fSrc = (float *)fftwf_malloc_addr(sizeof(float) * size2d );
		fSrcDCT = (float *)fftwf_malloc_addr(sizeof(float) * size2d );

		dctplan = fftwf_plan_r2r_2d_addr(sizey, sizex, fSrc, fSrcDCT, FFTW_REDFT10, FFTW_REDFT10, FFTW_ESTIMATE); // direct fft 
}
Exemplo n.º 2
0
DCTFFTW::DCTFFTW(int _sizex, int _sizey, HINSTANCE hinstFFTW3, int _dctmode) 
{
	fftwf_free_addr = (fftwf_free_proc) GetProcAddress(hinstFFTW3, "fftwf_free"); 
	fftwf_malloc_addr = (fftwf_malloc_proc)GetProcAddress(hinstFFTW3, "fftwf_malloc"); 
	fftwf_destroy_plan_addr = (fftwf_destroy_plan_proc) GetProcAddress(hinstFFTW3, "fftwf_destroy_plan");
	fftwf_plan_r2r_2d_addr = (fftwf_plan_r2r_2d_proc) GetProcAddress(hinstFFTW3, "fftwf_plan_r2r_2d");
	fftwf_execute_r2r_addr = (fftwf_execute_r2r_proc) GetProcAddress(hinstFFTW3, "fftwf_execute_r2r");

	sizex = _sizex;
	sizey = _sizey;
	dctmode = _dctmode;

	int size2d = sizey*sizex;

	int cursize = 1;
	dctshift = 0;
	while (cursize < size2d) 
	{
		dctshift++;
		cursize = (cursize<<1);
	}

	dctshift0 = dctshift + 2;

	// FFTW plan construction and destruction are not thread-safe.
	// http://www.fftw.org/fftw3_doc/Thread-safety.html#Thread-safety
	conc::CritSec	lock (_fftw_mutex);

	fSrc = (float *)fftwf_malloc_addr(sizeof(float) * size2d );
	fSrcDCT = (float *)fftwf_malloc_addr(sizeof(float) * size2d );

	dctplan = fftwf_plan_r2r_2d_addr(sizey, sizex, fSrc, fSrcDCT, FFTW_REDFT10, FFTW_REDFT10, FFTW_ESTIMATE); // direct fft 
}