[FFmpeg-devel] [PATCH] lavfi/noise: support slice threading

Michael Niedermayer michaelni at gmx.at
Wed May 29 19:11:20 CEST 2013


On Tue, May 28, 2013 at 10:52:19AM +0000, Paul B Mahol wrote:
> On 5/28/13, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sun, May 26, 2013 at 05:43:07PM +0000, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> ---
> >>
> >> Alternative version.
> >>
> >> ---
> >>  libavfilter/vf_noise.c | 85
> >> +++++++++++++++++++++++++++++---------------------
> >>  1 file changed, 49 insertions(+), 36 deletions(-)
> >>
> >> diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
> >> index 12aca24..7ae6c53 100644
> >> --- a/libavfilter/vf_noise.c
> >> +++ b/libavfilter/vf_noise.c
> >> @@ -47,7 +47,6 @@
> >>  typedef struct {
> >>      int strength;
> >>      unsigned flags;
> >> -    int shiftptr;
> >>      AVLFG lfg;
> >>      int seed;
> >>      int8_t *noise;
> >> @@ -67,6 +66,10 @@ typedef struct {
> >>      void (*line_noise_avg)(uint8_t *dst, const uint8_t *src, int len,
> >> int8_t **shift);
> >>  } NoiseContext;
> >>
> >> +typedef struct ThreadData {
> >> +    AVFrame *in, *out;
> >> +} ThreadData;
> >> +
> >>  #define OFFSET(x) offsetof(NoiseContext, x)
> >>  #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
> >>
> >> @@ -161,7 +164,6 @@ static int init_noise(NoiseContext *n, int comp)
> >>      }
> >>
> >>      fp->noise = noise;
> >> -    fp->shiftptr = 0;
> >>      return 0;
> >>  }
> >>
> >> @@ -328,48 +330,60 @@ static inline void line_noise_avg_mmx(uint8_t *dst,
> >> const uint8_t *src,
> >>  #endif
> >>  }
> >>
> >> -static void noise(uint8_t *dst, const uint8_t *src,
> >> -                  int dst_linesize, int src_linesize,
> >> -                  int width, int height, NoiseContext *n, int comp)
> >> +static int noise(AVFilterContext *ctx, void *arg, int jobnr, int
> >> nb_jobs)
> >
> > isnt it simpler to leave noise() as it is and add a function that
> > calls noise() nb_planes times ?
> >
> > otherwise patch should be ok
> 
> I would prefer if somebody tested and compared speed of both versions. I can't.

type1, type2,     old
2.011    2.022    1.938
2.270    1.999    1.994
2.195    1.958    2.102
2.243    1.962    2.079
2.247    1.962    1.871
2.220    2.043    2.014
2.293    1.942    2.051
2.261    1.939    1.925

tested with:
time ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -vf noise -f null -

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130529/4e234779/attachment.asc>


More information about the ffmpeg-devel mailing list