0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 22:45:48 +00:00

ffmpeg: Add extra checks and error messages (#2951)

* ffmpeg: Add extra checks and error messages

This PR adds some checks and logging error messages related to the ffmpeg context creation, that will prevent users to open issues because they don't have the correct packages installed.
Close #2762

* Update FFmpegContext.cs
This commit is contained in:
Ac_K 2022-01-03 12:38:21 +01:00 committed by GitHub
parent e98abf1820
commit 16c649934f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,11 +18,35 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
public FFmpegContext(AVCodecID codecId)
{
_codec = ffmpeg.avcodec_find_decoder(codecId);
_context = ffmpeg.avcodec_alloc_context3(_codec);
if (_codec == null)
{
Logger.Error?.PrintMsg(LogClass.FFmpeg, $"Codec wasn't found. Make sure you have the {codecId} codec present in your FFmpeg installation.");
ffmpeg.avcodec_open2(_context, _codec, null);
return;
}
_context = ffmpeg.avcodec_alloc_context3(_codec);
if (_context == null)
{
Logger.Error?.PrintMsg(LogClass.FFmpeg, "Codec context couldn't be allocated.");
return;
}
if (ffmpeg.avcodec_open2(_context, _codec, null) != 0)
{
Logger.Error?.PrintMsg(LogClass.FFmpeg, "Codec couldn't be opened.");
return;
}
_packet = ffmpeg.av_packet_alloc();
if (_packet == null)
{
Logger.Error?.PrintMsg(LogClass.FFmpeg, "Packet couldn't be allocated.");
return;
}
_decodeFrame = Marshal.GetDelegateForFunctionPointer<AVCodec_decode>(_codec->decode.Pointer);
}