Page 1 of 1

IDecklinkOutput increases reference count on frames

PostPosted: Mon Nov 23, 2020 8:19 am
by Steffen Pätzold

i have derived my own frame class from IDeckLinkMutableVideoFrame.
When i schedule it via IDecklinkOutput::ScheduleVideoFrame the reference count is increased by IDeckLinkMutableVideoFrame::AddRef by the output object.
But when the frame is returned in IDecklinkOutput::ScheduledFrameCompleted the reference count is not decreased before.
Is that a handling by design or a bug? It is not mentioned in the SDK documentation.
I think it would be better if the output object adds and removes its "lock" on the frame on its own.

Re: IDecklinkOutput increases reference count on frames

PostPosted: Tue Nov 24, 2020 10:23 pm
by Cameron Nichols
Hi Steffen,

Confirming, the DeckLinkAPI adds reference to the IDeckLinkVideoFrame object at IDeckLinkOutput::ScheduledVideoFrame, this is ensure that the frame object remains valid and not inadvertently deleted before transferred to DeckLink card.

The equivalent call to IDeckLinkVideoFrame::Release occurs after return from IDeckLinkVideoOutputCallback::ScheduledFrameCompleted callback.


Re: IDecklinkOutput increases reference count on frames

PostPosted: Wed Nov 25, 2020 5:41 am
by Steffen Pätzold
Hi Cameron,

in my opinion this is an unsafe behaviour. It´s implemented this way now for years and maybe nobody ever complained about it but it makes memory handling very tricky:
When i hand over the frame to the IDecklinkOutput device its absolutly clear that it adds an reference to it because it will access the data.
But at the moment when the IDecklinkOutput device tells me that the frame is completed i assume it will not use it anymore.
The release should take place right before the IDeckLinkVideoOutputCallback::ScheduledFrameCompleted callback.