@@ -19,6 +19,7 @@ struct FrameRateConverterNode : NodeContext
1919 uint32_t EffectiveCapacity = 1 ;
2020 uint32_t RemainingRepeatCount = 0 ;
2121 fb::vec2u Ratio = {1 , 1 };
22+ uint32_t PendingScheduleRemainder = 0 ;
2223
2324 enum class StatusType
2425 {
@@ -111,9 +112,20 @@ struct FrameRateConverterNode : NodeContext
111112 auto producerExecCount = EffectiveCapacity / Ratio.x ();
112113 auto consumerExecCount = EffectiveCapacity / Ratio.y ();
113114 RemainingRepeatCount = consumerExecCount - 1 ;
115+ PendingScheduleRemainder = 0 ;
114116 SendScheduleRequest (producerExecCount);
115117 }
116118
119+ void OverrideConsumerDeltaSeconds (nosVec2u& inoutDeltaSeconds) override
120+ {
121+ auto consumerDeltaSeconds = inoutDeltaSeconds;
122+ // My producer arm will run Y frames producing X objects and consumer arm will run X frames consuming Y objects.
123+ // Calculating the delta-seconds of my producer arm:
124+ auto producerDeltaSeconds = nosVec2u{consumerDeltaSeconds.x * Ratio.x (), consumerDeltaSeconds.y * Ratio.y ()};
125+ // Override it:
126+ inoutDeltaSeconds = producerDeltaSeconds;
127+ }
128+
117129 void OnPathStop () override { Ring.Shutdown (); }
118130
119131 nosResult OnCreate (nosFbNodePtr node) override
@@ -188,7 +200,12 @@ struct FrameRateConverterNode : NodeContext
188200 SetPinObject (NSN_Output, outputArrayObject);
189201 cpy->ShouldSetSourceFrameNumber = true ;
190202 cpy->FrameNumber = frameNumber;
191- SendScheduleRequest (1 );
203+ PendingScheduleRemainder += Ratio.y () % Ratio.x ();
204+ uint32_t newCount = Ratio.y () / Ratio.x ();
205+ newCount += PendingScheduleRemainder / Ratio.x ();
206+ PendingScheduleRemainder = PendingScheduleRemainder % Ratio.x ();
207+ if (newCount)
208+ SendScheduleRequest (newCount);
192209 return NOS_RESULT_SUCCESS;
193210 }
194211 return NOS_RESULT_PENDING;
0 commit comments