- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I have added an auto-detection piece of code to our software, where it tries to initialize a hardware encoder, and if that fails, uses a non-intel encoder (mostly for older hardware and non Intel hardware).
The function, as shown below, tries to initialize the encoder, then asks for the implementation (hardware/software). No matter what the result is, when MFXClose is called, the program crashes, while my understanding from the documentation is that it should work fine. What am I missing ?
regards
Jack
UINT8 QSVEncodingAvailable()
{
mfxVersion ver = {0, 1};
mfxSession EncoderSession;
mfxStatus Status=MFXInit (MFX_IMPL_AUTO_ANY,&ver,&EncoderSession);
if (Status!=MFX_ERR_NONE)
{
SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable failed : Init failed=%d\\n", Status));
// Removed, May cause a leak, but it appears to be an intel bug. When not initializing fully, crashes when this line is reached
// MFXClose (EncoderSession);
return false;
}
mfxIMPL Implementation;
Status=MFXQueryIMPL (EncoderSession,&Implementation);
if (Status!=MFX_ERR_NONE)
{
SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable failed : mfxQueryIMPL failed=%d\\n", Status));
// Removed, May cause a leak, but it appears to be an intel bug. When not initializing fully, crashes when this line is reached
// MFXClose (EncoderSession);
return false;
}
// Removed, May cause a leak, but it appears to be an intel bug. When not initializing fully, crashes when this line is reached
//MFXClose (EncoderSession);
//if (Implementation==MFX_IMPL_SOFTWARE)
//{
// SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable failed : Software-only implementation found\\n"));
// return false;
//}
SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable tested and working\\n"));
return true;
}
I have added an auto-detection piece of code to our software, where it tries to initialize a hardware encoder, and if that fails, uses a non-intel encoder (mostly for older hardware and non Intel hardware).
The function, as shown below, tries to initialize the encoder, then asks for the implementation (hardware/software). No matter what the result is, when MFXClose is called, the program crashes, while my understanding from the documentation is that it should work fine. What am I missing ?
regards
Jack
UINT8 QSVEncodingAvailable()
{
mfxVersion ver = {0, 1};
mfxSession EncoderSession;
mfxStatus Status=MFXInit (MFX_IMPL_AUTO_ANY,&ver,&EncoderSession);
if (Status!=MFX_ERR_NONE)
{
SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable failed : Init failed=%d\\n", Status));
// Removed, May cause a leak, but it appears to be an intel bug. When not initializing fully, crashes when this line is reached
// MFXClose (EncoderSession);
return false;
}
mfxIMPL Implementation;
Status=MFXQueryIMPL (EncoderSession,&Implementation);
if (Status!=MFX_ERR_NONE)
{
SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable failed : mfxQueryIMPL failed=%d\\n", Status));
// Removed, May cause a leak, but it appears to be an intel bug. When not initializing fully, crashes when this line is reached
// MFXClose (EncoderSession);
return false;
}
// Removed, May cause a leak, but it appears to be an intel bug. When not initializing fully, crashes when this line is reached
//MFXClose (EncoderSession);
//if (Implementation==MFX_IMPL_SOFTWARE)
//{
// SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable failed : Software-only implementation found\\n"));
// return false;
//}
SHOWMSG(DBGID_ENCODER, DBG_LEVEL_TRACE1, ("QSVEncodingAvailable tested and working\\n"));
return true;
}
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jack!
May be there is another (global)variable with same name as localEncoderSession also declared globally and which is not initialized?
Kind regards,
May be there is another (global)variable with same name as localEncoderSession also declared globally and which is not initialized?
Kind regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jack,
the behavior you describe is certainly strange. We have do not observe any issues using the same set of operations.
What version of Media SDK are you using?
Regards,
the behavior you describe is certainly strange. We have do not observe any issues using the same set of operations.
What version of Media SDK are you using?
Regards,
Petter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Petter
I use the "gold" version 3.0, A.K.A Media SDK 2012. is there a newer one ?
I have copied the code above into its own project, and encountered the same behaviour (after un-commenting the MFXClode, that is).
regards
Jack
I use the "gold" version 3.0, A.K.A Media SDK 2012. is there a newer one ?
I have copied the code above into its own project, and encountered the same behaviour (after un-commenting the MFXClode, that is).
regards
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jack,
We have not seen the issues you report with either the Media SDK 2012 or the new Media SDK 2012 R2, which is available on the Media SDK site.
Just as a sanity check I quickly tested this with a derivative of the code you provided. Works on my end without any crash. I'm guessing that something else is getting corrupted in your environment.
Regards,
We have not seen the issues you report with either the Media SDK 2012 or the new Media SDK 2012 R2, which is available on the Media SDK site.
Just as a sanity check I quickly tested this with a derivative of the code you provided. Works on my end without any crash. I'm guessing that something else is getting corrupted in your environment.
[cpp]mfxVersion ver = {0, 1}; mfxSession EncoderSession; mfxStatus Status=MFXInit (MFX_IMPL_AUTO_ANY,&ver,&EncoderSession); if (Status!=MFX_ERR_NONE) { MFXClose (EncoderSession); return 1; } mfxIMPL Implementation; Status=MFXQueryIMPL (EncoderSession,&Implementation); if (Status!=MFX_ERR_NONE) { MFXClose (EncoderSession); return 1; } MFXClose (EncoderSession); return 0;[/cpp]
Regards,
Petter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Here're my 3 cents:
1) Failed to create a session - don't close it, nothing to close. Should be no leak as a session wasn't created. If you see a leak, this is an MSDK bug.
2) You should not assume that data (or handles) are valid if the called function returns with an error.
3) Setting the session handle to NULL at least allows the MSDK to do paramter checks, if it's garbage, it might crash.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Eric
What you say makes sense, and that's how I've done that initially, until I read the following passage in the manual (mediasdk-man.pdf) :
The function MFXInit starts (initializes) an SDK session. MFXClose closes (de-initializes) the SDK session. To avoid memory leaks, always call MFXClose after MFXInit, even if MFXInit returns an error code.
So... perhaps the documentation needs to be corrected ?
regards
Jack
What you say makes sense, and that's how I've done that initially, until I read the following passage in the manual (mediasdk-man.pdf) :
The function MFXInit starts (initializes) an SDK session. MFXClose closes (de-initializes) the SDK session. To avoid memory leaks, always call MFXClose after MFXInit, even if MFXInit returns an error code.
So... perhaps the documentation needs to be corrected ?
regards
Jack
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jack,
It is ok to Close the session even though it was not properly initialized. However, it is not necessary as Eric pointed out. There are no memory leaks associated with this.
We will work on improving the manual to avoid confusion on this topic.
Regards,
It is ok to Close the session even though it was not properly initialized. However, it is not necessary as Eric pointed out. There are no memory leaks associated with this.
We will work on improving the manual to avoid confusion on this topic.
Regards,
Petter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another option is that the init function should zero the session handle on failure. It also indicates to the user that there's nothing to close.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page