MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / computeFrameRangeForReader

Method computeFrameRangeForReader

Engine/Node.cpp:4552–4605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4550}
4551
4552void
4553Node::computeFrameRangeForReader(KnobI* fileKnob)
4554{
4555 /*
4556 We compute the original frame range of the sequence for the plug-in
4557 because the plug-in does not have access to the exact original pattern
4558 hence may not exactly end-up with the same file sequence as what the user
4559 selected from the file dialog.
4560 */
4561 ReadNode* isReadNode = dynamic_cast<ReadNode*>( _imp->effect.get() );
4562 std::string pluginID;
4563
4564 if (isReadNode) {
4565 NodePtr embeddedPlugin = isReadNode->getEmbeddedReader();
4566 if (embeddedPlugin) {
4567 pluginID = embeddedPlugin->getPluginID();
4568 }
4569 } else {
4570 pluginID = getPluginID();
4571 }
4572
4573 int leftBound = std::numeric_limits<int>::min();
4574 int rightBound = std::numeric_limits<int>::max();
4575 ///Set the originalFrameRange parameter of the reader if it has one.
4576 KnobIPtr knob = getKnobByName(kReaderParamNameOriginalFrameRange);
4577 if (knob) {
4578 KnobInt* originalFrameRange = dynamic_cast<KnobInt*>( knob.get() );
4579 if ( originalFrameRange && (originalFrameRange->getDimension() == 2) ) {
4580 KnobFile* isFile = dynamic_cast<KnobFile*>(fileKnob);
4581 assert(isFile);
4582 if (!isFile) {
4583 throw std::logic_error("Node::computeFrameRangeForReader");
4584 }
4585
4586 if ( ReadNode::isVideoReader(pluginID) ) {
4587 ///If the plug-in is a video, only ffmpeg may know how many frames there are
4588 originalFrameRange->setValues(std::numeric_limits<int>::min(), std::numeric_limits<int>::max(), ViewSpec::all(), eValueChangedReasonNatronInternalEdited);
4589 } else {
4590 std::string pattern = isFile->getValue();
4591 getApp()->getProject()->canonicalizePath(pattern);
4592 SequenceParsing::SequenceFromPattern seq;
4593 FileSystemModel::filesListFromPattern(pattern, &seq);
4594 if ( seq.empty() || (seq.size() == 1) ) {
4595 leftBound = 1;
4596 rightBound = 1;
4597 } else if (seq.size() > 1) {
4598 leftBound = seq.begin()->first;
4599 rightBound = seq.rbegin()->first;
4600 }
4601 originalFrameRange->setValues(leftBound, rightBound, ViewSpec::all(), eValueChangedReasonNatronInternalEdited);
4602 }
4603 }
4604 }
4605}
4606
4607
4608void

Callers 1

Calls 15

maxFunction · 0.85
isVideoReaderFunction · 0.85
allFunction · 0.85
getAppFunction · 0.85
getEmbeddedReaderMethod · 0.80
setValuesMethod · 0.80
canonicalizePathMethod · 0.80
getProjectMethod · 0.80
emptyMethod · 0.80
getPluginIDFunction · 0.50
getMethod · 0.45
getPluginIDMethod · 0.45

Tested by

no test coverage detected