Variable is being used without being initialized

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

kurtis_kraft

  • Posts: 2
  • Joined: Wed May 04, 2022 12:53 pm
  • Real Name: Matheus Berçot

Variable is being used without being initialized

PostWed May 04, 2022 1:31 pm

Greetings,

I am an engineering student whose first project in my internship is to code a software to perform a very basic capture operation in a Decklink Duo 2 card. This is actually my very first "real life" code, other than the basic programming we learn at the university.

Trying to follow page 20 from the SDK manual to create this operation without success so far.

The few lines of code I have so far read as follows:

Code: Select all
#include <DeckLinkAPI.h>
...

int main (int argc, char** argv) {

IDeckLink*          deckLink;
IDeckLinkIterator*  deckLinkIterator;
IDeckLinkInput*    deckLinkInput;
HRESULT result;

//Initializing COM
result = CoInitializeEx(NULL, COINIT_MULTITHREADED);


result = CoCreateInstance (CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);


result = deckLinkInput->EnableVideoInput(bmdModelHD1080p6000, bmdFormat8BitYUV, bmdVideoInputFlagdefault);

getch();

}



It builds with zero errors, but when either executing or trying to debug this I get "Run-Time Check Failure #3 - The variable 'deckLinkInput' is being used without being initialized". That makes me believe that I am using the classes wrongly (to say the least) here. I've been checking files such as Capture.cpp (Linux) and DeviceList.cpp (Windows) and I fail to see the difference in instantiation. I didn't use IDeckLinkIterator yet because so far I don't have a concern of which camera to capture, but rather I want to test these methods and be able to capture any camera.

Isn't the idea to instantiate the class with a pointer and then apply the methods over this pointer? What things am I missing?

Apologies for the very elementar questions, been stuck with this for over a week without having a lot of progress. Any suggestions on how to study this SDK and improve are also very welcome.
Offline

Cameron Nichols

Blackmagic Design

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

Re: Variable is being used without being initialized

PostFri May 06, 2022 5:37 am

Hi Matheus,

From the code segment provided, there is no path that initialises the pointer deckLinkInput, so call to IDeckLinkInput::EnableVideoInput is invalid and will cause execution issue. There are 2 missing steps:

1) After CoCreateInstance, use IDeckLinkIterator object to iterate IDeckLink object:
Code: Select all
result = deckLinkIterator->Next(&deckLink);
if (result == S_OK)
    ...
You may need to call IDeckLinkIterator::Next several times if you targeting a device other than the first device in the DeckLink Duo 2.

2) With an IDeckLink object call IUnknown::QueryInterface to get the corresponding IDeckLinkInput interface object.
Code: Select all
result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput);
if (result == S_OK)
    ...
Regards
Cameron
Offline

kurtis_kraft

  • Posts: 2
  • Joined: Wed May 04, 2022 12:53 pm
  • Real Name: Matheus Berçot

Re: Variable is being used without being initialized

PostThu May 12, 2022 4:00 pm

OK, succeded in creating a code which captures the frames from the selected cameras to the RAM. How should I proceed now to pull these frames from RAM, transform them into video and save them into a folder as a video file? This should be my entire project I believe. I couldn't find any mention to this procedure in the documentation. Any advice and examples are immensely welcome. Still learning the ropes around it.

Thanks.
Offline

Cameron Nichols

Blackmagic Design

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

Re: Variable is being used without being initialized

PostThu May 12, 2022 11:01 pm

Hi Matheus,

Please be aware that the DeckLink SDK will deliver raw video frames and PCM audio samples and it is for the application to provide the encoder. The exception to this is the UltraStudio 4K Extreme which has a hardware encoder supporting H.265.

That said, please review the FileCapture sample in the Windows Samples folder in the SDK package. This sample provides a demonstration how interface the DeckLink SDK with Media Foundation Sink Writer component.

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 18 guests