IDecklinkOutput increases reference count on frames

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Steffen Pätzold

  • Posts: 21
  • Joined: Mon Mar 30, 2015 10:35 am
  • Location: Leipzig, Germany

IDecklinkOutput increases reference count on frames

PostMon Nov 23, 2020 8:19 am

Hello,

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.
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: IDecklinkOutput increases reference count on frames

PostTue Nov 24, 2020 10:23 pm

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.

Regards
Cameron
Offline

Steffen Pätzold

  • Posts: 21
  • Joined: Mon Mar 30, 2015 10:35 am
  • Location: Leipzig, Germany

Re: IDecklinkOutput increases reference count on frames

PostWed Nov 25, 2020 5:41 am

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.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 14 guests