| 8329 | } |
| 8330 | |
| 8331 | void |
| 8332 | Node::computeFrameRangeForReader(KnobI* fileKnob) |
| 8333 | { |
| 8334 | /* |
| 8335 | We compute the original frame range of the sequence for the plug-in |
| 8336 | because the plug-in does not have access to the exact original pattern |
| 8337 | hence may not exactly end-up with the same file sequence as what the user |
| 8338 | selected from the file dialog. |
| 8339 | */ |
| 8340 | ReadNode* isReadNode = dynamic_cast<ReadNode*>( _imp->effect.get() ); |
| 8341 | std::string pluginID; |
| 8342 | |
| 8343 | if (isReadNode) { |
| 8344 | NodePtr embeddedPlugin = isReadNode->getEmbeddedReader(); |
| 8345 | if (embeddedPlugin) { |
| 8346 | pluginID = embeddedPlugin->getPluginID(); |
| 8347 | } |
| 8348 | } else { |
| 8349 | pluginID = getPluginID(); |
| 8350 | } |
| 8351 | |
| 8352 | int leftBound = INT_MIN; |
| 8353 | int rightBound = INT_MAX; |
| 8354 | ///Set the originalFrameRange parameter of the reader if it has one. |
| 8355 | KnobPtr knob = getKnobByName(kReaderParamNameOriginalFrameRange); |
| 8356 | if (knob) { |
| 8357 | KnobInt* originalFrameRange = dynamic_cast<KnobInt*>( knob.get() ); |
| 8358 | if ( originalFrameRange && (originalFrameRange->getDimension() == 2) ) { |
| 8359 | KnobFile* isFile = dynamic_cast<KnobFile*>(fileKnob); |
| 8360 | assert(isFile); |
| 8361 | if (!isFile) { |
| 8362 | throw std::logic_error("Node::computeFrameRangeForReader"); |
| 8363 | } |
| 8364 | |
| 8365 | if ( ReadNode::isVideoReader(pluginID) ) { |
| 8366 | ///If the plug-in is a video, only ffmpeg may know how many frames there are |
| 8367 | originalFrameRange->setValues(INT_MIN, INT_MAX, ViewSpec::all(), eValueChangedReasonNatronInternalEdited); |
| 8368 | } else { |
| 8369 | std::string pattern = isFile->getValue(); |
| 8370 | getApp()->getProject()->canonicalizePath(pattern); |
| 8371 | SequenceParsing::SequenceFromPattern seq; |
| 8372 | FileSystemModel::filesListFromPattern(pattern, &seq); |
| 8373 | if ( seq.empty() || (seq.size() == 1) ) { |
| 8374 | leftBound = 1; |
| 8375 | rightBound = 1; |
| 8376 | } else if (seq.size() > 1) { |
| 8377 | leftBound = seq.begin()->first; |
| 8378 | rightBound = seq.rbegin()->first; |
| 8379 | } |
| 8380 | originalFrameRange->setValues(leftBound, rightBound, ViewSpec::all(), eValueChangedReasonNatronInternalEdited); |
| 8381 | } |
| 8382 | } |
| 8383 | } |
| 8384 | } |
| 8385 | |
| 8386 | bool |
| 8387 | Node::canHandleRenderScaleForOverlays() const |
no test coverage detected