aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-10-16 17:52:34 +0200
committerdec05eba <dec05eba@protonmail.com>2022-10-16 17:52:34 +0200
commit50777aae787ed4dd2bdbeace7cfba5268b1324aa (patch)
tree5a14ca6da1883e8e394cbccc6db911b04d72e3ef /src/main.cpp
parent1a6a828fa269defda0ae084e7a6e1fa707b28cac (diff)
Free test codec context
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp14
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;