[FFmpeg-cvslog] avfilter/vf_v360: add slice threading to remap calculation

Paul B Mahol git at videolan.org
Mon Sep 16 20:25:24 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Sep 16 18:41:51 2019 +0200| [6f4ec4d909cc6dae5ce51f95e7518f2553215dc8] | committer: Paul B Mahol

avfilter/vf_v360: add slice threading to remap calculation

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6f4ec4d909cc6dae5ce51f95e7518f2553215dc8
---

 libavfilter/vf_v360.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 6cccb2570f..d5b94cf747 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -2162,7 +2162,7 @@ static void set_dimensions(int *outw, int *outh, int w, int h, const AVPixFmtDes
 }
 
 // Calculate remap data
-static av_always_inline void v360_filter(AVFilterContext *ctx)
+static av_always_inline int v360_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
     V360Context *s = ctx->priv;
 
@@ -2172,11 +2172,13 @@ static av_always_inline void v360_filter(AVFilterContext *ctx)
         const int height = s->pr_height[p];
         const int in_width = s->inplanewidth[p];
         const int in_height = s->inplaneheight[p];
+        const int slice_start = (height *  jobnr     ) / nb_jobs;
+        const int slice_end   = (height * (jobnr + 1)) / nb_jobs;
         float du, dv;
         float vec[3];
         XYRemap rmap;
 
-        for (int j = 0; j < height; j++) {
+        for (int j = slice_start; j < slice_end; j++) {
             for (int i = 0; i < width; i++) {
                 uint16_t *u = s->u[p] + (j * uv_linesize + i) * s->elements;
                 uint16_t *v = s->v[p] + (j * uv_linesize + i) * s->elements;
@@ -2200,6 +2202,8 @@ static av_always_inline void v360_filter(AVFilterContext *ctx)
             }
         }
     }
+
+    return 0;
 }
 
 static int config_output(AVFilterLink *outlink)
@@ -2493,7 +2497,7 @@ static int config_output(AVFilterLink *outlink)
     calculate_rotation_matrix(s->yaw, s->pitch, s->roll, s->rot_mat, s->rotation_order);
     set_mirror_modifier(s->h_flip, s->v_flip, s->d_flip, s->output_mirror_modifier);
 
-    v360_filter(ctx);
+    ctx->internal->execute(ctx, v360_slice, NULL, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list