Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Write LineOrder #45

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion OIIO/WriteOIIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ enum ETuttlePluginComponents {
"Compression level for zip/deflate compression, on a scale from 1 (fastest, minimal compression) to 9 (slowest, maximal compression) [EXR, TIFF or Zfile w/ zip or zips comp.]"
#define kParamOutputZIPCompressionLevelDefault 4

#define kParamOutputLineOrder "lineOrder"
#define kParamOutputLineOrderLabel "Line Order"
#define kParamOutputLineOrderHint "Specifies in what order the scan lines [EXR]\n"

#define kParamOutputLineOrderOptionIncreasingY "increasingY", "first scan line has lowest y coordinate", "increasingY"
#define kParamOutputLineOrderOptionDecreasingY "decreasingY", "first scan line has highest y coordinate", "decreasingY"
#define kParamOutputLineOrderOptionRandomY "randomY", "only for tiled files; tiles are written in random order", "randomY"

enum EParamLineOrder {
eParamLineOrderIncreasingY = 0,
eParamLineOrderDecreasingY,
eParamLineOrderRandomY
};

#define kParamOutputOrientation "orientation"
#define kParamOutputOrientationLabel "Orientation"
#define kParamOutputOrientationHint \
Expand Down Expand Up @@ -370,6 +384,7 @@ class WriteOIIOPlugin
IntParam* _quality;
DoubleParam* _dwaCompressionLevel;
IntParam* _zipCompressionLevel;
ChoiceParam* _lineOrder;
ChoiceParam* _orientation;
ChoiceParam* _compression;
ChoiceParam* _tileSize;
Expand All @@ -389,6 +404,7 @@ WriteOIIOPlugin::WriteOIIOPlugin(OfxImageEffectHandle handle,
, _zipCompressionLevel(NULL)
, _orientation(NULL)
, _compression(NULL)
, _lineOrder(NULL)
, _tileSize(NULL)
, _outputLayers(NULL)
, _parts(NULL)
Expand All @@ -403,6 +419,7 @@ WriteOIIOPlugin::WriteOIIOPlugin(OfxImageEffectHandle handle,
_zipCompressionLevel = fetchIntParam(kParamOutputZIPCompressionLevel);
_orientation = fetchChoiceParam(kParamOutputOrientation);
_compression = fetchChoiceParam(kParamOutputCompression);
_lineOrder = fetchChoiceParam(kParamOutputLineOrder);
_tileSize = fetchChoiceParam(kParamTileSize);
if (gIsMultiplanarV2) {
_outputLayers = fetchChoiceParam(kParamOutputChannels);
Expand Down Expand Up @@ -843,6 +860,7 @@ WriteOIIOPlugin::refreshParamsVisibility(const string& filename)
if (_views) {
_views->setIsSecretAndDisabled(!isEXR);
}
if (_lineOrder) { _lineOrder->setIsSecretAndDisabled(!isEXR); }
if (_parts) {
_parts->setIsSecretAndDisabled(!output->supports("multiimage"));
}
Expand All @@ -855,6 +873,9 @@ WriteOIIOPlugin::refreshParamsVisibility(const string& filename)
if (_views) {
_views->setIsSecretAndDisabled(true);
}
if (_lineOrder) {
_lineOrder->setIsSecretAndDisabled(true);
}
if (_parts) {
_parts->setIsSecretAndDisabled(true);
}
Expand Down Expand Up @@ -1013,7 +1034,10 @@ WriteOIIOPlugin::beginEncodeParts(void* user_data,
int compression_i;
_compression->getValue(compression_i);
string compression;

int lineOrder_i;
_lineOrder->getValue(lineOrder_i);
TodicaIonut marked this conversation as resolved.
Show resolved Hide resolved
string lineOrder;

switch ((EParamCompression)compression_i) {
case eParamCompressionAuto:
break;
Expand Down Expand Up @@ -1061,6 +1085,18 @@ WriteOIIOPlugin::beginEncodeParts(void* user_data,
break;
}

switch ((EParamLineOrder)lineOrder_i) {
case eParamLineOrderIncreasingY:
lineOrder = "increasingY";
break;
case eParamLineOrderDecreasingY:
lineOrder = "decreasingY";
break;
case eParamLineOrderRandomY:
lineOrder = "randomY";
TodicaIonut marked this conversation as resolved.
Show resolved Hide resolved
break;
}

spec.attribute("oiio:BitsPerSample", bitsPerSample);
// oiio:UnassociatedAlpha should be set if the data buffer is unassociated/unpremultiplied.
// However, WriteOIIO::getExpectedInputPremultiplication() stated that input to the encode()
Expand Down Expand Up @@ -1142,6 +1178,7 @@ WriteOIIOPlugin::beginEncodeParts(void* user_data,
#endif
}
spec.attribute("Orientation", orientation + 1);
spec.attribute("openexr:lineOrder", lineOrder);
if (!compression.empty()) { // some formats have a good value for the default compression
spec.attribute("compression", compression);
}
Expand Down Expand Up @@ -1724,6 +1761,21 @@ WriteOIIOPluginFactory::describeInContext(ImageEffectDescriptor& desc,
page->addChild(*param);
}
}
{
ChoiceParamDescriptor* param = desc.defineChoiceParam(kParamOutputLineOrder);
param->setLabel(kParamOutputLineOrderLabel);
param->setHint(kParamOutputLineOrderHint);
assert(param->getNOptions() == eParamLineOrderIncreasingY);
param->appendOption(kParamOutputLineOrderOptionIncreasingY);
assert(param->getNOptions() == eParamLineOrderDecreasingY);
param->appendOption(kParamOutputLineOrderOptionDecreasingY);
assert(param->getNOptions() == eParamLineOrderRandomY);
param->appendOption(kParamOutputLineOrderOptionRandomY);
param->setDefault(eParamLineOrderIncreasingY);
if (page) {
page->addChild(*param);
}
}

if (gIsMultiplanarV2) {

Expand Down