Skip to content

Commit

Permalink
Merge branch 'master' into autobuild/alpha and bump version number.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-lipka committed Oct 8, 2016
2 parents c1b37df + 66cef4e commit 8add814
Show file tree
Hide file tree
Showing 24 changed files with 206 additions and 72 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ $RECYCLE.BIN/
/source/Makefile.in
/unix/Makefile.am
/unix/Makefile.in
/unix/config/compile
/unix/config/config.guess
/unix/config/config.sub
/unix/config/depcomp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ----------------- HF_Square macro ------------------
//-----------------------------------------------------
#include "shapes.inc"
// ----------------- HF_Square macro ------------------
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*2,y*2,z*2)*0.25)}
Expand All @@ -11,7 +13,7 @@ object{ HF_Square( Fn_1, //Function,
"",// FileName, ""=no file,
<-1,0,-1>*2, //MnExt,
<1,1,1>*2 //MxExt
) //------------------------------
) //------------------------------
texture{ pigment{ checker
color rgb<1,0.6,0>
color rgb<1,1,1>*0.9
Expand All @@ -21,4 +23,4 @@ object{ HF_Square( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,-1.5,0>
} // end of HF_Square ----------------------------------
} // end of HF_Square ----------------------------------
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ----------------- HF_Sphere macro ----------------------
//----------------------------------------------------------
#include "shapes.inc"
// ----------------- HF_Sphere macro -----------------------
#declare Fn_1 =
function(x, y, z)
{1+f_snoise3d(x*7,y*7,z*7)*0.75 }
Expand All @@ -23,5 +25,5 @@ object{ HF_Sphere( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,0.00,0>
} // end of HF_Sphere --------------------------------------
} // end of HF_Sphere --------------------------------------

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//-----------------------------------------------------
#include "shapes.inc"
// -------------- HF_Cylinder macro -------------------
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*3,y*3 , z*3)*0.8)}
{1-(-f_snoise3d(x*3,y*3,z*3)*0.8)}

// ----------------------------------------------------
object{ HF_Cylinder( Fn_1, //Function,
Expand All @@ -24,4 +26,4 @@ object{ HF_Cylinder( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,0.00,0>
} // end of HF_Cylinder -------------------------------
} // end of HF_Cylinder -------------------------------
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//-------------------------------------------------------
#include "shapes.inc"
// ----------------- HF_Torus macro ---------------------
#declare Fn_1 =
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*3,y*3,z*3)*0.8)}

Expand All @@ -13,8 +15,8 @@ object{ HF_Torus( Fn_1, //Function,
2.00, 1.00 ,// R_Major, R_Minor// Radius
-0.25 // Depth
) //--------------------------------------
texture{
pigment{ gradient x+y
texture{
pigment{ gradient x+y
color_map{
[ 0.0 color rgb< 1.0,0.95, 0.9>*1]
[ 0.5 color rgb< 1.0,0.95, 0.9>*1]
Expand All @@ -24,9 +26,9 @@ object{ HF_Torus( Fn_1, //Function,
turbulence 0.0 scale< 1,3,1>*0.015
} // end pigment
finish { phong 1 reflection 0.01}
} // end of texture
} // end of texture

scale<1,1,1>*1
rotate<0,0,0>
translate<0,0.00,0>
} // end of HF_Torus ------------------------------------
} // end of HF_Torus ------------------------------------
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ----------------- HF_Square macro
//-----------------------------------------------------
#include "shapes.inc"
// ----------------- HF_Square macro ------------------
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*2,y*2,z*2)*0.25)}
Expand All @@ -22,4 +24,4 @@ HF_Square( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,-1.5,0>
} // end of HF_Square ---------------------
} // end of HF_Square --------------------------------
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ----------------- HF_Sphere macro
//-----------------------------------------------------
#include "shapes.inc"
// ----------------- HF_Sphere macro ------------------
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*7,y*7,z*7)*0.5) }
Expand All @@ -23,5 +25,5 @@ HF_Sphere( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,0.00,0>
} // end of HF_Sphere -------------------
} // end of HF_Sphere --------------------------------

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// -------------- HF_Cylinder macro
//-----------------------------------------------------
#include "shapes.inc"
// -------------- HF_Cylinder macro -------------------
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*3,y*3 , z*3)*0.8)}
{1-(-f_snoise3d(x*3,y*3,z*3)*0.8)}

