]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add shift argument to MULL() macro
authormru <mru@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 24 Nov 2008 09:28:55 +0000 (09:28 +0000)
committermru <mru@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 24 Nov 2008 09:28:55 +0000 (09:28 +0000)
This replaces use of FRAC_BITS in the MULL() definition with a third
argument specifying the shift amount.  All uses of this macro are
updated to pass FRAC_BITS as third argument.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@15921 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/armv4l/mathops.h
libavcodec/i386/mathops.h
libavcodec/lsp.c
libavcodec/mathops.h
libavcodec/mpegaudiodec.c

index 37a0d3fcace25892af9ec68b0cb6af004a20193b..f8a3d6db402266192ff232017b588d80068abe11 100644 (file)
 #include <stdint.h>
 #include "libavutil/common.h"
 
-#ifdef FRAC_BITS
 #   define MULL MULL
-static inline av_const int MULL(int a, int b)
+static inline av_const int MULL(int a, int b, unsigned shift)
 {
     int lo, hi;
     __asm__("smull %0, %1, %2, %3     \n\t"
             "mov   %0, %0,     lsr %4 \n\t"
             "add   %1, %0, %1, lsl %5 \n\t"
             : "=&r"(lo), "=&r"(hi)
-            : "r"(b), "r"(a), "i"(FRAC_BITS), "i"(32-FRAC_BITS));
+            : "r"(b), "r"(a), "i"(shift), "i"(32-shift));
     return hi;
 }
-#endif
 
 #define MULH MULH
 #ifdef HAVE_ARMV6
index 2ae24fcaaca52649391961d6140f1981322ab065..77c72d85eae63b7b6c5d15a8ffc21d90fb85e87a 100644 (file)
 #ifndef AVCODEC_I386_MATHOPS_H
 #define AVCODEC_I386_MATHOPS_H
 
-#ifdef FRAC_BITS
-#   define MULL(ra, rb) \
+#define MULL(ra, rb, shift) \
         ({ int rt, dummy; __asm__ (\
             "imull %3               \n\t"\
             "shrdl %4, %%edx, %%eax \n\t"\
             : "=a"(rt), "=d"(dummy)\
-            : "a" ((int)ra), "rm" ((int)rb), "i"(FRAC_BITS));\
+            : "a" ((int)ra), "rm" ((int)rb), "i"(shift));\
          rt; })
-#endif
 
 #define MULH(ra, rb) \
     ({ int rt, dummy;\
index d2785f7183809ad2b0ed20095fff2471a998a389..f57f62135009e4715036d12ccb4794da1a04138b 100644 (file)
@@ -72,7 +72,7 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
     {
         f[i] = f[i-2];
         for(j=i; j>1; j--)
-            f[j] -= MULL(f[j-1], lsp[2*i-2]) - f[j-2];
+            f[j] -= MULL(f[j-1], lsp[2*i-2], FRAC_BITS) - f[j-2];
 
         f[1] -= lsp[2*i-2] << 8;
     }
index 123fcb76c76030648096d934ed5e46e5bc17e508..817e4525c7f8bba881dc6291d028191ee1ccee80 100644 (file)
@@ -45,7 +45,7 @@
 /* generic implementation */
 
 #ifndef MULL
-#   define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
+#   define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s))
 #endif
 
 #ifndef MULH
index a2774927272128d4fbfbb670d8442ec83b569bcd..a853562a3f9baa4b18de4fca768c83521d0d226d 100644 (file)
@@ -351,9 +351,9 @@ static int decode_init(AVCodecContext * avctx)
             int n, norm;
             n = i + 2;
             norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
-            scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm);
-            scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm);
-            scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm);
+            scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm, FRAC_BITS);
+            scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm, FRAC_BITS);
+            scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm, FRAC_BITS);
             dprintf(avctx, "%d: norm=%x s=%x %x %x\n",
                     i, norm,
                     scale_factor_mult[i][0],
@@ -1097,7 +1097,7 @@ static void imdct36(int *out, int *buf, int *in, int *win)
         t2 = tmp[i + 1];
         t3 = tmp[i + 3];
         s1 = MULH(2*(t3 + t2), icos36h[j]);
-        s3 = MULL(t3 - t2, icos36[8 - j]);
+        s3 = MULL(t3 - t2, icos36[8 - j], FRAC_BITS);
 
         t0 = s0 + s1;
         t1 = s0 - s1;
@@ -1705,8 +1705,8 @@ static void compute_stereo(MPADecodeContext *s,
                     v2 = is_tab[1][sf];
                     for(j=0;j<len;j++) {
                         tmp0 = tab0[j];
-                        tab0[j] = MULL(tmp0, v1);
-                        tab1[j] = MULL(tmp0, v2);
+                        tab0[j] = MULL(tmp0, v1, FRAC_BITS);
+                        tab1[j] = MULL(tmp0, v2, FRAC_BITS);
                     }
                 } else {
                 found1:
@@ -1716,8 +1716,8 @@ static void compute_stereo(MPADecodeContext *s,
                         for(j=0;j<len;j++) {
                             tmp0 = tab0[j];
                             tmp1 = tab1[j];
-                            tab0[j] = MULL(tmp0 + tmp1, ISQRT2);
-                            tab1[j] = MULL(tmp0 - tmp1, ISQRT2);
+                            tab0[j] = MULL(tmp0 + tmp1, ISQRT2, FRAC_BITS);
+                            tab1[j] = MULL(tmp0 - tmp1, ISQRT2, FRAC_BITS);
                         }
                     }
                 }
@@ -1749,8 +1749,8 @@ static void compute_stereo(MPADecodeContext *s,
                 v2 = is_tab[1][sf];
                 for(j=0;j<len;j++) {
                     tmp0 = tab0[j];
-                    tab0[j] = MULL(tmp0, v1);
-                    tab1[j] = MULL(tmp0, v2);
+                    tab0[j] = MULL(tmp0, v1, FRAC_BITS);
+                    tab1[j] = MULL(tmp0, v2, FRAC_BITS);
                 }
             } else {
             found2:
@@ -1760,8 +1760,8 @@ static void compute_stereo(MPADecodeContext *s,
                     for(j=0;j<len;j++) {
                         tmp0 = tab0[j];
                         tmp1 = tab1[j];
-                        tab0[j] = MULL(tmp0 + tmp1, ISQRT2);
-                        tab1[j] = MULL(tmp0 - tmp1, ISQRT2);
+                        tab0[j] = MULL(tmp0 + tmp1, ISQRT2, FRAC_BITS);
+                        tab1[j] = MULL(tmp0 - tmp1, ISQRT2, FRAC_BITS);
                     }
                 }
             }