From 22348665963116c3daeb6cc326dba9494536a436 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 16 Jun 2016 17:53:49 +0200 Subject: [PATCH 01/11] oiio writer: set 'Software' metadata when write an output image * This metadata is ignored by most of the format. * It is taken by the DPX for example. --- .../io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc index 8858f05b9..20b08b941 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc @@ -542,6 +542,8 @@ void OpenImageIOWriterProcess::writeImage(View& src, const std::string& fi ImageSpec spec(src.width(), src.height(), gil::num_channels::value, oiioBitDepth); + spec.attribute("Software", "TuttleOFX OIIO Writer"); + spec.attribute("oiio:BitsPerSample", bitsPerSample); spec.attribute("oiio:UnassociatedAlpha", params._premultiply); spec.attribute("CompressionQuality", params._quality); From 8667f707eb4d34f8551c09572512bd860b0cba0f Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 16 Jun 2016 17:54:23 +0200 Subject: [PATCH 02/11] oiio writer: set 'DateTime' metadata when write an output image * This metadata is ignored by most of the format. * It is taken by the DPX for example. --- .../io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc index 20b08b941..b243a563d 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -544,6 +545,12 @@ void OpenImageIOWriterProcess::writeImage(View& src, const std::string& fi spec.attribute("Software", "TuttleOFX OIIO Writer"); + const time_t rawtime = time(0); + const struct tm * timeinfo = localtime(&rawtime); + char buffer[80]; + strftime(buffer, 80,"%d-%m-%Y %I:%M:%S", timeinfo); + spec.attribute("DateTime", std::string(buffer)); + spec.attribute("oiio:BitsPerSample", bitsPerSample); spec.attribute("oiio:UnassociatedAlpha", params._premultiply); spec.attribute("CompressionQuality", params._quality); From b108c75088d43b9b750c7b3be6efeebea9702004 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 09:50:15 +0200 Subject: [PATCH 03/11] oiio writer: added a choice param to set endianness of the output * This feature exists in the dpxwriter. * I add this parameter in the oiiowriter to delete the dpxwriter plugin when all of its features will be available in oiio plugins. --- .../src/writer/OpenImageIOWriterDefinitions.hpp | 13 +++++++++++++ .../src/writer/OpenImageIOWriterPlugin.cpp | 2 ++ .../src/writer/OpenImageIOWriterPlugin.hpp | 2 ++ .../src/writer/OpenImageIOWriterPluginFactory.cpp | 7 +++++++ .../src/writer/OpenImageIOWriterProcess.tcc | 12 ++++++++++++ 5 files changed, 36 insertions(+) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp index 7ac573ffd..c766d6860 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp @@ -69,6 +69,19 @@ static const std::string kParamOutputOrientationR90Clockwise = "90clockwise"; static const std::string kParamOutputOrientationTransverse = "transverse"; static const std::string kParamOutputOrientationR90CounterClockwise = "90counter-clockwise"; +enum ETuttlePluginEndianness +{ + eTuttlePluginEndiannessDefault = 0, + eTuttlePluginEndiannessLittle, + eTuttlePluginEndiannessBig +}; + +static const std::string kParamOutputEndianness = "endianness"; +static const std::string kParamOutputEndiannessHint = "Endianness of the output."; +static const std::string kParamOutputEndiannessDefault = "default The default endianness choosen by oiio dependening on the platform."; +static const std::string kParamOutputEndiannessLittle = "little Force to little endian."; +static const std::string kParamOutputEndiannessBig = "big Force to big endian."; + static const std::string kParamOutputCompression = "compression"; static const std::string kParamOutputCompressionLabel = "Compression"; diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp index 19e961102..d91476596 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp @@ -20,6 +20,7 @@ OpenImageIOWriterPlugin::OpenImageIOWriterPlugin(OfxImageEffectHandle handle) _orientation = fetchChoiceParam(kParamOutputOrientation); _quality = fetchIntParam(kParamOutputQuality); _paramSubsampling = fetchChoiceParam(kParamOutputSubsampling); + _endianness = fetchChoiceParam(kParamOutputEndianness); } OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const OfxTime time) @@ -31,6 +32,7 @@ OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const O params._components = static_cast(this->_components->getValue()); params._bitDepth = static_cast(this->_paramBitDepth->getValue()); params._subsampling = static_cast(_paramSubsampling->getValue()); + params._endianness = static_cast(_endianness->getValue()); params._quality = _quality->getValue(); params._orientation = static_cast(_orientation->getValue()); params._premultiply = this->_paramPremult->getValue(); diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp index 825c0b1d4..5d68d1796 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp @@ -22,6 +22,7 @@ struct OpenImageIOWriterProcessParams ETuttlePluginComponents _components; ///< Force RGB ETuttlePluginBitDepth _bitDepth; ///< Output bit depth (real bit depth, not the buffer passed to OpenImageIO) ETuttlePluginSubsampling _subsampling; ///< Output subsampling + ETuttlePluginEndianness _endianness; ///< Output endianness bool _premultiply; ///< Output premultiply int _quality; ///< Output quality @@ -45,6 +46,7 @@ class OpenImageIOWriterPlugin : public WriterPlugin OFX::IntParam* _quality; OFX::ChoiceParam* _paramSubsampling; OFX::ChoiceParam* _orientation; + OFX::ChoiceParam* _endianness; }; } } diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp index 116578aa5..bc5adc901 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp @@ -126,6 +126,13 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto orientation->appendOption(kParamOutputOrientationR90CounterClockwise); orientation->setDefault(0); + OFX::ChoiceParamDescriptor* endianness = desc.defineChoiceParam(kParamOutputEndianness); + endianness->setHint(kParamOutputEndiannessHint); + endianness->appendOption(kParamOutputEndiannessDefault); + endianness->appendOption(kParamOutputEndiannessLittle); + endianness->appendOption(kParamOutputEndiannessBig); + endianness->setDefault(0); + OFX::ChoiceParamDescriptor* compression = desc.defineChoiceParam(kParamOutputCompression); compression->setLabel(kParamOutputOrientationLabel); #if(TUTTLE_EXPERIMENTAL) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc index b243a563d..f423ff970 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc @@ -556,6 +556,18 @@ void OpenImageIOWriterProcess::writeImage(View& src, const std::string& fi spec.attribute("CompressionQuality", params._quality); spec.attribute("Orientation", params._orientation); + switch(params._endianness) + { + case eTuttlePluginEndiannessLittle: + spec.attribute("oiio:Endian", "little"); + break; + case eTuttlePluginEndiannessBig: + spec.attribute("oiio:Endian", "big"); + break; + default: + break; + } + // controlling chroma-subsampling of jpeg // Other formats don't have this attribute and ignore it. switch(params._subsampling) From bf66e615ffcbd96211cf0f3ae410a86a5181dc0c Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 14:07:12 +0200 Subject: [PATCH 04/11] oiio writer: fixed 'Orientation' metadata when write an output file * The orientation is an 'int' and starts with 1 (default). * Fixed order of 90clockwise (rotated top right) and transverse (rotated bottom left). --- .../io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp | 2 +- .../OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp | 2 +- .../io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp index c766d6860..ad265704a 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp @@ -65,8 +65,8 @@ static const std::string kParamOutputOrientationFlop = "flop"; static const std::string kParamOutputOrientationR180 = "180"; static const std::string kParamOutputOrientationFlip = "flip"; static const std::string kParamOutputOrientationTransposed = "transposed"; -static const std::string kParamOutputOrientationR90Clockwise = "90clockwise"; static const std::string kParamOutputOrientationTransverse = "transverse"; +static const std::string kParamOutputOrientationR90Clockwise = "90clockwise"; static const std::string kParamOutputOrientationR90CounterClockwise = "90counter-clockwise"; enum ETuttlePluginEndianness diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp index bc5adc901..8f85b814c 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp @@ -121,8 +121,8 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto orientation->appendOption(kParamOutputOrientationR180); orientation->appendOption(kParamOutputOrientationFlip); orientation->appendOption(kParamOutputOrientationTransposed); - orientation->appendOption(kParamOutputOrientationR90Clockwise); orientation->appendOption(kParamOutputOrientationTransverse); + orientation->appendOption(kParamOutputOrientationR90Clockwise); orientation->appendOption(kParamOutputOrientationR90CounterClockwise); orientation->setDefault(0); diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc index f423ff970..e2f381124 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc @@ -554,7 +554,7 @@ void OpenImageIOWriterProcess::writeImage(View& src, const std::string& fi spec.attribute("oiio:BitsPerSample", bitsPerSample); spec.attribute("oiio:UnassociatedAlpha", params._premultiply); spec.attribute("CompressionQuality", params._quality); - spec.attribute("Orientation", params._orientation); + spec.attribute("Orientation", params._orientation + 1); switch(params._endianness) { From 3eeba946ac656a8b7906494a8591a8834f8d314a Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 14:09:53 +0200 Subject: [PATCH 05/11] oiio writer: added description for each choices of output orientation --- .../src/writer/OpenImageIOWriterDefinitions.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp index ad265704a..16e4e7ed4 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp @@ -60,14 +60,14 @@ static const std::string kParamOutputSubsampling444 = "444"; static const std::string kParamOutputOrientation = "orientation"; static const std::string kParamOutputOrientationLabel = "Orientation"; -static const std::string kParamOutputOrientationNormal = "normal"; -static const std::string kParamOutputOrientationFlop = "flop"; -static const std::string kParamOutputOrientationR180 = "180"; -static const std::string kParamOutputOrientationFlip = "flip"; -static const std::string kParamOutputOrientationTransposed = "transposed"; -static const std::string kParamOutputOrientationTransverse = "transverse"; -static const std::string kParamOutputOrientationR90Clockwise = "90clockwise"; -static const std::string kParamOutputOrientationR90CounterClockwise = "90counter-clockwise"; +static const std::string kParamOutputOrientationNormal = "normal Oriented left to right, top to bottom"; +static const std::string kParamOutputOrientationFlop = "flop Oriented right to left, top to bottom"; +static const std::string kParamOutputOrientationR180 = "180 Oriented left to right, bottom to top"; +static const std::string kParamOutputOrientationFlip = "flip Oriented right to left, bottom to top"; +static const std::string kParamOutputOrientationTransposed = "transposed Oriented top to bottom, left to right"; +static const std::string kParamOutputOrientationTransverse = "transverse Oriented bottom to top, left to right"; +static const std::string kParamOutputOrientationR90Clockwise = "90clockwise Oriented top to bottom, right to left"; +static const std::string kParamOutputOrientationR90CounterClockwise = "90counter-clockwise Oriented bottom to top, right to left"; enum ETuttlePluginEndianness { From f2a1523ba92d6c0bcc49a6d5817994a0f47a1009 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 14:10:44 +0200 Subject: [PATCH 06/11] oiio writer: refactored how to set default value of subsampling and endianness Use enum value instead of hardcoded int. --- .../OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp index 8f85b814c..f5ecff0dd 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp @@ -112,7 +112,7 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto subsampling->appendOption(kParamOutputSubsampling422); subsampling->appendOption(kParamOutputSubsampling411); subsampling->appendOption(kParamOutputSubsampling444); - subsampling->setDefault(0); + subsampling->setDefault(eETuttlePluginSubsampling420); OFX::ChoiceParamDescriptor* orientation = desc.defineChoiceParam(kParamOutputOrientation); orientation->setLabel(kParamOutputOrientationLabel); @@ -131,7 +131,7 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto endianness->appendOption(kParamOutputEndiannessDefault); endianness->appendOption(kParamOutputEndiannessLittle); endianness->appendOption(kParamOutputEndiannessBig); - endianness->setDefault(0); + endianness->setDefault(eTuttlePluginEndiannessDefault); OFX::ChoiceParamDescriptor* compression = desc.defineChoiceParam(kParamOutputCompression); compression->setLabel(kParamOutputOrientationLabel); From de820d8ad1cdcd14e3c6e49802b19a07f9ffb72e Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 14:37:02 +0200 Subject: [PATCH 07/11] oiio writer: added hint to 'quality' and 'orientation' parameters And set the hint of the 'endianness' parameter. --- .../OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp | 6 +++++- .../src/writer/OpenImageIOWriterPluginFactory.cpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp index 16e4e7ed4..0afe79a13 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp @@ -35,6 +35,8 @@ enum ETuttlePluginComponents static const std::string kParamOutputQuality = "quality"; static const std::string kParamOutputQualityLabel = "Quality"; +static const std::string kParamOutputQualityHint = "Set the compression quality of the output file.\n" + "It could be ignored depending on the format.\n"; enum ETuttlePluginSubsampling { @@ -59,6 +61,8 @@ static const std::string kParamOutputSubsampling444 = "444"; static const std::string kParamOutputOrientation = "orientation"; static const std::string kParamOutputOrientationLabel = "Orientation"; +static const std::string kParamOutputOrientationHint = "Set the 'Orientation' metadata of the output file (does not update the pixel data).\n" + "It could be ignored depending on the format.\n"; static const std::string kParamOutputOrientationNormal = "normal Oriented left to right, top to bottom"; static const std::string kParamOutputOrientationFlop = "flop Oriented right to left, top to bottom"; @@ -77,7 +81,7 @@ enum ETuttlePluginEndianness }; static const std::string kParamOutputEndianness = "endianness"; -static const std::string kParamOutputEndiannessHint = "Endianness of the output."; +static const std::string kParamOutputEndiannessHint = "Set the endianness of the output file"; static const std::string kParamOutputEndiannessDefault = "default The default endianness choosen by oiio dependening on the platform."; static const std::string kParamOutputEndiannessLittle = "little Force to little endian."; static const std::string kParamOutputEndiannessBig = "big Force to big endian."; diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp index f5ecff0dd..696e5deb3 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp @@ -100,6 +100,7 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto bitDepth->setDefault(eTuttlePluginBitDepthAuto); OFX::IntParamDescriptor* quality = desc.defineIntParam(kParamOutputQuality); + quality->setHint(kParamOutputQualityHint); quality->setLabel(kParamOutputQualityLabel); quality->setRange(0, 100); quality->setDisplayRange(0, 100); @@ -115,6 +116,7 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto subsampling->setDefault(eETuttlePluginSubsampling420); OFX::ChoiceParamDescriptor* orientation = desc.defineChoiceParam(kParamOutputOrientation); + orientation->setHint(kParamOutputOrientationHint); orientation->setLabel(kParamOutputOrientationLabel); orientation->appendOption(kParamOutputOrientationNormal); orientation->appendOption(kParamOutputOrientationFlop); From f5112c1cea1b006eac0799f8c3725cfa8812a2fb Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 14:38:12 +0200 Subject: [PATCH 08/11] oiio writer: added 'project' and 'copyright' parameters * This feature exists in the dpxwriter. * I add this parameter in the oiiowriter to delete the dpxwriter plugin when all of its features will be available in oiio plugins. --- .../src/writer/OpenImageIOWriterDefinitions.hpp | 7 +++++++ .../io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp | 4 ++++ .../io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp | 4 ++++ .../src/writer/OpenImageIOWriterPluginFactory.cpp | 8 ++++++++ .../OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc | 3 +++ 5 files changed, 26 insertions(+) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp index 0afe79a13..eebb90155 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp @@ -73,6 +73,13 @@ static const std::string kParamOutputOrientationTransverse = "transverse Orien static const std::string kParamOutputOrientationR90Clockwise = "90clockwise Oriented top to bottom, right to left"; static const std::string kParamOutputOrientationR90CounterClockwise = "90counter-clockwise Oriented bottom to top, right to left"; +static const std::string kParamProject = "project"; +static const std::string kParamProjectHint = "Set the 'Project' metadata of the output file. \n" + "It could be ignored depending on the format.\n"; +static const std::string kParamCopyright = "copyright"; +static const std::string kParamCopyrightHint = "Set the 'Copyright' metadata of the output file. \n" + "It could be ignored depending on the format.\n"; + enum ETuttlePluginEndianness { eTuttlePluginEndiannessDefault = 0, diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp index d91476596..be830cfa4 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.cpp @@ -21,6 +21,8 @@ OpenImageIOWriterPlugin::OpenImageIOWriterPlugin(OfxImageEffectHandle handle) _quality = fetchIntParam(kParamOutputQuality); _paramSubsampling = fetchChoiceParam(kParamOutputSubsampling); _endianness = fetchChoiceParam(kParamOutputEndianness); + _project = fetchStringParam(kParamProject); + _copyright = fetchStringParam(kParamCopyright); } OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const OfxTime time) @@ -29,6 +31,8 @@ OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const O OpenImageIOWriterProcessParams params; params._filepath = getAbsoluteFilenameAt(time); + params._project = _project->getValue(); + params._copyright = _copyright->getValue(); params._components = static_cast(this->_components->getValue()); params._bitDepth = static_cast(this->_paramBitDepth->getValue()); params._subsampling = static_cast(_paramSubsampling->getValue()); diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp index 5d68d1796..9990c3c0d 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPlugin.hpp @@ -19,6 +19,8 @@ namespace writer struct OpenImageIOWriterProcessParams { std::string _filepath; ///< filepath + std::string _project; ///< project metadata + std::string _copyright; ///< copyright metadata ETuttlePluginComponents _components; ///< Force RGB ETuttlePluginBitDepth _bitDepth; ///< Output bit depth (real bit depth, not the buffer passed to OpenImageIO) ETuttlePluginSubsampling _subsampling; ///< Output subsampling @@ -46,6 +48,8 @@ class OpenImageIOWriterPlugin : public WriterPlugin OFX::IntParam* _quality; OFX::ChoiceParam* _paramSubsampling; OFX::ChoiceParam* _orientation; + OFX::StringParam* _project; + OFX::StringParam* _copyright; OFX::ChoiceParam* _endianness; }; } diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp index 696e5deb3..a9d09726c 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterPluginFactory.cpp @@ -128,6 +128,14 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto orientation->appendOption(kParamOutputOrientationR90CounterClockwise); orientation->setDefault(0); + OFX::StringParamDescriptor* project = desc.defineStringParam(kParamProject); + project->setHint(kParamProjectHint); + project->setDefault(""); + + OFX::StringParamDescriptor* copyright = desc.defineStringParam(kParamCopyright); + copyright->setHint(kParamCopyrightHint); + copyright->setDefault(""); + OFX::ChoiceParamDescriptor* endianness = desc.defineChoiceParam(kParamOutputEndianness); endianness->setHint(kParamOutputEndiannessHint); endianness->appendOption(kParamOutputEndiannessDefault); diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc index e2f381124..0e30b98f5 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc @@ -551,6 +551,9 @@ void OpenImageIOWriterProcess::writeImage(View& src, const std::string& fi strftime(buffer, 80,"%d-%m-%Y %I:%M:%S", timeinfo); spec.attribute("DateTime", std::string(buffer)); + spec.attribute("DocumentName", params._project); + spec.attribute("Copyright", params._copyright); + spec.attribute("oiio:BitsPerSample", bitsPerSample); spec.attribute("oiio:UnassociatedAlpha", params._premultiply); spec.attribute("CompressionQuality", params._quality); From 6b12d6a4d28c18afcc25363aa4b20672c99d0c37 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 15:00:32 +0200 Subject: [PATCH 09/11] plugins: removed Dpx writer plugin * Since oiio-1.4+, the library made a lot of improvements to write DPX images. * For these reasons, the dpx writer is not needed anymore. --- plugins/CMakeLists.txt | 1 - plugins/image/io/Dpx/CMakeLists.txt | 10 - .../io/Dpx/Resources/tuttle.dpxreader.png | Bin 674 -> 0 bytes .../io/Dpx/Resources/tuttle.dpxreader.svg | 84 - .../io/Dpx/Resources/tuttle.dpxwriter.png | Bin 1263 -> 0 bytes .../io/Dpx/Resources/tuttle.dpxwriter.svg | 84 - plugins/image/io/Dpx/Resources/tuttle.png | Bin 674 -> 0 bytes plugins/image/io/Dpx/Resources/tuttle.svg | 600 ----- .../libdpx/BaseTypeConverter.h | 199 -- .../Dpx/src/dpx-google-code/libdpx/Codec.cpp | 80 - .../io/Dpx/src/dpx-google-code/libdpx/Codec.h | 97 - .../io/Dpx/src/dpx-google-code/libdpx/DPX.cpp | 59 - .../io/Dpx/src/dpx-google-code/libdpx/DPX.h | 514 ---- .../src/dpx-google-code/libdpx/DPXHeader.cpp | 804 ------ .../src/dpx-google-code/libdpx/DPXHeader.h | 2282 ----------------- .../src/dpx-google-code/libdpx/DPXStream.h | 204 -- .../libdpx/ElementReadStream.cpp | 111 - .../libdpx/ElementReadStream.h | 66 - .../src/dpx-google-code/libdpx/EndianSwap.h | 152 -- .../src/dpx-google-code/libdpx/InStream.cpp | 111 - .../src/dpx-google-code/libdpx/Makefile.am | 29 - .../src/dpx-google-code/libdpx/OutStream.cpp | 99 - .../Dpx/src/dpx-google-code/libdpx/Reader.cpp | 225 -- .../dpx-google-code/libdpx/ReaderInternal.h | 584 ----- .../libdpx/RunLengthEncoding.cpp | 160 -- .../libdpx/RunLengthEncoding.h | 95 - .../src/dpx-google-code/libdpx/TestFunc.cpp | 38 - .../Dpx/src/dpx-google-code/libdpx/TestFunc.h | 48 - .../Dpx/src/dpx-google-code/libdpx/Writer.cpp | 408 --- .../dpx-google-code/libdpx/WriterInternal.h | 443 ---- plugins/image/io/Dpx/src/mainEntry.cpp | 16 - .../io/Dpx/src/writer/DPXWriterAlgorithm.hpp | 318 --- .../Dpx/src/writer/DPXWriterDefinitions.hpp | 117 - .../io/Dpx/src/writer/DPXWriterPlugin.cpp | 726 ------ .../io/Dpx/src/writer/DPXWriterPlugin.hpp | 67 - .../Dpx/src/writer/DPXWriterPluginFactory.cpp | 203 -- .../Dpx/src/writer/DPXWriterPluginFactory.hpp | 22 - .../io/Dpx/src/writer/DPXWriterProcess.hpp | 48 - .../io/Dpx/src/writer/DPXWriterProcess.tcc | 263 -- plugins/image/io/Dpx/tests/plugin_io_dpx.cpp | 20 - 40 files changed, 9387 deletions(-) delete mode 100644 plugins/image/io/Dpx/CMakeLists.txt delete mode 100644 plugins/image/io/Dpx/Resources/tuttle.dpxreader.png delete mode 100644 plugins/image/io/Dpx/Resources/tuttle.dpxreader.svg delete mode 100644 plugins/image/io/Dpx/Resources/tuttle.dpxwriter.png delete mode 100644 plugins/image/io/Dpx/Resources/tuttle.dpxwriter.svg delete mode 100644 plugins/image/io/Dpx/Resources/tuttle.png delete mode 100644 plugins/image/io/Dpx/Resources/tuttle.svg delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/BaseTypeConverter.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.h delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXStream.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.h delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/EndianSwap.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/InStream.cpp delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/Makefile.am delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/OutStream.cpp delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/Reader.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/ReaderInternal.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.h delete mode 100644 plugins/image/io/Dpx/src/dpx-google-code/libdpx/Writer.cpp delete mode 100755 plugins/image/io/Dpx/src/dpx-google-code/libdpx/WriterInternal.h delete mode 100644 plugins/image/io/Dpx/src/mainEntry.cpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterAlgorithm.hpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterDefinitions.hpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterPlugin.cpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterPlugin.hpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.cpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.hpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterProcess.hpp delete mode 100644 plugins/image/io/Dpx/src/writer/DPXWriterProcess.tcc delete mode 100644 plugins/image/io/Dpx/tests/plugin_io_dpx.cpp diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 37cabae8b..a34eef123 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(image/generator/Constant) add_subdirectory(image/generator/Ramp) add_subdirectory(image/generator/SeExpr) add_subdirectory(image/generator/Text) -add_subdirectory(image/io/Dpx) add_subdirectory(image/io/Exr) add_subdirectory(image/io/ImageMagick) add_subdirectory(image/io/Jpeg) diff --git a/plugins/image/io/Dpx/CMakeLists.txt b/plugins/image/io/Dpx/CMakeLists.txt deleted file mode 100644 index 96f3d3a4e..000000000 --- a/plugins/image/io/Dpx/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Macros used to create an openfx plugin with tuttle -include(TuttleMacros) - -tuttle_ofx_plugin_target(Dpx) - -# Add include of dpx-google-code only to DPX plugin -target_include_directories(Dpx PUBLIC "src/dpx-google-code") - -# Add external libraries -tuttle_ofx_plugin_add_libraries(Dpx sequenceParser) diff --git a/plugins/image/io/Dpx/Resources/tuttle.dpxreader.png b/plugins/image/io/Dpx/Resources/tuttle.dpxreader.png deleted file mode 100644 index 42f62c1fe691432badec9c020dc61191a4c9d8c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 674 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|*pj^6T^L?5 zyk)TOspdKl6yYrJh%9Dc;1&j9Muu5)B!GhKC7!;n?6+9tcujfV<=fo_3Q3l@MwB?` z=jNv7l`uFLr6!i7rYMwWmSiZnd-?{1H}Z)Ct@`Wf;uunK>+Nj&b%zXij@@0Q{(?7R zhl6-nl|bI1BfeD=%2FRP#qMBK&c6R)iu(Rly?6g8ub8hI!s#UQ|IbxVXN`^wrM;qG zWS8}=R8o>U)|U5u`PRhx%8TZax36A1zkWIM-2VP}hG)Gy@4oZjHIGkej=;>0g;vJj zmfom%e%Zh*DgF6lWiPd)m44E}OJDYAJ4j!+^&t0VMDQ)Kj$`Ym{H!-U@a)d@9|}GF zs`1NY^Y2fNzq|2h%AXKB#z^Ch1{Kk^8&iE=UuKP(xyi`e@mSEpS7H-1cAuKazBJH5 zgCpu{h~j%~U)~7rqRdl97m~G-iv{mQF*|7-Sjy({(L&tudd>%)+ady&(!*Q>b{*gP z`P+4-3DcI&pT)X>;rdJ0UAwd#qIhz@u4Y^Cwjupe*;EmOd}ZCqv46dcZ{EMW;7Vb~ z@`I)Z8|Sf^8cvNm#dBkt_}A&zlN5p;ys>WWj$a$(wRVfGnK74ARdtQ|iCxLLvOy}h zgy+aGy4>&d+Ie#3(`VUJ1sJx*>e|UHy;tMAOMb#)MqsQF0}j~be7ElxpULuPW1*X^ zyup9tY2O~0FVdQ&MBb@04WXyasU7T diff --git a/plugins/image/io/Dpx/Resources/tuttle.dpxreader.svg b/plugins/image/io/Dpx/Resources/tuttle.dpxreader.svg deleted file mode 100644 index ea543fbee..000000000 --- a/plugins/image/io/Dpx/Resources/tuttle.dpxreader.svg +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/image/io/Dpx/Resources/tuttle.dpxwriter.png b/plugins/image/io/Dpx/Resources/tuttle.dpxwriter.png deleted file mode 100644 index 7fa489c0fe615ddfa1d1f8dae1de37c8ed858dcd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1263 zcmVM8$}SF`)$W|Vz+h^3K1d&siN<^An_F5_&0!O z)Rzj0@&v6^_10 zg~*Nh4_Qv0^%;Z#{w#!k|1X#ZQ;;@Dp6+HDfFwzvR;z(y+w7a5d4<3CPl}Rf7-tVSvZMG^9)A0BAQf8V&LJ zVG9{>Z3|Y_U^M`ViOHx#!ZB013K_`6*9ZV_uqB#YC@zDZ2d0D?f6(P|tQ3#a@s(2L z01}P3@xh-TA45^onUU7wF%q&o*g97OmE=lL4uFOcKDoWQ{=CRE|L5o=qZ!D84eqm0 z(TY!}fpk-G0x@+f4Xgl&tX`6`UHUODLTUZqH4rBXBHE6TT3rHJy|_6BfHj~JeTEX? z(^0ITcRZGj$IvMk;Sv)L>kUjP&dLt6R- zyYa=Bbgatf8{D{glU698=svQ`7Y~CniEsL{qWLobmqjQA_hgE!!xHWaYvFXB9A-fFUE*Y87hrIt&Mc0u2-(v~0T& zKomz11c4+VD@>5(9wI1v4m741bguyr;G&{9J{<$#x*U9p55;jL|g$=_H zfzf=j5U4rdp6zxU`u#o_*fcf*z=O+|E`3m`*1o|~wbT1m=)U#UEdfQHwk8G7iBS9~ z3|T7zz%osq?{>Q^UTjrN8wdl&ql1G#H#RoD-hSocXL!RJi!cf~kv-Q!YQ;po(4Rhx zD7a`UT{6*-j6*c%v3CUk-TC)uH2Mye-|{@~A`$TRl`GZ{4<78euIssuZ~ diff --git a/plugins/image/io/Dpx/Resources/tuttle.dpxwriter.svg b/plugins/image/io/Dpx/Resources/tuttle.dpxwriter.svg deleted file mode 100644 index ea543fbee..000000000 --- a/plugins/image/io/Dpx/Resources/tuttle.dpxwriter.svg +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/image/io/Dpx/Resources/tuttle.png b/plugins/image/io/Dpx/Resources/tuttle.png deleted file mode 100644 index 42f62c1fe691432badec9c020dc61191a4c9d8c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 674 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|*pj^6T^L?5 zyk)TOspdKl6yYrJh%9Dc;1&j9Muu5)B!GhKC7!;n?6+9tcujfV<=fo_3Q3l@MwB?` z=jNv7l`uFLr6!i7rYMwWmSiZnd-?{1H}Z)Ct@`Wf;uunK>+Nj&b%zXij@@0Q{(?7R zhl6-nl|bI1BfeD=%2FRP#qMBK&c6R)iu(Rly?6g8ub8hI!s#UQ|IbxVXN`^wrM;qG zWS8}=R8o>U)|U5u`PRhx%8TZax36A1zkWIM-2VP}hG)Gy@4oZjHIGkej=;>0g;vJj zmfom%e%Zh*DgF6lWiPd)m44E}OJDYAJ4j!+^&t0VMDQ)Kj$`Ym{H!-U@a)d@9|}GF zs`1NY^Y2fNzq|2h%AXKB#z^Ch1{Kk^8&iE=UuKP(xyi`e@mSEpS7H-1cAuKazBJH5 zgCpu{h~j%~U)~7rqRdl97m~G-iv{mQF*|7-Sjy({(L&tudd>%)+ady&(!*Q>b{*gP z`P+4-3DcI&pT)X>;rdJ0UAwd#qIhz@u4Y^Cwjupe*;EmOd}ZCqv46dcZ{EMW;7Vb~ z@`I)Z8|Sf^8cvNm#dBkt_}A&zlN5p;ys>WWj$a$(wRVfGnK74ARdtQ|iCxLLvOy}h zgy+aGy4>&d+Ie#3(`VUJ1sJx*>e|UHy;tMAOMb#)MqsQF0}j~be7ElxpULuPW1*X^ zyup9tY2O~0FVdQ&MBb@04WXyasU7T diff --git a/plugins/image/io/Dpx/Resources/tuttle.svg b/plugins/image/io/Dpx/Resources/tuttle.svg deleted file mode 100644 index 97afbfbd4..000000000 --- a/plugins/image/io/Dpx/Resources/tuttle.svg +++ /dev/null @@ -1,600 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/BaseTypeConverter.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/BaseTypeConverter.h deleted file mode 100755 index a963b1d23..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/BaseTypeConverter.h +++ /dev/null @@ -1,199 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_BASETYPECONVERTER_H -#define _DPX_BASETYPECONVERTER_H 1 - - -namespace dpx -{ - // convert between all of the DPX base types in a controllable way - - // Note: These bit depth promotions (low precision -> high) use - // a combination of bitshift and the 'or' operator in order to - // fully populate the output coding space - // - // For example, when converting 8->16 bits, the 'simple' method - // (shifting 8 bits) maps 255 to 65280. This result is not ideal - // (uint16 'max' of 65535 is preferable). Overall, the best conversion - // is one that approximates the 'true' floating-point scale factor. - // 8->16 : 65535.0 / 255.0. 10->16 : 65535.0 / 1023.0. - // For performance considerations, we choose to emulate this - // floating-poing scaling with pure integer math, using a trick - // where we duplicate portions of the MSB in the LSB. - // - // For bit depth demotions, simple truncation is used. - // - - inline void BaseTypeConverter(U8 &src, U8 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U8 &src, U16 &dst) - { - dst = (src << 8) | src; - } - - inline void BaseTypeConverter(U8 &src, U32 &dst) - { - dst = (src << 24) | (src << 16) | (src << 8) | src; - } - - inline void BaseTypeConverter(U8 &src, R32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U8 &src, R64 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U16 &src, U8 &dst) - { - dst = src >> 8; - } - - inline void BaseTypeConverter(U16 &src, U16 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U16 &src, U32 &dst) - { - dst = (src << 16) | src; - } - - inline void BaseTypeConverter(U16 &src, R32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U16 &src, R64 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U32 &src, U8 &dst) - { - dst = src >> 24; - } - - inline void BaseTypeConverter(U32 &src, U16 &dst) - { - dst = src >> 16; - } - - inline void BaseTypeConverter(U32 &src, U32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U32 &src, R32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(U32 &src, R64 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R32 &src, U8 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R32 &src, U16 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R32 &src, U32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R32 &src, R32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R32 &src, R64 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R64 &src, U8 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R64 &src, U16 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R64 &src, U32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R64 &src, R32 &dst) - { - dst = src; - } - - inline void BaseTypeConverter(R64 &src, R64 &dst) - { - dst = src; - } - - inline void BaseTypeConvertU10ToU16(U16 &src, U16 &dst) - { - dst = (src << 6) | (src >> 4); - } - - inline void BaseTypeConvertU12ToU16(U16 &src, U16 &dst) - { - dst = (src << 4) | (src >> 8); - } - -} - -#endif - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.cpp deleted file mode 100644 index 42eb0330d..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "DPX.h" -#include "Codec.h" -#include "ElementReadStream.h" -#include "ReaderInternal.h" - -dpx::Codec::Codec() - : scanline(0) -{ -} - -dpx::Codec::~Codec() -{ - if(this->scanline) - delete[] scanline; -} - -void dpx::Codec::Reset() -{ - if(this->scanline) - { - delete[] scanline; - this->scanline = 0; - } -} - -bool dpx::Codec::Read(const Header& dpxHeader, ElementReadStream* fd, const int element, const Block& block, void* data, - const DataSize size) -{ - // scanline buffer - if(this->scanline == 0) - { - // get the number of components for this element descriptor - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - - // bit depth of the image element - const int bitDepth = dpxHeader.BitDepth(element); - - // size of the scanline buffer is image width * number of components * bytes per component - int slsize = ((numberOfComponents * dpxHeader.Width() * (bitDepth / 8 + (bitDepth % 8 ? 1 : 0))) / sizeof(U32)) + 1; - - this->scanline = new U32[slsize]; - } - - // read the image block - return ReadImageBlock(dpxHeader, this->scanline, fd, element, block, data, size); -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.h deleted file mode 100755 index 1372f0832..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Codec.h +++ /dev/null @@ -1,97 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_CODEC_H -#define _DPX_CODEC_H 1 - - -#include "DPX.h" - - -namespace dpx -{ - - /*! - * \brief compress / decompress data segments - * base class defaults to None - */ - class Codec - { - public: - /*! - * \brief constructor - */ - Codec(); - - /*! - * \brief destructor - */ - virtual ~Codec(); - - /*! - * \brief reset instance - */ - virtual void Reset(); - - /*! - * \brief read data - * \param dpxHeader dpx header information - * \param fd field descriptor - * \param element element (0-7) - * \param block image area to read - * \param data buffer - * \param size size of the buffer component - * \return success - */ - virtual bool Read(const Header &dpxHeader, - ElementReadStream *fd, - const int element, - const Block &block, - void *data, - const DataSize size); - - protected: - U32 *scanline; //!< single scanline - - - }; - - -} - - -#endif - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.cpp deleted file mode 100644 index 85b64cb44..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "DPX.h" - -// determine byte order for current system -// Intel processors are Little Endian -// Power PC, MIPS and Ultra Sparc are Big Endian -static unsigned long lValue = 0x12345678; -static unsigned long* lPtr = &lValue; -dpx::Endian dpx::systemByteOrder = (*(unsigned char*)lPtr == 0x78 ? dpx::kLittleEndian : dpx::kBigEndian); - -bool dpx::IdentifyFile(InStream* fp) -{ - U32 magic; - - fp->Rewind(); - - if(fp->Read(&magic, sizeof(magic)) != sizeof(magic)) - return false; - - return dpx::Header::ValidMagicCookie(magic); -} - -bool dpx::IdentifyFile(const void* p) -{ - U32 magic = *((U32*)p); - return dpx::Header::ValidMagicCookie(magic); -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.h deleted file mode 100755 index 0bbf2a0d0..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPX.h +++ /dev/null @@ -1,514 +0,0 @@ -// vi: ts=4 - -/*! \file DPX.h */ - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_H -#define _DPX_H 1 - -#include -#include - -#include "DPXHeader.h" -#include "DPXStream.h" - - -/*! - * \def OPENDPX_VERSION - * \brief OpenDPX Version - */ -#define OPENDPX_VERSION "0.5.0" - - - - -/*! - * \namespace dpx - * \brief OpenDPX namespace - */ -namespace dpx -{ - // forward definitions - class Codec; - class ElementReadStream; - - /*! - * \enum Endian - * \brief DPX files can be stored in big- or little-endian byte order - */ - enum Endian - { - kLittleEndian, //!< increasing numeric significance with increasing memory - kBigEndian //!< big end first - }; - - - /*! \struct Block - * \brief Rectangle block definition defined by two points - */ - struct Block - { - int x1, y1, x2, y2; - - /*! - * \brief Constructor - */ - inline Block(); - - /*! - * \brief Constructor - * - * \param x1 upper left x coordinate - * \param y1 upper left y coordinate - * \param x2 lower right x coordinate - * \param y2 lower right y coordinate - */ - Block(const int x1, const int y1, const int x2, const int y2); - - /*! - * \brief Set the block coordinates - * - * \param x1 upper left x coordinate - * \param y1 upper left y coordinate - * \param x2 lower right x coordinate - * \param y2 lower right y coordinate - */ - void Set(const int x1, const int y1, const int x2, const int y2); - - /*! - * \brief Check to see if a point is within the block - * - * \param x x coordinate - * \param y y coordinate - * \return true/false if coordinates within block - */ - inline bool Inside(const int x, const int y) const; - - /*! - * \brief Rearrange coordinates if necessary so the first coordinate is upper left and the second is lower right - */ - inline void Check(); - }; - - - // Current platform endian byte order - extern Endian systemByteOrder; - - // namespace functions - - /*! - * \brief determine if the image file is DPX - * - * \param file buffer to read and search - * \return true/false if identified as DPX - */ - bool IdentifyFile(InStream *file); - - /*! - * \brief determine if the image file is DPX - * - * \param data memory to search - * \return true/false if identified as DPX - */ - bool IdentifyFile(const void *data); - - /*! - * \brief returns a char * of the default DPX file extension - * - * \return .dpx file extenion - */ - inline const char *DefaultExtension(); - - /*! - * returns a string of the highest SMPTE DPX version supported by this library - * - * \return SMPTE DPX version - */ - inline const char *Version(); - - - /*! - * \brief returns the version string for this library - * - * \return OpenDPX version - */ - inline const char *LibraryVersion(); - - - - - - /*! - * \class Reader - * \brief DPX Image Reader class - */ - - class Reader - { - - public: - - /*! - * \brief DPX header - */ - Header header; - - /*! - * \brief Constructor - */ - Reader(); - - /*! - * \brief Destructor - */ - virtual ~Reader(); - - /*! - * \brief Set the InStream object to be used to read images - * - * \param stream Object to use for low level reads - */ - void SetInStream(InStream *stream); - - /*! - * \brief clear any caching or memory allocated specific to an image - */ - void Reset(); - - /*! - * \brief Read the dpx header into the header member - * - * \return success true/false - */ - bool ReadHeader(); - - /*! - * \brief Read an image element into a buffer - * - * the size of the buffer must be large enough - * simple calculation would be: - * width * height * num_of_components * size_of_component - * - * \param element element (0-7) - * \param data buffer - * \return success true/false - */ - bool ReadImage(const int element, void *data); - - /*! - * \brief Read an image element into a buffer that matches the image description type - * - * The DataSize allows the user to specific the buffer DataSize which can differ - * from the image element. It is possible, for example, to read an 8-bit per - * component (3 components per pixel for RGB) into 16-bits. - * - * \param data buffer - * \param size size of the buffer component - * \param desc element description type - * \return success true/false - */ - bool ReadImage(void *data, const DataSize size = kWord, - const Descriptor desc = kRGB); - - /*! - * \brief Read a rectangular image block into a buffer from the specified image element - * - * \param element element (0-7) - * \param data buffer - * \param block image area to read - * \return success true/false - */ - bool ReadBlock(const int element, unsigned char *data, Block &block); - - /*! - * \brief Read a rectangular image block into a buffer from the image element - * specified by the Descriptor type - * - * \param data buffer - * \param size size of the buffer component - * \param block image area to read - * \param desc element description type - * \return success true/false - */ - bool ReadBlock(void *data, const DataSize size, Block &block, - const Descriptor desc = kRGB); - - /*! - * \brief Read the user data into a buffer. - * - * Buffer must be large enough to hold the user data. - * - * \param data buffer - * \return success true/false - */ - bool ReadUserData(unsigned char *data); - - - protected: - InStream *fd; - - Codec *codex[MAX_ELEMENTS]; - ElementReadStream *rio; - }; - - - - - - - - - - /*! - * \class Writer - * \brief DPX Image Writer class - */ - - class Writer - { - - public: - - /*! - * \brief DPX Header - */ - Header header; - - /*! - * \brief Constructor - */ - Writer(); - - /*! - * \brief Destructor - */ - virtual ~Writer(); - - /*! - * \brief Start defining the header and writing the images - */ - void Start(); - - /*! - * \brief Set the basic file information about DPX - * - * \param fileName name of this created file (100 characters max) - * \param creationTimeDate creation time and date - format is "YYYY:MM:DD:HH:MM:SSLTZ" - * where HH is 24 hour time, LTZ is local time zone using either - * three character notation (i.e., -04) or five character notation - * representing hours and minutes offset from Greenwich Mean time - * (i.e., -0700) (24 characters max) - * \param creator creator (100 characters max) - * \param project project name (200 characters max) - * \param copyright copyright statement (200 characters max) - * \param encryptKey encryption key - * \param swapEndian whether to write the image header in reverse to native endianness - */ - void SetFileInfo(const char *fileName, const char *creationTimeDate = 0, const char *creator = 0, - const char *project = 0, const char *copyright = 0, const U32 encryptKey = ~0, - const bool swapEndian = false); - - /*! - * \brief Set the Width and Height of the images - * - * \param width width of the image - * \param height height of the image - */ - void SetImageInfo(const U32 width, const U32 height); - - /*! - * \brief Get the next available element - * \return next available - */ - int NextAvailElement() const; - - - /*! - * \brief Set the parameters on an element - * - * There are 8 elements maximum in an single DPX and each element used must be set before writing the header - * - * \param element element number (0-7) - * \param desc image descriptor - * \param bitDepth bit depth of image, valid values are [8,10,12,16,32,64] - * \param transfer transfer characteristic - * \param colorimetric colorimetric specification - * \param packing packing type - * \param encoding encoding type - * \param dataSign - * \param lowData - * \param lowQuantity - * \param highData - * \param highQuantity - * \param eolnPadding end of line padding (in bytes) - * \param eoimPadding end of image padding (in bytes) - */ - void SetElement(const int element = 0, - const Descriptor desc = kRGB, - const U8 bitDepth = 10, - const Characteristic transfer = kLogarithmic, - const Characteristic colorimetric = kLogarithmic, - const Packing packing = kFilledMethodA, - const Encoding encoding = kNone, - const U32 dataSign = 0, - const U32 lowData = ~0, const R32 lowQuantity = std::numeric_limits::quiet_NaN(), - const U32 highData = ~0, const R32 highQuantity = std::numeric_limits::quiet_NaN(), - const U32 eolnPadding = 0, const U32 eoimPadding = 0); - - /*! - * \brief Set the OutStream object will use to write the files - * - * \param stream OutStream object - */ - void SetOutStream(OutStream *stream); - - /*! - * \brief Set the size of the user data area - * - * \param size size of user data - */ - void SetUserData(const long size); - - /*! - * \brief Write the header - * - * \return success true/false - */ - bool WriteHeader(); - - /*! - * \brief Write the user data - * - * \param data buffer - must match size set in Writer::SetUserData() - * \return success true/false - */ - bool WriteUserData(void *data); - - /*! - * \brief Write the entire element to the dpx file - * - * \param element element number (0-7) - * \param data buffer - * \return success true/false - */ - bool WriteElement(const int element, void *data); - bool WriteElement(const int element, void *data, const DataSize size); - bool WriteElement(const int element, void *data, const long count); - - /** - * \brief Finish up writing image - * - * \return success true/false - */ - bool Finish(); - - - protected: - long fileLoc; - OutStream *fd; - - bool WriteThrough(void *, const U32, const U32, const int, const int, const U32, const U32, char *); - - }; - -} - - - -inline const char *dpx::DefaultExtension() -{ - return "dpx"; -} - - -inline const char *dpx::Version() -{ - return SMPTE_VERSION; -} - - -inline const char *dpx::LibraryVersion() -{ - return OPENDPX_VERSION; -} - - -inline dpx::Block::Block() : x1(0), y1(0), x2(0), y2(0) -{ -} - - -inline dpx::Block::Block(const int x1, const int y1, const int x2, const int y2) : x1(x1), y1(y1), x2(x2), y2(y2) -{ - this->Check(); -} - - -inline void dpx::Block::Set(const int x1, const int y1, const int x2, const int y2) -{ - this->x1 = x1; - this->y1 = y1; - this->x2 = x2; - this->y2 = y2; -} - - -// check the coordinates that x1 < x2 and y1 < y2 -inline void dpx::Block::Check() -{ - if (this->x1 > this->x2) - { - int t = x1; - this->x1 = this->x2; - this->x2 = t; - } - if (this->y1 > this->y2) - { - int t = y1; - this->y1 = this->y2; - this->y2 = t; - } -} - - -inline bool dpx::Block::Inside(const int x, const int y) const -{ - if (x >= this->x1 && x <= this->x2 && y >= this->y1 && y <= this->y2) - return true; - return false; -} - - -#endif - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.cpp deleted file mode 100644 index 8c17a91ed..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.cpp +++ /dev/null @@ -1,804 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "DPXHeader.h" -#include "EndianSwap.h" - -// function prototypes -static void EmptyString(char*, const int); - -char Hex(char x) -{ - if(x >= 10) - return (x - 10 + 'A'); - else - return (x + '0'); -} - -dpx::Header::Header() - : GenericHeader() - , IndustryHeader() - , datumSwap(true) -{ -} - -dpx::GenericHeader::GenericHeader() -{ - this->Reset(); -} - -void dpx::GenericHeader::Reset() -{ - // File Information - this->magicNumber = MAGIC_COOKIE; - this->imageOffset = ~0; - EmptyString(this->version, 8); - ::strcpy(this->version, SMPTE_VERSION); - fileSize = sizeof(dpx::Header); - this->dittoKey = 1; // new - - // genericSize is the size of the file/image/orientation headers - // sizeof(dpx::GenericHeader) won't give the correct results because - // of compiler padding - // file header is 768 bytes - // image header is 640 bytes - // orientation header 256 bytes - - this->genericSize = 768 + 640 + 256; - - // industrySize is the size of the motion picture/television headers - // motion picture header is 256 bytes - // television header is 128 bytes - this->industrySize = 256 + 128; - - this->userSize = 0; - EmptyString(this->fileName, 100); - EmptyString(this->creationTimeDate, 24); - EmptyString(this->creator, 100); - EmptyString(this->project, 200); - EmptyString(this->copyright, 200); - this->encryptKey = 0xffffffff; - EmptyString(this->reserved1, 104); - - // Image Information - this->imageOrientation = kUndefinedOrientation; - this->numberOfElements = 0xffff; - this->pixelsPerLine = this->linesPerElement = 0xffffffff; - EmptyString(this->reserved2, 52); - - // Image Orientation - this->xOffset = this->yOffset = 0xffffffff; - this->xCenter = this->yCenter = std::numeric_limits::quiet_NaN(); - this->xOriginalSize = this->yOriginalSize = 0xffffffff; - EmptyString(this->sourceImageFileName, 100); - EmptyString(this->sourceTimeDate, 24); - EmptyString(this->inputDevice, 32); - EmptyString(this->inputDeviceSerialNumber, 32); - this->border[0] = this->border[1] = this->border[2] = this->border[3] = 0xffff; - this->aspectRatio[0] = this->aspectRatio[1] = 0xffffffff; - this->xScannedSize = this->yScannedSize = std::numeric_limits::quiet_NaN(); - EmptyString(this->reserved3, 28); -} - -dpx::IndustryHeader::IndustryHeader() -{ - this->Reset(); -} - -void dpx::IndustryHeader::Reset() -{ - // Motion Picture Industry Specific - EmptyString(this->filmManufacturingIdCode, 2); - EmptyString(this->filmType, 2); - EmptyString(this->perfsOffset, 2); - EmptyString(this->prefix, 6); - EmptyString(this->count, 4); - EmptyString(this->format, 32); - this->framePosition = this->sequenceLength = this->heldCount = 0xffffffff; - this->frameRate = this->shutterAngle = std::numeric_limits::quiet_NaN(); - EmptyString(this->frameId, 32); - EmptyString(this->slateInfo, 200); - EmptyString(this->reserved4, 56); - - // Television Industry Specific - this->timeCode = this->userBits = 0xffffffff; - this->interlace = this->fieldNumber = 0xff; - this->videoSignal = kUndefined; - this->zero = 0xff; - this->horizontalSampleRate = this->verticalSampleRate = this->temporalFrameRate = - std::numeric_limits::quiet_NaN(); - this->timeOffset = this->gamma = std::numeric_limits::quiet_NaN(); - this->blackLevel = this->blackGain = std::numeric_limits::quiet_NaN(); - this->breakPoint = this->whiteLevel = this->integrationTimes = std::numeric_limits::quiet_NaN(); - EmptyString(this->reserved5, 76); -} - -dpx::ImageElement::ImageElement() -{ - this->dataSign = 0xffffffff; - this->lowData = 0xffffffff; - this->lowQuantity = 0xffffffff; - this->highData = 0xffffffff; - this->highQuantity = 0xffffffff; - this->descriptor = kUndefinedDescriptor; - this->transfer = kUndefinedCharacteristic; - this->colorimetric = kUndefinedCharacteristic; - this->bitDepth = 0xff; - this->packing = this->encoding = 0xffff; - this->dataOffset = this->endOfLinePadding = this->endOfImagePadding = 0xffffffff; - EmptyString(this->description, 32); -} - -bool dpx::Header::Read(InStream* io) -{ - // rewind file - io->Rewind(); - - // read in the header from the file - size_t r = sizeof(GenericHeader) + sizeof(IndustryHeader); - if(io->Read(&(this->magicNumber), r) != r) - return false; - - // validate - return this->Validate(); -} - -// Check to see if the compiler placed the data members in the expected memory offsets - -bool dpx::Header::Check() -{ - // genericSize is the size of the file/image/orientation headers - // sizeof(dpx::GenericHeader) won't give the correct results because - // of compiler padding - // file header is 768 bytes - // image header is 640 bytes - // orientation header 256 bytes - - if(sizeof(GenericHeader) != (768 + 640 + 256)) - return false; - - // industrySize is the size of the motion picture/television headers - // motion picture header is 256 bytes - // television header is 128 bytes - if(sizeof(IndustryHeader) != (256 + 128)) - return false; - - // data size checks - if(sizeof(U8) != 1 || sizeof(U16) != 2 || sizeof(U32) != 4 || sizeof(R32) != 4 || sizeof(R64) != 8) - return false; - - return true; -} - -bool dpx::Header::Write(OutStream* io) -{ - // validate and byte swap, if necessary - if(!this->Validate()) - return false; - - // write the header to the file - size_t r = sizeof(GenericHeader) + sizeof(IndustryHeader); - if(io->Write(&(this->magicNumber), r) != r) - return false; - - // swap back - data is in file, now we need it native again - this->Validate(); - return true; -} - -bool dpx::Header::WriteOffsetData(OutStream* io) -{ - // calculate the number of elements - this->CalculateNumberOfElements(); - - // write the image offset - const long FIELD2 = 4; // offset to image in header - if(io->Seek(FIELD2, OutStream::kStart) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->imageOffset); - if(io->Write(&this->imageOffset, sizeof(U32)) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->imageOffset); - - // write the file size - const long FIELD4 = 16; // offset to total image file size in header - if(io->Seek(FIELD4, OutStream::kStart) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->fileSize); - if(io->Write(&this->fileSize, sizeof(U32)) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->fileSize); - - // write the number of elements - const long FIELD19 = 770; // offset to number of image elements in header - if(io->Seek(FIELD19, OutStream::kStart) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->numberOfElements); - if(io->Write(&this->numberOfElements, sizeof(U16)) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->numberOfElements); - - // write the image offsets - const long FIELD21_12 = 808; // offset to image offset in image element data structure - const long IMAGE_STRUCTURE = 72; // sizeof the image data structure - - int i; - for(i = 0; i < MAX_ELEMENTS; i++) - { - // only write if there is a defined image description - if(this->chan[i].descriptor == kUndefinedDescriptor) - continue; - - // seek to the image offset entry in each image element - if(io->Seek((FIELD21_12 + (IMAGE_STRUCTURE * i)), OutStream::kStart) == false) - return false; - - // write - if(this->RequiresByteSwap()) - SwapBytes(this->chan[i].dataOffset); - if(io->Write(&this->chan[i].dataOffset, sizeof(U32)) == false) - return false; - if(this->RequiresByteSwap()) - SwapBytes(this->chan[i].dataOffset); - } - - return true; -} - -bool dpx::Header::ValidMagicCookie(const U32 magic) -{ - U32 mc = MAGIC_COOKIE; - - if(magic == mc) - return true; - else if(magic == SwapBytes(mc)) - return true; - else - return false; -} - -bool dpx::Header::DetermineByteSwap(const U32 magic) const -{ - U32 mc = MAGIC_COOKIE; - - bool byteSwap = false; - - if(magic != mc) - byteSwap = true; - - return byteSwap; -} - -bool dpx::Header::Validate() -{ - // check magic cookie - if(!this->ValidMagicCookie(this->magicNumber)) - return false; - - // determine if bytes needs to be swapped around - if(this->DetermineByteSwap(this->magicNumber)) - { - // File information - SwapBytes(this->imageOffset); - SwapBytes(this->fileSize); - SwapBytes(this->dittoKey); - SwapBytes(this->genericSize); - SwapBytes(this->industrySize); - SwapBytes(this->userSize); - SwapBytes(this->encryptKey); - - // Image information - SwapBytes(this->imageOrientation); - SwapBytes(this->numberOfElements); - SwapBytes(this->pixelsPerLine); - SwapBytes(this->linesPerElement); - for(int i = 0; i < MAX_ELEMENTS; i++) - { - SwapBytes(this->chan[i].dataSign); - SwapBytes(this->chan[i].lowData); - SwapBytes(this->chan[i].lowQuantity); - SwapBytes(this->chan[i].highData); - SwapBytes(this->chan[i].highQuantity); - SwapBytes(this->chan[i].descriptor); - SwapBytes(this->chan[i].transfer); - SwapBytes(this->chan[i].colorimetric); - SwapBytes(this->chan[i].bitDepth); - SwapBytes(this->chan[i].packing); - SwapBytes(this->chan[i].encoding); - SwapBytes(this->chan[i].dataOffset); - SwapBytes(this->chan[i].endOfLinePadding); - SwapBytes(this->chan[i].endOfImagePadding); - } - - // Image Origination information - SwapBytes(this->xOffset); - SwapBytes(this->yOffset); - SwapBytes(this->xCenter); - SwapBytes(this->yCenter); - SwapBytes(this->xOriginalSize); - SwapBytes(this->yOriginalSize); - SwapBytes(this->border[0]); - SwapBytes(this->border[1]); - SwapBytes(this->border[2]); - SwapBytes(this->border[3]); - SwapBytes(this->aspectRatio[0]); - SwapBytes(this->aspectRatio[1]); - - // Motion Picture Industry Specific - SwapBytes(this->framePosition); - SwapBytes(this->sequenceLength); - SwapBytes(this->heldCount); - SwapBytes(this->frameRate); - SwapBytes(this->shutterAngle); - - // Television Industry Specific - SwapBytes(this->timeCode); - SwapBytes(this->userBits); - SwapBytes(this->interlace); - SwapBytes(this->fieldNumber); - SwapBytes(this->videoSignal); - SwapBytes(this->zero); - SwapBytes(this->horizontalSampleRate); - SwapBytes(this->verticalSampleRate); - SwapBytes(this->temporalFrameRate); - SwapBytes(this->timeOffset); - SwapBytes(this->gamma); - SwapBytes(this->blackLevel); - SwapBytes(this->blackGain); - SwapBytes(this->breakPoint); - SwapBytes(this->whiteLevel); - SwapBytes(this->integrationTimes); - } - - return true; -} - -void dpx::Header::Reset() -{ - GenericHeader::Reset(); - IndustryHeader::Reset(); -} - -int dpx::GenericHeader::ImageElementComponentCount(const int element) const -{ - int count = 1; - - switch(this->chan[element].descriptor) - { - case kUserDefinedDescriptor: - case kRed: - case kGreen: - case kBlue: - case kAlpha: - case kLuma: - case kColorDifference: - case kDepth: - count = 1; - break; - case kCompositeVideo: - count = 1; - break; - case kRGB: - count = 3; - break; - case kRGBA: - case kABGR: - count = 4; - break; - case kCbYCrY: - count = 2; - break; - case kCbYACrYA: - count = 3; - break; - case kCbYCr: - count = 3; - break; - case kCbYCrA: - count = 4; - break; - case kUserDefined2Comp: - count = 2; - break; - case kUserDefined3Comp: - count = 3; - break; - case kUserDefined4Comp: - count = 4; - break; - case kUserDefined5Comp: - count = 5; - break; - case kUserDefined6Comp: - count = 6; - break; - case kUserDefined7Comp: - count = 7; - break; - case kUserDefined8Comp: - count = 8; - break; - }; - - return count; -} - -int dpx::GenericHeader::ImageElementCount() const -{ - if(this->numberOfElements > 0 && this->numberOfElements <= MAX_ELEMENTS) - return this->numberOfElements; - - // If the image header does not list a valid number of elements, - // count how many defined image descriptors we have... - - int i = 0; - - while(i < MAX_ELEMENTS) - { - if(this->ImageDescriptor(i) == kUndefinedDescriptor) - break; - i++; - } - - return i; -} - -void dpx::GenericHeader::CalculateNumberOfElements() -{ - this->numberOfElements = 0xffff; - int i = this->ImageElementCount(); - - if(i == 0) - this->numberOfElements = 0xffff; - else - this->numberOfElements = U16(i); -} - -void dpx::Header::CalculateOffsets() -{ - int i; - - for(i = 0; i < MAX_ELEMENTS; i++) - { - // only write if there is a defined image description - if(this->chan[i].descriptor == kUndefinedDescriptor) - continue; - } -} - -dpx::DataSize dpx::GenericHeader::ComponentDataSize(const int element) const -{ - if(element < 0 || element >= MAX_ELEMENTS) - return kByte; - - dpx::DataSize ret; - - switch(this->chan[element].bitDepth) - { - case 8: - ret = kByte; - break; - case 10: - case 12: - case 16: - ret = kWord; - break; - case 32: - ret = kFloat; - break; - case 64: - ret = kDouble; - break; - default: - assert(0 && "Unknown bit depth"); - ret = kDouble; - break; - } - - return ret; -} - -int dpx::GenericHeader::ComponentByteCount(const int element) const -{ - if(element < 0 || element >= MAX_ELEMENTS) - return kByte; - - int ret; - - switch(this->chan[element].bitDepth) - { - case 8: - ret = sizeof(U8); - break; - case 10: - case 12: - case 16: - ret = sizeof(U16); - break; - case 32: - ret = sizeof(R32); - break; - case 64: - ret = sizeof(R64); - break; - default: - assert(0 && "Unknown bit depth"); - ret = sizeof(R64); - break; - } - - return ret; -} - -int dpx::GenericHeader::DataSizeByteCount(const DataSize ds) -{ - - int ret; - - switch(ds) - { - case kByte: - ret = sizeof(U8); - break; - case kWord: - ret = sizeof(U16); - break; - case kInt: - ret = sizeof(U32); - break; - case kFloat: - ret = sizeof(R32); - break; - case kDouble: - ret = sizeof(R64); - break; - } - - return ret; -} - -void dpx::IndustryHeader::FilmEdgeCode(char* edge) const -{ - edge[0] = this->filmManufacturingIdCode[0]; - edge[1] = this->filmManufacturingIdCode[1]; - edge[2] = this->filmType[0]; - edge[3] = this->filmType[1]; - edge[4] = this->perfsOffset[0]; - edge[5] = this->perfsOffset[1]; - edge[6] = this->prefix[0]; - edge[7] = this->prefix[1]; - edge[8] = this->prefix[2]; - edge[9] = this->prefix[3]; - edge[10] = this->prefix[4]; - edge[11] = this->prefix[5]; - edge[12] = this->count[0]; - edge[13] = this->count[1]; - edge[14] = this->count[2]; - edge[15] = this->count[3]; - edge[16] = '\0'; -} - -void dpx::IndustryHeader::SetFileEdgeCode(const char* edge) -{ - this->filmManufacturingIdCode[0] = edge[0]; - this->filmManufacturingIdCode[1] = edge[1]; - this->filmType[0] = edge[2]; - this->filmType[1] = edge[3]; - this->perfsOffset[0] = edge[4]; - this->perfsOffset[1] = edge[5]; - this->prefix[0] = edge[6]; - this->prefix[1] = edge[7]; - this->prefix[2] = edge[8]; - this->prefix[3] = edge[9]; - this->prefix[4] = edge[10]; - this->prefix[5] = edge[11]; - this->count[0] = edge[12]; - this->count[1] = edge[13]; - this->count[2] = edge[14]; - this->count[3] = edge[15]; -} - -void dpx::IndustryHeader::TimeCode(char* str) const -{ - register U32 tc = this->timeCode; - ::sprintf(str, "%c%c:%c%c:%c%c:%c%c", Hex((tc & 0xf0000000) >> 28), Hex((tc & 0xf000000) >> 24), - Hex((tc & 0xf00000) >> 20), Hex((tc & 0xf0000) >> 16), Hex((tc & 0xf000) >> 12), Hex((tc & 0xf00) >> 8), - Hex((tc & 0xf0) >> 4), Hex(tc & 0xf)); -} - -void dpx::IndustryHeader::UserBits(char* str) const -{ - register U32 ub = this->userBits; - ::sprintf(str, "%c%c:%c%c:%c%c:%c%c", Hex((ub & 0xf0000000) >> 28), Hex((ub & 0xf000000) >> 24), - Hex((ub & 0xf00000) >> 20), Hex((ub & 0xf0000) >> 16), Hex((ub & 0xf000) >> 12), Hex((ub & 0xf00) >> 8), - Hex((ub & 0xf0) >> 4), Hex(ub & 0xf)); -} - -dpx::U32 dpx::IndustryHeader::TCFromString(const char* str) const -{ - // make sure the string is the correct length - if(::strlen(str) != 11) - return U32(~0); - - U32 tc = 0; - int i, idx; - U8 ch; - U32 value, mask; - - for(i = 0; i < 8; i++) - { - // determine string index skipping : - idx = i + ((i + 1) / 3); - ch = str[idx]; - - // error check - if(ch < '0' || ch > '9') - return 0xffffffff; - - value = U32(ch - '0') << (28 - (i * 4)); - mask = 0xf << (28 - (i * 4)); - - // mask in new value - tc = (tc & ~mask) | (value & mask); - } - - return tc; -} - -void dpx::IndustryHeader::SetTimeCode(const char* str) -{ - U32 tc = this->TCFromString(str); - if(tc != 0xffffffff) - this->timeCode = tc; -} - -void dpx::IndustryHeader::SetUserBits(const char* str) -{ - U32 ub = this->TCFromString(str); - if(ub != 0xffffffff) - this->timeCode = ub; -} - -static void EmptyString(char* str, const int len) -{ - for(int i = 0; i < len; i++) - str[i] = '\0'; -} - -void dpx::GenericHeader::SetCreationTimeDate(const long sec) -{ - struct tm* tm_time; - char str[32]; - -#ifdef WIN32 - _tzset(); -#endif - - const time_t t = time_t(sec); - tm_time = ::localtime(&t); - ::strftime(str, 32, "%Y:%m:%d:%H:%M:%S%Z", tm_time); - ::strncpy(this->creationTimeDate, str, 24); -} - -void dpx::GenericHeader::SetSourceTimeDate(const long sec) -{ - struct tm* tm_time; - char str[32]; - -#ifdef WIN32 - _tzset(); -#endif - - const time_t t = time_t(sec); - tm_time = ::localtime(&t); - ::strftime(str, 32, "%Y:%m:%d:%H:%M:%S%Z", tm_time); - ::strncpy(this->sourceTimeDate, str, 24); -} - -bool dpx::Header::DatumSwap(const int element) const -{ - if(this->datumSwap) - { - if(this->ImageDescriptor(element) == kRGB || this->ImageDescriptor(element) == kCbYCrY) - return true; - } - return false; -} - -void dpx::Header::SetDatumSwap(const bool swap) -{ - this->datumSwap = swap; -} - -// Height() -// this function determines the height of the image taking in account for the image orientation -// if an image is 1920x1080 but is oriented top to bottom, left to right then the height stored -// in the image is 1920 rather than 1080 - -dpx::U32 dpx::Header::Height() const -{ - U32 h; - - switch(this->ImageOrientation()) - { - case kTopToBottomLeftToRight: - case kTopToBottomRightToLeft: - case kBottomToTopLeftToRight: - case kBottomToTopRightToLeft: - h = this->PixelsPerLine(); - break; - default: - h = this->LinesPerElement(); - break; - } - - return h; -} - -// Width() -// this function determines the width of the image taking in account for the image orientation -// if an image is 1920x1080 but is oriented top to bottom, left to right then the width stored -// in the image is 1920 rather than 1080 - -dpx::U32 dpx::Header::Width() const -{ - U32 w; - - switch(this->ImageOrientation()) - { - case kTopToBottomLeftToRight: - case kTopToBottomRightToLeft: - case kBottomToTopLeftToRight: - case kBottomToTopRightToLeft: - w = this->LinesPerElement(); - break; - default: - w = this->PixelsPerLine(); - break; - } - - return w; -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.h deleted file mode 100755 index 1a36538e4..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXHeader.h +++ /dev/null @@ -1,2282 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/*! \file DPXHeader.h */ - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -// SMPTE DPX graphic file format v2.0 - - -#ifndef _DPX_DPXHEADER_H -#define _DPX_DPXHEADER_H 1 - -#include - -#include "DPXStream.h" - - - -/*! - * \def SMPTE_VERSION - * \brief SMPTE 268M-2003 DPX Version - */ -#define SMPTE_VERSION "V2.0" - -/*! - * \def MAX_ELEMENTS - * \brief Maximum number of image elements - */ -#define MAX_ELEMENTS 8 - -/*! - * \def MAX_COMPONENTS - * \brief Maximum number of components per image element - */ -#define MAX_COMPONENTS 8 - - -/*! - * \def MAGIC_COOKIE - * \brief HEX value of "SDPX" - */ -#define MAGIC_COOKIE 0x53445058 - - - - -namespace dpx -{ - - - // DPX data types - - /*! - * \typedef unsigned char U8 - * \brief Unsigned 8 bit integer - */ - typedef unsigned char U8; - - /*! - * \typedef unsigned char U16 - * \brief Unsigned 16 bit integer - */ - typedef unsigned short U16; - - /*! - * \typedef unsigned char U32 - * \brief Unsigned 32 bit integer - */ - typedef unsigned int U32; - - /*! - * \typedef float R32 - * \brief 32 bit floating point number - */ - typedef float R32; - - /*! - * \typedef float R64 - * \brief 64 bit floating point number - */ - typedef double R64; - - /*! - * \typedef char ASCII - * \brief ASCII character - */ - typedef char ASCII; - - - /*! - * \enum DataSize - * \brief Component Data Storage Data Type - */ - enum DataSize - { - kByte, //!< 8-bit size component - kWord, //!< - kInt, //!< - kFloat, //!< - kDouble //!< - }; - - - /*! - * \enum Orientation - * \brief Image Orientation Code - */ - enum Orientation - { - kLeftToRightTopToBottom = 0, //!< Oriented left to right, top to bottom - kRightToLeftTopToBottom = 1, //!< Oriented right to left, top to bottom - kLeftToRightBottomToTop = 2, //!< Oriented left to right, bottom to top - kRightToLeftBottomToTop = 3, //!< Oriented right to left, bottom to top - kTopToBottomLeftToRight = 4, //!< Oriented top to bottom, left to right - kTopToBottomRightToLeft = 5, //!< Oriented top to bottom, right to left - kBottomToTopLeftToRight = 6, //!< Oriented bottom to top, left to right - kBottomToTopRightToLeft = 7, //!< Oriented bottom to top, right to left - kUndefinedOrientation = 0xffff //!< Undefined orientation - }; - - - /*! - * \enum Descriptor - * \brief Image element Descriptor - */ - enum Descriptor - { - kUserDefinedDescriptor = 0, //!< User defined descriptor - kRed = 1, //!< Red - kGreen = 2, //!< Green - kBlue = 3, //!< Blue - kAlpha = 4, //!< Alpha - kLuma = 6, //!< Luma (Y) - kColorDifference = 7, //!< Color difference - kDepth = 8, //!< Depth - kCompositeVideo = 9, //!< Composite video - kRGB = 50, //!< R,G,B - kRGBA = 51, //!< R,G,B,A - kABGR = 52, //!< A,B,G,R - kCbYCrY = 100, //!< Cb,Y,Cr,Y (4:2:2) - kCbYACrYA = 101, //!< Cb,Y,A,Cr,Y,A (4:2:2:4) - kCbYCr = 102, //!< Cb,Y,Cr (4:4:4) - kCbYCrA = 103, //!< Cb,Y,Cr,A (4:4:4:4) - kUserDefined2Comp = 150, //!< User defined 2 component element - kUserDefined3Comp = 151, //!< User defined 3 component element - kUserDefined4Comp = 152, //!< User defined 4 component element - kUserDefined5Comp = 153, //!< User defined 5 component element - kUserDefined6Comp = 154, //!< User defined 6 component element - kUserDefined7Comp = 155, //!< User defined 7 component element - kUserDefined8Comp = 156, //!< User defined 8 component element - kUndefinedDescriptor = 0xff //!< Undefined descriptor - }; - - - /*! - * \enum Characteristic - * \brief Transfer Characteristic and Colorimetric Specification - */ - enum Characteristic - { - kUserDefined = 0, //!< User defined - kPrintingDensity, //!< Printing density - kLinear, //!< Linear, transfer only - kLogarithmic, //!< Logarithmic, transfer only - kUnspecifiedVideo, //!< Unspecified video - kSMPTE274M, //!< SMPTE 274M - kITUR709, //!< ITU-R 709-4 - kITUR601, //!< ITU-R 601-5 system B or G - kITUR602, //!< ITU-R 601-5 system M - kNTSCCompositeVideo, //!< NTSC composite video - kPALCompositeVideo, //!< PAL composite video - kZLinear, //!< Z depth linear, transfer only - kZHomogeneous, //!< Z depth homogeneous, transfer only - kUndefinedCharacteristic = 0xff //!< Undefined - }; - - - /*! - * \enum VideoSignal - * \brief Video Signal Standard - */ - enum VideoSignal - { - kUndefined = 0, //!< Undefined - kNTSC = 1, //!< NTSC - kPAL = 2, //!< PAL - kPAL_M = 3, //!< PAL-M - kSECAM = 4, //!< SECAM - k525LineInterlace43AR = 50, //!< YCbCr ITU-R 601-5 525-line, 2:1 interlace, 4:3 aspect ratio - k625LineInterlace43AR = 51, //!< YCbCr ITU-R 601-5 625-line, 2:1 interlace, 4:3 aspect ratio - k525LineInterlace169AR = 100, //!< YCbCr ITU-R 601-5 525-line, 2:1 interlace, 16:9 aspect ratio - k625LineInterlace169AR = 101, //!< YCbCr ITU-R 601-5 625-line, 2:1 interlace, 16:9 aspect ratio - k1050LineInterlace169AR = 150, //!< YCbCr 1050-line, 2:1 interlace, 16:9 aspect ratio - k1125LineInterlace169AR_274 = 151, //!< YCbCr 1125-line, 2:1 interlace, 16:9 aspect ratio (SMPTE 274M) - k1250LineInterlace169AR = 152, //!< YCbCr 1250-line, 2:1 interlace, 16:9 aspect ratio - k1125LineInterlace169AR_240 = 153, //!< YCbCr 1125-line, 2:1 interlace, 16:9 aspect ratio (SMPTE 240M) - k525LineProgressive169AR = 200, //!< YCbCr 525-line, 1:1 progressive, 16:9 aspect ratio - k625LineProgressive169AR = 201, //!< YCbCr 625-line, 1:1 progressive, 16:9 aspect ratio - k750LineProgressive169AR = 202, //!< YCbCr 750-line, 1:1 progressive, 16:9 aspect ratio (SMPTE 296M) - k1125LineProgressive169AR = 203 //!< YCbCr 1125-line, 1:1 progressive, 16:9 aspect ratio (SMPTE 274M) - }; - - - /*! - * \enum Packing - * \brief Component data packing method - */ - enum Packing - { - kPacked = 0, //!< Packed into 32-bit words - kFilledMethodA = 1, //!< Filled to 32-bit words, method A - kFilledMethodB = 2 //!< Filled to 32-bit words, method B - }; - - - /*! - * \enum Encoding - * \brief Component data encoding method - */ - enum Encoding - { - kNone = 0, //DetermineByteSwap(this->magicNumber); - } - - inline const U32 Header::Size() const - { - return 2048; - } - - - - inline U32 GenericHeader::MagicNumber() const - { - return this->magicNumber; - } - - inline U32 GenericHeader::ImageOffset() const - { - return this->imageOffset; - } - - inline void GenericHeader::SetImageOffset(const U32 offset) - { - this->imageOffset = offset; - } - - inline void GenericHeader::Version(char *v) const - { - ::strncpy(v, this->version, 8); - v[8] = '\0'; - } - - inline void GenericHeader::SetVersion(const char * v) - { - ::strncpy(this->version, v, 8); - } - - inline U32 GenericHeader::FileSize() const - { - return this->fileSize; - } - - inline void GenericHeader::SetFileSize(const U32 fs) - { - this->fileSize = fs; - } - - inline U32 GenericHeader::DittoKey() const - { - return this->dittoKey; - } - - inline void GenericHeader::SetDittoKey(const U32 key) - { - this->dittoKey = key; - } - - inline U32 GenericHeader::GenericSize() const - { - return this->genericSize; - } - - inline U32 GenericHeader::IndustrySize() const - { - return this->industrySize; - } - - inline U32 GenericHeader::UserSize() const - { - return this->userSize; - } - - inline void GenericHeader::SetUserSize(const U32 size) - { - this->userSize = size; - } - - inline void GenericHeader::FileName(char *fn) const - { - ::strncpy(fn, this->fileName, 100); - fn[100] = '\0'; - } - - inline void GenericHeader::SetFileName(const char *fn) - { - ::strncpy(this->fileName, fn, 100); - } - - inline void GenericHeader::CreationTimeDate(char *ct) const - { - ::strncpy(ct, this->creationTimeDate, 24); - ct[24] = '\0'; - } - - inline void GenericHeader::SetCreationTimeDate(const char *ct) - { - ::strncpy(this->creationTimeDate, ct, 24); - } - - inline void GenericHeader::Creator(char *creat) const - { - ::strncpy(creat, this->creator, 100); - creat[200] = '\0'; - } - - inline void GenericHeader::SetCreator(const char *creat) - { - ::strncpy(this->creator, creat, 100); - } - - inline void GenericHeader::Project(char *prj) const - { - ::strncpy(prj, this->project, 200); - prj[200] = '\0'; - } - - inline void GenericHeader::SetProject(const char *prj) - { - ::strncpy(this->project, prj, 200); - } - - inline void GenericHeader::Copyright(char *copy) const - { - ::strncpy(copy, this->copyright, 200); - copy[200] = '\0'; - } - - inline void GenericHeader::SetCopyright(const char *copy) - { - ::strncpy(this->copyright, copy, 200); - } - - inline U32 GenericHeader::EncryptKey() const - { - return this->encryptKey; - } - - inline void GenericHeader::SetEncryptKey(const U32 key) - { - this->encryptKey = key; - } - - - inline Orientation GenericHeader::ImageOrientation() const - { - return Orientation(this->imageOrientation); - } - - inline void GenericHeader::SetImageOrientation(const Orientation orient) - { - this->imageOrientation = orient; - } - - inline U16 GenericHeader::NumberOfElements() const - { - return this->numberOfElements; - } - - inline void GenericHeader::SetNumberOfElements(const U16 num) - { - this->numberOfElements = num; - } - - inline U32 GenericHeader::PixelsPerLine() const - { - return this->pixelsPerLine; - } - - inline void GenericHeader::SetPixelsPerLine(const U32 ppl) - { - this->pixelsPerLine = ppl; - } - - inline U32 GenericHeader::LinesPerElement() const - { - return this->linesPerElement; - } - - inline void GenericHeader::SetLinesPerElement(const U32 lpe) - { - this->linesPerElement = lpe; - } - - inline U32 GenericHeader::DataSign(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - return this->chan[i].dataSign; - } - - inline void GenericHeader::SetDataSign(const int i, const U32 sign) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].dataSign = sign; - } - - inline U32 GenericHeader::LowData(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - return this->chan[i].lowData; - } - - inline void GenericHeader::SetLowData(const int i, const U32 data) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].lowData = data; - } - - inline R32 GenericHeader::LowQuantity(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - return this->chan[i].lowQuantity; - } - - inline void GenericHeader::SetLowQuantity(const int i, const R32 quant) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].lowQuantity = quant; - } - - inline U32 GenericHeader::HighData(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - return this->chan[i].highData; - } - - inline void GenericHeader::SetHighData(const int i, const U32 data) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].highData = data; - } - - inline R32 GenericHeader::HighQuantity(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - return this->chan[i].highQuantity; - } - - inline void GenericHeader::SetHighQuantity(const int i, const R32 quant) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].highQuantity = quant; - } - - inline Descriptor GenericHeader::ImageDescriptor(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return Descriptor(0xff); - return Descriptor(this->chan[i].descriptor); - } - - inline void GenericHeader::SetImageDescriptor(const int i, const Descriptor desc) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].descriptor = desc; - } - - inline Characteristic GenericHeader::Transfer(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return Characteristic(0xff); - return Characteristic(this->chan[i].transfer); - } - - inline void GenericHeader::SetTransfer(const int i, const Characteristic ch) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].transfer = ch; - } - - inline Characteristic GenericHeader::Colorimetric(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return Characteristic(0xff); - return Characteristic(this->chan[i].colorimetric); - } - - inline void GenericHeader::SetColorimetric(const int i, const Characteristic c) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].colorimetric = c; - } - - inline U8 GenericHeader::BitDepth(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xff; - return this->chan[i].bitDepth; - } - - inline void GenericHeader::SetBitDepth(const int i, const U8 depth) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].bitDepth = depth; - } - - inline Packing GenericHeader::ImagePacking(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return Packing(0xff); - return Packing(this->chan[i].packing); - } - - inline void GenericHeader::SetImagePacking(const int i, const Packing pack) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].packing = pack; - } - - inline Encoding GenericHeader::ImageEncoding(const int i) const - { - Encoding e = kNone; - - if (i < 0 || i >= MAX_ELEMENTS) - return kNone; - - if (this->chan[i].encoding == 1) - e = kRLE; - - return e; - } - - inline void GenericHeader::SetImageEncoding(const int i, const Encoding enc) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - - this->chan[i].encoding = (enc == kNone ? 0 : 1); - } - - inline U32 GenericHeader::DataOffset(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - return this->chan[i].dataOffset; - } - - inline void GenericHeader::SetDataOffset(const int i, const U32 offset) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].dataOffset = offset; - } - - inline U32 GenericHeader::EndOfLinePadding(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - if (this->chan[i].endOfLinePadding == 0xffffffff) - return 0; - return this->chan[i].endOfLinePadding; - } - - inline void GenericHeader::SetEndOfLinePadding(const int i, const U32 eolp) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].endOfLinePadding = eolp; - } - - inline U32 GenericHeader::EndOfImagePadding(const int i) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return 0xffffffff; - if (this->chan[i].endOfImagePadding == 0xffffffff) - return 0; - return this->chan[i].endOfImagePadding; - } - - inline void GenericHeader::SetEndOfImagePadding(const int i, const U32 eoip) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - this->chan[i].endOfImagePadding = eoip; - } - - inline void GenericHeader::Description(const int i, char *desc) const - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - strncpy(desc, this->chan[i].description, 32); - } - - inline void GenericHeader::SetDescription(const int i, const char *desc) - { - if (i < 0 || i >= MAX_ELEMENTS) - return; - ::strncpy(this->chan[i].description, desc, 32); - } - - - inline U32 GenericHeader::XOffset() const - { - return this->xOffset; - } - - inline void GenericHeader::SetXOffset(const U32 offset) - { - this->xOffset = offset; - } - - inline U32 GenericHeader::YOffset() const - { - return this->yOffset; - } - - inline void GenericHeader::SetYOffset(const U32 offset) - { - this->yOffset = offset; - } - - inline R32 GenericHeader::XCenter() const - { - return this->xCenter; - } - - inline void GenericHeader::SetXCenter(const R32 center) - { - this->xCenter = center; - } - - inline R32 GenericHeader::YCenter() const - { - return this->yCenter; - } - - inline void GenericHeader::SetYCenter(const R32 center) - { - this->yCenter = center; - } - - inline U32 GenericHeader::XOriginalSize() const - { - return this->xOriginalSize; - } - - inline void GenericHeader::SetXOriginalSize(const U32 size) - { - this->xOriginalSize = size; - } - - inline U32 GenericHeader::YOriginalSize() const - { - return this->yOriginalSize; - } - - inline void GenericHeader::SetYOriginalSize(const U32 size) - { - this->yOriginalSize = size; - } - - inline void GenericHeader::SourceImageFileName(char *fn) const - { - ::strncpy(fn, this->sourceImageFileName, 100); - fn[100] = '\0'; - } - - inline void GenericHeader::SetSourceImageFileName(const char *fn) - { - ::strncpy(this->sourceImageFileName, fn, 100); - } - - inline void GenericHeader::SourceTimeDate(char *td) const - { - ::strncpy(td, this->sourceTimeDate, 24); - td[24] = '\0'; - } - - inline void GenericHeader::SetSourceTimeDate(const char *td) - { - ::strncpy(this->sourceTimeDate, td, 24); - } - - inline void GenericHeader::InputDevice(char *dev) const - { - ::strncpy(dev, this->inputDevice, 32); - dev[32] = '\0'; - } - - inline void GenericHeader::SetInputDevice(const char *dev) - { - ::strncpy(this->inputDevice, dev, 32); - } - - inline void GenericHeader::InputDeviceSerialNumber(char *sn) const - { - ::strncpy(sn, this->inputDeviceSerialNumber, 32); - sn[32] = '\0'; - } - - inline void GenericHeader::SetInputDeviceSerialNumber(const char *sn) - { - ::strncpy(this->inputDeviceSerialNumber, sn, 32); - } - - inline U16 GenericHeader::Border(const int i) const - { - if (i < 0 || i > 3) - return 0xffff; - - return this->border[i]; - } - - inline void GenericHeader::SetBorder(const int i, const U16 bord) - { - if (i < 0 || i > 3) - return; - this->border[i] = bord; - } - - inline U32 GenericHeader::AspectRatio(const int i) const - { - if (i != 0 && i != 1) - return 0xffffffff; - - return this->aspectRatio[i]; - } - - inline void GenericHeader::SetAspectRatio(const int i, const U32 ar) - { - if (i != 0 && i != 1) - return; - this->aspectRatio[i] = ar; - } - - inline R32 GenericHeader::XScannedSize() const - { - return this->xScannedSize; - } - - inline void GenericHeader::SetXScannedSize(const R32 size) - { - this->xScannedSize = size; - } - - inline R32 GenericHeader::YScannedSize() const - { - return this->yScannedSize; - } - - inline void GenericHeader::SetYScannedSize(const R32 size) - { - this->yScannedSize = size; - } - - - inline void IndustryHeader::Format(char *fmt) const - { - ::strncpy(fmt, this->format, 32); - fmt[32] = '\0'; - } - - inline void IndustryHeader::SetFormat(const char *fmt) - { - ::strncpy(this->format, fmt, 32); - } - - inline U32 IndustryHeader::FramePosition() const - { - return this->framePosition; - } - - inline void IndustryHeader::SetFramePosition(const U32 pos) - { - this->framePosition = pos; - } - - inline U32 IndustryHeader::SequenceLength() const - { - return this->sequenceLength; - } - - inline void IndustryHeader::SetSequenceLength(const U32 len) - { - this->sequenceLength = len; - } - - inline U32 IndustryHeader::HeldCount() const - { - return this->heldCount; - } - - inline void IndustryHeader::SetHeldCount(const U32 count) - { - this->heldCount = count; - } - - inline R32 IndustryHeader::FrameRate() const - { - return this->frameRate; - } - - inline void IndustryHeader::SetFrameRate(const R32 rate) - { - this->frameRate = rate; - } - - inline R32 IndustryHeader::ShutterAngle() const - { - return this->shutterAngle; - } - - inline void IndustryHeader::SetShutterAngle(const R32 angle) - { - this->shutterAngle = angle; - } - - inline void IndustryHeader::FrameId(char *id) const - { - ::strncpy(id, this->frameId, 32); - id[32] = '\0'; - } - - inline void IndustryHeader::SetFrameId(const char *id) - { - ::strncpy(this->frameId, id, 32); - } - - inline void IndustryHeader::SlateInfo(char *slate) const - { - ::strncpy(slate, this->slateInfo, 100); - slate[100] = '\0'; - } - - inline void IndustryHeader::SetSlateInfo(const char *slate) - { - ::strncpy(this->slateInfo, slate, 100); - } - - - inline U8 IndustryHeader::Interlace() const - { - return this->interlace; - } - - inline void IndustryHeader::SetInterlace(const U8 lace) - { - this->interlace = lace; - } - - inline U8 IndustryHeader::FieldNumber() const - { - return this->fieldNumber; - } - - inline void IndustryHeader::SetFieldNumber(const U8 fn) - { - this->fieldNumber = fn; - } - - inline VideoSignal IndustryHeader::Signal() const - { - return VideoSignal(this->videoSignal); - } - - inline void IndustryHeader::SetSignal(const VideoSignal vs) - { - this->videoSignal = vs; - } - - inline R32 IndustryHeader::HorizontalSampleRate() const - { - return this->horizontalSampleRate; - } - - inline void IndustryHeader::SetHorizontalSampleRate(const R32 rate) - { - this->horizontalSampleRate = rate; - } - - inline R32 IndustryHeader::VerticalSampleRate() const - { - return this->verticalSampleRate; - } - - inline void IndustryHeader::SetVerticalSampleRate(const R32 rate) - { - this->verticalSampleRate = rate; - } - - inline R32 IndustryHeader::TemporalFrameRate() const - { - return this->temporalFrameRate; - } - - inline void IndustryHeader::SetTemporalFrameRate(const R32 rate) - { - this->temporalFrameRate = rate; - } - - inline R32 IndustryHeader::TimeOffset() const - { - return this->timeOffset; - } - - inline void IndustryHeader::SetTimeOffset(const R32 offset) - { - this->timeOffset = offset; - } - - inline R32 IndustryHeader::Gamma() const - { - return this->gamma; - } - - inline void IndustryHeader::SetGamma(const R32 g) - { - this->gamma = g; - } - - inline R32 IndustryHeader::BlackLevel() const - { - return this->blackLevel; - } - - inline void IndustryHeader::SetBlackLevel(const R32 bl) - { - this->blackLevel = bl; - } - - inline R32 IndustryHeader::BlackGain() const - { - return this->blackGain; - } - - inline void IndustryHeader::SetBlackGain(const R32 bg) - { - this->blackGain = bg; - } - - inline R32 IndustryHeader::BreakPoint() const - { - return this->breakPoint; - } - - inline void IndustryHeader::SetBreakPoint(const R32 bp) - { - this->breakPoint = bp; - } - - inline R32 IndustryHeader::WhiteLevel() const - { - return this->whiteLevel; - } - - inline void IndustryHeader::SetWhiteLevel(const R32 wl) - { - this->whiteLevel = wl; - } - - inline R32 IndustryHeader::IntegrationTimes() const - { - return this->integrationTimes; - } - - inline void IndustryHeader::SetIntegrationTimes(const R32 times) - { - this->integrationTimes = times; - } - -} - -#endif diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXStream.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXStream.h deleted file mode 100755 index 091e60077..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/DPXStream.h +++ /dev/null @@ -1,204 +0,0 @@ -/// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/*! \file DPXStream.h */ - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_DPXSTREAM_H -#define _DPX_DPXSTREAM_H 1 - - -#include - - - -/*! - * \class InStream - * \brief Input Stream for reading files - */ -class InStream -{ - - public: - - /*! - * \enum Origin - * \brief file pointing positioning offset - */ - enum Origin - { - kStart, //!< beginning of the file - kCurrent, //!< current file pointer - kEnd //!< end of the file - }; - - - /*! - * \brief Constructor - */ - InStream(); - - /*! - * \brief Destructor - */ - virtual ~InStream(); - - /*! - * \brief Open file - * \param fn File name - * \return success true/false - */ - virtual bool Open(const char * fn); - - /*! - * \brief Close file - */ - virtual void Close(); - - /*! - * \brief Rewind file pointer to beginning of file - */ - virtual void Rewind(); - - /*! - * \brief Read data from file - * \param buf data buffer - * \param size bytes to read - * \return number of bytes read - */ - virtual size_t Read(void * buf, const size_t size); - - - /*! - * \brief Read data from file without any buffering as fast as possible - * \param buf data buffer - * \param size bytes to read - * \return number of bytes read - */ - virtual size_t ReadDirect(void * buf, const size_t size); - - /*! - * \brief Query if end of file has been reached - * \return end of file true/false - */ - virtual bool EndOfFile() const; - - /*! - * \brief Seek to a position in the file - * \param offset offset from originating position - * \param origin originating position - * \return success true/false - */ - virtual bool Seek(long offset, Origin origin); - - protected: - FILE *fp; -}; - - - -/*! - * \class OutStream - * \brief Output Stream for writing files - */ -class OutStream -{ - - public: - - /*! - * \enum Origin - * \brief file pointing positioning offset - */ - enum Origin - { - kStart, //!< beginning of the file - kCurrent, //!< current file pointer - kEnd //!< end of the file - }; - - /*! - * \brief Constructor - */ - OutStream(); - - /*! - * \brief Destructor - */ - virtual ~OutStream(); - - /*! - * \brief Open file - * \param fn File name - * \return success true/false - */ - virtual bool Open(const char *fn); - - /*! - * \brief Close file - */ - virtual void Close(); - - /*! - * \brief Write data to file - * \param buf data buffer - * \param size bytes to write - * \return number of bytes written - */ - virtual size_t Write(void * buf, const size_t size); - - /*! - * \brief Seek to a position in the file - * \param offset offset from originating position - * \param origin originating position - * \return success true/false - */ - virtual bool Seek(long offset, Origin origin); - - /*! - * \brief Flush any buffers - */ - virtual void Flush(); - - - protected: - FILE *fp; -}; - - - - - -#endif - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.cpp deleted file mode 100644 index 0590057a6..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "DPX.h" -#include "EndianSwap.h" -#include "ElementReadStream.h" - -dpx::ElementReadStream::ElementReadStream(InStream* fd) - : fd(fd) -{ -} - -dpx::ElementReadStream::~ElementReadStream() -{ -} - -void dpx::ElementReadStream::Reset() -{ -} - -bool dpx::ElementReadStream::Read(const dpx::Header& dpxHeader, const int element, const long offset, void* buf, - const size_t size) -{ - long position = dpxHeader.DataOffset(element) + offset; - - // seek to the memory position - if(this->fd->Seek(position, InStream::kStart) == false) - return false; - - // read in the data, calculate buffer offset - if(this->fd->Read(buf, size) != size) - return false; - - // swap the bytes if different byte order - this->EndianDataCheck(dpxHeader, element, buf, size); - - return true; -} - -bool dpx::ElementReadStream::ReadDirect(const dpx::Header& dpxHeader, const int element, const long offset, void* buf, - const size_t size) -{ - long position = dpxHeader.DataOffset(element) + offset; - - // seek to the memory position - if(this->fd->Seek(position, InStream::kStart) == false) - return false; - - // read in the data, calculate buffer offset - if(this->fd->ReadDirect(buf, size) != size) - return false; - - // swap the bytes if different byte order - this->EndianDataCheck(dpxHeader, element, buf, size); - - return true; -} - -void dpx::ElementReadStream::EndianDataCheck(const dpx::Header& dpxHeader, const int element, void* buf, const size_t size) -{ - if(dpxHeader.RequiresByteSwap()) - { - switch(dpxHeader.BitDepth(element)) - { - case 8: - break; - case 12: - if(dpxHeader.ImagePacking(element) == dpx::kPacked) - dpx::EndianSwapImageBuffer(buf, size / sizeof(U32)); - else - dpx::EndianSwapImageBuffer(buf, size / sizeof(U16)); - break; - case 16: - dpx::EndianSwapImageBuffer(buf, size / sizeof(U16)); - break; - default: // 10-bit, 32-bit, 64-bit - dpx::EndianSwapImageBuffer(buf, size / sizeof(U32)); - } - } -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.h deleted file mode 100755 index 65b2b94d2..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ElementReadStream.h +++ /dev/null @@ -1,66 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_ELEMENTREADSTREAM_H -#define _DPX_ELEMENTREADSTREAM_H 1 - - -#include "DPXStream.h" - - -namespace dpx -{ - - class ElementReadStream - { - public: - ElementReadStream(InStream *); - virtual ~ElementReadStream(); - - virtual void Reset(); - - virtual bool Read(const dpx::Header &, const int element, const long offset, void * buf, const size_t size); - virtual bool ReadDirect(const dpx::Header &, const int element, const long offset, void * buf, const size_t size); - - protected: - void EndianDataCheck(const dpx::Header &, const int element, void *, const size_t size); - - InStream *fd; - }; - -} - - -#endif diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/EndianSwap.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/EndianSwap.h deleted file mode 100755 index 55aa70242..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/EndianSwap.h +++ /dev/null @@ -1,152 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_ENDIANSWAP_H -#define _DPX_ENDIANSWAP_H 1 - - -namespace dpx -{ - -template -T SwapBytes(T& value) -{ - register unsigned char *pe, *ps = reinterpret_cast(&value); - register unsigned char c; - register size_t s = (sizeof(T)); - - pe = ps + s - 1; - for (size_t i = s/2; i > 0; i--) - { - c = *ps; - *ps = *pe; - *pe = c; - - ps++; pe--; - } - - return value; -} - - -template <> -inline unsigned short SwapBytes( unsigned short& value ) -{ - register unsigned char *p = reinterpret_cast(&value); - register unsigned char c = p[0]; - p[0] = p[1]; - p[1] = c; - return value; -} - -template <> -inline unsigned char SwapBytes( unsigned char& value ) -{ - return value; -} - - -template <> -inline char SwapBytes( char& value ) -{ - return value; -} - - -template -void SwapBuffer(T *buf, unsigned int len) -{ - for (unsigned int i = 0; i < len; i++) - SwapBytes(buf[i]); -} - - -template -void EndianSwapImageBuffer(void *data, int length) -{ - switch (SIZE) - { - case dpx::kByte: - break; - - case dpx::kWord: - SwapBuffer(reinterpret_cast(data), length); - break; - - case dpx::kInt: - SwapBuffer(reinterpret_cast(data), length); - break; - - case dpx::kFloat: - SwapBuffer(reinterpret_cast(data), length); - break; - - case dpx::kDouble: - SwapBuffer(reinterpret_cast(data), length); - break; - } -} - - -inline void EndianSwapImageBuffer(DataSize size, void *data, int length) -{ - switch (size) - { - case dpx::kByte: - break; - - case dpx::kWord: - SwapBuffer(reinterpret_cast(data), length); - break; - - case dpx::kInt: - SwapBuffer(reinterpret_cast(data), length); - break; - - case dpx::kFloat: - SwapBuffer(reinterpret_cast(data), length); - break; - - case dpx::kDouble: - SwapBuffer(reinterpret_cast(data), length); - break; - } -} - - -} - -#endif - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/InStream.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/InStream.cpp deleted file mode 100644 index 9ef7f2875..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/InStream.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "DPXStream.h" - -InStream::InStream() - : fp(0) -{ -} - -InStream::~InStream() -{ -} - -bool InStream::Open(const char* f) -{ - if(this->fp) - this->Close(); - if((this->fp = ::fopen(f, "rb")) == 0) - return false; - - return true; -} - -void InStream::Close() -{ - if(this->fp) - { - ::fclose(this->fp); - this->fp = 0; - } -} - -void InStream::Rewind() -{ - if(this->fp) - ::rewind(fp); -} - -bool InStream::Seek(long offset, Origin origin) -{ - int o = 0; - switch(origin) - { - case kCurrent: - o = SEEK_CUR; - break; - case kEnd: - o = SEEK_END; - break; - case kStart: - o = SEEK_SET; - break; - } - - if(this->fp == 0) - return -1; - return (::fseek(this->fp, offset, o) == 0); -} - -size_t InStream::Read(void* buf, const size_t size) -{ - if(this->fp == 0) - return 0; - return ::fread(buf, 1, size, this->fp); -} - -size_t InStream::ReadDirect(void* buf, const size_t size) -{ - return this->Read(buf, size); -} - -bool InStream::EndOfFile() const -{ - if(this->fp == 0) - return true; - return ::feof(this->fp); -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Makefile.am b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Makefile.am deleted file mode 100644 index 12021c5e7..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ - -lib_LIBRARIES = libdpx.a - -libdpx_a_SOURCES = Codec.cpp \ - DPX.cpp \ - DPXHeader.cpp \ - ElementReadStream.cpp \ - InStream.cpp \ - OutStream.cpp \ - Reader.cpp \ - RunLengthEncoding.cpp \ - TestFunc.cpp \ - Writer.cpp - -noinst_HEADERS = BaseTypeConverter.h \ - Codec.h \ - ElementReadStream.h \ - EndianSwap.h \ - ReaderInternal.h \ - RunLengthEncoding.h \ - TestFunc.h \ - WriterInternal.h - -libdpxincludedir = $(includedir) - -libdpxinclude_HEADERS = DPX.h DPXHeader.h DPXStream.h - - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/OutStream.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/OutStream.cpp deleted file mode 100644 index fac1bdefd..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/OutStream.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "DPXStream.h" - -OutStream::OutStream() - : fp(0) -{ -} - -OutStream::~OutStream() -{ -} - -bool OutStream::Open(const char* f) -{ - if(this->fp) - this->Close(); - if((this->fp = ::fopen(f, "wb")) == 0) - return false; - - return true; -} - -void OutStream::Close() -{ - if(this->fp) - { - ::fclose(this->fp); - this->fp = 0; - } -} - -size_t OutStream::Write(void* buf, const size_t size) -{ - if(this->fp == 0) - return false; - return ::fwrite(buf, 1, size, this->fp); -} - -bool OutStream::Seek(long offset, Origin origin) -{ - int o = 0; - switch(origin) - { - case kCurrent: - o = SEEK_CUR; - break; - case kEnd: - o = SEEK_END; - break; - case kStart: - o = SEEK_SET; - break; - } - - if(this->fp == 0) - return -1; - return (::fseek(this->fp, offset, o) == 0); -} - -void OutStream::Flush() -{ - if(this->fp) - ::fflush(this->fp); -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Reader.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Reader.cpp deleted file mode 100644 index dae3d2634..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Reader.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include "DPX.h" -#include "EndianSwap.h" -#include "ReaderInternal.h" -#include "ElementReadStream.h" -#include "Codec.h" -#include "RunLengthEncoding.h" - -dpx::Reader::Reader() - : fd(0) - , rio(0) -{ - // initialize all of the Codec* to NULL - for(int i = 0; i < MAX_ELEMENTS; i++) - this->codex[i] = 0; -} - -dpx::Reader::~Reader() -{ - this->Reset(); -} - -void dpx::Reader::Reset() -{ - // delete all of the Codec * entries - for(int i = 0; i < MAX_ELEMENTS; i++) - if(this->codex[i]) - { - delete codex[i]; - this->codex[i] = 0; - } - - // Element Reader - if(this->rio) - { - delete rio; - this->rio = 0; - } - if(this->fd) - this->rio = new ElementReadStream(this->fd); -} - -void dpx::Reader::SetInStream(InStream* fd) -{ - this->fd = fd; - this->Reset(); -} - -bool dpx::Reader::ReadHeader() -{ - return this->header.Read(this->fd); -} - -bool dpx::Reader::ReadImage(const int element, void* data) -{ - // make sure the range is good - if(element < 0 || element >= MAX_ELEMENTS) - return false; - - // make sure the entry is valid - if(this->header.ImageDescriptor(element) == kUndefinedDescriptor) - return false; - - return this->ReadImage(data, this->header.ComponentDataSize(element), this->header.ImageDescriptor(element)); -} - -bool dpx::Reader::ReadImage(void* data, const DataSize size, const Descriptor desc) -{ - Block block(0, 0, this->header.Width() - 1, this->header.Height() - 1); - return this->ReadBlock(data, size, block, desc); -} - -/** - block - this contains the square block of data to read in. The data elements in this - structure need to be normalized Left to Right, Top to Bottom. - */ - -bool dpx::Reader::ReadBlock(const int element, unsigned char* data, Block& block) -{ - // make sure the range is good - if(element < 0 || element >= MAX_ELEMENTS) - return false; - - // make sure the entry is valid - if(this->header.ImageDescriptor(element) == kUndefinedDescriptor) - return false; - - return this->ReadBlock(data, this->header.ComponentDataSize(element), block, this->header.ImageDescriptor(element)); -} - -/* - implementation notes: - - dpx::readBlock reads in the image starting from the beginning of the channel. This can - be optimized if the image isn't encoded; we can skip forward in the file to close to the - start of (block.x1, block.y1) and determine exactly which bit will be the start. This - certainly will save some time for cases where we are only reading ROIs (regions of interest). - -*/ - -bool dpx::Reader::ReadBlock(void* data, const DataSize size, Block& block, const Descriptor desc) -{ - int i; - int element; - - // check the block coordinates - block.Check(); - - // determine which element we are viewing - for(i = 0; i < MAX_ELEMENTS; i++) - { - if(this->header.ImageDescriptor(i) == desc) - { - element = i; - break; - } - } - if(i == MAX_ELEMENTS) // was it found? - return false; - - // get the number of components for this element descriptor - const int numberOfComponents = this->header.ImageElementComponentCount(element); - - // bit depth of the image element - const int bitDepth = this->header.BitDepth(element); - - // rle encoding? - const bool rle = (this->header.ImageEncoding(element) == kRLE); - - // lets see if this can be done in a single fast read - if(!rle && this->header.EndOfLinePadding(element) == 0 && - ((bitDepth == 8 && size == dpx::kByte) || (bitDepth == 16 && size == dpx::kWord) || - (bitDepth == 32 && size == dpx::kFloat) || (bitDepth == 64 && size == dpx::kDouble)) && - block.x1 == 0 && block.x2 == (int)(this->header.Width() - 1)) - { - // seek to the beginning of the image block - if(this->fd->Seek( - (this->header.DataOffset(element) + (block.y1 * this->header.Width() * (bitDepth / 8) * numberOfComponents)), - InStream::kStart) == false) - return false; - - // size of the image - const size_t imageSize = this->header.Width() * (block.y2 - block.y1 + 1) * numberOfComponents; - const size_t imageByteSize = imageSize * bitDepth / 8; - - size_t rs = this->fd->ReadDirect(data, imageByteSize); - if(rs != imageByteSize) - return false; - - // swap the bytes if different byte order - if(this->header.RequiresByteSwap()) - dpx::EndianSwapImageBuffer(size, data, imageSize); - - return true; - } - - // determine if the encoding system is loaded - if(this->codex[element] == 0) - { - // this element reader has not been used - if(rle) - // TODO - // this->codex[element] = new RunLengthEncoding; - return false; - else - this->codex[element] = new Codec; - } - - // read the image block - return this->codex[element]->Read(this->header, this->rio, element, block, data, size); -} - -bool dpx::Reader::ReadUserData(unsigned char* data) -{ - // check to make sure there is some user data - if(this->header.UserSize() == 0) - return true; - - // seek to the beginning of the user data block - if(this->fd->Seek(sizeof(GenericHeader) + sizeof(IndustryHeader), InStream::kStart) == false) - return false; - - size_t rs = this->fd->ReadDirect(data, this->header.UserSize()); - if(rs != this->header.UserSize()) - return false; - - return true; -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ReaderInternal.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ReaderInternal.h deleted file mode 100755 index 8fb1685fc..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/ReaderInternal.h +++ /dev/null @@ -1,584 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_READERINTERNAL_H -#define _DPX_READERINTERNAL_H 1 - - -#include -#include "BaseTypeConverter.h" - - -#define PADDINGBITS_10BITFILLEDMETHODA 2 -#define PADDINGBITS_10BITFILLEDMETHODB 0 - -#define MASK_10BITPACKED 0xffc0 -#define MULTIPLIER_10BITPACKED 2 -#define REMAIN_10BITPACKED 4 -#define REVERSE_10BITPACKED 6 - -#define MASK_12BITPACKED 0xfff0 -#define MULTIPLIER_12BITPACKED 4 -#define REMAIN_12BITPACKED 2 -#define REVERSE_12BITPACKED 4 - - - - -namespace dpx -{ - - // this function is called when the DataSize is 10 bit and the packing method is kFilledMethodA or kFilledMethodB - template - void Unfill10bitFilled(U32 *readBuf, const int x, BUF *data, int count, int bufoff, const int numberOfComponents) - { - // unpack the words in the buffer - BUF *obuf = data + bufoff; - - int index = (x * sizeof(U32)) % numberOfComponents; - - for (int i = count - 1; i >= 0; i--) - { - // unpacking the buffer backwords - register U32 word = readBuf[(i + index) / 3 / sizeof(U32)]; - register U16 d1 = U16(word >> ((2 - (i + index) % 3) * 10 + PADDINGBITS) & 0x3ff); - BaseTypeConvertU10ToU16(d1, d1); - BaseTypeConverter(d1, obuf[i]); - } -#if 0 - // NOTE: REVERSE -- is this something we really need to handle? - // There were many dpx images that write the components backwords - // because of some confusion with DPX v1 spec - - switch (dpxHeader.DatumSwap(element)) - { - case 0: // no swap - for (i = count - 1; i >= 0; i--) - { - U32 word = readBuf[(i + index) / 3 / sizeof(U32)]; - U16 d1 = U16(word >> (((i + index) % 3) * 10 + PADDINGBITS) & 0x3ff); - BaseTypeConvertU10ToU16(d1, d1); - BaseTypeConverter(d1, obuf[i]); - } - - case 1: // swap the three datum around so BGR becomes RGB - for (i = count - 1; i >= 0; i--) - { - // unpacking the buffer backwords - U32 word = readBuf[(i + index) / 3 / sizeof(U32)]; - U16 d1 = U16(word >> ((2 - (i + index) % 3) * 10 + PADDINGBITS) & 0x3ff); - BaseTypeConvertU10ToU16(d1, d1); - BaseTypeConverter(d1, obuf[i]); - } - - // NOTE: NOT DONE case 2 - case 2: // swap the second two of three datum around so YCrCb becomes YCbCr - for (i = count - 1; i >= 0; i--) - { - // unpacking the buffer backwords - U32 word = readBuf[(i + index) / 3 / sizeof(U32)]; - U16 d1 = U16(word >> ((2 - (count + index) % 3) * 10 + PADDINGBITS) & 0x3ff); - BaseTypeConvertU10ToU16(d1, d1); - BaseTypeConverter(d1, obuf[i]); - } - - } -#endif - } - - template - bool Read10bitFilled(const Header &dpxHeader, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - // image height to read - const int height = block.y2 - block.y1 + 1; - - // get the number of components for this element descriptor - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - - // end of line padding - int eolnPad = dpxHeader.EndOfLinePadding(element); - - // number of datums in one row - int datums = dpxHeader.Width() * numberOfComponents; - - // read in each line at a time directly into the user memory space - for (int line = 0; line < height; line++) - { - // determine offset into image element - - int actline = line + block.y1; - - // first get line offset - long offset = actline * datums; - - // add in the accumulated round-up offset - the following magical formula is - // just an unrolling of a loop that does the same work in constant time: - // for (int i = 1; i <= actline; ++i) - // offset += (i * datums) % 3; - offset += datums % 3 * ((actline + 2) / 3) + (3 - datums % 3) % 3 * ((actline + 1) / 3); - - // round up to the 32-bit boundary - offset = offset / 3 * 4; - - // add in eoln padding - offset += line * eolnPad; - - // add in offset within the current line, rounding down so to catch any components within the word - offset += block.x1 * numberOfComponents / 3 * 4; - - - // get the read count in bytes, round to the 32-bit boundry - int readSize = (block.x2 - block.x1 + 1) * numberOfComponents; - readSize += readSize % 3; - readSize = readSize / 3 * 4; - - // determine buffer offset - int bufoff = line * datums; - - fd->Read(dpxHeader, element, offset, readBuf, readSize); - - // unpack the words in the buffer -#if RLE_WORKING - int count = (block.x2 - block.x1 + 1) * numberOfComponents; - Unfill10bitFilled(readBuf, block.x1, data, count, bufoff, numberOfComponents); -#else - BUF *obuf = data + bufoff; - int index = (block.x1 * sizeof(U32)) % numberOfComponents; - - for (int count = (block.x2 - block.x1 + 1) * numberOfComponents - 1; count >= 0; count--) - { - // unpacking the buffer backwords - U16 d1 = U16(readBuf[(count + index) / 3] >> ((2 - (count + index) % 3) * 10 + PADDINGBITS) & 0x3ff); - BaseTypeConvertU10ToU16(d1, d1); - - BaseTypeConverter(d1, obuf[count]); - - // work-around for 1-channel DPX images - to swap the outlying pixels, otherwise the columns are in the wrong order - if (numberOfComponents == 1 && count % 3 == 0) - std::swap(obuf[count], obuf[count + 2]); - } -#endif - } - - return true; - } - - - template - bool Read10bitFilledMethodA(const Header &dpx, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - // padding bits for PackedMethodA is 2 - return Read10bitFilled(dpx, readBuf, fd, element, block, data); - } - - - template - bool Read10bitFilledMethodB(const Header &dpx, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - return Read10bitFilled(dpx, readBuf, fd, element, block, data); - } - - - // 10 bit, packed data - // 12 bit, packed data - template - void UnPackPacked(U32 *readBuf, const int bitDepth, BUF *data, int count, int bufoff) - { - // unpack the words in the buffer - BUF *obuf = data + bufoff; - - for (int i = count - 1; i >= 0; i--) - { - // unpacking the buffer backwords - // find the byte that the data starts in, read in as a 16 bits then shift and mask - // the pattern with byte offset is: - // 10 bits datasize rotates every 4 data elements - // element 0 -> 6 bit shift to normalize at MSB (10 LSB shifted 6 bits) - // element 1 -> 4 bit shift to normalize at MSB - // element 2 -> 2 bit shift to normalize at MSB - // element 3 -> 0 bit shift to normalize at MSB - // 10 bit algorithm: (6-((count % 4)*2)) - // the pattern repeats every 160 bits - // 12 bits datasize rotates every 2 data elements - // element 0 -> 4 bit shift to normalize at MSB - // element 1 -> 0 bit shift to normalize at MSB - // 12 bit algorithm: (4-((count % 2)*4)) - // the pattern repeats every 96 bits - - // first determine the word that the data element completely resides in - U16 *d1 = reinterpret_cast(reinterpret_cast(readBuf)+((i * bitDepth) / 8 /*bits*/)); - - // place the component in the MSB and mask it for both 10-bit and 12-bit - U16 d2 = (*d1 << (REVERSE - ((i % REMAIN) * MULTIPLIER))) & MASK; - - // For the 10/12 bit cases, specialize the 16-bit conversion by - // repacking into the LSB and using a specialized conversion - if(bitDepth == 10) - { - d2 = d2 >> REVERSE; - BaseTypeConvertU10ToU16(d2, d2); - } - else if(bitDepth == 12) - { - d2 = d2 >> REVERSE; - BaseTypeConvertU12ToU16(d2, d2); - } - - BaseTypeConverter(d2, obuf[i]); - } - } - - - template - bool ReadPacked(const Header &dpxHeader, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - // image height to read - const int height = block.y2 - block.y1 + 1; - - // get the number of components for this element descriptor - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - - // end of line padding - int eolnPad = dpxHeader.EndOfLinePadding(element); - - // data size in bits - const int dataSize = dpxHeader.BitDepth(element); - - // number of bytes - const int lineSize = (dpxHeader.Width() * numberOfComponents * dataSize + 31) / 32; - - // read in each line at a time directly into the user memory space - for (int line = 0; line < height; line++) - { - // determine offset into image element - long offset = (line + block.y1) * (lineSize * sizeof(U32)) + - (block.x1 * numberOfComponents * dataSize / 32 * sizeof(U32)) + (line * eolnPad); - - // calculate read size - int readSize = ((block.x2 - block.x1 + 1) * numberOfComponents * dataSize); - readSize += (block.x1 * numberOfComponents * dataSize % 32); // add the bits left over from the beginning of the line - readSize = ((readSize + 31) / 32) * sizeof(U32); - - // calculate buffer offset - int bufoff = line * dpxHeader.Width() * numberOfComponents; - - fd->Read(dpxHeader, element, offset, readBuf, readSize); - - // unpack the words in the buffer - int count = (block.x2 - block.x1 + 1) * numberOfComponents; - UnPackPacked(readBuf, dataSize, data, count, bufoff); - } - - return true; - } - - - template - bool Read10bitPacked(const Header &dpxHeader, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - return ReadPacked(dpxHeader, readBuf, fd, element, block, data); - - } - - template - bool Read12bitPacked(const Header &dpxHeader, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - return ReadPacked(dpxHeader, readBuf, fd, element, block, data); - } - - - template - bool ReadBlockTypes(const Header &dpxHeader, SRC *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - // get the number of components for this element descriptor - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - - // byte count component type - const int bytes = dpxHeader.ComponentByteCount(element); - - // image image/height to read - const int width = (block.x2 - block.x1 + 1) * numberOfComponents; - const int height = block.y2 - block.y1 + 1; - - // end of line padding - int eolnPad = dpxHeader.EndOfLinePadding(element); - if (eolnPad == ~0) - eolnPad = 0; - - // image width - const int imageWidth = dpxHeader.Width(); - - // read in each line at a time directly into the user memory space - for (int line = 0; line < height; line++) - { - - // determine offset into image element - long offset = (line + block.y1) * imageWidth * numberOfComponents * bytes + - block.x1 * numberOfComponents * bytes + (line * eolnPad); - - if (BUFTYPE == SRCTYPE) - { - fd->ReadDirect(dpxHeader, element, offset, reinterpret_cast(data + (width*line)), width*bytes); - } - else - { - fd->Read(dpxHeader, element, offset, readBuf, width*bytes); - - // convert data - for (int i = 0; i < width; i++) - BaseTypeConverter(readBuf[i], data[width*line+i]); - } - - } - - return true; - } - - - template - bool Read12bitFilledMethodB(const Header &dpxHeader, U16 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - // get the number of components for this element descriptor - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - - // image width & height to read - const int width = (block.x2 - block.x1 + 1) * numberOfComponents; - const int height = block.y2 - block.y1 + 1; - - // width of image - const int imageWidth = dpxHeader.Width(); - - // end of line padding (not a required data element so check for ~0) - int eolnPad = dpxHeader.EndOfLinePadding(element); - if (eolnPad == ~0) - eolnPad = 0; - - // read in each line at a time directly into the user memory space - for (int line = 0; line < height; line++) - { - // determine offset into image element - long offset = (line + block.y1) * imageWidth * numberOfComponents * 2 + - block.x1 * numberOfComponents * 2 + (line * eolnPad); - - fd->Read(dpxHeader, element, offset, readBuf, width*2); - - // convert data - for (int i = 0; i < width; i++) - { - U16 d1 = readBuf[i]; - BaseTypeConvertU12ToU16(d1, d1); - BaseTypeConverter(d1, data[width*line+i]); - } - } - - return true; - } - -#ifdef RLE_WORKING - template - void ProcessImageBlock(const Header &dpxHeader, const int element, U32 *readBuf, const int x, BUF *data, const int bufoff) - { - const int bitDepth = dpxHeader.BitDepth(element); - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - const Packing packing = dpxHeader.ImagePacking(element); - - if (bitDepth == 10) - { - if (packing == kFilledMethodA) - Read10bitFilledMethodA(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - Unfill10bitFilled(readBuf, x, data, count, bufoff, numberOfComponents); - else if (packing == kFilledMethodB) - Read10bitFilledMethodB(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (packing == kPacked) - Read10bitPacked(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - UnPackPacked(readBuf, dataSize, data, count, bufoff); - } - else if (bitDepth == 12) - { - if (packing == kPacked) - Read12bitPacked(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (packing == kFilledMethodB) - Read12bitFilledMethodB(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - } - } -#endif - - template - bool ReadImageBlock(const Header &dpxHeader, U32 *readBuf, IR *fd, const int element, const Block &block, BUF *data) - { - const int bitDepth = dpxHeader.BitDepth(element); - const DataSize size = dpxHeader.ComponentDataSize(element); - const Packing packing = dpxHeader.ImagePacking(element); - - if (bitDepth == 10) - { - if (packing == kFilledMethodA) - return Read10bitFilledMethodA(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (packing == kFilledMethodB) - return Read10bitFilledMethodB(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (packing == kPacked) - return Read10bitPacked(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - } - else if (bitDepth == 12) - { - if (packing == kPacked) - return Read12bitPacked(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (packing == kFilledMethodB) - // filled method B - // 12 bits fill LSB of 16 bits - return Read12bitFilledMethodB(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - else - // filled method A - // 12 bits fill MSB of 16 bits - return ReadBlockTypes(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - } - else if (size == dpx::kByte) - return ReadBlockTypes(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kWord) - return ReadBlockTypes(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kInt) - return ReadBlockTypes(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kFloat) - return ReadBlockTypes(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kDouble) - return ReadBlockTypes(dpxHeader, reinterpret_cast(readBuf), fd, element, block, reinterpret_cast(data)); - - // should not reach here - return false; - } - - template - bool ReadImageBlock(const Header &dpxHeader, U32 *readBuf, IR *fd, const int element, const Block &block, void *data, const DataSize size) - { - if (size == dpx::kByte) - return ReadImageBlock(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kWord) - return ReadImageBlock(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kInt) - return ReadImageBlock(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kFloat) - return ReadImageBlock(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - else if (size == dpx::kDouble) - return ReadImageBlock(dpxHeader, readBuf, fd, element, block, reinterpret_cast(data)); - - // should not reach here - return false; - } - - -#ifdef RLE_WORKING - // THIS IS PART OF THE INCOMPLETE RLE CODE - - // src is full image without any eoln padding - template - void CopyImageBlock(const Header &dpxHeader, const int element, SRC *src, DataSize srcSize, DST *dst, DataSize dstSize, const Block &block) - { - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - const int width = dpxHeader.Width(); - const int byteCount = dpxHeader.ComponentByteCount(element); - const int pixelByteCount = numberOfComponents * byteCount; - - int srcoff, dstoff; - int x, y, nc; - - if (srcSize == dstSize) - { - int lineSize = (width * numberOfComponents * byteCount); - U8 * srcU8 = reinterpret_cast(src); - U8 * dstU8 = reinterpret_cast(dst); - for (y = block.y1; y <= block.y2; y++) - { - int copySize = (block.x2 - block.x1 + 1) * numberOfComponents * byteCount; - memcpy(srcU8 + (y * lineSize) + (block.x1 * numberOfComponents * byteCount), dstU8, copySize); - outBuf += copySize; - } - return; - } - - - for (y = block.y1; y <= block.y2; y++) - { - dstoff = (y - block.y1) * ((block.x2 - block.x1 + 1) * numberOfComponents) - block.x1; - for (x = block.x1; x <= block.x2; x++) - { - for (nc = 0; nc < numberOfComponents; nc++) - { - SRC d1 = src[(y * width * numberOfComponents) + (x * numberOfComponents) + nc]; - BaseTypeConverter(d1, dst[dstoff+((x-block.x1)*numberOfComponents) + nc]); - } - } - } - } - - - template - void CopyImageBlock(const Header &dpxHeader, const int element, SRC *src, DataSize srcSize, void *dst, DataSize dstSize, const Block &block) - { - if (dstSize == dpx::kByte) - CopyImageBlock(dpxHeader, element, src, srcSize, reinterpret_cast(dst), dstSize, block); - else if (dstSize == dpx::kWord) - CopyImageBlock(dpxHeader, element, src, srcSize, reinterpret_cast(dst), dstSize, block); - else if (dstSize == dpx::kInt) - CopyImageBlock(dpxHeader, element, src, srcSize, reinterpret_cast(dst), dstSize, block); - else if (dstSize == dpx::kFloat) - CopyImageBlock(dpxHeader, element, src, srcSize, reinterpret_cast(dst), dstSize, block); - else if (dstSize == dpx::kDouble) - CopyImageBlock(dpxHeader, element, src, srcSize, reinterpret_cast(dst), dstSize, block); - - } - - - void CopyImageBlock(const Header &dpxHeader, const int element, void *src, DataSize srcSize, void *dst, DataSize dstSize, const Block &block) - { - if (srcSize == dpx::kByte) - CopyImageBlock(dpxHeader, element, reinterpret_cast(src), srcSize, dst, dstSize, block); - else if (srcSize == dpx::kWord) - CopyImageBlock(dpxHeader, element, reinterpret_cast(src), srcSize, dst, dstSize, block); - else if (srcSize == dpx::kInt) - CopyImageBlock(dpxHeader, element, reinterpret_cast(src), srcSize, dst, dstSize, block); - else if (srcSize == dpx::kFloat) - CopyImageBlock(dpxHeader, element, reinterpret_cast(src), srcSize, dst, dstSize, block); - else if (srcSize == dpx::kDouble) - CopyImageBlock(dpxHeader, element, reinterpret_cast(src), srcSize, dst, dstSize, block); - - } -#endif - -} - - -#endif - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.cpp deleted file mode 100644 index f8803f5e7..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "DPX.h" -#include "RunLengthEncoding.h" -#include "ElementReadStream.h" -#include "ReaderInternal.h" - -// Basic size of a packet is the number of bytes that all data packing methods will fit into that are whole and complete -#define PACKET_REPEAT (10 * sizeof(U32)) // 320 bits repeating pattern -#define BUFFER_SIZE (PACKET_REPEAT * 1002) // read in temp buffer size -#define EXPANDED_BUFFER_SIZE (BUFFER_SIZE + (BUFFER_SIZE / 3)) // expaded size after unpacking (max) - -dpx::RunLengthEncoding::RunLengthEncoding() - : buf(0) -{ -} - -dpx::RunLengthEncoding::~RunLengthEncoding() -{ - if(this->buf) - delete[] buf; -} - -void dpx::RunLengthEncoding::Reset() -{ - if(this->buf) - { - delete[] buf; - this->buf = 0; - } -} - -bool dpx::RunLengthEncoding::Read(const Header& dpxHeader, ElementReadStream* fd, const int element, const Block& block, - void* data, const DataSize size) -{ - int i; - - // just check to make sure that this element is RLE - if(dpxHeader.ImageEncoding(element) != kRLE) - return false; - - // get the number of components for this element descriptor - const int numberOfComponents = dpxHeader.ImageElementComponentCount(element); - const int width = dpxHeader.Width(); - const int height = dpxHeader.Height(); - const int byteCount = dpxHeader.ComponentByteCount(element); - const U32 eolnPad = dpxHeader.EndOfLinePadding(element); - // DataSize srcSize = dpxHeader.ComponentDataSize(element); - - // has the buffer been read in and decoded? - if(this->buf == 0) - { - // not yet - - // bit depth of the image element - const int bitDepth = dpxHeader.BitDepth(element); - - // error out if the bit depth 10 or 12 and have eoln bytes - // this is particularly slow to parse and eoln padding bytes - // are not needed for those formats - // also if end of padding makes the line length odd, error out for that as well - if(bitDepth != 8 && bitDepth != 16 && eolnPad > 0) - return false; - else if(bitDepth == 16 && eolnPad != 2 && eolnPad != 0) - return false; - - // error out for real types since bit operations don't really make sense - if(size == kFloat || size == kDouble) - return false; - - // find start and possible end of the element - U32 startOffset = dpxHeader.DataOffset(element); - U32 endOffset = 0xffffffff; - U32 currentOffset = startOffset; - - for(i = 0; i < MAX_ELEMENTS; i++) - { - if(i == element) - continue; - U32 doff = dpxHeader.DataOffset(i); - if(doff == 0xffffffff) - continue; - if(doff > startOffset && (endOffset == 0xffffffff || doff < endOffset)) - endOffset = doff - 1; - } - - // size of the image - const size_t imageSize = width * height * numberOfComponents; - const size_t imageByteSize = imageSize * byteCount; - - // allocate the buffer that will store the entire image - this->buf = new U8[imageByteSize]; - - // allocate the temporary buffer that will read in the encoded image - U8* tempBuf = new U8[EXPANDED_BUFFER_SIZE]; - - // xpos, ypos in decoding - /*int xpos = 0; - int ypos = 0;*/ - - // read in the encoded image block at a time - bool done = false; - while(!done) - { - // read in temp buffer - size_t rs = fd->ReadDirect(dpxHeader, element, (currentOffset - startOffset), tempBuf, BUFFER_SIZE); - currentOffset += rs; - if(rs != BUFFER_SIZE) - done = true; - else if(endOffset != 0xffffffff && currentOffset >= endOffset) - done = true; - - // if 10-bit, 12-bit, unpack or unfill - - // step through and decode - } - - // no longer need temp buffer - delete[] tempBuf; - } - -#ifdef RLE_WORKING - // NOT COMPLETE YET - // copy buffer - CopyImageBlock(dpxHeader, element, buf, srcSize, data, size, dstSize, block); -#endif - return true; -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.h deleted file mode 100755 index 81878acc7..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/RunLengthEncoding.h +++ /dev/null @@ -1,95 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_RUNLENGTHENCODING_H -#define _DPX_RUNLENGTHENCODING_H 1 - - -#include "DPX.h" -#include "Codec.h" - - -namespace dpx -{ - - /*! - * \brief compress / decompress data segments, used for RLE compression - */ - class RunLengthEncoding : public Codec - { - public: - /*! - * \brief constructor - */ - RunLengthEncoding(); - - /*! - * \brief destructor - */ - virtual ~RunLengthEncoding(); - - /*! - * \brief reset instance - */ - virtual void Reset(); - - /*! - * \brief read data - * \param dpxHeader dpx header information - * \param fd field descriptor - * \param element element (0-7) - * \param block image area to read - * \param data buffer - * \param size size of the buffer component - * \return success - */ - virtual bool Read(const dpx::Header &dpxHeader, - ElementReadStream *fd, - const int element, - const Block &block, - void *data, - const DataSize size); - - protected: - U8 *buf; //!< intermediate buffer - }; - - -} - - -#endif - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.cpp deleted file mode 100644 index 87c25c539..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -int OpenDPXTestFunc() -{ - return 1; -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.h deleted file mode 100755 index 7f5d58b21..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/TestFunc.h +++ /dev/null @@ -1,48 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_TESTFUNC_H -#define _DPX_TESTFUNC_H - - -// C function that can be called by autoconf AC_CHECK_LIB() -// to check the existance of the OpenDPX library -extern "C" int OpenDPXTestFunc(); - - - -#endif - - diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Writer.cpp b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Writer.cpp deleted file mode 100644 index 4ea852f6a..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/Writer.cpp +++ /dev/null @@ -1,408 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "DPX.h" -#include "DPXStream.h" -#include "EndianSwap.h" -#include "WriterInternal.h" - -dpx::Writer::Writer() - : fileLoc(0) -{ -} - -dpx::Writer::~Writer() -{ -} - -void dpx::Writer::Start() -{ -} - -void dpx::Writer::SetFileInfo(const char* fileName, const char* creationTimeDate, const char* creator, const char* project, - const char* copyright, const U32 encryptKey, const bool swapEndian) -{ - if(fileName) - this->header.SetFileName(fileName); - - if(creationTimeDate) - this->header.SetCreationTimeDate(creationTimeDate); - else - { - time_t seconds = time(0); - this->header.SetCreationTimeDate(seconds); - } - - if(creator) - this->header.SetCreator(creator); - else - this->header.SetCreator("OpenDPX library"); - - if(project) - this->header.SetProject(project); - if(copyright) - this->header.SetCopyright(copyright); - this->header.SetEncryptKey(encryptKey); - - if(swapEndian) - this->header.magicNumber = SwapBytes(this->header.magicNumber); -} - -void dpx::Writer::SetImageInfo(const U32 width, const U32 height) -{ - this->header.SetImageOrientation(kLeftToRightTopToBottom); - this->header.SetPixelsPerLine(width); - this->header.SetLinesPerElement(height); -} - -// returns next available or MAX_ELEMENTS if full -int dpx::Writer::NextAvailElement() const -{ - unsigned int i; - - for(i = 0; i < MAX_ELEMENTS; i++) - { - if(this->header.ImageDescriptor(i) == kUndefinedDescriptor) - break; - } - - return i; -} - -void dpx::Writer::SetOutStream(OutStream* fd) -{ - this->fd = fd; -} - -bool dpx::Writer::WriteHeader() -{ - // calculate any header info - this->header.CalculateOffsets(); - - // seek to the beginning of the file - if(!this->fd->Seek(0, OutStream::kStart)) - return false; - - // writing the header count - this->fileLoc = this->header.Size(); - - return this->header.Write(fd); -} - -void dpx::Writer::SetUserData(const long size) -{ - // TODO -} - -bool dpx::Writer::WriteUserData(void* data) -{ - // XXX TODO - return false; -} - -void dpx::Writer::SetElement(const int num, const Descriptor desc, const U8 bitDepth, const Characteristic transfer, - const Characteristic colorimetric, const Packing packing, const Encoding encoding, - const U32 dataSign, const U32 lowData, const R32 lowQuantity, const U32 highData, - const R32 highQuantity, const U32 eolnPadding, const U32 eoimPadding) -{ - // make sure the range is good - if(num < 0 || num >= MAX_ELEMENTS) - return; - - // set values - this->header.SetDataSign(num, dataSign); - this->header.SetLowData(num, lowData); - this->header.SetLowQuantity(num, lowQuantity); - this->header.SetHighData(num, highData); - this->header.SetHighQuantity(num, highQuantity); - this->header.SetImageDescriptor(num, desc); - this->header.SetTransfer(num, transfer); - this->header.SetColorimetric(num, colorimetric); - this->header.SetBitDepth(num, bitDepth); - this->header.SetImagePacking(num, packing); - this->header.SetImageEncoding(num, encoding); - this->header.SetEndOfLinePadding(num, eolnPadding); - this->header.SetEndOfImagePadding(num, eoimPadding); - - // determine if increases element count - this->header.CalculateNumberOfElements(); -} - -// the data is processed so write it straight through -// argument count is total size in bytes of the passed data -bool dpx::Writer::WriteElement(const int element, void* data, const long count) -{ - // make sure the range is good - if(element < 0 || element >= MAX_ELEMENTS) - return false; - - // make sure the entry is valid - if(this->header.ImageDescriptor(element) == kUndefinedDescriptor) - return false; - - // update file ptr - this->header.SetDataOffset(element, this->fileLoc); - this->fileLoc += count; - - // write - return (this->fd->Write(data, count) > 0); -} - -bool dpx::Writer::WriteElement(const int element, void* data) -{ - // make sure the range is good - if(element < 0 || element >= MAX_ELEMENTS) - return false; - - // make sure the entry is valid - if(this->header.ImageDescriptor(element) == kUndefinedDescriptor) - return false; - - return this->WriteElement(element, data, this->header.ComponentDataSize(element)); -} - -bool dpx::Writer::WriteElement(const int element, void* data, const DataSize size) -{ - bool status = true; - - // make sure the range is good - if(element < 0 || element >= MAX_ELEMENTS) - return false; - - // make sure the entry is valid - if(this->header.ImageDescriptor(element) == kUndefinedDescriptor) - return false; - - // mark location in headers - if(element == 0) - this->header.SetImageOffset(this->fileLoc); - this->header.SetDataOffset(element, this->fileLoc); - - // reverse the order of the components - bool reverse = false; - - // rle encoding? - const bool rle = this->header.ImageEncoding(element) == kRLE; - - // image parameters - const U32 eolnPad = this->header.EndOfLinePadding(element); - const U32 eoimPad = this->header.EndOfImagePadding(element); - const U8 bitDepth = this->header.BitDepth(element); - const U32 width = this->header.Width(); - const U32 height = this->header.Height(); - const int noc = this->header.ImageElementComponentCount(element); - const Packing packing = this->header.ImagePacking(element); - - // check width & height, just in case - if(width == 0 || height == 0) - return false; - - // sizeof a component in an image - const int bytes = (bitDepth + 7) / 8; - - // allocate memory for use to write blank space - char* blank = 0; - if(eolnPad || eoimPad) - { - int bsize = eolnPad > eoimPad ? eolnPad : eoimPad; - blank = new char[bsize]; - memset(blank, 0, bsize * sizeof(char)); - } - - // can we write the entire memory chunk at once without any additional processing - if(!rle && - ((bitDepth == 8 && size == dpx::kByte) || (bitDepth == 12 && size == dpx::kWord && packing == kFilledMethodA) || - (bitDepth == 16 && size == dpx::kWord) || (bitDepth == 32 && size == dpx::kFloat) || - (bitDepth == 64 && size == dpx::kDouble))) - { - status = this->WriteThrough(data, width, height, noc, bytes, eolnPad, eoimPad, blank); - if(blank) - delete[] blank; - return status; - } - else - { - switch(bitDepth) - { - case 8: - if(size == dpx::kByte) - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - else - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - break; - - case 10: - // are the channels stored in reverse - if(this->header.ImageDescriptor(element) == kRGB && this->header.DatumSwap(element) && bitDepth == 10) - reverse = true; - - if(size == dpx::kWord) - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - else - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - break; - - case 12: - if(size == dpx::kWord) - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - else - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - break; - - case 16: - if(size == dpx::kWord) - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - else - this->fileLoc += - WriteBuffer(this->fd, size, data, width, height, noc, packing, rle, reverse, eolnPad, - blank, status, this->header.RequiresByteSwap()); - break; - - case 32: - if(size == dpx::kFloat) - this->fileLoc += - WriteFloatBuffer(this->fd, size, data, width, height, noc, packing, rle, eolnPad, - blank, status, this->header.RequiresByteSwap()); - else - this->fileLoc += - WriteFloatBuffer(this->fd, size, data, width, height, noc, packing, rle, eolnPad, - blank, status, this->header.RequiresByteSwap()); - break; - - case 64: - if(size == dpx::kDouble) - this->fileLoc += - WriteFloatBuffer(this->fd, size, data, width, height, noc, packing, rle, eolnPad, - blank, status, this->header.RequiresByteSwap()); - else - this->fileLoc += - WriteFloatBuffer(this->fd, size, data, width, height, noc, packing, rle, eolnPad, - blank, status, this->header.RequiresByteSwap()); - break; - } - } - - // if successful - if(status && eoimPad) - { - // end of image padding - this->fileLoc += eoimPad; - status = (this->fd->Write(blank, eoimPad) > 0); - } - - // rid of memory - if(blank) - delete[] blank; - - return status; -} - -// the passed in image buffer is written to the file untouched - -bool dpx::Writer::WriteThrough(void* data, const U32 width, const U32 height, const int noc, const int bytes, - const U32 eolnPad, const U32 eoimPad, char* blank) -{ - bool status = true; - const int count = width * height * noc; - unsigned int i; - unsigned char* imageBuf = reinterpret_cast(data); - - // file pointer location after write - this->fileLoc += bytes * count + (eolnPad * height); - - // write data - if(eolnPad) - { - // loop if have end of line padding - for(i = 0; i < height; i++) - { - // write one line - if(this->fd->Write(imageBuf + (width * bytes * i), bytes * width) == false) - { - status = false; - break; - } - - // write end of line padding - if(this->fd->Write(blank, eoimPad) == false) - { - status = false; - break; - } - } - } - else - { - // write data as one chunk - if(this->fd->Write(imageBuf, bytes * count) == false) - { - status = false; - } - } - - // end of image padding - if(status && eoimPad) - { - this->fileLoc += eoimPad; - status = (this->fd->Write(blank, eoimPad) > 0); - } - - return status; -} - -bool dpx::Writer::Finish() -{ - // write the file size in the header - this->header.SetFileSize(this->fileLoc); - - // rewrite all of the offsets in the header - return this->header.WriteOffsetData(this->fd); -} diff --git a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/WriterInternal.h b/plugins/image/io/Dpx/src/dpx-google-code/libdpx/WriterInternal.h deleted file mode 100755 index 6805a802c..000000000 --- a/plugins/image/io/Dpx/src/dpx-google-code/libdpx/WriterInternal.h +++ /dev/null @@ -1,443 +0,0 @@ -// -*- mode: C++; tab-width: 4 -*- -// vi: ts=4 - -/* - * Copyright (c) 2009, Patrick A. Palmer. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Patrick A. Palmer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#ifndef _DPX_WRITERINTERNAL_H -#define _DPX_WRITERINTERNAL_H 1 - - -#include "BaseTypeConverter.h" - - -namespace dpx -{ - - - void EndianBufferSwap(int bitdepth, dpx::Packing packing, void *buf, const size_t size) - { - switch (bitdepth) - { - case 8: - break; - case 12: - if (packing == dpx::kPacked) - dpx::EndianSwapImageBuffer(buf, size / sizeof(U32)); - else - dpx::EndianSwapImageBuffer(buf, size / sizeof(U16)); - break; - case 16: - dpx::EndianSwapImageBuffer(buf, size / sizeof(U16)); - break; - default: // 10-bit, 32-bit, 64-bit - dpx::EndianSwapImageBuffer(buf, size / sizeof(U32)); - } - } - - - template - void MultiTypeBufferCopy(T1 *dst, T2 *src, const int len) - { - for (int i = 0; i < len; i++) - BaseTypeConverter(src[i], dst[i]); - } - - - template - void CopyWriteBuffer(DataSize src_size, unsigned char *src, IB * dst, const int len) - { - if (src_size == kByte) - MultiTypeBufferCopy(dst, reinterpret_cast(src), len); - else if (src_size == kWord) - MultiTypeBufferCopy(dst, reinterpret_cast(src), len); - else if (src_size == kFloat) - MultiTypeBufferCopy(dst, reinterpret_cast(src), len); - else if (src_size == kDouble) - MultiTypeBufferCopy(dst, reinterpret_cast(src), len); - - } - - - // access modifications to the buffer based on compression and packing - struct BufferAccess - { - int offset; - int length; - BufferAccess() : offset(0), length(0) { } - }; - - - - // \todo NOT DONE - template - void RleCompress(IB *src, IB *dst, const int bufsize, const int len, BufferAccess &access) - { - IB ch; - int count; - int i; - int index = bufsize - 1; - bool start = true; - //bool match = true; - - // for each data type, have maximum length of rle datum - // subtract one so it the LSBit can be used to state - int maxCount; - if (BITDEPTH == 8) - maxCount = 0xff - 1; - else if (BITDEPTH == 10) - maxCount = 0x3ff - 1; - else if (BITDEPTH == 12) - maxCount = 0xfff - 1; - else if (BITDEPTH == 16) - maxCount = 0xffff - 1; - else - maxCount = 1000000; // high number for floats, doubles - - - for (i = len - 1; i >= 0; i--) - { - if (start) - { - count = 1; - start = false; - ch = src[i]; - dst[index--] = ch; - } - } - - access.offset = index; - access.length = bufsize - index; - } - - - template - void WritePackedMethod(IB *src, IB *dst, const int len, const bool reverse, BufferAccess &access) - { - // pack into the same memory space - U32 *dst_u32 = reinterpret_cast(dst); - - // bit shift count for U16 source - const int shift = 16 - BITDEPTH; - - // bit mask - U32 mask = 0; - if (BITDEPTH == 10) - mask = 0x03ff; - else if (BITDEPTH == 12) - mask = 0x0fff; - else if (BITDEPTH == 8) - return; - - int i, entry; - for (i = 0; i < len; i++) - { - // read value and determine write location - U32 value = static_cast(src[i+access.offset]) >> shift; - - // if reverse the order -/*** XXX TODO REVERSE - if (reverse) - // reverse the triplets so entry would be 2,1,0,5,4,3,8,7,6,... - entry = ((i / 3) * 3) + (2 - (i % 3)); - else -***/ - entry = i; - - int div = (entry * BITDEPTH) / 32; // 32 bits in a U32 - int rem = (entry * BITDEPTH) % 32; - - // write the bits that belong in the first U32 - // calculate the masked bits for the added value - U32 shift_mask = mask << rem; - - // mask sure to mask the bits to save as part of the src_buf - // so if writing bits 8-18, save the bits of the source material - dst_u32[div] = (dst_u32[div] & ~shift_mask) | ((value << rem) & shift_mask); - - // write across multiple U16? count the carry bits - int carry = BITDEPTH - (32 - rem); - if (carry > 0) - { - U32 save = BITDEPTH - carry; - dst_u32[div+1] = (dst_u32[div+1] & ~(mask >> save)) | ((value >> save) & (mask >> save)); - } - } - - // adjust offset/length - access.offset = 0; - access.length = (((len * BITDEPTH) / 32) + ((len * BITDEPTH) % 32 ? 1 : 0)) * 2; - } - - - - // this routine expects a type of U16 - template - void WritePackedMethodAB_10bit(IB *src, IB *dst, const int len, const bool reverse, BufferAccess &access) - { - // pack into the same memory space - U32 *dst_u32 = reinterpret_cast(dst); - - // bit shift count - const U32 shift = 6; // (16 - BITDEPTH) - const U32 bitdepth = 10; - const U32 bitmask = 0x03ff; - - // shift bits over 2 if Method A - const int method_shift = (METHOD == kFilledMethodA ? 2 : 0); - - // loop through the buffer - int i; - U32 value = 0; - for (i = 0; i < len; i++) - { - int div = i / 3; // 3 10-bit values in a U32 - int rem = i % 3; - - // write previously calculated value - if (i && rem == 0) - { - dst_u32[div-1] = value; - value = 0; - } - - // if reverse the order - if (reverse) - rem = 2 - rem; - - // place the 10 bits in the proper place with mask - U32 comp = ((static_cast(src[i+access.offset]) >> shift) << (bitdepth * rem)) << method_shift; - U32 mask = (bitmask << (bitdepth * rem)) << method_shift ; - - // overwrite only the proper 10 bits - value = (value & ~mask) | (comp & mask); - } - - // write last - dst_u32[(len+2)/3-1] = value; - - // adjust offset/length - // multiply * 2 because it takes two U16 = U32 and this func packs into a U32 - access.offset = 0; - access.length = ((len / 3) + (len % 3 ? 1 : 0)) * 2; - } - - - - template - int WriteBuffer(OutStream *fd, DataSize src_size, void *src_buf, const U32 width, const U32 height, const int noc, const Packing packing, - const bool rle, const bool reverse, const int eolnPad, char *blank, bool &status, bool swapEndian) - { - int fileOffset = 0; - - // determine any impact on the max line size due to RLE - // impact may be that rle is true but the data can not be compressed at all - // the worst possible compression with RLE is increasing the image size by 1/3 - // so we will just double the destination size if RLE - int rleBufAdd = (rle ? ((width * noc / 3) + 1) : 0); - - // buffer access parameters - BufferAccess bufaccess; - bufaccess.offset = 0; - bufaccess.length = width * noc; - - // allocate one line - IB *src; - IB *dst = new IB[(width * noc) + 1 + rleBufAdd]; - - // each line in the buffer - for (U32 h = 0; h < height; h++) - { - // image buffer - unsigned char *imageBuf = reinterpret_cast(src_buf); - const int bytes = Header::DataSizeByteCount(src_size); - - // copy buffer if need to promote data types from src to destination - if (!SAMEBUFTYPE) - { - src = dst; - CopyWriteBuffer(src_size, (imageBuf+(h*width*noc*bytes)+(h*eolnPad)), dst, (width*noc)); - } - else - // not a copy, access source - src = reinterpret_cast(imageBuf + (h * width * noc * bytes) + (h*eolnPad)); - - // if rle, compress - if (rle) - { - RleCompress(src, dst, ((width * noc) + rleBufAdd), width * noc, bufaccess); - src = dst; - } - - // if 10 or 12 bit, pack - if (BITDEPTH == 10) - { - if (packing == dpx::kPacked) - { - WritePackedMethod(src, dst, (width*noc), reverse, bufaccess); - } - else if (packing == kFilledMethodA) - { - WritePackedMethodAB_10bit(src, dst, (width*noc), reverse, bufaccess); - } - else // if (packing == dpx::kFilledMethodB) - { - WritePackedMethodAB_10bit(src, dst, (width*noc), reverse, bufaccess); - } - } - else if (BITDEPTH == 12) - { - if (packing == dpx::kPacked) - { - WritePackedMethod(src, dst, (width*noc), reverse, bufaccess); - } - else if (packing == dpx::kFilledMethodB) - { - // shift 4 MSB down, so 0x0f00 would become 0x00f0 - for (int w = 0; w < bufaccess.length; w++) - dst[w] = src[bufaccess.offset+w] >> 4; - bufaccess.offset = 0; - } - // a bitdepth of 12 by default is packed with dpx::kFilledMethodA - // assumes that either a copy or rle was required - // otherwise this routine should not be called with: - // 12-bit Method A with the source buffer data type is kWord - } - - // write line - fileOffset += (bufaccess.length * sizeof(IB)); - if (swapEndian) - EndianBufferSwap(BITDEPTH, packing, dst + bufaccess.offset, bufaccess.length * sizeof(IB)); - if (fd->Write(dst+bufaccess.offset, (bufaccess.length * sizeof(IB))) == false) - { - status = false; - break; - } - - // end of line padding - if (eolnPad) - { - fileOffset += eolnPad; - if (fd->Write(blank, eolnPad) == false) - { - status = false; - break; - } - } - - } - - // done with buffer - delete [] dst; - - return fileOffset; - } - - - template - int WriteFloatBuffer(OutStream *fd, DataSize src_size, void *src_buf, const U32 width, const U32 height, const int noc, const Packing packing, - const bool rle, const int eolnPad, char *blank, bool &status, bool swapEndian) - { - int fileOffset = 0; - - // determine any impact on the max line size due to RLE - // impact may be that rle is true but the data can not be compressed at all - // the worst possible compression with RLE is increasing the image size by 1/3 - // so we will just double the destination size if RLE - int rleBufAdd = (rle ? ((width * noc / 3) + 1) : 0); - - // buffer access parameters - BufferAccess bufaccess; - bufaccess.offset = 0; - bufaccess.length = width * noc; - - // allocate one line - IB *src; - IB *dst = new IB[(width * noc) + rleBufAdd]; - - // each line in the buffer - for (U32 h = 0; h < height; h++) - { - // image buffer - unsigned char *imageBuf = reinterpret_cast(src_buf); - const int bytes = Header::DataSizeByteCount(src_size); - - // copy buffer if need to promote data types from src to destination - if (!SAMEBUFTYPE) - { - src = dst; - CopyWriteBuffer(src_size, (imageBuf+(h*width*noc*bytes)+(h*eolnPad)), dst, (width*noc)); - } - else - // not a copy, access source - src = reinterpret_cast(imageBuf + (h * width * noc * bytes) + (h*eolnPad)); - - // if rle, compress - if (rle) - { - RleCompress(src, dst, ((width * noc) + rleBufAdd), width * noc, bufaccess); - src = dst; - } - - // write line - fileOffset += (bufaccess.length * sizeof(IB)); - if (swapEndian) - EndianBufferSwap(BITDEPTH, packing, dst + bufaccess.offset, bufaccess.length * sizeof(IB)); - if (fd->Write(dst+bufaccess.offset, (bufaccess.length * sizeof(IB))) == false) - { - status = false; - break; - } - - // end of line padding - if (eolnPad) - { - fileOffset += eolnPad; - if (fd->Write(blank, eolnPad) == false) - { - status = false; - break; - } - } - - } - - // done with buffer - delete [] dst; - - return fileOffset; - } -} - -#endif - - diff --git a/plugins/image/io/Dpx/src/mainEntry.cpp b/plugins/image/io/Dpx/src/mainEntry.cpp deleted file mode 100644 index 93a89fd08..000000000 --- a/plugins/image/io/Dpx/src/mainEntry.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#define OFXPLUGIN_VERSION_MAJOR 1 -#define OFXPLUGIN_VERSION_MINOR 1 - -#include -#include "writer/DPXWriterPluginFactory.hpp" - -namespace OFX -{ -namespace Plugin -{ -void getPluginIDs(OFX::PluginFactoryArray& ids) -{ - mAppendPluginFactory(ids, tuttle::plugin::dpx::writer::DPXWriterPluginFactory, "tuttle.dpxwriter"); -} -} -} diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterAlgorithm.hpp b/plugins/image/io/Dpx/src/writer/DPXWriterAlgorithm.hpp deleted file mode 100644 index c587473d7..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterAlgorithm.hpp +++ /dev/null @@ -1,318 +0,0 @@ -#ifndef _TUTTLE_PLUGIN_DPXWRITER_ALGORITHM_HPP_ -#define _TUTTLE_PLUGIN_DPXWRITER_ALGORITHM_HPP_ - -#include - -#ifndef __SSSE3__ -#include -#else -// SSSE3 -#include -#endif - -#include -#include - -using namespace boost::gil; - -typedef std::vector > DataVector; - -void convertGrayToRGB(DataVector& dataVec, size_t width, size_t height, int pixelSize) -{ - size_t size = width * height; - switch(pixelSize) - { - case 1: - { - char* ptrS = (char*)&dataVec.front(); - char* ptrD = (char*)&dataVec.front(); - // go to end of image - ptrS += size - 1; - ptrD += (3 * size) - 1; - // process from back to begin - for(size_t i = 0; i < size; i++) - { - *ptrD = *ptrS; - ptrD--; // red - *ptrD = *ptrS; - ptrD--; // green - *ptrD = *ptrS; - ptrD--; - ptrS--; // blue - } - break; - } - case 2: - { - short* ptrS = (short*)&dataVec.front(); - short* ptrD = (short*)&dataVec.front(); - // go to end of image - ptrS += size - 1; - ptrD += (3 * size) - 1; - // process from back to begin - for(size_t i = 0; i < size; i++) - { - *ptrD = *ptrS; - ptrD--; // red - *ptrD = *ptrS; - ptrD--; // green - *ptrD = *ptrS; - ptrD--; - ptrS--; // blue - } - break; - } - case 4: - { - float* ptrS = (float*)&dataVec.front(); - float* ptrD = (float*)&dataVec.front(); - // go to end of image - ptrS += size - 1; - ptrD += (3 * size) - 1; - // process from back to begin - for(size_t i = 0; i < size; i++) - { - *ptrD = *ptrS; - ptrD--; // red - *ptrD = *ptrS; - ptrD--; // green - *ptrD = *ptrS; - ptrD--; - ptrS--; // blue - } - break; - } - } -} - -void convertRGBToRGBA() -{ -} - -void convertRGBToABGR() -{ -} - -void convertRGBAToRGB(DataVector& dataVec, size_t width, size_t height, int pixelSize) -{ - size_t size = width * height; - - switch(pixelSize) - { - case 4: - { - char* ptrS = (char*)&dataVec.front(); - char* ptrD = ptrS; - for(size_t i = 0; i < size; i++) - { - *ptrD = *ptrS; - ptrS++; - ptrD++; // red - *ptrD = *ptrS; - ptrS++; - ptrD++; // green - *ptrD = *ptrS; - ptrS += 2; /*skip alpha*/ - ptrD++; // blue - } - break; - } - case 8: - { - short* ptrS = (short*)&dataVec.front(); - short* ptrD = ptrS; - for(size_t i = 0; i < size; i++) - { - *ptrD = *ptrS; - ptrS++; - ptrD++; // red - *ptrD = *ptrS; - ptrS++; - ptrD++; // green - *ptrD = *ptrS; - ptrS += 2; /*skip alpha*/ - ptrD++; // blue - } - break; - } - case 16: - { - float* ptrS = (float*)&dataVec.front(); - float* ptrD = ptrS; - for(size_t i = 0; i < size; i++) - { - *ptrD = *ptrS; - ptrS++; - ptrD++; // red - *ptrD = *ptrS; - ptrS++; - ptrD++; // green - *ptrD = *ptrS; - ptrS += 2; /*skip alpha*/ - ptrD++; // blue - } - } - } -} - -void convertRGBAToABGR(DataVector& dataVec, size_t width, size_t height, int pixelSize) -{ - float* dataPtrIt = (float*)&dataVec.front(); - __m128i* dataCharIt = NULL; - __m128i data, mask; - - char* charPtr = NULL; - // define flipping data - char charMask[16] = { - 0x03, 0x02, 0x01, - 0x00, // pixel 1 - 0x07, 0x06, 0x05, - 0x04, // pixel 2 - 0x0B, 0x0A, 0x09, - 0x08, // pixel 3 - 0x0F, 0x0E, 0x0D, - 0x0C // pixel 4 - }; - char shortMask[16] = { - 0x06, 0x07, 0x04, 0x05, 0x02, - 0x03, 0x00, 0x01, // pixel 1 - 0x0E, 0x0F, 0x0C, 0x0D, 0x0A, - 0x0B, 0x08, 0x09 // pixel 2 - }; - - size_t size = width * height; - - size_t i = 0; - - switch(pixelSize) - { - case 4: - { - // loading mask to flip with char data - mask = _mm_loadu_si128((__m128i*)charMask); -#ifndef __SSSE3__ - __m128i maskA = _mm_set_epi32(0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff); - __m128i maskB = _mm_sll_epi32(maskA, _mm_set_epi32(8, 8, 8, 8)); - __m128i maskC = _mm_sll_epi32(maskB, _mm_set_epi32(8, 8, 8, 8)); - __m128i maskD = _mm_sll_epi32(maskC, _mm_set_epi32(8, 8, 8, 8)); -#endif - for(; i < size - 3; i += 4) - { - dataCharIt = (__m128i*)dataPtrIt; - data = _mm_loadu_si128(dataCharIt); -#ifdef __SSSE3__ - data = _mm_shuffle_epi8(data, mask); -#else - - __m128i result = _mm_srl_epi32(_mm_and_si128(data, maskD), _mm_set_epi32(24, 24, 24, 24)); - result = _mm_or_si128(_mm_srl_epi32(_mm_and_si128(data, maskC), _mm_set_epi32(8, 8, 8, 8)), result); - result = _mm_or_si128(_mm_sll_epi32(_mm_and_si128(data, maskB), _mm_set_epi32(8, 8, 8, 8)), result); - result = _mm_or_si128(_mm_sll_epi32(_mm_and_si128(data, maskA), _mm_set_epi32(24, 24, 24, 24)), result); - - data = result; -#endif - _mm_store_si128(dataCharIt, data); - dataPtrIt += 4; - } - charPtr = (char*)dataPtrIt; - for(size_t lastPixel = 0; lastPixel < size - i; i++) - { - char pixel[4]; - for(size_t c = 0; c < 4; c++) - { - pixel[c] = *charPtr; - charPtr++; - } - charPtr -= 4; - for(int c = 3; c > -1; c--) - { - *charPtr = pixel[c]; - charPtr++; - } - } - break; - } - case 8: - { - // loading mask to flip with short data - mask = _mm_loadu_si128((__m128i*)shortMask); -#ifndef __SSSE3__ - __m128i maskA = _mm_set_epi32(0x00000000, 0x0000ffff, 0x00000000, 0x0000ffff); - __m128i maskB = _mm_sll_epi32(maskA, _mm_set_epi32(16, 16, 16, 16)); - __m128i maskC = _mm_set_epi32(0x0000ffff, 0x00000000, 0x0000ffff, 0x00000000); - __m128i maskD = _mm_sll_epi32(maskC, _mm_set_epi32(16, 16, 16, 16)); -#endif - for(; i < size - 1; i += 2) - { - dataCharIt = (__m128i*)dataPtrIt; - data = _mm_loadu_si128(dataCharIt); -#ifdef __SSSE3__ - data = _mm_shuffle_epi8(data, mask); -#else - __m128i result = _mm_srl_epi32(_mm_and_si128(data, maskD), _mm_set_epi32(48, 48, 48, 48)); - result = _mm_or_si128(_mm_srl_epi32(_mm_and_si128(data, maskC), _mm_set_epi32(16, 16, 16, 16)), result); - result = _mm_or_si128(_mm_sll_epi32(_mm_and_si128(data, maskB), _mm_set_epi32(16, 16, 16, 16)), result); - result = _mm_or_si128(_mm_sll_epi32(_mm_and_si128(data, maskA), _mm_set_epi32(48, 48, 48, 48)), result); - - data = result; -#endif - _mm_store_si128(dataCharIt, data); - dataPtrIt += 4; - } - if(i != size) - { - short* shortPtr = (short*)dataPtrIt; - short pixel[4]; - for(size_t c = 0; c < 4; c++) - { - pixel[c] = *shortPtr; - shortPtr++; - } - shortPtr -= 4; - for(int c = 3; c > -1; c--) - { - *shortPtr = pixel[c]; - shortPtr++; - } - } - break; - } - case 16: - { - float* dataFloatIt; - dataFloatIt = dataPtrIt; - - /*for(char c=0; c<4; c++) - TUTTLE_LOG_INFO( *(dataFloatIt+c) ); - TUTTLE_LOG_INFO( "" );*/ - - __m128 floatData; - // only interate on 1 dimension: 128 bits is one pixel - for(; i < size; i++) - { - // load 4 float into floatData ( R, G, B, A ) - floatData = _mm_loadu_ps(dataPtrIt); - // store reversed ( A, B, G, R ) - _mm_storer_ps(dataPtrIt, floatData); - // increase pointer from 4 float - dataPtrIt += 4; - } - - /*for(char i=0; i<4; i++) - TUTTLE_LOG_INFO( *(dataFloatIt+i) );*/ - break; - } - } -} - -void selectChannelInRGB() -{ -} - -void selectChannelInRGBA(void* dataSrcPtr) -{ - // boost::gil::rgb32f_view_t vw = boost::gil::interleaved_view ( size.x, size.y, Iterator pixels, std::ptrdiff_t - // rowsize_in_bytes); -} - -#endif diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterDefinitions.hpp b/plugins/image/io/Dpx/src/writer/DPXWriterDefinitions.hpp deleted file mode 100644 index e64361dfa..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterDefinitions.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef _DPXWRITER_DEFINITIONS_HPP_ -#define _DPXWRITER_DEFINITIONS_HPP_ - -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -enum ETuttlePluginBitDepth -{ - eTuttlePluginBitDepth8 = 0, - eTuttlePluginBitDepth10, - eTuttlePluginBitDepth12, - eTuttlePluginBitDepth16, - eTuttlePluginBitDepth32, - eTuttlePluginBitDepth64, -}; - -static const std::string kParamDescriptorHint = "Select Components\n" - "auto: Luma for 1 channel, RGB for 3 channels and RGBA for 4 channels\n"; - -static const std::string kParamDescriptorUserDefinedDescriptor = "userDefined"; -static const std::string kParamDescriptorRed = "red"; -static const std::string kParamDescriptorGreen = "green"; -static const std::string kParamDescriptorBlue = "blue"; -static const std::string kParamDescriptorAlpha = "alpha"; -static const std::string kParamDescriptorLuma = "luma / Y"; -static const std::string kParamDescriptorColorDifference = "colorDifference"; -static const std::string kParamDescriptorDepth = "depth"; -static const std::string kParamDescriptorCompositeVideo = "compositeVideo"; -static const std::string kParamDescriptorRGB = "rgb"; -static const std::string kParamDescriptorRGBA = "rgba"; -static const std::string kParamDescriptorABGR = "abgr"; -static const std::string kParamDescriptorCbYCrY = "cbycry (4:2:2)"; -static const std::string kParamDescriptorCbYACrYA = "cbyacrya (4:2:2:4)"; -static const std::string kParamDescriptorCbYCr = "cbycr (4:4:4)"; -static const std::string kParamDescriptorCbYCrA = "cbycra (4:4:4:4)"; -static const std::string kParamDescriptorUserDefined2Comp = "2componentElement"; -static const std::string kParamDescriptorUserDefined3Comp = "3componentElement"; -static const std::string kParamDescriptorUserDefined4Comp = "4componentElement"; -static const std::string kParamDescriptorUserDefined5Comp = "5componentElement"; -static const std::string kParamDescriptorUserDefined6Comp = "6componentElement"; -static const std::string kParamDescriptorUserDefined7Comp = "7componentElement"; -static const std::string kParamDescriptorUserDefined8Comp = "8componentElement"; -static const std::string kParamDescriptorUndefinedDescriptor = "undefined"; -static const std::string kParamDescriptorAuto = "auto"; - -static const std::string kParamCharacteristicHint = "* transfer only\n"; - -static const std::string kParamTransfer = "transfer"; -static const std::string kParamTransferLabel = "Transfer"; -static const std::string kParamTransferHint = "Transfer\n" + kParamCharacteristicHint; - -static const std::string kParamColorimetric = "colorimetric"; -static const std::string kParamColorimetricLabel = "Colorimetric"; -static const std::string kParamColorimetricHint = "Colorimetric\n" + kParamCharacteristicHint; - -static const std::string kParamCharacteristicUserDefined = "userDefined"; -static const std::string kParamCharacteristicPrintingDensity = "printingDensity"; -static const std::string kParamCharacteristicLinear = "linear *"; -static const std::string kParamCharacteristicLogarithmic = "logarithmic *"; -static const std::string kParamCharacteristicUnspecifiedVideo = "unspecifiedVideo"; -static const std::string kParamCharacteristicSMPTE274M = "smpte-274m"; -static const std::string kParamCharacteristicITUR709 = "itu-r709-4"; -static const std::string kParamCharacteristicITUR601 = "itu-r601-5system-b-or-g"; -static const std::string kParamCharacteristicITUR602 = "itu-r601-5system-m"; -static const std::string kParamCharacteristicNTSCCompositeVideo = "ntsc"; -static const std::string kParamCharacteristicPALCompositeVideo = "pal"; -static const std::string kParamCharacteristicZLinear = "zdepthlinear *"; -static const std::string kParamCharacteristicZHomogeneous = "zdepthhomogeneous *"; -static const std::string kParamCharacteristicUndefinedCharacteristic = "undefined"; - -static const std::string kParamPacked = "packed"; -static const std::string kParamPackedLabel = "Packed"; -static const std::string kParamPackedHint = "Packed or filled mode into 32-bit words"; - -static const std::string kParamPackedPacked = "packed"; -static const std::string kParamPackedMethodA = "a"; -static const std::string kParamPackedMethodB = "b (deprecated)"; - -static const std::string kParamSwapEndian = "swapendian"; -static const std::string kParamSwapEndianLabel = "Swap Endian"; -static const std::string kParamSwapEndianHint = "Swap endian"; - -static const std::string kParamEncoding = "encoding"; -static const std::string kParamEncodingLabel = "Encoding"; -static const std::string kParamEncodingHint = "Encoding mode: no encoding (none) or Run Length Encoding (rle)"; -static const std::string kParamEncodingNone = "none"; -static const std::string kParamEncodingRle = "rle"; - -static const std::string kParamOrientation = "orientation"; -static const std::string kParamOrientationLabel = "Orientation"; -static const std::string kParamOrientationHint = "Orientation mode: select image orientation"; -static const std::string kParamOrientationLeftToRightTopToBottom = "lefttorighttoptobottom"; -static const std::string kParamOrientationRightToLeftTopToBottom = "righttolefttoptobottom"; -static const std::string kParamOrientationLeftToRightBottomToTop = "bottomtotoplefttorightbtt"; -static const std::string kParamOrientationRightToLeftBottomToTop = "bottomtotoprighttoleft"; -static const std::string kParamOrientationTopToBottomLeftToRight = "toptobottomlefttoright"; -static const std::string kParamOrientationTopToBottomRightToLeft = "toptobottomrighttoleft"; -static const std::string kParamOrientationBottomToTopLeftToRight = "bottomtotoplefttoright"; -static const std::string kParamOrientationBottomToTopRightToLeft = "bottomtotoprighttoleft"; -static const std::string kParamOrientationUndefinedOrientation = "undefined"; - -static const std::string kParamProject = "project"; -static const std::string kParamCopyright = "copyright"; -} -} -} -} - -#endif diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterPlugin.cpp b/plugins/image/io/Dpx/src/writer/DPXWriterPlugin.cpp deleted file mode 100644 index 99da781d3..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterPlugin.cpp +++ /dev/null @@ -1,726 +0,0 @@ -#include "DPXWriterPlugin.hpp" -#include "DPXWriterProcess.hpp" -#include "DPXWriterDefinitions.hpp" - -#include - -#include - -#include - -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -using namespace boost::gil; - -DPXWriterPlugin::DPXWriterPlugin(OfxImageEffectHandle handle) - : WriterPlugin(handle) -{ - _bitDepth = fetchChoiceParam(kTuttlePluginBitDepth); - _descriptor = fetchChoiceParam(kTuttlePluginChannel); - _transfer = fetchChoiceParam(kParamTransfer); - _colorimetric = fetchChoiceParam(kParamColorimetric); - _packed = fetchChoiceParam(kParamPacked); - _swapEndian = fetchBooleanParam(kParamSwapEndian); - _encoding = fetchChoiceParam(kParamEncoding); - _orientation = fetchChoiceParam(kParamOrientation); - _project = fetchStringParam(kParamProject); - _copyright = fetchStringParam(kParamCopyright); -} - -DPXWriterProcessParams DPXWriterPlugin::getProcessParams(const OfxTime time) -{ - DPXWriterProcessParams params; - - params._filepath = getAbsoluteFilenameAt(time); - params._project = _project->getValue(); - params._copyright = _copyright->getValue(); - params._bitDepth = static_cast(_bitDepth->getValue()); - - switch(params._bitDepth) - { - case eTuttlePluginBitDepth8: - params._iBitDepth = 8; - break; - case eTuttlePluginBitDepth10: - params._iBitDepth = 10; - break; - case eTuttlePluginBitDepth12: - params._iBitDepth = 12; - break; - case eTuttlePluginBitDepth16: - params._iBitDepth = 16; - break; - case eTuttlePluginBitDepth32: - params._iBitDepth = 32; - break; - case eTuttlePluginBitDepth64: - params._iBitDepth = 64; - break; - } - - switch(_descriptor->getValue()) - { - case 0: - params._descriptor = ::dpx::kUserDefinedDescriptor; - break; - case 1: - params._descriptor = ::dpx::kRed; - break; - case 2: - params._descriptor = ::dpx::kGreen; - break; - case 3: - params._descriptor = ::dpx::kBlue; - break; - case 4: - params._descriptor = ::dpx::kAlpha; - break; - case 5: - params._descriptor = ::dpx::kLuma; - break; - case 6: - params._descriptor = ::dpx::kColorDifference; - break; - case 7: - params._descriptor = ::dpx::kDepth; - break; - case 8: - params._descriptor = ::dpx::kCompositeVideo; - break; - case 9: - params._descriptor = ::dpx::kRGB; - break; - case 10: - params._descriptor = ::dpx::kRGBA; - break; - case 11: - params._descriptor = ::dpx::kABGR; - break; - case 12: - params._descriptor = ::dpx::kCbYCrY; - break; - case 13: - params._descriptor = ::dpx::kCbYACrYA; - break; - case 14: - params._descriptor = ::dpx::kCbYCr; - break; - case 15: - params._descriptor = ::dpx::kCbYCrA; - break; - case 16: - params._descriptor = ::dpx::kUserDefined2Comp; - break; - case 17: - params._descriptor = ::dpx::kUserDefined3Comp; - break; - case 18: - params._descriptor = ::dpx::kUserDefined4Comp; - break; - case 19: - params._descriptor = ::dpx::kUserDefined5Comp; - break; - case 20: - params._descriptor = ::dpx::kUserDefined6Comp; - break; - case 21: - params._descriptor = ::dpx::kUserDefined7Comp; - break; - case 22: - params._descriptor = ::dpx::kUserDefined8Comp; - break; - case 23: - params._descriptor = ::dpx::kUndefinedDescriptor; - break; - case 24: - switch(_clipSrc->getPixelComponents()) - { - case OFX::ePixelComponentAlpha: - params._descriptor = ::dpx::kLuma; - break; - case OFX::ePixelComponentRGB: - params._descriptor = ::dpx::kRGB; - break; - case OFX::ePixelComponentRGBA: - params._descriptor = ::dpx::kRGBA; - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user("Dpx: unknown input channel type.")); - break; - } - break; - default: - break; - } - switch(_transfer->getValue()) - { - case 13: - params._transfer = ::dpx::kUndefinedCharacteristic; - break; - default: - params._transfer = static_cast< ::dpx::Characteristic>(_transfer->getValue()); - break; - } - switch(_colorimetric->getValue()) - { - case 13: - params._colorimetric = ::dpx::kUndefinedCharacteristic; - break; - default: - params._colorimetric = static_cast< ::dpx::Characteristic>(_colorimetric->getValue()); - break; - } - - params._packed = static_cast< ::dpx::Packing>(_packed->getValue()); - params._encoding = static_cast< ::dpx::Encoding>(_encoding->getValue()); - params._orientation = static_cast< ::dpx::Orientation>(_orientation->getValue()); - params._swapEndian = _swapEndian->getValue(); - - return params; -} - -/** - * @brief The overridden render function - * @param[in] args Rendering parameters - */ -void DPXWriterPlugin::render(const OFX::RenderArguments& args) -{ - WriterPlugin::render(args); - DPXWriterProcessParams params = getProcessParams(args.time); - - OFX::EBitDepth eOfxBitDepth = _clipSrc->getPixelDepth(); - OFX::EPixelComponent components = _clipSrc->getPixelComponents(); - OfxPointI size = _clipSrc->getPixelRodSize(args.time); - - switch(params._bitDepth) - { - case eTuttlePluginBitDepth8: - switch(eOfxBitDepth) - { - case OFX::eBitDepthCustom: - case OFX::eBitDepthNone: - BOOST_THROW_EXCEPTION(exception::BitDepthMismatch() - << exception::user("Dpx: Unable to write upper bit depth")); - break; - case OFX::eBitDepthUShort: - case OFX::eBitDepthFloat: - switch(components) - { - case OFX::ePixelComponentAlpha: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGB: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGBA: - doGilRender(*this, args, eOfxBitDepth); - break; - default: - BOOST_THROW_EXCEPTION(exception::InputMismatch() << exception::user("Dpx: Unknown component.")); - break; - } - return; - case OFX::eBitDepthUByte: - break; - } - break; - case eTuttlePluginBitDepth10: - switch(eOfxBitDepth) - { - case OFX::eBitDepthCustom: - case OFX::eBitDepthNone: - { - BOOST_THROW_EXCEPTION(exception::BitDepthMismatch() - << exception::user("Dpx: Unable to write upper bit depth")); - break; - } - case OFX::eBitDepthUShort: // break; // @TODO temporary use GIL, the conversion Gray => RGBA provide a - // segfault after writer.Finish() function. - case OFX::eBitDepthUByte: - case OFX::eBitDepthFloat: - { - switch(components) - { - case OFX::ePixelComponentAlpha: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGB: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGBA: - doGilRender(*this, args, eOfxBitDepth); - break; - default: - BOOST_THROW_EXCEPTION(exception::InputMismatch() << exception::user("Dpx: Unknown component.")); - break; - } - return; - } - } - break; - case eTuttlePluginBitDepth12: - switch(eOfxBitDepth) - { - case OFX::eBitDepthCustom: - case OFX::eBitDepthNone: - { - BOOST_THROW_EXCEPTION(exception::BitDepthMismatch() - << exception::user("Dpx: Unable to write upper bit depth")); - break; - } - case OFX::eBitDepthUByte: - case OFX::eBitDepthFloat: - { - switch(components) - { - case OFX::ePixelComponentAlpha: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGB: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGBA: - doGilRender(*this, args, eOfxBitDepth); - break; - default: - BOOST_THROW_EXCEPTION(exception::InputMismatch() << exception::user("Dpx: Unknown component.")); - break; - } - return; - } - case OFX::eBitDepthUShort: - break; - } - break; - case eTuttlePluginBitDepth16: - switch(eOfxBitDepth) - { - case OFX::eBitDepthCustom: - case OFX::eBitDepthNone: - { - BOOST_THROW_EXCEPTION(exception::BitDepthMismatch() - << exception::user("Dpx: Unable to write upper bit depth")); - break; - } - case OFX::eBitDepthUByte: - case OFX::eBitDepthFloat: - { - switch(components) - { - case OFX::ePixelComponentAlpha: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGB: - doGilRender(*this, args, eOfxBitDepth); - break; - case OFX::ePixelComponentRGBA: - doGilRender(*this, args, eOfxBitDepth); - break; - default: - BOOST_THROW_EXCEPTION(exception::InputMismatch() << exception::user("Dpx: Unknown component.")); - break; - } - return; - } - case OFX::eBitDepthUShort: - break; - } - break; - case eTuttlePluginBitDepth32: - case eTuttlePluginBitDepth64: - break; - } - - std::string filename = getAbsoluteFilenameAt(args.time); - - ::dpx::Writer writer; - ::dpx::DataSize dataSize = ::dpx::kByte; - - OutStream stream; - - if(!stream.Open(filename.c_str())) - { - BOOST_THROW_EXCEPTION(exception::File() << exception::user("Dpx: Unable to open output file")); - } - - writer.SetOutStream(&stream); - - writer.Start(); - - writer.SetFileInfo(filename.c_str(), 0, "TuttleOFX DPX Writer", params._project.c_str(), params._copyright.c_str(), ~0, - params._swapEndian); - - writer.SetImageInfo(size.x, size.y); - - writer.header.SetImageOrientation(params._orientation); - - int pixelSize = 0; - std::string inputComponentString = "unknown"; - - switch(eOfxBitDepth) - { - case OFX::eBitDepthCustom: - case OFX::eBitDepthNone: - BOOST_THROW_EXCEPTION(exception::BitDepthMismatch() - << exception::user("Dpx: Unable to compute custom or non bit depth")); - break; - case OFX::eBitDepthUByte: - dataSize = ::dpx::kByte; - pixelSize = 1; - break; - case OFX::eBitDepthUShort: - dataSize = ::dpx::kWord; - pixelSize = 2; - break; - case OFX::eBitDepthFloat: - dataSize = ::dpx::kFloat; - pixelSize = 4; - break; - } - switch(components) - { - case OFX::ePixelComponentAlpha: - inputComponentString = "Gray/Alpha"; - break; // pixelSize *= 1; - case OFX::ePixelComponentRGB: - inputComponentString = "RGB"; - pixelSize *= 3; - break; - case OFX::ePixelComponentRGBA: - inputComponentString = "RGBA"; - pixelSize *= 4; - break; - default: - break; - } - - typedef std::vector > DataVector; - const std::size_t rowBytesToCopy = size.x * pixelSize; - // const std::size_t rowBytesToCopy = size.x * 4; // allocation of 4 channels, to allow conversion after on this buffer - // (Gray=>RGBA). Better option to do this ? - - DataVector data(rowBytesToCopy * size.y); - char* dataPtrIt = &data.front(); - - boost::scoped_ptr src(_clipSrc->fetchImage(args.time)); - - for(int y = size.y; y > 0; --y) - { - void* dataSrcPtr = src->getPixelAddress(0, y - 1); - memcpy(dataPtrIt, dataSrcPtr, rowBytesToCopy); - - dataPtrIt += rowBytesToCopy; - } - - switch(params._descriptor) - { - case ::dpx::kUserDefinedDescriptor: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user("Dpx: Unable to write user defined")); - break; - } - break; - case ::dpx::kRed: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write Red channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kGreen: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write Green channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kBlue: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write Blue channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kAlpha: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write Alpha channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kLuma: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write Luma channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kColorDifference: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() - << exception::user("Dpx: Unable to write ColorDifference channel (input is " + - inputComponentString + ").")); - break; - } - break; - case ::dpx::kDepth: - switch(components) - { - case OFX::ePixelComponentAlpha: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write Depth channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kCompositeVideo: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kRGB: - switch(components) - { - case OFX::ePixelComponentAlpha: - { - convertGrayToRGB(data, size.x, size.y, pixelSize); - break; - } - case OFX::ePixelComponentRGB: - break; - case OFX::ePixelComponentRGBA: - { - convertRGBAToRGB(data, size.x, size.y, pixelSize); - break; - } - default: - { - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write RGB channels (input is " + inputComponentString + ").")); - break; - } - } - break; - case ::dpx::kRGBA: - switch(components) - { - case OFX::ePixelComponentRGBA: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write RGBA channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kABGR: - switch(components) - { - case OFX::ePixelComponentRGBA: - convertRGBAToABGR(data, size.x, size.y, pixelSize); - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write ABGR channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kCbYCrY: - switch(components) - { - case OFX::ePixelComponentRGB: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write CbYCrY channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kCbYACrYA: - switch(components) - { - case OFX::ePixelComponentRGBA: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() - << exception::user("Dpx: Unable to write CbYCrYA channels (input is " + - inputComponentString + ").")); - break; - } - break; - case ::dpx::kCbYCr: - switch(components) - { - case OFX::ePixelComponentRGB: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write CbYCr channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kCbYCrA: - switch(components) - { - case OFX::ePixelComponentRGBA: - break; - default: - BOOST_THROW_EXCEPTION( - exception::ImageFormat() - << exception::user("Dpx: Unable to write CbYCrA channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined2Comp: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 2 channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined3Comp: - switch(components) - { - case OFX::ePixelComponentRGB: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 3 channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined4Comp: - switch(components) - { - case OFX::ePixelComponentRGBA: - break; - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 4 channel (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined5Comp: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 5 channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined6Comp: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 6 channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined7Comp: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 7 channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUserDefined8Comp: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user( - "Dpx: Unable to write 8 channels (input is " + inputComponentString + ").")); - break; - } - break; - case ::dpx::kUndefinedDescriptor: - switch(components) - { - default: - BOOST_THROW_EXCEPTION(exception::ImageFormat() - << exception::user("Dpx: Unable to write undefined descriptor (input is " + - inputComponentString + ").")); - break; - } - break; - } - - writer.SetElement(0, params._descriptor, params._iBitDepth, params._transfer, params._colorimetric, params._packed, - params._encoding); - - if(!writer.WriteHeader()) - { - BOOST_THROW_EXCEPTION(exception::Data() << exception::user("Dpx: Unable to write data (DPX Header)")); - } - if(!writer.WriteElement(0, &data.front(), dataSize)) - { - BOOST_THROW_EXCEPTION(exception::Data() << exception::user("Dpx: Unable to write data (DPX User Data)")); - } - - if(!writer.Finish()) - { - BOOST_THROW_EXCEPTION(exception::Data() << exception::user("Dpx: Unable to write data (DPX finish)")); - } - - stream.Close(); -} - -void DPXWriterPlugin::changedParam(const OFX::InstanceChangedArgs& args, const std::string& paramName) -{ - WriterPlugin::changedParam(args, paramName); -} -} -} -} -} diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterPlugin.hpp b/plugins/image/io/Dpx/src/writer/DPXWriterPlugin.hpp deleted file mode 100644 index eb3c1ac2e..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterPlugin.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _TUTTLE_PLUGIN_DPXWRITER_PLUGIN_HPP_ -#define _TUTTLE_PLUGIN_DPXWRITER_PLUGIN_HPP_ - -#include -#include "DPXWriterDefinitions.hpp" - -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -struct DPXWriterProcessParams -{ - std::string _filepath; ///< filepath - std::string _project; ///< project metadata - std::string _copyright; ///< copyright metadata - ETuttlePluginBitDepth _bitDepth; ///< Output bit depth - size_t _iBitDepth; ///< Int value of output bit depth - ::dpx::Descriptor _descriptor; ///< Components type - ::dpx::Characteristic _transfer; - ::dpx::Characteristic _colorimetric; - ::dpx::Packing _packed; ///< Bit streaming packing - ::dpx::Encoding _encoding; - ::dpx::Orientation _orientation; - bool _swapEndian; ///< set endianness -}; - -/** - * @brief - * - */ -class DPXWriterPlugin : public WriterPlugin -{ -public: - DPXWriterPlugin(OfxImageEffectHandle handle); - -public: - DPXWriterProcessParams getProcessParams(const OfxTime time); - - void changedParam(const OFX::InstanceChangedArgs& args, const std::string& paramName); - - void render(const OFX::RenderArguments& args); - -protected: - OFX::ChoiceParam* _bitDepth; ///< Dpx bit depth - OFX::ChoiceParam* _descriptor; ///< Dpx descriptor - OFX::ChoiceParam* _transfer; ///< Dpx transfer - OFX::ChoiceParam* _colorimetric; ///< Dpx colorimetric - OFX::ChoiceParam* _packed; ///< Dpx packed method - OFX::BooleanParam* _swapEndian; ///< Dpx swap endian - OFX::ChoiceParam* _encoding; ///< Dpx encoding - OFX::ChoiceParam* _orientation; ///< Dpx orientation - OFX::StringParam* _project; ///< Dpx metadata Project - OFX::StringParam* _copyright; ///< Dpx metadata Copyright -}; -} -} -} -} - -#endif diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.cpp b/plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.cpp deleted file mode 100644 index aa6c02f9b..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "DPXWriterPluginFactory.hpp" -#include "DPXWriterPlugin.hpp" -#include "DPXWriterDefinitions.hpp" - -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -/** - * @brief Function called to describe the plugin main features. - * @param[in, out] desc Effect descriptor - */ -void DPXWriterPluginFactory::describe(OFX::ImageEffectDescriptor& desc) -{ - desc.setLabels("TuttleDpxWriter", "DpxWriter", "Dpx file writer"); - desc.setPluginGrouping("tuttle/image/io"); - - desc.setDescription("Digital Picture Exchange (DPX), ANSI/SMPTE standard (268M-2003)"); - - // add the supported contexts - desc.addSupportedContext(OFX::eContextWriter); - desc.addSupportedContext(OFX::eContextGeneral); - - // add supported pixel depths - desc.addSupportedBitDepth(OFX::eBitDepthUByte); - desc.addSupportedBitDepth(OFX::eBitDepthUShort); - desc.addSupportedBitDepth(OFX::eBitDepthFloat); - - // add supported extensions - desc.addSupportedExtension("dpx"); - desc.setPluginEvaluation(30); - - // plugin flags - desc.setRenderThreadSafety(OFX::eRenderFullySafe); - desc.setHostFrameThreading(false); - desc.setSupportsMultiResolution(false); - desc.setSupportsMultipleClipDepths(true); - desc.setSupportsTiles(kSupportTiles); -} - -/** - * @brief Function called to describe the plugin controls and features. - * @param[in, out] desc Effect descriptor - * @param[in] context Application context - */ -void DPXWriterPluginFactory::describeInContext(OFX::ImageEffectDescriptor& desc, OFX::EContext context) -{ - OFX::ClipDescriptor* srcClip = desc.defineClip(kOfxImageEffectSimpleSourceClipName); - srcClip->addSupportedComponent(OFX::ePixelComponentRGBA); - srcClip->addSupportedComponent(OFX::ePixelComponentRGB); - srcClip->addSupportedComponent(OFX::ePixelComponentAlpha); - srcClip->setSupportsTiles(kSupportTiles); - - OFX::ClipDescriptor* dstClip = desc.defineClip(kOfxImageEffectOutputClipName); - dstClip->addSupportedComponent(OFX::ePixelComponentRGBA); - dstClip->addSupportedComponent(OFX::ePixelComponentRGB); - dstClip->addSupportedComponent(OFX::ePixelComponentAlpha); - dstClip->setSupportsTiles(kSupportTiles); - - // Controls - - describeWriterParamsInContext(desc, context); - - OFX::ChoiceParamDescriptor* bitDepth = - static_cast(desc.getParamDescriptor(kTuttlePluginBitDepth)); - bitDepth->resetOptions(); - bitDepth->appendOption(kTuttlePluginBitDepth8); - bitDepth->appendOption(kTuttlePluginBitDepth10); - bitDepth->appendOption(kTuttlePluginBitDepth12); - bitDepth->appendOption(kTuttlePluginBitDepth16); - bitDepth->appendOption(kTuttlePluginBitDepth32); - bitDepth->appendOption(kTuttlePluginBitDepth64); - bitDepth->setDefault(eTuttlePluginBitDepth10); - - OFX::ChoiceParamDescriptor* descriptor = - static_cast(desc.getParamDescriptor(kTuttlePluginChannel)); - descriptor->resetOptions(); - descriptor->appendOption(kParamDescriptorUserDefinedDescriptor); - descriptor->appendOption(kParamDescriptorRed); - descriptor->appendOption(kParamDescriptorGreen); - descriptor->appendOption(kParamDescriptorBlue); - descriptor->appendOption(kParamDescriptorAlpha); - descriptor->appendOption(kParamDescriptorLuma); - descriptor->appendOption(kParamDescriptorColorDifference); - descriptor->appendOption(kParamDescriptorDepth); - descriptor->appendOption(kParamDescriptorCompositeVideo); - descriptor->appendOption(kParamDescriptorRGB); - descriptor->appendOption(kParamDescriptorRGBA); - descriptor->appendOption(kParamDescriptorABGR); - descriptor->appendOption(kParamDescriptorCbYCrY); - descriptor->appendOption(kParamDescriptorCbYACrYA); - descriptor->appendOption(kParamDescriptorCbYCr); - descriptor->appendOption(kParamDescriptorCbYCrA); - descriptor->appendOption(kParamDescriptorUserDefined2Comp); - descriptor->appendOption(kParamDescriptorUserDefined3Comp); - descriptor->appendOption(kParamDescriptorUserDefined4Comp); - descriptor->appendOption(kParamDescriptorUserDefined5Comp); - descriptor->appendOption(kParamDescriptorUserDefined6Comp); - descriptor->appendOption(kParamDescriptorUserDefined7Comp); - descriptor->appendOption(kParamDescriptorUserDefined8Comp); - descriptor->appendOption(kParamDescriptorUndefinedDescriptor); - descriptor->appendOption(kParamDescriptorAuto); - descriptor->setDefault(9); // rgb - - OFX::ChoiceParamDescriptor* transfer = desc.defineChoiceParam(kParamTransfer); - transfer->setLabel(kParamTransferLabel); - transfer->setHint(kParamTransferHint); - transfer->appendOption(kParamCharacteristicUserDefined); - transfer->appendOption(kParamCharacteristicPrintingDensity); - transfer->appendOption(kParamCharacteristicLinear); - transfer->appendOption(kParamCharacteristicLogarithmic); - transfer->appendOption(kParamCharacteristicUnspecifiedVideo); - transfer->appendOption(kParamCharacteristicSMPTE274M); - transfer->appendOption(kParamCharacteristicITUR709); - transfer->appendOption(kParamCharacteristicITUR601); - transfer->appendOption(kParamCharacteristicITUR602); - transfer->appendOption(kParamCharacteristicNTSCCompositeVideo); - transfer->appendOption(kParamCharacteristicPALCompositeVideo); - transfer->appendOption(kParamCharacteristicZLinear); - transfer->appendOption(kParamCharacteristicZHomogeneous); - transfer->appendOption(kParamCharacteristicUndefinedCharacteristic); - transfer->setDefault(2); // Linear - - OFX::ChoiceParamDescriptor* colorimetric = desc.defineChoiceParam(kParamColorimetric); - colorimetric->setLabel(kParamColorimetricLabel); - colorimetric->setHint(kParamColorimetricHint); - colorimetric->appendOption(kParamCharacteristicUserDefined); - colorimetric->appendOption(kParamCharacteristicPrintingDensity); - colorimetric->appendOption(kParamCharacteristicLinear); - colorimetric->appendOption(kParamCharacteristicLogarithmic); - colorimetric->appendOption(kParamCharacteristicUnspecifiedVideo); - colorimetric->appendOption(kParamCharacteristicSMPTE274M); - colorimetric->appendOption(kParamCharacteristicITUR709); - colorimetric->appendOption(kParamCharacteristicITUR601); - colorimetric->appendOption(kParamCharacteristicITUR602); - colorimetric->appendOption(kParamCharacteristicNTSCCompositeVideo); - colorimetric->appendOption(kParamCharacteristicPALCompositeVideo); - colorimetric->appendOption(kParamCharacteristicZLinear); - colorimetric->appendOption(kParamCharacteristicZHomogeneous); - colorimetric->appendOption(kParamCharacteristicUndefinedCharacteristic); - colorimetric->setDefault(2); // Linear - - OFX::ChoiceParamDescriptor* packed = desc.defineChoiceParam(kParamPacked); - packed->setLabel(kParamPackedLabel); - packed->setHint(kParamPackedHint); - packed->appendOption(kParamPackedPacked); - packed->appendOption(kParamPackedMethodA); - packed->appendOption(kParamPackedMethodB); - packed->setDefault(1); - - OFX::BooleanParamDescriptor* swapEndian = desc.defineBooleanParam(kParamSwapEndian); - swapEndian->setLabel(kParamSwapEndianLabel); - swapEndian->setHint(kParamSwapEndianHint); - swapEndian->setDefault(true); - - OFX::ChoiceParamDescriptor* encoding = desc.defineChoiceParam(kParamEncoding); - encoding->setLabel(kParamEncodingLabel); - encoding->setHint(kParamEncodingHint); - encoding->appendOption(kParamEncodingNone); - encoding->appendOption(kParamEncodingRle); - encoding->setDefault(0); - - OFX::ChoiceParamDescriptor* orientation = desc.defineChoiceParam(kParamOrientation); - orientation->setLabel(kParamOrientationLabel); - orientation->setHint(kParamOrientationHint); - orientation->appendOption(kParamOrientationLeftToRightTopToBottom); - orientation->appendOption(kParamOrientationRightToLeftTopToBottom); - orientation->appendOption(kParamOrientationLeftToRightBottomToTop); - orientation->appendOption(kParamOrientationRightToLeftBottomToTop); - orientation->appendOption(kParamOrientationTopToBottomLeftToRight); - orientation->appendOption(kParamOrientationTopToBottomRightToLeft); - orientation->appendOption(kParamOrientationBottomToTopLeftToRight); - orientation->appendOption(kParamOrientationBottomToTopRightToLeft); - orientation->appendOption(kParamOrientationUndefinedOrientation); - orientation->setDefault(0); - - OFX::StringParamDescriptor* project = desc.defineStringParam(kParamProject); - project->setDefault(""); - OFX::StringParamDescriptor* copyright = desc.defineStringParam(kParamCopyright); - copyright->setDefault(""); -} - -/** - * @brief Function called to create a plugin effect instance - * @param[in] handle effect handle - * @param[in] context Application context - * @return plugin instance - */ -OFX::ImageEffect* DPXWriterPluginFactory::createInstance(OfxImageEffectHandle handle, OFX::EContext context) -{ - return new DPXWriterPlugin(handle); -} -} -} -} -} diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.hpp b/plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.hpp deleted file mode 100644 index 3ccc44cae..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterPluginFactory.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _DPX_WRITER_PLUGIN_FACTORY_HPP_ -#define _DPX_WRITER_PLUGIN_FACTORY_HPP_ -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -static const bool kSupportTiles = false; - -mDeclarePluginFactory(DPXWriterPluginFactory, {}, {}); -} -} -} -} - -#endif diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterProcess.hpp b/plugins/image/io/Dpx/src/writer/DPXWriterProcess.hpp deleted file mode 100644 index 48dbbc70f..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterProcess.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _DPXWRITER_PROCESS_HPP_ -#define _DPXWRITER_PROCESS_HPP_ - -#include - -#include -#include -#include - -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -/** - * @brief Dpx writer - */ -template -class DPXWriterProcess : public ImageGilFilterProcessor -{ -protected: - DPXWriterPlugin& _plugin; ///< Rendering plugin - DPXWriterProcessParams _params; - - void setup(const OFX::RenderArguments& args); - void multiThreadProcessImages(const OfxRectI& procWindowRoW); - -private: - template - void writeImage(::dpx::Writer& writer, View& src, ::dpx::DataSize& dataSize, size_t pixelSize); - -public: - DPXWriterProcess(DPXWriterPlugin& instance); -}; -} -} -} -} - -#include "DPXWriterProcess.tcc" - -#endif diff --git a/plugins/image/io/Dpx/src/writer/DPXWriterProcess.tcc b/plugins/image/io/Dpx/src/writer/DPXWriterProcess.tcc deleted file mode 100644 index f7a30d613..000000000 --- a/plugins/image/io/Dpx/src/writer/DPXWriterProcess.tcc +++ /dev/null @@ -1,263 +0,0 @@ -#include "DPXWriterDefinitions.hpp" -#include "DPXWriterPlugin.hpp" - -#include "DPXWriterAlgorithm.hpp" - -#include - -#include - -#include -#include - -#include -#include - -#include // for boost::uint_t -#include -#include -#include -#include - -namespace tuttle -{ -namespace plugin -{ -namespace dpx -{ -namespace writer -{ - -using namespace boost::gil; - -template -DPXWriterProcess::DPXWriterProcess(DPXWriterPlugin& instance) - : ImageGilFilterProcessor(instance, eImageOrientationFromTopToBottom) - , _plugin(instance) -{ - this->setNoMultiThreading(); -} - -template -void DPXWriterProcess::setup(const OFX::RenderArguments& args) -{ - using namespace boost::gil; - ImageGilFilterProcessor::setup(args); - _params = _plugin.getProcessParams(args.time); -} - -/** - * @brief Function called by rendering thread each time a process must be done. - * @param[in] procWindowRoW Processing window in RoW - */ -template -void DPXWriterProcess::multiThreadProcessImages(const OfxRectI& procWindowRoW) -{ - using namespace boost::gil; - OfxRectI procWindowOutput = this->translateRoWToOutputClipCoordinates(procWindowRoW); - OfxPointI procWindowSize = {procWindowRoW.x2 - procWindowRoW.x1, procWindowRoW.y2 - procWindowRoW.y1}; - - View src = subimage_view(this->_srcView, procWindowOutput.x1, procWindowOutput.y1, procWindowSize.x, procWindowSize.y); - - ::dpx::Writer writer; - ::dpx::DataSize dataSize = ::dpx::kByte; - - OutStream stream; - - if(!stream.Open(_params._filepath.c_str())) - { - BOOST_THROW_EXCEPTION(exception::File() << exception::user("Dpx: Unable to open output file")); - } - - writer.SetOutStream(&stream); - writer.Start(); - writer.SetFileInfo(_params._filepath.c_str(), 0, "TuttleOFX DPX Writer", _params._project.c_str(), - _params._copyright.c_str(), ~0, _params._swapEndian); - writer.SetImageInfo(procWindowSize.x, procWindowSize.y); - -#if(TUTTLE_EXPERIMENTAL) - writer.header.SetImageOrientation(_params._orientation); -#endif - - switch(_params._bitDepth) - { - case eTuttlePluginBitDepth8: - dataSize = ::dpx::kByte; - break; - case eTuttlePluginBitDepth10: - case eTuttlePluginBitDepth12: - case eTuttlePluginBitDepth16: - dataSize = ::dpx::kWord; - break; - case eTuttlePluginBitDepth32: - case eTuttlePluginBitDepth64: - dataSize = ::dpx::kFloat; - break; - } - - writer.SetElement(0, _params._descriptor, _params._iBitDepth, _params._transfer, _params._colorimetric, _params._packed, - _params._encoding); - - if(!writer.WriteHeader()) - { - BOOST_THROW_EXCEPTION(exception::Data() << exception::user("Dpx: Unable to write data (DPX Header)")); - } - - // TUTTLE_LOG_VAR( TUTTLE_INFO, _params._descriptor); - switch(_params._descriptor) - { - case ::dpx::kUserDefinedDescriptor: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user("Dpx: Unable to write user defined")); - break; - case ::dpx::kRed: - break; - case ::dpx::kGreen: - break; - case ::dpx::kBlue: - break; - case ::dpx::kAlpha: - BOOST_THROW_EXCEPTION(exception::ImageFormat() << exception::user("Dpx: Unable to write user defined")); - break; - case ::dpx::kLuma: - switch(_params._bitDepth) - { - case eTuttlePluginBitDepth8: - writeImage(writer, src, dataSize, 1); - break; - case eTuttlePluginBitDepth10: - case eTuttlePluginBitDepth12: - case eTuttlePluginBitDepth16: - writeImage(writer, src, dataSize, 2); - break; - case eTuttlePluginBitDepth32: - case eTuttlePluginBitDepth64: - writeImage(writer, src, dataSize, 4); - break; - } - break; - break; - case ::dpx::kColorDifference: - break; - case ::dpx::kDepth: - break; - case ::dpx::kCompositeVideo: - break; - case ::dpx::kRGB: - switch(_params._bitDepth) - { - case eTuttlePluginBitDepth8: - writeImage(writer, src, dataSize, 3); - break; - case eTuttlePluginBitDepth10: - case eTuttlePluginBitDepth12: - case eTuttlePluginBitDepth16: - writeImage(writer, src, dataSize, 6); - break; - case eTuttlePluginBitDepth32: - case eTuttlePluginBitDepth64: - writeImage(writer, src, dataSize, 12); - break; - } - break; - case ::dpx::kRGBA: - switch(_params._bitDepth) - { - case eTuttlePluginBitDepth8: - writeImage(writer, src, dataSize, 4); - break; - case eTuttlePluginBitDepth10: - case eTuttlePluginBitDepth12: - case eTuttlePluginBitDepth16: - writeImage(writer, src, dataSize, 8); - break; - case eTuttlePluginBitDepth32: - case eTuttlePluginBitDepth64: - writeImage(writer, src, dataSize, 16); - break; - } - break; - case ::dpx::kABGR: - switch(_params._bitDepth) - { - case eTuttlePluginBitDepth8: - writeImage(writer, src, dataSize, 4); - break; - case eTuttlePluginBitDepth10: - case eTuttlePluginBitDepth12: - case eTuttlePluginBitDepth16: - writeImage(writer, src, dataSize, 8); - break; - case eTuttlePluginBitDepth32: - case eTuttlePluginBitDepth64: - writeImage(writer, src, dataSize, 16); - break; - } - break; - case ::dpx::kCbYCrY: - break; - case ::dpx::kCbYACrYA: - break; - case ::dpx::kCbYCr: - break; - case ::dpx::kCbYCrA: - break; - case ::dpx::kUserDefined2Comp: - break; - case ::dpx::kUserDefined3Comp: - break; - case ::dpx::kUserDefined4Comp: - break; - case ::dpx::kUserDefined5Comp: - break; - case ::dpx::kUserDefined6Comp: - break; - case ::dpx::kUserDefined7Comp: - break; - case ::dpx::kUserDefined8Comp: - break; - case ::dpx::kUndefinedDescriptor: - break; - } - - if(!writer.Finish()) - { - BOOST_THROW_EXCEPTION(exception::Data() << exception::user("Dpx: Unable to write data (DPX finish)")); - } - - stream.Close(); -} - -template -template -void DPXWriterProcess::writeImage(::dpx::Writer& writer, View& src, ::dpx::DataSize& dataSize, size_t pixelSize) -{ - using namespace terry; - typedef image image_t; // interleaved image - typedef typename image_t::view_t view_t; - image_t img(src.width(), src.height()); - view_t dvw(view(img)); - copy_and_convert_pixels(src, dvw); - - typedef std::vector > DataVector; - const size_t rowBytesToCopy = src.width() * pixelSize; - - DataVector data(rowBytesToCopy * src.height()); - char* dataPtrIt = &data.front(); - - for(int y = 0; y < src.height(); y++) - { - void* dataSrcPtr = reinterpret_cast(&dvw(0, y)[0]); - memcpy(dataPtrIt, dataSrcPtr, rowBytesToCopy); - - dataPtrIt += rowBytesToCopy; - } - - if(!writer.WriteElement(0, &data.front(), dataSize)) - { - BOOST_THROW_EXCEPTION(exception::Data() << exception::user("Dpx: Unable to write data (DPX User Data)")); - } -} -} -} -} -} diff --git a/plugins/image/io/Dpx/tests/plugin_io_dpx.cpp b/plugins/image/io/Dpx/tests/plugin_io_dpx.cpp deleted file mode 100644 index 26cec10ca..000000000 --- a/plugins/image/io/Dpx/tests/plugin_io_dpx.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#define BOOST_TEST_MODULE plugin_Dpx -#include - -#include - -#include - -#include - -#include -#include - -using namespace boost::unit_test; -using namespace tuttle::host; - -BOOST_AUTO_TEST_SUITE(plugin_Dpx_writer) -std::string pluginName = "tuttle.dpxwriter"; -std::string filename = "test-png.png"; -#include -BOOST_AUTO_TEST_SUITE_END() From 9ba65689f9c5b6e88c3b678f5b10ae6e278d2ba2 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 16:31:34 +0200 Subject: [PATCH 10/11] oiio writer: set 'project' and 'copyright' metadata only if they are indicated Avoid having metadata in the output file with empty value. --- .../io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc index 0e30b98f5..852804ad9 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterProcess.tcc @@ -551,8 +551,10 @@ void OpenImageIOWriterProcess::writeImage(View& src, const std::string& fi strftime(buffer, 80,"%d-%m-%Y %I:%M:%S", timeinfo); spec.attribute("DateTime", std::string(buffer)); - spec.attribute("DocumentName", params._project); - spec.attribute("Copyright", params._copyright); + if(! params._project.empty()) + spec.attribute("DocumentName", params._project); + if(! params._copyright.empty()) + spec.attribute("Copyright", params._copyright); spec.attribute("oiio:BitsPerSample", bitsPerSample); spec.attribute("oiio:UnassociatedAlpha", params._premultiply); From 51205dcfee01a734923c88a0164b05eb0332c137 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Fri, 17 Jun 2016 16:32:23 +0200 Subject: [PATCH 11/11] oiio writer: updated hint of subsampling parameter This parameter could be used in other format than JPEG (PNG for example). --- .../src/writer/OpenImageIOWriterDefinitions.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp index eebb90155..1a9416cb5 100644 --- a/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp +++ b/plugins/image/io/OpenImageIO/src/writer/OpenImageIOWriterDefinitions.hpp @@ -48,11 +48,12 @@ enum ETuttlePluginSubsampling static const std::string kParamOutputSubsampling = "subsampling"; static const std::string kParamOutputSubsamplingLabel = "Subsampling"; -static const std::string kParamOutputSubsamplingHint = "Controlling chroma-subsampling of output JPEG files:\n" +static const std::string kParamOutputSubsamplingHint = "Controlling chroma-subsampling of the output file.\n" "4:2:0 : one chrominance component for every 2x2 block of pixels.\n" "4:2:2 : one chrominance component for every 2x1 block of pixels.\n" "4:1:1 : one chrominance component for every 4x1 block of pixels.\n" - "4:4:4 : one chrominance component for every pixel (no subsampling)\n"; + "4:4:4 : one chrominance component for every pixel (no subsampling)\n" + "It could be ignored depending on the format.\n"; static const std::string kParamOutputSubsampling420 = "420"; static const std::string kParamOutputSubsampling422 = "422"; @@ -78,7 +79,7 @@ static const std::string kParamProjectHint = "Set the 'Project' metadata of the "It could be ignored depending on the format.\n"; static const std::string kParamCopyright = "copyright"; static const std::string kParamCopyrightHint = "Set the 'Copyright' metadata of the output file. \n" - "It could be ignored depending on the format.\n"; + "It could be ignored depending on the format.\n"; enum ETuttlePluginEndianness {