Skip to content

Commit

Permalink
Small code and docs changes, especially in the predictor.
Browse files Browse the repository at this point in the history
  • Loading branch information
vcunat committed Jul 14, 2009
1 parent efb48da commit 6e8358a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
5 changes: 2 additions & 3 deletions interfaces.h
Expand Up @@ -370,8 +370,7 @@ struct IStdEncPredictor: public Interface<IStdEncPredictor> {
typedef std::vector<Prediction> Predictions;

/** %Interface for objects that predict domains for a concrete range block */
class IOneRangePredictor {
public:
struct IOneRangePredictor {
/** Virtual destructor needed for safe deletion of derived classes */
virtual ~IOneRangePredictor() {}
/** Makes several predictions at once, returns \p store reference */
Expand All @@ -383,7 +382,7 @@ struct IStdEncPredictor: public Interface<IStdEncPredictor> {

/** Creates a predictor (passing the ownership) for a range block */
virtual IOneRangePredictor* newPredictor(const NewPredictorData &data) =0;
/** Releases common resources (called when encoding is complete) */
/** Releases common resources (to be called when encoding is complete) */
virtual void cleanUp() =0;
}; // IStdEncPredictor interface

Expand Down
2 changes: 1 addition & 1 deletion modules.cpp
Expand Up @@ -20,7 +20,7 @@
using namespace std;

typedef Loki::TL::MakeTypelist< MRoot, MColorModel, MSquarePixels, MQuadTree, MStdDomains
, MQuality2SE_std, MStdEncoder, MDifferentialVLICodec, MSaupePredictor, NoPredictor
, MQuality2SE_std, MStdEncoder, MDifferentialVLICodec, MSaupePredictor, MNoPredictor
, MQuality2SE_alt >
::Result Modules;

Expand Down
10 changes: 5 additions & 5 deletions modules/noPredictor.h
Expand Up @@ -4,9 +4,9 @@
#include "../headers.h"

/** Predictor that doesn't predict, just tries all the domains */
class NoPredictor: public IStdEncPredictor {
class MNoPredictor: public IStdEncPredictor {

DECLARE_TypeInfo_noSettings( NoPredictor, "brute force"
DECLARE_TypeInfo_noSettings( MNoPredictor, "brute force"
, "Doesn't predict, tries all possibilities." )

public:
Expand All @@ -17,7 +17,7 @@ class NoPredictor: public IStdEncPredictor {
void cleanUp() {} // nothing to clean up
/// @}

private:
protected:
/** Predictor class returned when calling #newPredictor
* - returns all domains in all rotations in one chunk */
class OneRangePredictor: public IOneRangePredictor {
Expand All @@ -41,8 +41,8 @@ class NoPredictor: public IStdEncPredictor {
return store;
}
/// @}
}; // NoPredictor::OneRangePredictor class
}; // MNoPredictor::OneRangePredictor class

}; // NoPredictor class
}; // MNoPredictor class

#endif
2 changes: 1 addition & 1 deletion modules/root.h
Expand Up @@ -42,7 +42,7 @@ class MRoot: public IRoot {
desc: "Maximum domain count for level 2 range blocks\n"
"(for this purpose are different rotations\n"
"of one domain counted as different domains)",
type: settingInt(0,15,24,IntLog2)
type: settingInt(0,15,30,IntLog2)
} )

protected:
Expand Down
20 changes: 13 additions & 7 deletions modules/saupePredictor.h
Expand Up @@ -4,7 +4,12 @@
#include "../headers.h"
#include "../kdTree.h"

/** Predictor for MStdEncoder based on a theorem proven in Saupe's work */
/// \ingroup modules
/** Predictor for MStdEncoder based on a theorem proven in Saupe's work.
* It resizes the blocks to 4x4 and normalizes them.
* Domains for every level are stored in a KDTree instance and searched.
* The user can set the size of returned chunks of the blocks
* and the maximal part of domains returned. */
class MSaupePredictor: public IStdEncPredictor {
DECLARE_debugModule;

Expand All @@ -15,17 +20,17 @@ class MSaupePredictor: public IStdEncPredictor {
desc: "The number of predicted domains in a chunk",
type: settingInt(1,8,32)
}, {
label: "Max. predictions (%)",
desc: "The maximal percentage of domains predicted for a range block",
type: settingFloat(0,5,100)
label: "Max. predicted part",
desc: "The maximal part of domains predicted for a range block",
type: settingInt(-10,-5,0,IntLog2)
} )

protected:
/** Indices for settings */
enum Settings { ChunkSize, MaxPredPercent };
enum Settings { ChunkSize, MaxPredPart };

/** maxPredCoeff() * "the number of domains" == "max. number of predictions" */
Real maxPredCoeff() { return settings[MaxPredPercent].val.f / Real(100); }
Real maxPredCoeff() { return ldexp( Real(1), settingsInt(MaxPredPart) ); }

public:
typedef float KDReal; ///< The floating point type used in the KD-tree
Expand Down Expand Up @@ -59,7 +64,7 @@ class MSaupePredictor: public IStdEncPredictor {
protected:
/** Computes the level for predictions based on the actual level */
int getPredLevel(int /*realLevel*/) const
{ return 2; }
{ return 2; }

/** Builds a new tree for one level of range blocks using passed domain blocks */
Tree* createTree(const NewPredictorData &data);
Expand Down Expand Up @@ -99,6 +104,7 @@ class MSaupePredictor: public IStdEncPredictor {
void initialize(const NewPredictorData &data,int predLevel) {
int shift= 2 * (predLevel - data.rangeBlock->level);
errorAccel= ldexp( data.pixCount/data.rnDev2, shift );
//errorAccel= data.pixCount/data.rnDev2;
}
/** Computes normalized-tree-error from real SE (::initialize has been called) */
Real normSE(Real error) const {
Expand Down
2 changes: 1 addition & 1 deletion modules/stdEncoder.cpp
Expand Up @@ -395,7 +395,7 @@ float MStdEncoder::findBestSE(const RangeNode &range,bool allowHigherSE) {
{ // a goto-skippable block
// create and initialize a new predictor (in auto_ptr because of exceptions)
auto_ptr<IStdEncPredictor::IOneRangePredictor> predictor
( modulePredictor()->newPredictor(info.stable) );
( modulePredictor()->newPredictor(info.stable) );
typedef IStdEncPredictor::Predictions Predictions;
Predictions predicts;

Expand Down
4 changes: 2 additions & 2 deletions modules/stdEncoder.h
Expand Up @@ -61,12 +61,12 @@ class MStdEncoder: public ISquareEncoder {
label: "Quantization steps for average",
desc: "The number (a power of two) of possible range block\n"
"average color values (real average will be rounded)",
type: settingInt(2,7,10,IntLog2)
type: settingInt(2,8,10,IntLog2)
}, {
label: "Quantization steps for deviation",
desc: "The number (a power of two) of possible range block\n"
"standard color value deviations",
type: settingInt(2,7,10,IntLog2)
type: settingInt(2,6,10,IntLog2)
}, {
label: "The codec for averages",
desc: "The module that will code and decode\n"
Expand Down

0 comments on commit 6e8358a

Please sign in to comment.