[FFmpeg-devel] [PATCH 3/4] vf_ssim: remove another obscure double loop.

Michael Niedermayer michael at niedermayer.cc
Mon Jul 13 02:39:57 CEST 2015


On Sun, Jul 12, 2015 at 10:04:32PM +0000, Paul B Mahol wrote:
> On 7/12/15, Paul B Mahol <onemda at gmail.com> wrote:
> > Dana 12. 7. 2015. 01:57 osoba "Ronald S. Bultje" <rsbultje at gmail.com>
> > napisala je:
> >>
> >> ---
> >>  libavfilter/vf_ssim.c | 18 ++++++++----------
> >>  1 file changed, 8 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
> >> index b1c3368..f7a259e 100644
> >> --- a/libavfilter/vf_ssim.c
> >> +++ b/libavfilter/vf_ssim.c
> >> @@ -85,13 +85,13 @@ static void set_meta(AVDictionary **metadata, const
> > char *key, char comp, float
> >>      }
> >>  }
> >>
> >> -static void ssim_4x4x2_core(const uint8_t *main, int main_stride,
> >> -                            const uint8_t *ref, int ref_stride,
> >> -                            int sums[2][4])
> >> +static void ssim_4x4xn(const uint8_t *main, int main_stride,
> >> +                       const uint8_t *ref, int ref_stride,
> >> +                       int (*sums)[4], int width)
> >>  {
> >>      int x, y, z;
> >>
> >> -    for (z = 0; z < 2; z++) {
> >> +    for (z = 0; z < width; z++) {
> >>          uint32_t s1 = 0, s2 = 0, ss = 0, s12 = 0;
> >>
> >>          for (y = 0; y < 4; y++) {
> >> @@ -149,8 +149,7 @@ static float ssim_plane(uint8_t *main, int
> > main_stride,
> >>                          uint8_t *ref, int ref_stride,
> >>                          int width, int height, void *temp)
> >>  {
> >> -    int z = 0;
> >> -    int x, y;
> >> +    int z = 0, y;
> >>      float ssim = 0.0;
> >>      int (*sum0)[4] = temp;
> >>      int (*sum1)[4] = sum0 + (width >> 2) + 3;
> >> @@ -161,10 +160,9 @@ static float ssim_plane(uint8_t *main, int
> > main_stride,
> >>      for (y = 1; y < height; y++) {
> >>          for (; z <= y; z++) {
> >>              FFSWAP(void*, sum0, sum1);
> >> -            for (x = 0; x < width; x+=2)
> >> -                ssim_4x4x2_core(&main[4 * (x + z * main_stride)],
> > main_stride,
> >> -                                &ref[4 * (x + z * ref_stride)],
> > ref_stride,
> >> -                                &sum0[x]);
> >> +            ssim_4x4xn(&main[4 * z * main_stride], main_stride,
> >> +                       &ref[4 * z * ref_stride], ref_stride,
> >> +                       sum0, width);
> >>          }
> >>
> >>          ssim += ssim_endn(sum0, sum1, width - 1);
> >> --
> >> 2.1.2
> >>
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel at ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > Ok if results are same and pure C speed is not slower.
> >
> 
> lgtm

applied

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150713/503dc2de/attachment.sig>


More information about the ffmpeg-devel mailing list