Beispiel #1
0
	int main(int Extent)
	{
		int Error = 0;

		gli::texture2d Texture(gli::FORMAT_R8_UNORM_PACK8, gli::texture2d::extent_type(Extent));
		Texture.clear(gli::u8(255));

		gli::sampler2d<float> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_NEAREST, gli::FILTER_LINEAR);

		std::clock_t TimeBegin = std::clock();

		for(gli::texture2d::size_type LevelIndex = 0, LevelCount = Texture.levels(); LevelIndex < LevelCount; ++LevelIndex)
		{
			gli::texture2d::extent_type const Extent = Texture.extent(LevelIndex);
			for(gli::size_t y = 0; y < Extent.y; ++y)
			for(gli::size_t x = 0; x < Extent.x; ++x)
			{
				gli::vec4 const& Texel = Sampler.texture_lod(glm::vec2(x, y) / glm::vec2(Extent), static_cast<float>(LevelIndex));
				Error += gli::all(gli::epsilonEqual(Texel, gli::vec4(1, 0, 0, 1), 0.001f)) ? 0 : 1;
			}
		}

		std::clock_t TimeEnd = std::clock();
		printf("2D texture lod linear performance test: %d\n", TimeEnd - TimeBegin);

		return Error;
	}
	int test()
	{
		int Error = 0;

		{
			gli::texture_cube_array Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture_cube_array::extent_type(1), 1, 1);
			Texture.clear(gli::u8vec4(0, 0, 0, 255));
			Texture.store(gli::texture_cube_array::extent_type(0), 0, 0, 0, gli::u8vec4(255,   0,   0, 255));
			Texture.store(gli::texture_cube_array::extent_type(0), 0, 1, 0, gli::u8vec4(255, 127,   0, 255));
			Texture.store(gli::texture_cube_array::extent_type(0), 0, 2, 0, gli::u8vec4(255, 255,   0, 255));
			Texture.store(gli::texture_cube_array::extent_type(0), 0, 3, 0, gli::u8vec4(  0, 255,   0, 255));
			Texture.store(gli::texture_cube_array::extent_type(0), 0, 4, 0, gli::u8vec4(  0,   0, 255, 255));
			Texture.store(gli::texture_cube_array::extent_type(0), 0, 5, 0, gli::u8vec4(255,   0, 255, 255));

			gli::fsamplerCubeArray Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR, gli::vec4(1.0f));

			gli::vec4 SampleA = Sampler.texture_lod(gli::fsamplerCubeArray::normalized_type(0.25f), 0, 1, 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleA, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;

			gli::vec4 SampleB = Sampler.texture_lod(gli::fsamplerCubeArray::normalized_type(0.8f), 0, 1, 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleB, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;

			gli::vec4 SampleC = Sampler.texture_lod(gli::fsamplerCubeArray::normalized_type(0.20f, 0.8f), 0, 1, 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleC, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;
		}

		return Error;
	}
Beispiel #3
0
TEST(SamplerTest, ReturnCorrectSample) {
    
    Sampler sampler = Sampler(2,2);
    
    Sample *sample;
    
    // 1. (0.5,0.5)
    EXPECT_EQ(sampler.getSample(sample), true);
    EXPECT_EQ(sample->x, 0.5);
    EXPECT_EQ(sample->y, 0.5);
    
    // 2. (1.5, 0.5)
    EXPECT_EQ(sampler.getSample(sample), true);
    EXPECT_EQ(sample->x, 1.5);
    EXPECT_EQ(sample->y, 0.5);
    
    // 3. (0.5, 1.5)
    EXPECT_EQ(sampler.getSample(sample), true);
    EXPECT_EQ(sample->x, 0.5);
    EXPECT_EQ(sample->y, 1.5);
    
    // 4. (1.5, 1.5)
    EXPECT_EQ(sampler.getSample(sample), true);
    EXPECT_EQ(sample->x, 1.5);
    EXPECT_EQ(sample->y, 1.5);
    
    // 5. false
    EXPECT_EQ(sampler.getSample(sample), false);
    
}
	int test()
	{
		int Error = 0;

		{
			gli::texture2D Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2D::texelcoord_type(4), 1);
			Texture.clear(gli::u8vec4(0, 0, 0, 255));
			Texture.store(gli::dim2_t(0, 0), 0, gli::u8vec4(255, 127,   0, 255));
			Texture.store(gli::dim2_t(1, 0), 0, gli::u8vec4(255, 127,   0, 255));
			Texture.store(gli::dim2_t(0, 1), 0, gli::u8vec4(255, 127,   0, 255));
			Texture.store(gli::dim2_t(1, 1), 0, gli::u8vec4(255, 127,   0, 255));
			Texture.store(gli::dim2_t(2, 2), 0, gli::u8vec4(  0, 127, 255, 255));
			Texture.store(gli::dim2_t(3, 2), 0, gli::u8vec4(  0, 127, 255, 255));
			Texture.store(gli::dim2_t(2, 3), 0, gli::u8vec4(  0, 127, 255, 255));
			Texture.store(gli::dim2_t(3, 3), 0, gli::u8vec4(  0, 127, 255, 255));

			gli::sampler2D<float> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f));

			gli::vec4 SampleA = Sampler.texture_lod(gli::fsampler2D::samplecoord_type(0.25f), 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleA, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;

			gli::vec4 SampleB = Sampler.texture_lod(gli::fsampler2D::samplecoord_type(0.8f), 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleB, gli::vec4(0.0f, 0.5f, 1.0f, 1.0f), 0.01f)) ? 0 : 1;

			gli::vec4 SampleC = Sampler.texture_lod(gli::fsampler2D::samplecoord_type(0.20f, 0.8f), 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleC, gli::vec4(0.0f, 0.0f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;
		}

		return Error;
	}
