diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-10-16 17:52:34 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-10-16 17:52:34 +0200 |
commit | 50777aae787ed4dd2bdbeace7cfba5268b1324aa (patch) | |
tree | 5a14ca6da1883e8e394cbccc6db911b04d72e3ef /src | |
parent | 1a6a828fa269defda0ae084e7a6e1fa707b28cac (diff) |
Free test codec context
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 1fc1afa..021d6e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -697,9 +697,12 @@ static const AVCodec* find_h264_encoder() { checked = true; // Do not use AV_PIX_FMT_CUDA because we dont want to do full check with hardware context AVCodecContext *codec_context = create_video_codec_context(AV_PIX_FMT_YUV420P, VideoQuality::VERY_HIGH, 1920, 1080, 60, codec, false); - if (avcodec_open2(codec_context, codec_context->codec, NULL) < 0) { + if(codec_context) { + if (avcodec_open2(codec_context, codec_context->codec, NULL) < 0) { + avcodec_free_context(&codec_context); + return nullptr; + } avcodec_free_context(&codec_context); - return nullptr; } } return codec; @@ -718,9 +721,12 @@ static const AVCodec* find_h265_encoder() { checked = true; // Do not use AV_PIX_FMT_CUDA because we dont want to do full check with hardware context AVCodecContext *codec_context = create_video_codec_context(AV_PIX_FMT_YUV420P, VideoQuality::VERY_HIGH, 1920, 1080, 60, codec, false); - if (avcodec_open2(codec_context, codec_context->codec, NULL) < 0) { + if(codec_context) { + if (avcodec_open2(codec_context, codec_context->codec, NULL) < 0) { + avcodec_free_context(&codec_context); + return nullptr; + } avcodec_free_context(&codec_context); - return nullptr; } } return codec; |