summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2019-05-06 11:48:31 +0800
committerRuiling Song <ruiling.song@intel.com>2019-05-08 10:39:43 +0800
commit06ba4783a0ba331153b71993bc1908958d483c2d (patch)
tree71d3c40b45dfd27eec06f4afbc44ed666125d503
parentfcf53f616e635d36bda18069a9815148b328783a (diff)
downloadffmpeg-streaming-06ba4783a0ba331153b71993bc1908958d483c2d.zip
ffmpeg-streaming-06ba4783a0ba331153b71993bc1908958d483c2d.tar.gz
lavfi/gblur: doing several columns at the same time
Instead of doing each column one by one, doing several columns together gives about 30% better performance. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
-rw-r--r--libavfilter/vf_gblur.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index f77a3ff..b91a8c0 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -108,6 +108,40 @@ static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int n
return 0;
}
+static void do_vertical_columns(float *buffer, int width, int height,
+ int column_begin, int column_end, int steps,
+ float nu, float boundaryscale, int column_step)
+{
+ const int numpixels = width * height;
+ int i, x, k, step;
+ float *ptr;
+ for (x = column_begin; x < column_end;) {
+ for (step = 0; step < steps; step++) {
+ ptr = buffer + x;
+ for (k = 0; k < column_step; k++) {
+ ptr[k] *= boundaryscale;
+ }
+ /* Filter downwards */
+ for (i = width; i < numpixels; i += width) {
+ for (k = 0; k < column_step; k++) {
+ ptr[i + k] += nu * ptr[i - width + k];
+ }
+ }
+ i = numpixels - width;
+
+ for (k = 0; k < column_step; k++)
+ ptr[i + k] *= boundaryscale;
+
+ /* Filter upwards */
+ for (; i > 0; i -= width) {
+ for (k = 0; k < column_step; k++)
+ ptr[i - width + k] += nu * ptr[i + k];
+ }
+ }
+ x += column_step;
+ }
+}
+
static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
GBlurContext *s = ctx->priv;
@@ -117,31 +151,19 @@ static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_
const int slice_start = (width * jobnr ) / nb_jobs;
const int slice_end = (width * (jobnr+1)) / nb_jobs;
const float boundaryscale = s->boundaryscaleV;
- const int numpixels = width * height;
const int steps = s->steps;
const float nu = s->nuV;
float *buffer = s->buffer;
- int i, x, step;
- float *ptr;
-
- /* Filter vertically along each column */
- for (x = slice_start; x < slice_end; x++) {
- for (step = 0; step < steps; step++) {
- ptr = buffer + x;
- ptr[0] *= boundaryscale;
-
- /* Filter downwards */
- for (i = width; i < numpixels; i += width)
- ptr[i] += nu * ptr[i - width];
-
- ptr[i = numpixels - width] *= boundaryscale;
+ int aligned_end;
- /* Filter upwards */
- for (; i > 0; i -= width)
- ptr[i - width] += nu * ptr[i];
- }
- }
+ aligned_end = slice_start + (((slice_end - slice_start) >> 3) << 3);
+ /* Filter vertically along columns (process 8 columns in each step) */
+ do_vertical_columns(buffer, width, height, slice_start, aligned_end,
+ steps, nu, boundaryscale, 8);
+ /* Filter un-aligned columns one by one */
+ do_vertical_columns(buffer, width, height, aligned_end, slice_end,
+ steps, nu, boundaryscale, 1);
return 0;
}
OpenPOWER on IntegriCloud