summaryrefslogtreecommitdiffstats
path: root/libhb/nlmeans.c
diff options
context:
space:
mode:
authorBradley Sepos <[email protected]>2018-01-10 23:50:43 -0500
committerBradley Sepos <[email protected]>2018-01-10 23:51:03 -0500
commitb8e11e0a5292c81c06831b8a0543dbfca5346f89 (patch)
tree54974702e6b72f11993257365769fa42de6bb810 /libhb/nlmeans.c
parent72b0bbcb5fb9ad26f64e7594fd2046f301af117e (diff)
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.
Diffstat (limited to 'libhb/nlmeans.c')
-rw-r--r--libhb/nlmeans.c12
1 files changed, 10 insertions, 2 deletions
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);
}