void
SDLTextureRenderer::start_draw()
{
  if (!m_texture)
  {
    const int w = m_size.width / m_downscale;
    const int h = m_size.height / m_downscale;
    SDL_Texture* sdl_texture = SDL_CreateTexture(m_renderer,
                                                 SDL_PIXELFORMAT_RGB888,
                                                 SDL_TEXTUREACCESS_TARGET,
                                                 w, h);
    if (!sdl_texture)
    {
      std::stringstream msg;
      msg << "Couldn't create lightmap texture: " << SDL_GetError();
      throw std::runtime_error(msg.str());
    }

    m_texture = TexturePtr(new SDLTexture(sdl_texture, w, h, Sampler()));
  }

  SDL_SetRenderTarget(m_renderer, get_sdl_texture());
  SDL_RenderSetScale(m_renderer,
                     1.0f / static_cast<float>(m_downscale),
                     1.0f / static_cast<float>(m_downscale));
}
Beispiel #6
0
	int main(int Extent)
	{
		int Error = 0;

		gli::texture2d Texture(gli::FORMAT_R8_UNORM_PACK8, gli::texture2d::extent_type(Extent));
		Texture.clear(gli::u8(255));

		gli::sampler2d<float> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE);

		std::clock_t TimeBegin = std::clock();

		for(gli::texture2d::size_type LevelIndex = 0, LevelCount = Texture.levels(); LevelIndex < LevelCount; ++LevelIndex)
		{
			gli::texture2d::extent_type const Extent = Texture.extent(LevelIndex);
			for(gli::size_t y = 0; y < Extent.y; ++y)
			for(gli::size_t x = 0; x < Extent.x; ++x)
			{
				gli::vec4 const& Texel = Sampler.texel_fetch(gli::texture2d::extent_type(x, y), LevelIndex);
				Error += gli::all(gli::epsilonEqual(Texel, gli::vec4(1, 0, 0, 1), 0.001f)) ? 0 : 1;
				assert(!Error);
			}
		}

		std::clock_t TimeEnd = std::clock();
		printf("2D texture fetch performance test: %d\n", TimeEnd - TimeBegin);

		return Error;
	}
