Skip to content
Merged
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
51 changes: 43 additions & 8 deletions src/apps/ocioconvert/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ int main(int argc, const char **argv)
std::vector<std::string> intAttrs;
std::vector<std::string> stringAttrs;

std::string outputDepth;

bool usegpu = false;
bool usegpuLegacy = false;
bool outputgpuInfo = false;
Expand Down Expand Up @@ -84,6 +86,7 @@ int main(int argc, const char **argv)
"--help", &help, "Display the help and exit",
"-v" , &verbose, "Display general information",
"<SEPARATOR>", "\nOpenImageIO or OpenEXR options:",
"--bitdepth %s", &outputDepth, "Output image bitdepth",
"--float-attribute %L", &floatAttrs, "\"name=float\" pair defining OIIO float attribute "
"for outputimage",
"--int-attribute %L", &intAttrs, "\"name=int\" pair defining an int attribute "
Expand Down Expand Up @@ -115,6 +118,31 @@ int main(int argc, const char **argv)
}
#endif // OCIO_GPU_ENABLED

OCIO::BitDepth userOutputBitDepth = OCIO::BIT_DEPTH_UNKNOWN;
if (!outputDepth.empty())
{
if (outputDepth == "uint8")
{
userOutputBitDepth = OCIO::BIT_DEPTH_UINT8;
}
else if (outputDepth == "uint16")
{
userOutputBitDepth = OCIO::BIT_DEPTH_UINT16;
}
else if (outputDepth == "half")
{
userOutputBitDepth = OCIO::BIT_DEPTH_F16;
}
else if (outputDepth == "float")
{
userOutputBitDepth = OCIO::BIT_DEPTH_F32;
}
else
{
throw OCIO::Exception("Unsupported output bitdepth, must be uint8, uint16, half or float.");
}
}

const char * inputimage = nullptr;
const char * inputcolorspace = nullptr;
const char * outputimage = nullptr;
Expand Down Expand Up @@ -477,17 +505,24 @@ int main(int argc, const char **argv)
const OCIO::BitDepth inputBitDepth = imgInput.getBitDepth();
OCIO::BitDepth outputBitDepth;

if (inputBitDepth == OCIO::BIT_DEPTH_UINT16 || inputBitDepth == OCIO::BIT_DEPTH_F32)
if (userOutputBitDepth != OCIO::BIT_DEPTH_UNKNOWN)
{
outputBitDepth = OCIO::BIT_DEPTH_F32;
}
else if (inputBitDepth == OCIO::BIT_DEPTH_UINT8 || inputBitDepth == OCIO::BIT_DEPTH_F16)
{
outputBitDepth = OCIO::BIT_DEPTH_F16;
outputBitDepth = userOutputBitDepth;
}
else
{
throw OCIO::Exception("Unsupported input bitdepth, must be uint8, uint16, half or float.");
if (inputBitDepth == OCIO::BIT_DEPTH_UINT16 || inputBitDepth == OCIO::BIT_DEPTH_F32)
{
outputBitDepth = OCIO::BIT_DEPTH_F32;
}
else if (inputBitDepth == OCIO::BIT_DEPTH_UINT8 || inputBitDepth == OCIO::BIT_DEPTH_F16)
{
outputBitDepth = OCIO::BIT_DEPTH_F16;
}
else
{
throw OCIO::Exception("Unsupported input bitdepth, must be uint8, uint16, half or float.");
}
}

OCIO::ConstCPUProcessorRcPtr cpuProcessor
Expand Down Expand Up @@ -611,7 +646,7 @@ int main(int argc, const char **argv)
imgOutput->attribute("oiio:ColorSpace", outputcolorspace);
}

imgOutput->write(outputimage);
imgOutput->write(outputimage, userOutputBitDepth);
Comment thread
doug-walker marked this conversation as resolved.
}
catch (...)
{
Expand Down