[FFmpeg-cvslog] avcodec/jpeg2000dwt: Replace /2 by >>1

Michael Niedermayer git at videolan.org
Tue Jun 23 19:24:28 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Jun 23 18:47:18 2015 +0200| [0416b5e0330c5eb226f92cf6c150eb6b7daa8b92] | committer: Michael Niedermayer

avcodec/jpeg2000dwt: Replace /2 by >>1

Divisions can be slow if the compiler fails to replace them by shifts

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/jpeg2000dwt.c |   40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index e090eba..28ac6c4 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -88,9 +88,9 @@ static void sd_1d53(int *p, int i0, int i1)
 
     extend53(p, i0, i1);
 
-    for (i = (i0+1)/2 - 1; i < (i1+1)/2; i++)
+    for (i = ((i0+1)>>1) - 1; i < (i1+1)>>1; i++)
         p[2*i+1] -= (p[2*i] + p[2*i+2]) >> 1;
-    for (i = (i0+1)/2; i < (i1+1)/2; i++)
+    for (i = ((i0+1)>>1); i < (i1+1)>>1; i++)
         p[2*i] += (p[2*i-1] + p[2*i+1] + 2) >> 2;
 }
 
@@ -159,13 +159,13 @@ static void sd_1d97_float(float *p, int i0, int i1)
     extend97_float(p, i0, i1);
     i0++; i1++;
 
-    for (i = i0/2 - 2; i < i1/2 + 1; i++)
+    for (i = (i0>>1) - 2; i < (i1>>1) + 1; i++)
         p[2*i+1] -= 1.586134 * (p[2*i] + p[2*i+2]);
-    for (i = i0/2 - 1; i < i1/2 + 1; i++)
+    for (i = (i0>>1) - 1; i < (i1>>1) + 1; i++)
         p[2*i] -= 0.052980 * (p[2*i-1] + p[2*i+1]);
-    for (i = i0/2 - 1; i < i1/2; i++)
+    for (i = (i0>>1) - 1; i < (i1>>1); i++)
         p[2*i+1] += 0.882911 * (p[2*i] + p[2*i+2]);
-    for (i = i0/2; i < i1/2; i++)
+    for (i = (i0>>1); i < (i1>>1); i++)
         p[2*i] += 0.443506 * (p[2*i-1] + p[2*i+1]);
 }
 
@@ -235,13 +235,13 @@ static void sd_1d97_int(int *p, int i0, int i1)
     extend97_int(p, i0, i1);
     i0++; i1++;
 
-    for (i = i0/2 - 2; i < i1/2 + 1; i++)
+    for (i = (i0>>1) - 2; i < (i1>>1) + 1; i++)
         p[2 * i + 1] -= (I_LFTG_ALPHA * (p[2 * i]     + p[2 * i + 2]) + (1 << 15)) >> 16;
-    for (i = i0/2 - 1; i < i1/2 + 1; i++)
+    for (i = (i0>>1) - 1; i < (i1>>1) + 1; i++)
         p[2 * i]     -= (I_LFTG_BETA  * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
-    for (i = i0/2 - 1; i < i1/2; i++)
+    for (i = (i0>>1) - 1; i < (i1>>1); i++)
         p[2 * i + 1] += (I_LFTG_GAMMA * (p[2 * i]     + p[2 * i + 2]) + (1 << 15)) >> 16;
-    for (i = i0/2; i < i1/2; i++)
+    for (i = (i0>>1); i < (i1>>1); i++)
         p[2 * i]     += (I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
 }
 
@@ -317,9 +317,9 @@ static void sr_1d53(int *p, int i0, int i1)
 
     extend53(p, i0, i1);
 
-    for (i = i0 / 2; i < i1 / 2 + 1; i++)
+    for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++)
         p[2 * i] -= (p[2 * i - 1] + p[2 * i + 1] + 2) >> 2;
-    for (i = i0 / 2; i < i1 / 2; i++)
+    for (i = (i0 >> 1); i < (i1 >> 1); i++)
         p[2 * i + 1] += (p[2 * i] + p[2 * i + 2]) >> 1;
 }
 
@@ -386,16 +386,16 @@ static void sr_1d97_float(float *p, int i0, int i1)
 
     extend97_float(p, i0, i1);
 
-    for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
+    for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 2; i++)
         p[2 * i]     -= F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]);
     /* step 4 */
-    for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
+    for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 1; i++)
         p[2 * i + 1] -= F_LFTG_GAMMA * (p[2 * i]     + p[2 * i + 2]);
     /*step 5*/
-    for (i = i0 / 2; i < i1 / 2 + 1; i++)
+    for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++)
         p[2 * i]     += F_LFTG_BETA  * (p[2 * i - 1] + p[2 * i + 1]);
     /* step 6 */
-    for (i = i0 / 2; i < i1 / 2; i++)
+    for (i = (i0 >> 1); i < (i1 >> 1); i++)
         p[2 * i + 1] += F_LFTG_ALPHA * (p[2 * i]     + p[2 * i + 2]);
 }
 
@@ -463,16 +463,16 @@ static void sr_1d97_int(int32_t *p, int i0, int i1)
 
     extend97_int(p, i0, i1);
 
-    for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
+    for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 2; i++)
         p[2 * i]     -= (I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
     /* step 4 */
-    for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
+    for (i = (i0 >> 1) - 1; i < (i1 >> 1) + 1; i++)
         p[2 * i + 1] -= (I_LFTG_GAMMA * (p[2 * i]     + p[2 * i + 2]) + (1 << 15)) >> 16;
     /*step 5*/
-    for (i = i0 / 2; i < i1 / 2 + 1; i++)
+    for (i = (i0 >> 1); i < (i1 >> 1) + 1; i++)
         p[2 * i]     += (I_LFTG_BETA  * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
     /* step 6 */
-    for (i = i0 / 2; i < i1 / 2; i++)
+    for (i = (i0 >> 1); i < (i1 >> 1); i++)
         p[2 * i + 1] += (I_LFTG_ALPHA * (p[2 * i]     + p[2 * i + 2]) + (1 << 15)) >> 16;
 }
 



More information about the ffmpeg-cvslog mailing list