1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

CVideoHandler: fix codecContext according to docs

This commit is contained in:
Konstantin 2022-05-14 12:11:57 +03:00 committed by Andrii Danylchenko
parent e7b753c222
commit 8757a577e3

View File

@ -143,11 +143,14 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
} }
codecContext = avcodec_alloc_context3(codec); codecContext = avcodec_alloc_context3(codec);
if(!codecContext)
return false;
// Get a pointer to the codec context for the video stream // Get a pointer to the codec context for the video stream
int ret = avcodec_parameters_to_context(codecContext, format->streams[stream]->codecpar); int ret = avcodec_parameters_to_context(codecContext, format->streams[stream]->codecpar);
if (ret < 0) if (ret < 0)
{ {
//We cannot get codec from parameters //We cannot get codec from parameters
avcodec_free_context(&codecContext);
return false; return false;
} }
@ -410,7 +413,6 @@ void CVideoPlayer::close()
if (codecContext) if (codecContext)
{ {
avcodec_free_context(&codecContext); avcodec_free_context(&codecContext);
codecContext = nullptr;
} }
if (format) if (format)