Skip to content

Commit

Permalink
oiio writer: added 'storage' parameter to write scanLine or tiles images
Browse files Browse the repository at this point in the history
* Set the type of storage of the output file.
* It could be scanLine (default) or tiles (64x64 pixels).
  • Loading branch information
Clement Champetier committed Jun 24, 2016
1 parent 95720a4 commit 69c26d7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ enum ETuttlePluginComponents
static const std::string kParamOutputQuality = "quality";
static const std::string kParamOutputQualityLabel = "Quality";

static const std::string kParamOutputStorageType = "storage";
static const std::string kParamOutputStorageTypeLabel = "Storage type";
static const std::string kParamOutputStorageTypeHint = "Set the type of storage of the output file.\n"
"It could be ignored depending on the format.\n";
static const std::string kParamOutputStorageScanLine = "scanLine";
static const std::string kParamOutputStorageTiles = "tiles (64x64)";

enum ETuttlePluginStorage
{
eTuttlePluginStorageScanLine = 0,
eTuttlePluginStorageTiles
};

enum ETuttlePluginSubsampling
{
eETuttlePluginSubsampling420 = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ OpenImageIOWriterPlugin::OpenImageIOWriterPlugin(OfxImageEffectHandle handle)
_components = fetchChoiceParam(kTuttlePluginChannel);
_orientation = fetchChoiceParam(kParamOutputOrientation);
_quality = fetchIntParam(kParamOutputQuality);
_storageType = fetchChoiceParam(kParamOutputStorageType);
_paramSubsampling = fetchChoiceParam(kParamOutputSubsampling);
_compression = fetchChoiceParam(kParamCompression);
}
Expand All @@ -31,6 +32,7 @@ OpenImageIOWriterProcessParams OpenImageIOWriterPlugin::getProcessParams(const O
params._filepath = getAbsoluteFilenameAt(time);
params._components = static_cast<ETuttlePluginComponents>(this->_components->getValue());
params._bitDepth = static_cast<ETuttlePluginBitDepth>(this->_paramBitDepth->getValue());
params._storageType = static_cast<ETuttlePluginStorage>(this->_storageType->getValue());
params._subsampling = static_cast<ETuttlePluginSubsampling>(_paramSubsampling->getValue());
params._compression = static_cast<ETuttlePluginCompression>(_compression->getValue());
params._quality = _quality->getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct OpenImageIOWriterProcessParams
std::string _filepath; ///< filepath
ETuttlePluginComponents _components; ///< Force RGB
ETuttlePluginBitDepth _bitDepth; ///< Output bit depth (real bit depth, not the buffer passed to OpenImageIO)
ETuttlePluginStorage _storageType; ///< Output storage type
ETuttlePluginSubsampling _subsampling; ///< Output subsampling
ETuttlePluginCompression _compression; ///< Output compression

Expand All @@ -44,6 +45,7 @@ class OpenImageIOWriterPlugin : public WriterPlugin
public:
OFX::ChoiceParam* _components; ///< Choose components RGBA/RGB
OFX::IntParam* _quality;
OFX::ChoiceParam* _storageType;
OFX::ChoiceParam* _paramSubsampling;
OFX::ChoiceParam* _orientation;
OFX::ChoiceParam* _compression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ void OpenImageIOWriterPluginFactory::describeInContext(OFX::ImageEffectDescripto
quality->setDisplayRange(0, 100);
quality->setDefault(80);

OFX::ChoiceParamDescriptor* storageType = desc.defineChoiceParam(kParamOutputStorageType);
storageType->setLabel(kParamOutputStorageTypeLabel);
storageType->setHint(kParamOutputStorageTypeHint);
storageType->appendOption(kParamOutputStorageScanLine);
storageType->appendOption(kParamOutputStorageTiles);
storageType->setDefault(eTuttlePluginStorageScanLine);

OFX::ChoiceParamDescriptor* subsampling = desc.defineChoiceParam(kParamOutputSubsampling);
subsampling->setLabel(kParamOutputSubsamplingLabel);
subsampling->setHint(kParamOutputSubsamplingHint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,13 @@ void OpenImageIOWriterProcess<View>::writeImage(View& src, const std::string& fi
spec.attribute("XResolution", par);
spec.attribute("YResolution", 1);

// Write image data in tiles of 64x64 pixels
if(params._storageType == eTuttlePluginStorageTiles)
{
spec.tile_width = 64;
spec.tile_height = 64;
}

if(!out->open(filepath, spec))
{
BOOST_THROW_EXCEPTION(exception::Unknown() << exception::user("OIIO Writer: " + out->geterror())
Expand Down

0 comments on commit 69c26d7

Please sign in to comment.