Re: Verificattion for reducing the size of rq_table.dat

Rob Leslie <[email protected]> Mon, 29 Aug 2005 16:23:57 -0700
Newsgroups gmane.comp.audio.mad.devel
Message-ID <[email protected]>
On Aug 28, 2005, at 10:20 PM, Swapnil Wagle wrote:
> For reducing the size of rq_tbale.dat as suggested by you people I  
> have done following changes within the libray.Can you please verify  
> whether this is correct or not.
> The changed 'III_requantize' is as follows
>
>   static
> mad_fixed_t III_requantize(unsigned int value, signed int exp)
> {
>   mad_fixed_t requantized;
>   signed int frac;
>   struct fixedfloat const *power;
>
>   frac = exp % 4;  /* assumes sign(frac) == sign(exp) */
>   exp /= 4;
>
>   value = value / 8;  // Dividing the input value by 8
>
>   power = &rq_table[value];
>
>   power = power * 16; // Multiplying the result after finding the  
> array index by 16

Pointer multiplication will not get you far...

The following patch should accomplish the result I intended to convey.


As this is currently experimental, you will need to define OPT_SPACE  
when building, e.g.:

   ./configure CFLAGS="-DOPT_SPACE"

A quick check reveals that this optimization reduces the decoder's  
computational ISO/IEC 11172-4 compliance to "limited accuracy."

-- 
Rob Leslie
[email protected]
opt-space.patch (application/octet-stream, 1.8 KB)
diff -u -w -r1.44 layer3.c
--- layer3.c	29 Oct 2004 23:38:16 -0000	1.44
+++ layer3.c	29 Aug 2005 23:04:42 -0000
@@ -318,6 +318,12 @@
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0
 };
 
+# if defined(OPT_SPACE)
+#  define RQ_TABLE_SZ  1024
+# else
+#  define RQ_TABLE_SZ  8207
+# endif
+
 /*
  * table for requantization
  *
@@ -327,7 +333,7 @@
 struct fixedfloat {
   unsigned long mantissa  : 27;
   unsigned short exponent :  5;
-} const rq_table[8207] = {
+} const rq_table[RQ_TABLE_SZ] = {
 # include "rq_table.dat"
 };
 
@@ -883,6 +889,16 @@
   frac = exp % 4;  /* assumes sign(frac) == sign(exp) */
   exp /= 4;
 
+# if defined(OPT_SPACE)
+  if (value >= 8192)
+    value = 8192 - 1;
+
+  if (value >= 1024) {
+    value /= 8;
+    exp += 4;
+  }
+# endif
+
   power = &rq_table[value];
   exp += power->exponent;
   requantized = power->mantissa;
diff -u -w -r1.7 rq_table.dat
--- rq_table.dat	23 Jan 2004 09:41:32 -0000	1.7
+++ rq_table.dat	29 Aug 2005 23:04:42 -0000
@@ -1114,6 +1114,7 @@
   /* 1022 */  { MAD_F(0x0506cceb) /* 0.314160269 */, 15 },
   /* 1023 */  { MAD_F(0x05087ac2) /* 0.314570199 */, 15 },
 
+# if !defined(OPT_SPACE)
   /* 1024 */  { MAD_F(0x050a28be) /* 0.314980262 */, 15 },
   /* 1025 */  { MAD_F(0x050bd6de) /* 0.315390460 */, 15 },
   /* 1026 */  { MAD_F(0x050d8521) /* 0.315800790 */, 15 },
@@ -8745,3 +8746,4 @@
   /* 8204 */  { MAD_F(0x050cadfb) /* 0.315595608 */, 19 },
   /* 8205 */  { MAD_F(0x050ce3c4) /* 0.315646901 */, 19 },
   /* 8206 */  { MAD_F(0x050d198d) /* 0.315698195 */, 19 }
+# endif
diff -u -w -r1.15 version.c
--- version.c	23 Jan 2004 09:41:33 -0000	1.15
+++ version.c	29 Aug 2005 23:04:42 -0000
@@ -77,6 +77,10 @@
   "OPT_ACCURACY "
 # endif
 
+# if defined(OPT_SPACE)
+  "OPT_SPACE "
+# endif
+
 # if defined(OPT_SSO)
   "OPT_SSO "
 # endif