MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / bake

Method bake

src/OpenColorIO/fileformats/FileFormatCSP.cpp:701–849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699}
700
701void LocalFileFormat::bake(const Baker & baker,
702 const std::string & /*formatName*/,
703 std::ostream & ostream) const
704{
705 const int DEFAULT_CUBE_SIZE = 32;
706 const int DEFAULT_SHAPER_SIZE = 1024;
707
708 ConstConfigRcPtr config = baker.getConfig();
709
710 // TODO: Add 1D/3D LUT writing switch, using hasChannelCrosstalk.
711 int cubeSize = baker.getCubeSize();
712 if(cubeSize==-1) cubeSize = DEFAULT_CUBE_SIZE;
713 cubeSize = std::max(2, cubeSize); // smallest cube is 2x2x2
714
715 std::vector<float> cubeData;
716 cubeData.resize(cubeSize*cubeSize*cubeSize*3);
717 GenerateIdentityLut3D(&cubeData[0], cubeSize, 3, LUT3DORDER_FAST_RED);
718 PackedImageDesc cubeImg(&cubeData[0], cubeSize*cubeSize*cubeSize, 1, 3);
719
720 std::vector<float> shaperInData;
721 std::vector<float> shaperOutData;
722
723 // Use an explicitly shaper space.
724 // TODO: Use the optional allocation for the shaper space,
725 // instead of the implied 0-1 uniform allocation.
726 std::string shaperSpace = baker.getShaperSpace();
727 if(!shaperSpace.empty())
728 {
729 int shaperSize = baker.getShaperSize();
730 if(shaperSize==-1) shaperSize = DEFAULT_SHAPER_SIZE;
731
732 shaperOutData.resize(shaperSize*3);
733 shaperInData.resize(shaperSize*3);
734 GenerateIdentityLut1D(&shaperOutData[0], shaperSize, 3);
735 GenerateIdentityLut1D(&shaperInData[0], shaperSize, 3);
736
737 ConstCPUProcessorRcPtr shaperToInput = GetShaperToInputProcessor(baker);
738 PackedImageDesc shaperInImg(&shaperInData[0], shaperSize, 1, 3);
739 shaperToInput->apply(shaperInImg);
740
741 ConstCPUProcessorRcPtr shaperToTarget = GetShaperToTargetProcessor(baker);
742 shaperToTarget->apply(cubeImg);
743 }
744 else
745 {
746 // A shaper is not specified, let's fake one, using the input space allocation as
747 // our guide.
748
749 ConstColorSpaceRcPtr inputColorSpace = config->getColorSpace(baker.getInputSpace());
750
751 // Let's make an allocation transform for this colorspace.
752 AllocationTransformRcPtr allocationTransform = AllocationTransform::Create();
753 allocationTransform->setAllocation(inputColorSpace->getAllocation());
754
755 // numVars may be '0'.
756 int numVars = inputColorSpace->getAllocationNumVars();
757 if(numVars>0)
758 {

Callers

nothing calls this directly

Calls 15

GenerateIdentityLut1DFunction · 0.85
getElementValueMethod · 0.80
GenerateIdentityLut3DFunction · 0.50
getConfigMethod · 0.45
getCubeSizeMethod · 0.45
resizeMethod · 0.45
getShaperSpaceMethod · 0.45

Tested by

no test coverage detected