Ring buffer size

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

mkrebs

  • Posts: 2
  • Joined: Mon Aug 10, 2020 8:32 am
  • Real Name: Michael Krebs

Ring buffer size

PostMon Aug 10, 2020 8:39 am

Hello,

I'm developing on a decklink duo 2 card. I made some test regarding the latency and i see that if i acquire a signal 1920x1080@50Hz and if i take long time in method "VideoInputFrameArrived" the latency increase (this is normal) and i lost frame only after 28 frames. So i have deduced that the internal ring buffer of the card can save 28 frames before lost the last one. My questions are :

- 28 frames in the buffer is the constant ? or it is dependent of the signal type ?
- how can i ask to the card (with the api) the maximum number of frames in the buffer ? or how can i set the limit ?

Thank you !
Offline

Cameron Nichols

Blackmagic Design

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

Re: Ring buffer size

PostFri Aug 14, 2020 6:57 am

Hi Michael,

The buffer size provided by the default memory allocator is based on the maximum frame size supported by the device. In the case of DeckLink Duo 2, where 1920x1080 is the maximum frame size - you would have higher frame buffer for 720p, NTSC, PAL.

You cannot alter this limit, to increase the number of frames you can implement your own custom memory allocator with the following steps:
  • Create custom allocator class that implements IDeckLinkMemoryAllocator interface[1]. Implement all methods defined by interface.
  • AllocateBuffer should output the pointer to allocated memory of size requested by DeckLinkAPI. This will be repetitively called on IDeckLinkInput::EnableVideoInput, return HRESULT = E_OUTOFMEMORY when you have reached upper limit of allocated frames
  • ReleaseBuffer called when frame is released by DeckLinkAPI, you can either delete allocation, or cache and reuse for later allocation
  • Commit and Decommit are optional, they can be used to create and delete resources for memory pool allocation.
  • Register your customer memory allocator with IDeckLinkInput::SetVideoInputFrameMemoryAllocator [2] (prior to call to EnableVideoInput).
Regards
Cameron

Refs:
[1] 2.5.18 IDeckLinkMemoryAllocator Interface
[2] 2.5.4.11 IDeckLinkInput::SetVideoInputFrameMemoryAllocator method
Offline

mkrebs

  • Posts: 2
  • Joined: Mon Aug 10, 2020 8:32 am
  • Real Name: Michael Krebs

Re: Ring buffer size

PostFri Aug 14, 2020 7:23 am

Hi Cameron,

thank you for your reply. Ok I will implement the IDeckLinkMemoryAllocator to control the limit of number of buffers (I suspected that I had to do that). It is possible to see somewhere the source code of the default implementation of this interface ?

Best regards
Michaël
Offline

Cameron Nichols

Blackmagic Design

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

Re: Ring buffer size

PostSun Aug 16, 2020 10:50 am

Hi Michael,

The following SDK samples use the IDeckLinkMemoryAllocator:
  • FileCapture (Win), allocates buffers in format of Media Foundation IMFMediaBuffer.
  • LoopThroughWithOpenGLCompositing (Win/Linux), and
  • LoopThroughWithDX11Compositing (Win) for creating pinned memory to shareable with GPU (GPUDirect).
Regards
Cameron
Offline

mf_keycast

  • Posts: 3
  • Joined: Tue Mar 22, 2022 2:27 pm
  • Real Name: Michael Figueroa

Re: Ring buffer size

PostTue Mar 22, 2022 7:21 pm

I am having a similar issue, when calling GetBufferedVideoFrameCount it return something like 6-7 frames in its buffer. i need this value to max out at 2-3 frames. so I have implemented a custom Memory Allocater taken from the samples,as suggested above, included with the SDK. however, it is only called when calling CreateVideoFrame and not when EnableVideoOutput is called. is there a different way to specify the max number of frames that can be buffered for output by the device?

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 43 guests