int main( int argc, char** argv )
{
    if( argc != 3 )
    {
        printf( "%s", "Usage arguments: -play somefile.wav\n" );
        
        return 1;
    }
    
    DEBUG( "InitDummy" );   

    jack_set_error_function( error );
    
    WavReader WavFile;
   
    WavFile.open( argv[2] );

    WavFile.read( );
    
    WavFile.close( );

    WavReader * WavFilePtr = &WavFile;

    SamplerClass Sampler( WavFilePtr );

    SamplerClass * SamplerPtr = &Sampler;

    SoundEngineClass * PolySampler = SamplerPtr;
    
    Sampler.setSampleIterator( SamplerPtr->getSoundFile()->begin() /*- 1000000*/ );
    
    PolySampler->OpenClient( client, "Wav Sampler" );

    PolySampler->setProcessCallback( SamplerPtr->Process, SamplerPtr );

    PolySampler->setSampleRateCallback( SamplerPtr->SampleRate, SamplerPtr );

    PolySampler->setLeftChannelOutputPort( "DAW_LEFT_CHANNEL" );

    PolySampler->setRightChannelOutputPort( "DAW_RIGHT_CHANNEL" );

    PolySampler->ActivateClient( );

    PolySampler->ConnectPorts( );

    INFO( "Bits per sample " << *WavFile.getBitsPerSample( ) );

    STATUS( "Now Playing - " << argv[2] );
	
	INFO( "WavFile Sample Rate is: " << *WavFile.getSampleRate() );	

    while( !SamplerPtr->isAtEnd() )
    {
        sleep( 1 );
    }
   
    return 0;

}
Beispiel #8
0
 const Sampler& MeshRendererTransparentPS::sampler(const std::string& name) const
 {
     
     
     if(name == std::string("tex_sampler")) return tex_sampler;
     
     if(name == std::string("shadow_sampler")) return shadow_sampler;
     
     
     ASSERT(false, "Tried to look for non-existing resource");
     return Sampler();
 }
Beispiel #9
0
	int test()
	{
		int Error = 0;

		{
			gli::texture1d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture1d::extent_type(4), 1);
			gli::fsampler1D Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}

		{
			gli::texture1d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture1d::extent_type(4), 1);
			gli::dsampler1D Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}

		{
			gli::texture1d Texture(gli::FORMAT_RGBA8_UINT_PACK8, gli::texture1d::extent_type(4), 1);
			gli::isampler1D Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_NEAREST, gli::FILTER_NEAREST);
		}
		
		return Error;
	}
	int test()
	{
		int Error = 0;

		{
			gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(4), 1);
			gli::sampler2d<float> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}

		{
			gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(4), 1);
			gli::sampler2d<double> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}

		{
			gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(4), 1);
			gli::sampler2d<int> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_NEAREST, gli::FILTER_NEAREST);
		}
		
		return Error;
	}
void Film::renderScene(Camera &c, float stepSize) {
	Sampler sampler = Sampler(c);
	Sample s;
	while (sampler.hasNext()) {
		sampler.next();
		if (sampler.getSample().x < 300 && sampler.getSample().y > 100) {
			commitSample(Sample());
			continue;
		}
		s = sampler.getPixelRGBA(stepSize);
		commitSample(s);
	}
}
Beispiel #12
0
 const Sampler& SSAOPS::sampler(const std::string& name) const
 {
     
     
     if(name == std::string("ssaoSampler")) return ssaoSampler;
     
     if(name == std::string("depthSampler")) return depthSampler;
     
     if(name == std::string("defaultSampler")) return defaultSampler;
     
     
     ASSERT(false, "Tried to look for non-existing resource");
     return Sampler();
 }
