From: Bradley Sepos Date: Thu, 11 Jan 2018 04:50:43 +0000 (-0500) Subject: libhb: Plug memory leak in NLMeans. X-Git-Tag: 1.1.0~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8e11e0a5292c81c06831b8a0543dbfca5346f89;p=handbrake libhb: Plug memory leak in NLMeans. This reverts 0e072aa42e3affd6280447317375460753f9284b and implements a proper fix for some frames not being prefiltered correctly. Turns out it was an issue with an uninitialized variable. --- diff --git a/libhb/nlmeans.c b/libhb/nlmeans.c index 2226ee919..e6f8f1767 100644 --- a/libhb/nlmeans.c +++ b/libhb/nlmeans.c @@ -97,6 +97,7 @@ typedef struct int h; int border; hb_lock_t *mutex; + int prefiltered; } BorderedPlane; typedef struct @@ -251,8 +252,9 @@ static void nlmeans_alloc(const uint8_t *src, dst->border = border; nlmeans_border(dst->mem, dst->w, dst->h, dst->border); - dst->mem_pre = dst->mem; - dst->image_pre = dst->image; + dst->mem_pre = dst->mem; + dst->image_pre = dst->image; + dst->prefiltered = 0; } @@ -585,6 +587,11 @@ static void nlmeans_prefilter(BorderedPlane *src, const int filter_type) { hb_lock(src->mutex); + if (src->prefiltered) + { + hb_unlock(src->mutex); + return; + } if (filter_type & NLMEANS_PREFILTER_MODE_MEAN3X3 || filter_type & NLMEANS_PREFILTER_MODE_MEAN5X5 || @@ -696,6 +703,7 @@ static void nlmeans_prefilter(BorderedPlane *src, nlmeans_border(mem_pre, w, h, border); } + src->prefiltered = 1; hb_unlock(src->mutex); }