[FFmpeg-cvslog] avcodec/rdft: reorder calculation

Muhammad Faiz git at videolan.org
Wed Jul 26 02:18:00 EEST 2017


ffmpeg | branch: master | Muhammad Faiz <mfcc64 at gmail.com> | Sat Jul 22 06:52:45 2017 +0700| [c8305079dae1044d7e6d978ec3251176464fb5f6] | committer: Muhammad Faiz

avcodec/rdft: reorder calculation

old:
 165188 decicycles in  rdft,   65536 runs,      0 skips
 165865 decicycles in irdft,   65536 runs,      0 skips
new:
 142487 decicycles in  rdft,   65536 runs,      0 skips
 141498 decicycles in irdft,   65536 runs,      0 skips

Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>

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

 libavcodec/rdft.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/rdft.c b/libavcodec/rdft.c
index 194e0bc4ee..6ba7484238 100644
--- a/libavcodec/rdft.c
+++ b/libavcodec/rdft.c
@@ -35,7 +35,7 @@
 static void rdft_calc_c(RDFTContext *s, FFTSample *data)
 {
     int i, i1, i2;
-    FFTComplex ev, od;
+    FFTComplex ev, od, odsum;
     const int n = 1 << s->nbits;
     const float k1 = 0.5;
     const float k2 = 0.5 - s->inverse;
@@ -58,14 +58,16 @@ static void rdft_calc_c(RDFTContext *s, FFTSample *data)
         i2 = n-i1;                                                          \
         /* Separate even and odd FFTs */                                    \
         ev.re =  k1*(data[i1  ]+data[i2  ]);                                \
-        od.im = -k2*(data[i1  ]-data[i2  ]);                                \
+        od.im =  k2*(data[i2  ]-data[i1  ]);                                \
         ev.im =  k1*(data[i1+1]-data[i2+1]);                                \
         od.re =  k2*(data[i1+1]+data[i2+1]);                                \
         /* Apply twiddle factors to the odd FFT and add to the even FFT */  \
-        data[i1  ] =  ev.re + od.re*tcos[i] sign0 od.im*tsin[i];            \
-        data[i1+1] =  ev.im + od.im*tcos[i] sign1 od.re*tsin[i];            \
-        data[i2  ] =  ev.re - od.re*tcos[i] sign1 od.im*tsin[i];            \
-        data[i2+1] = -ev.im + od.im*tcos[i] sign1 od.re*tsin[i];            \
+        odsum.re = od.re*tcos[i] sign0 od.im*tsin[i];                       \
+        odsum.im = od.im*tcos[i] sign1 od.re*tsin[i];                       \
+        data[i1  ] =  ev.re + odsum.re;                                     \
+        data[i1+1] =  ev.im + odsum.im;                                     \
+        data[i2  ] =  ev.re - odsum.re;                                     \
+        data[i2+1] =  odsum.im - ev.im;                                     \
     }
 
     if (s->negative_sin) {



More information about the ffmpeg-cvslog mailing list