Beispiel #13
0
	int test()
	{
		int Error = 0;

		{
			gli::texture3D Texture(gli::FORMAT_RGBA8_UNORM, gli::texture3D::texelcoord_type(4), 1);
			gli::sampler3D<float> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}

		{
			gli::texture3D Texture(gli::FORMAT_RGBA8_UNORM, gli::texture3D::texelcoord_type(4), 1);
			gli::sampler3D<double> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}

#		if ENABLE_INTEGER_TESTS
		{
			gli::texture3D Texture(gli::FORMAT_RGBA8_UINT, gli::texture3D::texelcoord_type(4), 1);
			gli::sampler3D<int> Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		}
#		endif//ENABLE_INTEGER_TESTS
		
		return Error;
	}
	int test()
	{
		int Error = 0;

		glm::vec4 const Orange(1.0f, 0.5f, 0.0f, 1.0f);

		gli::texture2D Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2D::texelcoord_type(32), 1);
		gli::fsampler2D Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		Sampler.clear(Orange);

		glm::u8vec4 const Texel = Texture.load<glm::u8vec4>(gli::dim2_t(7), 0);

		Error += Texel == glm::u8vec4(255, 127, 0, 255) ? 0 : 1;

		return Error;
	}
Beispiel #15
0
void resample_subimage(const SrcMetaView& src, const DstMetaView& dst, 
                         double src_min_x, double src_min_y,
                         double src_max_x, double src_max_y,
                         double angle, const Sampler& sampler=Sampler()) {
    double src_width  = std::max<double>(src_max_x - src_min_x - 1,1);
    double src_height = std::max<double>(src_max_y - src_min_y - 1,1);
    double dst_width  = std::max<double>(dst.width()-1,1);
    double dst_height = std::max<double>(dst.height()-1,1);

    matrix3x2<double> mat = 
        matrix3x2<double>::get_translate(-dst_width/2.0, -dst_height/2.0) * 
        matrix3x2<double>::get_scale(src_width / dst_width, src_height / dst_height)*
        matrix3x2<double>::get_rotate(-angle)*
        matrix3x2<double>::get_translate(src_min_x + src_width/2.0, src_min_y + src_height/2.0);
    resample_pixels(src,dst,mat,sampler);
}
	int test()
	{
		int Error = 0;

		glm::f32vec4 const Orange(1.0f, 0.5f, 0.0f, 1.0f);

		gli::texture2D Texture(gli::FORMAT_RGBA32_SFLOAT_PACK32, gli::texture2D::texelcoord_type(4), 1);
		gli::fsampler2D Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);
		Sampler.clear(Orange);

		gli::f32vec4 const Texel0 = Texture.load<gli::f32vec4>(gli::dim2_t(0), 0);
		gli::f32vec4 const Texel1 = Texture.load<gli::f32vec4>(gli::dim2_t(2), 0);

		Error += glm::all(glm::epsilonEqual(Texel0, Orange, 0.01f)) ? 0 : 1;
		Error += glm::all(glm::epsilonEqual(Texel1, Orange, 0.01f)) ? 0 : 1;

		return Error;
	}