object{ //---------------------------
HF_Cylinder( Fn_1, //Function,
Expand All @@ -24,4 +26,4 @@ HF_Cylinder( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,0.00,0>
} // end of HF_Cylinder --------------
} // end of HF_Cylinder ------------------------------
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ----------------- HF_Torus macro
//-----------------------------------------------------
#include "shapes.inc"
// ----------------- HF_Torus macro -------------------
#declare Fn_1 =
function(x, y, z)
{1-(-f_snoise3d(x*3,y*3,z*3)*0.8)}
Expand All @@ -24,4 +26,4 @@ HF_Torus( Fn_1, //Function,
scale<1,1,1>*1
rotate<0,0,0>
translate<0,0.00,0>
} // end of HF_Torus -----------------
} // end of HF_Torus ---------------------------------
2 changes: 2 additions & 0 deletions source/base/fileinputoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ OStream::OStream(const UCS2String& name, unsigned int Flags) : IOBase(name), f(N

if (f != NULL)
{
fail = false;

if((Flags & append) != 0)
{
if(!seekg(0, seek_end))
Expand Down
79 changes: 63 additions & 16 deletions source/base/image/colourspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ boost::mutex GammaCurve::cacheMutex;
// definitions of static GammaCurve-derivatives' member variables to satisfy the linker
SimpleGammaCurvePtr NeutralGammaCurve::instance;
SimpleGammaCurvePtr SRGBGammaCurve::instance;
GammaCurvePtr ITURBT709GammaCurve::instance;
GammaCurvePtr Rec1361GammaCurve::instance;
SimpleGammaCurvePtr BT709GammaCurve::instance;
SimpleGammaCurvePtr BT1361GammaCurve::instance;
SimpleGammaCurvePtr BT2020GammaCurve::instance;

/*******************************************************************************/

Expand Down Expand Up @@ -200,53 +201,96 @@ int SRGBGammaCurve::GetTypeId() const

/*******************************************************************************/

ITURBT709GammaCurve::ITURBT709GammaCurve() {}
GammaCurvePtr ITURBT709GammaCurve::Get()
BT709GammaCurve::BT709GammaCurve() {}
SimpleGammaCurvePtr BT709GammaCurve::Get()
{
if (!instance)
instance.reset(new ITURBT709GammaCurve());
return GammaCurvePtr(instance);
instance.reset(new BT709GammaCurve());
return SimpleGammaCurvePtr(instance);
}
float ITURBT709GammaCurve::Encode(float x) const
float BT709GammaCurve::Encode(float x) const
{
if (x < 0.018f) return x * 4.5f;
else return 1.099f * pow(x, 0.45f) - 0.099f;
}
float ITURBT709GammaCurve::Decode(float x) const
float BT709GammaCurve::Decode(float x) const
{
// NB: ITU-R BT.709 does not officially specify a decoding transfer function. The following is the actual inverse
// of the implemented transfer function.
if (x < 0.081f) return x / 4.5f;
else return pow((x + 0.099f) / 1.099f, 1.0f/0.45f);
}
float ITURBT709GammaCurve::ApproximateDecodingGamma() const
float BT709GammaCurve::ApproximateDecodingGamma() const
{
return 1.9f; // very rough approximation
}
int BT709GammaCurve::GetTypeId() const
{
return kPOVList_GammaType_BT709;
}

/*******************************************************************************/

Rec1361GammaCurve::Rec1361GammaCurve() {}
GammaCurvePtr Rec1361GammaCurve::Get()
BT1361GammaCurve::BT1361GammaCurve() {}
SimpleGammaCurvePtr BT1361GammaCurve::Get()
{
if (!instance)
instance.reset(new Rec1361GammaCurve());
return GammaCurvePtr(instance);
instance.reset(new BT1361GammaCurve());
return SimpleGammaCurvePtr(instance);
}
float Rec1361GammaCurve::Encode(float x) const
float BT1361GammaCurve::Encode(float x) const
{
if (x < -0.0045f) return (1.099f * pow(-4*x, 0.45f) - 0.099f) / 4;
else if (x < 0.018f) return x * 4.5f;
else return 1.099f * pow(x,0.45f) - 0.099f;
}
float Rec1361GammaCurve::Decode(float x) const
float BT1361GammaCurve::Decode(float x) const
{
if (x < -0.02025f) return pow((4*x + 0.099f) / 1.099f, 1.0f/0.45f) / -4;
else if (x < 0.081f) return x / 4.5f;
else return pow((x + 0.099f) / 1.099f, 1.0f/0.45f);
}
float Rec1361GammaCurve::ApproximateDecodingGamma() const
float BT1361GammaCurve::ApproximateDecodingGamma() const
{
return 1.9f; // very rough approximation of the x>0 section
}
int BT1361GammaCurve::GetTypeId() const
{
return kPOVList_GammaType_BT1361;
}

/*******************************************************************************/

BT2020GammaCurve::BT2020GammaCurve() {}
SimpleGammaCurvePtr BT2020GammaCurve::Get()
{
if (!instance)
instance.reset(new BT2020GammaCurve());
return SimpleGammaCurvePtr(instance);
}
float BT2020GammaCurve::Encode(float x) const
{
// NB: We're using higher-precision coefficients than given in ITU-R BT.2020; note that this is perfectly in
// accordance with the specification, as the numerical values given there are just approximations, and the
// coefficients are instead defined as "the solutions to [a certain set of] simultaneous equations".
if (x < 0.01805396851080780734f) return x * 4.5f;
else return 1.09929682680944294035f * pow(x, 0.45f) - 0.09929682680944294035f;
}
float BT2020GammaCurve::Decode(float x) const
{
// NB: ITU-R BT.2020 does not officially specify a decoding transfer function. The following is the actual inverse
// of the implemented transfer function.
if (x < 0.08124285829863513301f) return x / 4.5f;
else return pow((x + 0.09929682680944294035f) / 1.09929682680944294035f, 1.0f/0.45f);
}
float BT2020GammaCurve::ApproximateDecodingGamma() const
{
return 1.9f; // very rough approximation
}
int BT2020GammaCurve::GetTypeId() const
{
return kPOVList_GammaType_BT2020;
}

/*******************************************************************************/

Expand Down Expand Up @@ -394,6 +438,9 @@ SimpleGammaCurvePtr GetGammaCurve(GammaTypeId type, float param)
case kPOVList_GammaType_Neutral: return NeutralGammaCurve::Get();
case kPOVList_GammaType_PowerLaw: return PowerLawGammaCurve::GetByDecodingGamma(param);
case kPOVList_GammaType_SRGB: return SRGBGammaCurve::Get();
case kPOVList_GammaType_BT709: return BT709GammaCurve::Get();
case kPOVList_GammaType_BT1361: return BT1361GammaCurve::Get();
case kPOVList_GammaType_BT2020: return BT2020GammaCurve::Get();
default: return PowerLawGammaCurve::GetByDecodingGamma(DEFAULT_FILE_GAMMA);
}
}
Expand Down
48 changes: 38 additions & 10 deletions source/base/image/colourspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,35 +463,60 @@ class SRGBGammaCurve : public UniqueGammaCurve

/// Class representing the ITU-R BT.709 transfer function.
///
/// @remark The ITU-R BT.709 transfer function is identical to that defined in ITU-R BT.601.
///
/// @note This class does _not_ account for the "black digital count" and "white digital count" being defined
/// as 16/255 and 235/255, respectively.
///
class ITURBT709GammaCurve : public GammaCurve // TODO we could make this a UniqueGammaCurve if we assign it a type ID
class BT709GammaCurve : public UniqueGammaCurve
{
public:
static GammaCurvePtr Get();
static SimpleGammaCurvePtr Get();
virtual float Encode(float x) const;
virtual float Decode(float x) const;
virtual float ApproximateDecodingGamma() const;
virtual int GetTypeId() const;
private:
static GammaCurvePtr instance;
ITURBT709GammaCurve();
static SimpleGammaCurvePtr instance;
BT709GammaCurve();
};

/// Class representing the Rec1361 transfer function.
/// Class representing the ITU-R BT.1361 transfer function.
///
/// This transfer function is a wide-gamut extension to that specified in ITU-R BT.709.
///
class Rec1361GammaCurve : public GammaCurve // TODO we could make this a UniqueGammaCurve if we assign it a type ID
class BT1361GammaCurve : public UniqueGammaCurve
{
public:
static GammaCurvePtr Get();
static SimpleGammaCurvePtr Get();
virtual float Encode(float x) const;
virtual float Decode(float x) const;
virtual float ApproximateDecodingGamma() const;
virtual int GetTypeId() const;
private:
static GammaCurvePtr instance;
Rec1361GammaCurve();
static SimpleGammaCurvePtr instance;
BT1361GammaCurve();
};

/// Class representing the ITU-R BT.2020 transfer function.
///
/// @remark The ITU-R BT.2020 transfer function is essentially identical to that defined in ITU-R BT.601 and BT.709,
/// albeit using more precise constants.
///
/// @note This class does _not_ account for the "black digital count" and "white digital count" being defined
/// as 16/255 and 235/255, respectively.
///
class BT2020GammaCurve : public UniqueGammaCurve
{
public:
static SimpleGammaCurvePtr Get();
virtual float Encode(float x) const;
virtual float Decode(float x) const;
virtual float ApproximateDecodingGamma() const;
virtual int GetTypeId() const;
private:
static SimpleGammaCurvePtr instance;
BT2020GammaCurve();
};

/// Class representing a classic constant-gamma (power-law) gamma encoding curve.
Expand Down Expand Up @@ -553,7 +578,10 @@ enum GammaTypeId
kPOVList_GammaType_Unknown,
kPOVList_GammaType_Neutral,
kPOVList_GammaType_PowerLaw,
kPOVList_GammaType_SRGB
kPOVList_GammaType_SRGB,
kPOVList_GammaType_BT709,
kPOVList_GammaType_BT1361, ///< Currently not exposed to the user.
kPOVList_GammaType_BT2020
};

/// Generic transfer function factory.
Expand Down
2 changes: 1 addition & 1 deletion source/base/image/hdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void ReadOldLine(unsigned char *scanline, int width, IStream *file)

// NB EOF won't be set at this point even if the last read obtained the
// final byte in the file (we need to read another byte for that to happen).
if(*file == false)
if(!*file)
throw POV_EXCEPTION(kFileDataErr, "Invalid HDR file (unexpected EOF)");

if(!file->Read_Byte(b))
Expand Down
Loading

0 comments on commit 8add814

Please sign in to comment.