include/sampler.h
branchpyrit
changeset 82 930a2d3ecaed
parent 78 9569e9f35374
child 87 1081e3dd3f3e
equal deleted inserted replaced
81:9dbb9c8c115b 82:930a2d3ecaed
    53  * and decide if other phase is needed. When the picture is complete,
    53  * and decide if other phase is needed. When the picture is complete,
    54  * initSampleSet returns zero and picture can be read from buffer.
    54  * initSampleSet returns zero and picture can be read from buffer.
    55  */
    55  */
    56 class Sampler
    56 class Sampler
    57 {
    57 {
    58 public:
    58 protected:
    59 	Float *buffer;
    59 	Float *buffer;
    60 	int w,h;
    60 	int w,h;
    61 
    61 	bool packetable;
    62 	Sampler(Float *abuffer, int &aw, int &ah): buffer(abuffer), w(aw), h(ah) {};
    62 public:
       
    63 	Sampler(Float *abuffer, int &aw, int &ah):
       
    64 		buffer(abuffer), w(aw), h(ah), packetable(false) {};
    63 	virtual ~Sampler() {};
    65 	virtual ~Sampler() {};
    64 	void resetBuffer(Float *abuffer, int &aw, int &ah) { buffer = abuffer; w = aw; h = ah; };
    66 	void resetBuffer(Float *abuffer, int &aw, int &ah) { buffer = abuffer; w = aw; h = ah; };
    65 	virtual void init() = 0;
    67 	virtual void init() = 0;
    66 	virtual int initSampleSet() = 0;
    68 	virtual int initSampleSet() = 0;
    67 	virtual bool nextSample(Sample *s) = 0;
    69 	virtual bool nextSample(Sample *s) = 0;
    68 	virtual void saveSample(Sample &samp, Colour &col) = 0;
    70 	virtual void saveSample(Sample &samp, Colour &col) = 0;
       
    71 	bool packetableSamples() { return packetable; };
    69 };
    72 };
    70 
    73 
    71 /**
    74 /**
    72  * Default sampler.
    75  * Default sampler.
    73  * Implements basic adaptive subsampling and oversampling.
    76  * Implements basic adaptive subsampling and oversampling.
    78 	int subsample;  // 0,1 = no, 1+ = size of sampling grid
    81 	int subsample;  // 0,1 = no, 1+ = size of sampling grid
    79 	int oversample; // 0 = no, 1 = 5x, 2 = 9x, 3 = 16x
    82 	int oversample; // 0 = no, 1 = 5x, 2 = 9x, 3 = 16x
    80 	int sx,sy,osa_samp; // current sample properties
    83 	int sx,sy,osa_samp; // current sample properties
    81 public:
    84 public:
    82 	DefaultSampler(Float *abuffer, int &aw, int &ah):
    85 	DefaultSampler(Float *abuffer, int &aw, int &ah):
    83 		Sampler(abuffer, aw, ah), phase(-1), subsample(4), oversample(0) {};
    86 		Sampler(abuffer, aw, ah), phase(-1), subsample(0), oversample(0) {};
    84 	void init();
    87 	void init();
    85 	int initSampleSet();
    88 	int initSampleSet();
    86 	bool nextSample(Sample *s);
    89 	bool nextSample(Sample *s);
    87 	void saveSample(Sample &samp, Colour &col);
    90 	void saveSample(Sample &samp, Colour &col);
    88 
    91