Beispiel #17
0
	int test()
	{
		int Error = 0;

		{
			gli::texture3D Texture(gli::FORMAT_RGBA8_UNORM, gli::texture3D::texelcoord_type(2), 1);
			Texture.clear(gli::u8vec4(255, 127,   0, 255));

			gli::fsampler3D Sampler(Texture, gli::WRAP_CLAMP_TO_EDGE, gli::FILTER_LINEAR, gli::FILTER_LINEAR);

			gli::vec4 SampleA = Sampler.texture_lod(gli::fsampler3D::samplecoord_type(0.25f), 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleA, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;

			gli::vec4 SampleB = Sampler.texture_lod(gli::fsampler3D::samplecoord_type(0.75f), 0.0f);
			Error += gli::all(gli::epsilonEqual(SampleB, gli::vec4(1.0f, 0.5f, 0.0f, 1.0f), 0.01f)) ? 0 : 1;
		}

		return Error;
	}
Beispiel #18
0
	int test()
	{
		int Error(0);

		glm::vec4 const Orange(1.0f, 0.5f, 0.0f, 1.0f);
		glm::vec4 const Blue(0.0f, 0.5f, 1.0f, 1.0f);

		gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(32), 1);
		Texture.clear(glm::packUnorm4x8(Orange));

		gli::fsampler2D Sampler(Texture, gli::WRAP_REPEAT, gli::FILTER_LINEAR, gli::FILTER_LINEAR, Blue);

		{
			std::array<gli::fsampler2D::normalized_type, 16> SampleCoord{
			{
				gli::fsampler2D::normalized_type( 0.5f, 0.5f),
				gli::fsampler2D::normalized_type( 0.1f, 0.1f),
				gli::fsampler2D::normalized_type( 0.5f, 0.1f),
				gli::fsampler2D::normalized_type( 0.1f, 0.5f),
				gli::fsampler2D::normalized_type( 0.5f, 0.9f),
				gli::fsampler2D::normalized_type( 0.9f, 0.9f),
				gli::fsampler2D::normalized_type( 0.9f, 0.5f),
				gli::fsampler2D::normalized_type( 0.1f, 0.9f),
				gli::fsampler2D::normalized_type( 0.5f,-0.5f),
				gli::fsampler2D::normalized_type(-0.5f,-0.5f),
				gli::fsampler2D::normalized_type(-0.5f, 0.5f),
				gli::fsampler2D::normalized_type( 1.5f, 0.5f),
				gli::fsampler2D::normalized_type( 1.5f, 1.5f),
				gli::fsampler2D::normalized_type( 0.5f, 1.5f),
				gli::fsampler2D::normalized_type( 1.5f,-0.5f),
				gli::fsampler2D::normalized_type(-0.5f, 1.5f)
			}};

			for(std::size_t i = 0, n = SampleCoord.size(); i < n; ++i)
			{
				gli::vec4 const Texel = Sampler.texture_lod(SampleCoord[i], 0.0f);
				Error += glm::all(glm::epsilonEqual(Texel, Orange, 0.01f)) ? 0 : 1;
			}
		}

		return Error;
	}
Beispiel #19
0
// rareEvents() function callable from R via Rcpp -- which is essentially 
// the same as main() from SMCTC's examples/rare-events/main.cc 
extern "C" SEXP rareEvents(SEXP numberS, SEXP iteratesS, SEXP thresholdS, SEXP scheduleS) { 	

    long lNumber = Rcpp::as<long>(numberS);			// Number of particles
    lIterates  = Rcpp::as<long>(iteratesS);			// Number of iterations
    dThreshold = Rcpp::as<double>(thresholdS);			// Rare event threshold
    dSchedule  = Rcpp::as<double>(scheduleS);			// Annealing schedule constant

    try{
        ///An array of move function pointers
        void (*pfMoves[])(long, smc::particle<mChain<double> > &,smc::rng*) = {fMove1, fMove2};
        smc::moveset<mChain<double> > Moveset(fInitialiseMC, fSelect, sizeof(pfMoves) / sizeof(pfMoves[0]), pfMoves, fMCMC);
        smc::sampler<mChain<double> > Sampler(lNumber, SMC_HISTORY_RAM);
        
        Sampler.SetResampleParams(SMC_RESAMPLE_STRATIFIED,0.5);
        Sampler.SetMoveSet(Moveset);

        Sampler.Initialise();
        Sampler.IterateUntil(lIterates);
      
        ///Estimate the normalising constant of the terminal distribution
        double zEstimate = Sampler.IntegratePathSampling(pIntegrandPS, pWidthPS, NULL) - log(2.0);
        ///Estimate the weighting factor for the terminal distribution
        double wEstimate = Sampler.Integrate(pIntegrandFS, NULL);
      
        // cout << zEstimate << " " << log(wEstimate) << " " << zEstimate + log(wEstimate) << endl;
        Rcpp::NumericVector res = Rcpp::NumericVector::create(Rcpp::Named("zEstimate") = zEstimate,
                                                              Rcpp::Named("log(wEstimate)") = log(wEstimate),
                                                              Rcpp::Named("sum") = zEstimate + log(wEstimate));
        return res;
    }
    catch(smc::exception  e) {
        Rcpp::Rcout << e;       	// not cerr, as R doesn't like to mix with i/o 
        //exit(e.lCode);		// we're just called from R so we should not exit
    }
    return R_NilValue;          	// to provide a return 

}
// [ref] ${SMCTC_HOME}/examples/rare-events/main.cc
void rare_events_example()
{
	// Number of Particles
	const long lNumber = 1000;

	// An array of move function pointers
	void (*pfMoves[])(long, smc::particle<mChain<double> > &, smc::rng *) = { simfunctions::fMove1, simfunctions::fMove2 };

	smc::moveset<mChain<double> > Moveset(simfunctions::fInitialise, simfunctions::fSelect, sizeof(pfMoves) / sizeof(pfMoves[0]), pfMoves, simfunctions::fMCMC);
	smc::sampler<mChain<double> > Sampler(lNumber, SMC_HISTORY_RAM);

	Sampler.SetResampleParams(SMC_RESAMPLE_STRATIFIED, 0.5);
	Sampler.SetMoveSet(Moveset);

	Sampler.Initialise();
	Sampler.IterateUntil(simfunctions::lIterates);

	// Estimate the normalising constant of the terminal distribution
	const double zEstimate = Sampler.IntegratePathSampling(simfunctions::pIntegrandPS, simfunctions::pWidthPS, NULL) - std::log(2.0);
	// Estimate the weighting factor for the terminal distribution
	const double wEstimate = Sampler.Integrate(simfunctions::pIntegrandFS, NULL);

	std::cout << zEstimate << " " << std::log(wEstimate) << " " << zEstimate + std::log(wEstimate) << endl;
}
Beispiel #21
0
 const Sampler& DebugViewerVS::sampler(const std::string& name) const
 {
     
     ASSERT(false, "Tried to look for non-existing resource");
     return Sampler();
 }
