FORUMS: list search recent posts

DisplayVideoFrameSync memory leaks problem

COW Forums : Blackmagic Design

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Mauro Gattari
DisplayVideoFrameSync memory leaks problem
on Jan 9, 2012 at 2:59:30 pm

Hi,
I'm trying to write a small C program that outputs frames to the card, but I'm experiencing memory leaks problems.

The program is very simple, after having enabled video output:

deckLinkOutput->EnableVideoOutput(bmdModeHD720p50, bmdVideoOutputFlagDefault);

It starts outputting frames at 50fps within a loop in which:
1. create an output video frame:

deckLinkOutput->CreateVideoFrame(
1280, 720, 1280*4,
bmdFormat8BitBGRA, bmdFrameFlagDefault,
&videoFrame);

2. write raw data within the frame (just a pattern of RED or GREEN pixels)
3. display the frame:

deckLinkOutput->DisplayVideoFrameSync(videoFrame);

4. release the frame:

videoFrame->Release();
videoFrame = NULL;


The program works, but memory consumption grows fast (1MB per second) and I can't understand why since I think I'm correctly releasing a video frame before creating a new one.

Can anybody give me any help?
Thanks!

Linux Ubuntu 11.10
DeckLink Studio
Drivers 9.0

--------------------------------------------------------------------
This is the whole source code:



#include "simple.h"

#include "DeckLinkAPI.h"
#include
#include
#include

IDeckLink* deckLink = NULL;
IDeckLinkOutput* deckLinkOutput = NULL;
IDeckLinkMutableVideoFrame* videoFrame = NULL;

unsigned char* publicCreateOutputVideoFrame()
{
unsigned char* outBytes = NULL;

HRESULT result = deckLinkOutput->CreateVideoFrame(
1280, 720, 1280*4,
bmdFormat8BitBGRA, bmdFrameFlagDefault,
&videoFrame);

if (result != S_OK)
return NULL;

result = videoFrame->GetBytes((void**)&outBytes);

return outBytes;
}

void publicDisplayVideoFrameSync()
{
deckLinkOutput->DisplayVideoFrameSync(videoFrame);
/* ULONG refCount = */ videoFrame->Release();
videoFrame = NULL;
}

void cleanUp()
{
if (deckLinkOutput != NULL)
{
deckLinkOutput->DisableVideoOutput();
deckLinkOutput = NULL;
}
if (deckLink != NULL)
{
deckLink->Release();
deckLink = NULL;
}
}

int setUp()
{
IDeckLinkIterator* deckLinkIterator;
HRESULT result;

deckLinkIterator = CreateDeckLinkIteratorInstance();
if (deckLinkIterator == NULL)
{
fprintf(stderr, "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.n");
return 1;
}

// Get the first DeckLinkCard
result = deckLinkIterator->Next(&deckLink);
if (result != S_OK)
{
fprintf(stderr, "Could not obtain the IDeckLink interface - result = %08dn", result);
goto bail;
}

result = deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&deckLinkOutput);
if (result != S_OK)
{
fprintf(stderr, "Could not obtain the IDeckLinkOutput interface - result = %08dn", result);
goto bail;
}

deckLinkOutput->EnableVideoOutput(bmdModeHD720p50, bmdVideoOutputFlagDefault);

bail:
deckLinkIterator->Release();
deckLinkIterator = NULL;

return 0;
}

int main()
{
const int fps = 50;
const int nrOfFramse = fps*60*1; // fps * seconds * minutes

int i,j;
unsigned int pattern;

setUp();

for(j=0; j nrOfFramse; j++)
{
unsigned char* frame = publicCreateOutputVideoFrame();

if (frame != NULL)
{
if ((j/fps)%2==0)
pattern = 0x0000ff00;
else
pattern = 0x000000ff;

for(i=0; i<1280*720; i++)
((unsigned int *)frame)[i] = pattern; // AARRGGBB

publicDisplayVideoFrameSync();
}

usleep(1000000/fps);
}

getchar();

cleanUp();

return 0;
}


Return to posts index

Joshua Helling
Re: DisplayVideoFrameSync memory leaks problem
on Jan 16, 2012 at 7:28:17 pm

Might be best to contact developer@blackmagic-design.com to get help with this issue.

Sincerely,

Joshua
Director of Support
Blackmagic Design Inc.


Return to posts index

Mauro Gattari
Re: DisplayVideoFrameSync memory leaks problem
on Jan 16, 2012 at 7:30:57 pm

Yes,
I already contacted the developers and they acknowledged the issue. They are working on it, I'm waiting for the fix release.
Thanks


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]