From b9a48eb4645b8a13f68803b0a805d0ea276925a3 Mon Sep 17 00:00:00 2001 From: Steve Gilvarry Date: Sun, 17 Jul 2016 08:11:53 +1000 Subject: [PATCH] Pass swscale_ctx back in to getCachedContext or it will create new context every frame and leak memory like a mofo. --- src/zm_ffmpeg.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 4af4055a4..2eb475e11 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -154,10 +154,10 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint // Error("Invalid input or output pixel formats"); // return -2; // } - // if(!width || !height) { - // Error("Invalid width or height"); - // return -3; - // } + if (!width || !height) { + Error("Invalid width or height"); + return -3; + } #if LIBSWSCALE_VERSION_CHECK(0, 8, 0, 8, 0) /* Warn if the input or output pixelformat is not supported */ @@ -190,7 +190,7 @@ int SWScale::Convert(const uint8_t* in_buffer, const size_t in_buffer_size, uint } /* Get the context */ - swscale_ctx = sws_getCachedContext( NULL, width, height, in_pf, width, height, out_pf, 0, NULL, NULL, NULL ); + swscale_ctx = sws_getCachedContext(swscale_ctx, width, height, in_pf, width, height, out_pf, 0, NULL, NULL, NULL); if(swscale_ctx == NULL) { Error("Failed getting swscale context"); return -6;