@@ -199,7 +199,7 @@ namespace IPCore
199199 // Finally if our asssumption was too low then we use the first index.
200200 //
201201
202- else if (index < 0 )
202+ if (index < 0 )
203203 {
204204 index = 0 ;
205205 }
@@ -215,7 +215,7 @@ namespace IPCore
215215 if (index >= m_edlSource->size () - 1 || index >= m_edlSourceIn->size () - 1 || index >= m_edlSourceOut->size () - 1
216216 || index >= m_edlGlobalIn->size () - 1 || index < 0 )
217217 {
218- TWK_THROW_STREAM (SequenceOutOfBoundsExc, " Out-of-bounds EDL data " ) ;
218+ return - 1 ;
219219 }
220220 }
221221
@@ -241,6 +241,8 @@ namespace IPCore
241241 const int globalOffset = m_edlGlobalIn->front ();
242242 int seekFrame = int (samplesToTime (seekSample, sampleRate) * fps + 0.49 );
243243 int index = indexAtFrame (seekFrame + globalOffset);
244+ if (index < 0 )
245+ return -1 ;
244246
245247 int inputFrame = (*m_edlGlobalIn)[index];
246248 SampleTime inputStart = frameToSample (inputFrame - globalOffset, fps, sampleRate);
@@ -267,30 +269,50 @@ namespace IPCore
267269 {
268270 const IPNodes& ins = inputs ();
269271
270- if (ins.size () > 0 )
272+ if (!ins.size ()
273+ || m_edlSource->size () < 1
274+ || m_edlSourceIn->size () < 1
275+ || m_edlSourceOut->size () < 1
276+ || m_edlGlobalIn->size () < 1 )
271277 {
272- const int index = (forceIndex == -1 ) ? indexAtFrame (frame) : forceIndex;
278+ return EvalPoint (-1 , 0 , -1 );
279+ }
273280
274- const int source = (*m_edlSource)[index];
275- const int in = (*m_edlSourceIn)[index];
276- const int out = (*m_edlSourceOut)[index];
277- const int iframe = (*m_edlGlobalIn)[index];
281+ const int index =
282+ (forceIndex == -1 ) ? indexAtFrame (frame) : forceIndex;
278283
279- const int f0 = (frame - iframe) + in;
284+ if (index >= (m_edlSource->size () - 1 )
285+ || index >= (m_edlSourceIn->size () - 1 )
286+ || index >= (m_edlSourceOut->size () - 1 )
287+ || index >= (m_edlGlobalIn->size () - 1 )
288+ || index < 0 )
289+ {
290+ return EvalPoint (-1 , 0 , -1 );
291+ }
280292
281- if (forceIndex == -1 )
282- {
283- const int f1 = min (f0, out);
284- const int f = max (f1, in);
293+ const int source = (*m_edlSource)[index];
285294
286- return EvalPoint (source, f, index);
287- }
288- else
289- return EvalPoint (source, f0, index);
295+ if (source < 0 || source > ins.size ())
296+ {
297+ return EvalPoint (-1 , 0 , -1 );
298+ }
299+
300+ const int in = (*m_edlSourceIn)[index];
301+ const int out = (*m_edlSourceOut)[index];
302+ const int iframe = (*m_edlGlobalIn)[index];
303+
304+ const int f0 = (frame - iframe) + in;
305+
306+ if (forceIndex == -1 )
307+ {
308+ const int f1 = min (f0, out);
309+ const int f = max (f1, in);
310+
311+ return EvalPoint (source, f, index);
290312 }
291313 else
292314 {
293- return EvalPoint (- 1 , 0 , - 1 );
315+ return EvalPoint (source, f0, index );
294316 }
295317 }
296318
@@ -319,8 +341,10 @@ namespace IPCore
319341
320342 if (source < 0 || source >= ins.size ())
321343 {
322- TWK_THROW_STREAM (SequenceOutOfBoundsExc,
323- " Bad Sequence EDL source number " << source << " is not in range [0," << ins.size () - 1 << " ]" );
344+ stringstream msg;
345+ msg << " Bad Sequence EDL source number " << source << " is not in range [0," << ins.size () - 1 << " ]" ;
346+
347+ return IPImage::newNoImage (this , msg.str ());
324348 }
325349
326350 IPImage* root = new IPImage (this , IPImage::BlendRenderType, vw, vh, 1.0 );
@@ -762,7 +786,7 @@ namespace IPCore
762786 {
763787 lazyBuildState ();
764788
765- if (inputs ().size () >= 1 )
789+ if (inputs ().size () >= 1 && m_edlGlobalIn-> size () >= 1 )
766790 {
767791 ImageRangeInfo info;
768792 info.inc = 1 ;
@@ -782,19 +806,26 @@ namespace IPCore
782806 lazyBuildState ();
783807
784808 const bool interactive = interactiveSize (context);
809+ const IPNodes& ins = inputs ();
785810 const float vw = interactive ? context.viewWidth : float (m_structInfo.width );
786811 const float vh = interactive ? context.viewHeight : float (m_structInfo.height );
787812
788- if (inputs ().empty () || interactive)
813+
814+ if (ins.empty () || interactive)
789815 {
790816 return ImageStructureInfo (vw, vh);
791817 }
792818 else
793819 {
794820 const float aspect = vw / vh;
795821 EvalPoint ep = evaluationPoint (context.frame );
822+ if (ep.sourceIndex < 0 || ep.sourceIndex >= ins.size ())
823+ {
824+ return ImageStructureInfo (vw, vh);
825+ }
826+
796827 Context context = graph ()->contextForFrame (ep.sourceFrame );
797- ImageStructureInfo ininfo = inputs () [ep.sourceIndex ]->imageStructureInfo (context);
828+ ImageStructureInfo ininfo = ins [ep.sourceIndex ]->imageStructureInfo (context);
798829
799830 //
800831 // We may have an input that has no media "behind it" (IE a
@@ -895,6 +926,12 @@ namespace IPCore
895926 //
896927
897928 int index = indexAtSample (readSample, rate, context.fps );
929+ if (index < 0 )
930+ {
931+ cerr << " ERROR: no samples read from input node" << endl;
932+ break ;
933+ }
934+
898935 int sourceIndex = (*m_edlSource)[index];
899936
900937 //
@@ -1028,31 +1065,15 @@ namespace IPCore
10281065
10291066 int frame = context.frame ;
10301067 const IPNodes& ins = inputs ();
1068+ EvalPoint ep = evaluationPoint (frame);
1069+ const int source = ep.sourceIndex ;
10311070
1032- if (ins.size () > 1 )
1071+ if (source > 0 && source < ins.size ())
10331072 {
1034- EvalPoint ep = evaluationPoint (frame);
1035- const int source = ep.sourceIndex ;
1036-
1037- if (source < 0 || source >= ins.size ())
1038- {
1039- outputProp (m_edlSource);
1040- outputProp (m_edlGlobalIn);
1041- outputProp (m_edlSourceIn);
1042- outputProp (m_edlSourceOut);
1043-
1044- TWK_THROW_STREAM (SequenceOutOfBoundsExc,
1045- " Bad Sequence EDL source number " << source << " is not in range [0," << ins.size () - 1 << " ]" );
1046- }
1047-
10481073 Context newContext = context;
10491074 newContext.frame = ep.sourceFrame ;
10501075 ins[source]->testEvaluate (newContext, result);
10511076 }
1052- else if (ins.size () == 1 )
1053- {
1054- ins[0 ]->testEvaluate (context, result);
1055- }
10561077 }
10571078
10581079 void SequenceIPNode::metaEvaluate (const Context& context, MetaEvalVisitor& visitor)
@@ -1061,18 +1082,11 @@ namespace IPCore
10611082
10621083 visitor.enter (context, this );
10631084 const IPNodes& ins = inputs ();
1085+ EvalPoint ep = evaluationPoint (context.frame );
1086+ const int source = ep.sourceIndex ;
10641087
1065- if (ins.size () >= 1 )
1088+ if (source >= 0 && source < ins.size ())
10661089 {
1067- EvalPoint ep = evaluationPoint (context.frame );
1068- const int source = ep.sourceIndex ;
1069-
1070- if (source < 0 || source >= ins.size ())
1071- {
1072- TWK_THROW_STREAM (SequenceOutOfBoundsExc,
1073- " Bad Sequence EDL source number " << source << " is not in range [0," << ins.size () - 1 << " ]" );
1074- }
1075-
10761090 Context c = context;
10771091 c.frame = ep.sourceFrame ;
10781092
@@ -1081,13 +1095,6 @@ namespace IPCore
10811095 ins[source]->metaEvaluate (c, visitor);
10821096 }
10831097 }
1084- else if (ins.size () == 1 )
1085- {
1086- if (visitor.traverseChild (context, 0 , this , ins[0 ]))
1087- {
1088- ins[0 ]->metaEvaluate (context, visitor);
1089- }
1090- }
10911098
10921099 visitor.leave (context, this );
10931100 }
0 commit comments