Beispiel #22
0
 const Sampler& ClearTexture2duCS::sampler(const std::string& name) const
 {
     
     ASSERT(false, "Tried to look for non-existing resource");
     return Sampler();
 }
Beispiel #23
0
void resample_pixels(const any_image_view<SrcTypes>& src, const any_image_view<DstTypes>& dst, const MapFn& dst_to_src, Sampler sampler=Sampler()) {
    apply_operation(src,dst,detail::resample_pixels_fn<Sampler,MapFn>(dst_to_src,sampler));
}
Beispiel #24
0
void resample_pixels(const V1& src, const any_image_view<Types2>& dst, const MapFn& dst_to_src, Sampler sampler=Sampler()) {
    apply_operation(dst,bind(detail::resample_pixels_fn<Sampler,MapFn>(dst_to_src,sampler), src, _1));
}
Beispiel #25
0
void resample_pixels(const SrcView& src_view, const DstView& dst_view, const MapFn& dst_to_src, Sampler sampler=Sampler()) {
    typename DstView::point_t dst_dims=dst_view.dimensions();
    typename DstView::point_t dst_p;
    //typename mapping_traits<MapFn>::result_type src_p;

    for (dst_p.y=0; dst_p.y<dst_dims.y; ++dst_p.y) {
        typename DstView::x_iterator xit = dst_view.row_begin(dst_p.y);
        for (dst_p.x=0; dst_p.x<dst_dims.x; ++dst_p.x) {
            sample(sampler, src_view, transform(dst_to_src, dst_p), xit[dst_p.x]);
        }
    }
}
Beispiel #26
0
void resize_view(const SrcMetaView& src, const DstMetaView& dst, const Sampler& sampler=Sampler()) {
    resample_subimage(src,dst,0,0,src.width(),src.height(),0,sampler);
}
Beispiel #27
0
// Models MappingFunctionConcept
void resample_pixels_progress( const SrcView& src_view, const DstView& dst_view, const MapFn& dst_to_src, const OfxRectI& procWindow, tuttle::plugin::IProgress* p, Sampler sampler = Sampler() )
{
	typename DstView::point_t dst_p;
	typename DstView::value_type black;
	color_convert( boost::gil::rgba32f_pixel_t( 0.0, 0.0, 0.0, 0.0 ), black );
	for( dst_p.y = procWindow.y1; dst_p.y < procWindow.y2; ++dst_p.y )
	{
		typename DstView::x_iterator xit = dst_view.row_begin( dst_p.y );
		for( dst_p.x = procWindow.x1; dst_p.x < procWindow.x2; ++dst_p.x )
		{
			if( !boost::gil::sample( sampler, src_view, transform( dst_to_src, dst_p ), xit[dst_p.x] ) )
			{
				xit[dst_p.x] = black; // if it is outside of the source image
			}
		}
		if( p->progressForward() )
			return;
	}
}
Beispiel #28
0
double Spectral_CompareSignals(signal_t *signal1_in, signal_t *signal2_in, int windowing)
{
  signal_t *sig1 = NULL, *sig2 = NULL;
  signal_t *sig1_sampled = NULL, *sig2_sampled = NULL;
  spectral_time_t samplingRate = 0;
  int    x1, x2, x3;
  double y1, y2, y3;
  double similarity;  
  char  *dbg_cross_both = NULL;
  char  *dbg_autocross1 = NULL;
  char  *dbg_autocross2 = NULL;
#if defined DEBUG_MODE
  dbg_cross_both = "cross_sig1_sig2.txt";
  dbg_autocross1 = "autocross_sig1.txt";
  dbg_autocross1 = "autocross_sig2.txt";
#endif

  if ((signal1_in == NULL) || (signal2_in == NULL)) return 0;

  /* XXX Input signals are copied because shifting and windowing modifies them (deleted at exit) */

  sig1 = Spectral_CloneSignal( signal1_in );
  sig2 = Spectral_CloneSignal( signal2_in );

  Spectral_ShiftSignal( sig1 );
  Spectral_ShiftSignal( sig2 );
  
  if (windowing != WINDOWING_NONE)
  {
    applyWindowing( sig1, windowing );
    applyWindowing( sig2, windowing );
  }
#if defined DEBUG_MODE
  Spectral_DumpSignal(sig1, "comp_sig1_shift.txt");
  Spectral_DumpSignal(sig2, "comp_sig2_shift.txt");
#endif

  samplingRate = _SPECTRAL_MAX( 
    Spectral_GetSignalSamplingRate(sig1, 1000),
    Spectral_GetSignalSamplingRate(sig2, 1000));
    
  //sig1_sampled = Sampler(sig1, (spectral_time_t)5000000);
  //sig2_sampled = Sampler(sig2, (spectral_time_t)5000000);
  
  sig1_sampled = Sampler(sig1, (spectral_time_t)samplingRate, NULL);
  sig2_sampled = Sampler(sig2, (spectral_time_t)samplingRate, NULL);

  Crosscorrelation(sig1_sampled, sig1_sampled, dbg_autocross1, &x1, &y1);
  Crosscorrelation(sig2_sampled, sig2_sampled, dbg_autocross2, &x2, &y2);
  Crosscorrelation(sig1_sampled, sig2_sampled, dbg_cross_both, &x3, &y3);

  /* x's -- points where sig1 is more similar to sig2
   * y's -- value of the crosscorrelation 
   */ 
  similarity = sqrt(pow(y3,2)/(y1 * y2));

  Spectral_FreeSignal(sig1_sampled);
  Spectral_FreeSignal(sig2_sampled);
  Spectral_FreeSignal(sig1);
  Spectral_FreeSignal(sig2);

  return similarity;
}
Beispiel #29
0
 Sampler         sample() const                                              { return Sampler(values, samples, cmp, num_samples); }
Settings PhotonMapper(int sampleCount)
{
	return Settings(Integrator("photonmapper", sampleCount > 32, sampleCount < 1),
					Sampler("ldsampler", sampleCount));
}