[FFmpeg-cvslog] avfilter/vf_morpho: Factor out (re)allocating lut
Andreas Rheinhardt
git at videolan.org
Mon Oct 4 18:36:50 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Oct 3 08:51:42 2021 +0200| [0536c5a449e5c9447d5042109b0b963d98e00596] | committer: Andreas Rheinhardt
avfilter/vf_morpho: Factor out (re)allocating lut
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0536c5a449e5c9447d5042109b0b963d98e00596
---
libavfilter/vf_morpho.c | 60 +++++++++++++++++++++++--------------------------
1 file changed, 28 insertions(+), 32 deletions(-)
diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c
index ce62c86f91..ea8a0c065e 100644
--- a/libavfilter/vf_morpho.c
+++ b/libavfilter/vf_morpho.c
@@ -315,6 +315,28 @@ static void free_lut(LUT *table)
av_freep(&rp);
}
+static int alloc_lut_if_necessary(LUT *Ty, IPlane *f, chord_set *SE,
+ int y, int num, enum MorphModes mode)
+{
+ if (Ty->I != SE->Lnum ||
+ Ty->X != f->w ||
+ Ty->min_r != SE->minY ||
+ Ty->max_r != SE->maxY + num - 1) {
+ int ret;
+
+ free_lut(Ty);
+
+ Ty->I = SE->Lnum;
+ Ty->X = f->w;
+ Ty->min_r = SE->minY;
+ Ty->max_r = SE->maxY + num - 1;
+ ret = alloc_lut(Ty, SE, f->type_size, mode);
+ if (ret < 0)
+ return ret;
+ }
+ return 0;
+}
+
static void circular_swap(LUT *Ty)
{
/*
@@ -362,22 +384,9 @@ static void update_min_lut(IPlane *f, LUT *Ty, chord_set *SE, int y, int tid, in
static int compute_min_lut(LUT *Ty, IPlane *f, chord_set *SE, int y, int num)
{
- if (Ty->I != SE->Lnum ||
- Ty->X != f->w ||
- Ty->min_r != SE->minY ||
- Ty->max_r != SE->maxY + num - 1) {
- int ret;
-
- free_lut(Ty);
-
- Ty->I = SE->Lnum;
- Ty->X = f->w;
- Ty->min_r = SE->minY;
- Ty->max_r = SE->maxY + num - 1;
- ret = alloc_lut(Ty, SE, f->type_size, ERODE);
- if (ret < 0)
- return ret;
- }
+ int ret = alloc_lut_if_necessary(Ty, f, SE, y, num, ERODE);
+ if (ret < 0)
+ return ret;
for (int r = Ty->min_r; r <= Ty->max_r; r++)
compute_min_row(f, Ty, SE, r, y);
@@ -416,22 +425,9 @@ static void update_max_lut(IPlane *f, LUT *Ty, chord_set *SE, int y, int tid, in
static int compute_max_lut(LUT *Ty, IPlane *f, chord_set *SE, int y, int num)
{
- if (Ty->I != SE->Lnum ||
- Ty->X != f->w ||
- Ty->min_r != SE->minY ||
- Ty->max_r != SE->maxY + num - 1) {
- int ret;
-
- free_lut(Ty);
-
- Ty->I = SE->Lnum;
- Ty->X = f->w;
- Ty->min_r = SE->minY;
- Ty->max_r = SE->maxY + num - 1;
- ret = alloc_lut(Ty, SE, f->type_size, DILATE);
- if (ret < 0)
- return ret;
- }
+ int ret = alloc_lut_if_necessary(Ty, f, SE, y, num, DILATE);
+ if (ret < 0)
+ return ret;
for (int r = Ty->min_r; r <= Ty->max_r; r++)
compute_max_row(f, Ty, SE, r, y);
More information about the ffmpeg-cvslog
mailing list