Skip to content

Commit

Permalink
- added OCIO::Config::CreateFromStream() so we can read a config from…
Browse files Browse the repository at this point in the history
… a stream

- added UnitTest.cpp which defines BOOST_TEST_MODULE for the core unit tests
- added BOOST_AUTO_TEST_SUITE to CSP and 3DL unit tests so you can differentiate between test when running 'ocio_core_tests --log_level=test_suite'
- added JPLogOp for applying the Josuha Pines loglin method
- added JPLogTransform so you can use the JPLogOp in the OCIO config
- added Config code of the <JPLog \> type
  • Loading branch information
malcolmhumphreys committed Sep 24, 2010
1 parent 13dfeeb commit 6d75841
Show file tree
Hide file tree
Showing 12 changed files with 841 additions and 6 deletions.
2 changes: 1 addition & 1 deletion export/OpenColorIO/OpenColorIO.h
Expand Up @@ -41,7 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define OCIO_NAMESPACE_EXIT using namespace OCIO_VERSION_NS; }
#define OCIO_NAMESPACE_USING using namespace OCIO_NAMESPACE;


#include <exception>
#include <iosfwd>
#include <string>
Expand Down Expand Up @@ -205,6 +204,7 @@ OCIO_NAMESPACE_ENTER
static ConfigRcPtr Create();
static ConstConfigRcPtr CreateFromEnv();
static ConstConfigRcPtr CreateFromFile(const char * filename);
static ConstConfigRcPtr CreateFromStream(std::istream & istream);

ConfigRcPtr createEditableCopy() const;

Expand Down
39 changes: 39 additions & 0 deletions export/OpenColorIO/OpenColorTransforms.h
Expand Up @@ -420,6 +420,45 @@ OCIO_NAMESPACE_ENTER

std::ostream& operator<< (std::ostream&, const MatrixTransform&);

///////////////////////////////////////////////////////////////////////////

// Joshua Pines LogLin Transform
//
// Converts cineon 10bit log to scene referred linear
// http://lists.nongnu.org/archive/html/openexr-devel/2005-03/msg00006.html

class JPLogTransform : public Transform
{

public:

static JPLogTransformRcPtr
Create();

virtual TransformRcPtr
createEditableCopy() const;

virtual TransformDirection
getDirection() const;

virtual void
setDirection(TransformDirection dir);

private:

JPLogTransform();
JPLogTransform(const JPLogTransform &);
virtual ~JPLogTransform();
JPLogTransform& operator= (const JPLogTransform &);
static void deleter(JPLogTransform* t);
class Impl;
friend class Impl;
std::auto_ptr<Impl> m_impl;

};

std::ostream& operator<< (std::ostream&, const JPLogTransform&);

}
OCIO_NAMESPACE_EXIT

Expand Down
5 changes: 3 additions & 2 deletions export/OpenColorIO/OpenColorTypes.h
Expand Up @@ -102,8 +102,9 @@ OCIO_NAMESPACE_ENTER
typedef OCIO_SHARED_PTR<const MatrixTransform> ConstMatrixTransformRcPtr;
typedef OCIO_SHARED_PTR<MatrixTransform> MatrixTransformRcPtr;



class JPLogTransform;
typedef OCIO_SHARED_PTR<const JPLogTransform> ConstJPLogTransformRcPtr;
typedef OCIO_SHARED_PTR<JPLogTransform> JPLogTransformRcPtr;

template <class T, class U>
inline OCIO_SHARED_PTR<T> DynamicPtrCast(OCIO_SHARED_PTR<U> const & ptr)
Expand Down
68 changes: 68 additions & 0 deletions src/core/Config.cpp
Expand Up @@ -255,6 +255,22 @@ OCIO_NAMESPACE_ENTER
return config;
}

ConstConfigRcPtr Config::CreateFromStream(std::istream & istream)
{
ConfigRcPtr config = Config::Create();

std::ostringstream oss;
oss << istream.rdbuf();

TiXmlDocument doc;
doc.Parse(oss.str().c_str());
const TiXmlElement* rootElement = doc.RootElement();
config->m_impl->loadXmlElement(rootElement, "ISTREAM_PROFILE");

return config;
}



///////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -954,6 +970,54 @@ OCIO_NAMESPACE_ENTER



///////////////////////////////////////////////////////////////////////
//
// JPLogTransform

JPLogTransformRcPtr CreateJPLogTransform(const TiXmlElement * element)
{
if(!element)
throw Exception("CreateJPLogTransform received null XmlElement.");

if(std::string(element->Value()) != "JPLog")
{
std::ostringstream os;
os << "HandleElement passed incorrect element type '";
os << element->Value() << "'. ";
os << "Expected 'JPlog'.";
throw Exception(os.str().c_str());
}

JPLogTransformRcPtr t = JPLogTransform::Create();

// TODO: do we need this yet?
/*
const TiXmlAttribute* pAttrib = element->FirstAttribute();
while(pAttrib)
{
std::string attrName = pystring::lower(pAttrib->Name());
if(attrName == "direction")
{
t->setDirection( TransformDirectionFromString(pAttrib->Value()) );
}
else
{
// TODO: unknown attr
}
pAttrib = pAttrib->Next();
}
*/

return t;
}

TiXmlElement * GetElement(const ConstJPLogTransformRcPtr & /* t */)
{
TiXmlElement * element = new TiXmlElement( "JPLog" );
// TODO: add user param support
return element;
}



///////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1079,6 +1143,10 @@ OCIO_NAMESPACE_ENTER
{
t->push_back( CreateMatrixTransform(pElem) );
}
else if(elementtype == "JPLog")
{
t->push_back( CreateJPLogTransform(pElem) );
}
else
{
std::ostringstream os;
Expand Down
4 changes: 4 additions & 0 deletions src/core/FileFormat3DL.cpp
Expand Up @@ -339,6 +339,8 @@ OCIO_NAMESPACE_EXIT
namespace OCIO = OCIO_NAMESPACE;
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE( FileFormat3DL_Unit_Tests )

// FILE EXPECTED MAX CORRECTLY DECODED IF MAX IN THIS RANGE
// 8-bit 255 [0, 511]
// 10-bit 1023 [512, 2047]
Expand Down Expand Up @@ -375,4 +377,6 @@ BOOST_AUTO_TEST_CASE ( test_GetLikelyLutBitDepth )
BOOST_CHECK_EQUAL (OCIO::GetLikelyLutBitDepth(131072), 16);
}

BOOST_AUTO_TEST_SUITE_END()

#endif // OCIO_BUILD_TESTS
7 changes: 4 additions & 3 deletions src/core/FileFormatCSP.cpp
Expand Up @@ -355,14 +355,13 @@ OCIO_NAMESPACE_EXIT

///////////////////////////////////////////////////////////////////////////////


#ifdef OCIO_UNIT_TEST

namespace OCIO = OCIO_NAMESPACE;

#define BOOST_TEST_MODULE ocio_core
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE( FileFormatCSP_Unit_Tests )

BOOST_AUTO_TEST_CASE ( test_simple1D )
{
std::ostringstream strebuf;
Expand Down Expand Up @@ -478,4 +477,6 @@ BOOST_AUTO_TEST_CASE ( test_simple3D )

}

BOOST_AUTO_TEST_SUITE_END()

#endif // OCIO_BUILD_TESTS

0 comments on commit 6d75841

Please sign in to comment.