[tremor] [patch] constify a few things

Aaron Lehmann aaronl at vitelus.com
Mon Sep 23 02:45:27 PDT 2002


On Mon, Sep 23, 2002 at 02:44:45AM -0700, Aaron Lehmann wrote:
> I developed a patch similar to this but quite a bit more exhaustive.
> It covers the tables in bitwise.c, floor0.c, floor1.c, framing.c,
> lsp_lookup.h, mdct.c, mdct_lookup.h, and window.c

now i'll actually attach it

-------------- next part --------------
Index: bitwise.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/bitwise.c,v
retrieving revision 1.2
diff -u -r1.2 bitwise.c
--- bitwise.c	3 Sep 2002 03:15:19 -0000	1.2
+++ bitwise.c	23 Sep 2002 09:34:44 -0000
@@ -24,7 +24,7 @@
 
 #define BUFFER_INCREMENT 256
 
-static unsigned long mask[]=
+static const unsigned long mask[]=
 {0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
  0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
  0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
Index: codec_internal.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codec_internal.h,v
retrieving revision 1.2
diff -u -r1.2 codec_internal.h
--- codec_internal.h	3 Sep 2002 03:15:19 -0000	1.2
+++ codec_internal.h	23 Sep 2002 09:34:44 -0000
@@ -39,7 +39,7 @@
 
 typedef struct backend_lookup_state {
   /* local lookup storage */
-  ogg_int32_t               *window[2];
+  const ogg_int32_t               *window[2];
 
   /* backend lookups are tied to the mode, not the backend or naked mapping */
   int                     modebits;
Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor0.c,v
retrieving revision 1.2
diff -u -r1.2 floor0.c
--- floor0.c	3 Sep 2002 03:15:19 -0000	1.2
+++ floor0.c	23 Sep 2002 09:34:44 -0000
@@ -94,7 +94,7 @@
   return(a);
 }
 
-static int barklook[28]={
+static const int barklook[28]={
   0,100,200,301,          405,516,635,766,
   912,1077,1263,1476,     1720,2003,2333,2721,
   3184,3742,4428,5285,    6376,7791,9662,12181,
@@ -117,21 +117,21 @@
   }
 }
 
-static int MLOOP_1[64]={
+static const int MLOOP_1[64]={
    0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
   14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
   15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
   15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
 };
 
-static int MLOOP_2[64]={
+static const int MLOOP_2[64]={
   0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
   8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
   9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
   9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
 };
 
-static int MLOOP_3[8]={0,1,2,2,3,3,3,3};
+static const int MLOOP_3[8]={0,1,2,2,3,3,3,3};
 
 void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
 			 ogg_int32_t *lsp,int m,
Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor1.c,v
retrieving revision 1.2
diff -u -r1.2 floor1.c
--- floor1.c	3 Sep 2002 03:15:19 -0000	1.2
+++ floor1.c	23 Sep 2002 09:34:44 -0000
@@ -216,7 +216,7 @@
   }
 }
 
-static ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
+static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
   0x000000e5, 0x000000f4, 0x00000103, 0x00000114,
   0x00000126, 0x00000139, 0x0000014e, 0x00000163,
   0x0000017a, 0x00000193, 0x000001ad, 0x000001c9,
Index: framing.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/framing.c,v
retrieving revision 1.2
diff -u -r1.2 framing.c
--- framing.c	3 Sep 2002 03:15:19 -0000	1.2
+++ framing.c	23 Sep 2002 09:34:45 -0000
@@ -95,7 +95,7 @@
   return(count);
 }
 
-static ogg_uint32_t crc_lookup[256]={
+static const ogg_uint32_t crc_lookup[256]={
   0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
   0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
   0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
Index: lsp_lookup.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/lsp_lookup.h,v
retrieving revision 1.2
diff -u -r1.2 lsp_lookup.h
--- lsp_lookup.h	3 Sep 2002 03:15:19 -0000	1.2
+++ lsp_lookup.h	23 Sep 2002 09:34:45 -0000
@@ -26,7 +26,7 @@
 #define FROMdB2_SHIFT 3
 #define FROMdB2_MASK 31
 
-static ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
+static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
   0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a,
   0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42,
   0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760,
@@ -37,7 +37,7 @@
   0x0000000b, 0x00000007, 0x00000004, 0x00000003,
   0x00000002, 0x00000001, 0x00000001};
 
-static ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
+static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
   0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7,
   0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc,
   0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2,
@@ -50,7 +50,7 @@
 
 #define INVSQ_LOOKUP_I_SHIFT 10
 #define INVSQ_LOOKUP_I_MASK 1023
-static long INVSQ_LOOKUP_I[64+1]={
+static const long INVSQ_LOOKUP_I[64+1]={
 	   92682,   91966,   91267,   90583,
 	   89915,   89261,   88621,   87995,
 	   87381,   86781,   86192,   85616,
@@ -70,7 +70,7 @@
 	   65536,
 };
 
-static long INVSQ_LOOKUP_IDel[64]={
+static const long INVSQ_LOOKUP_IDel[64]={
              716,     699,     684,     668,
              654,     640,     626,     614,
              600,     589,     576,     565,
@@ -92,7 +92,7 @@
 #define COS_LOOKUP_I_SHIFT 9
 #define COS_LOOKUP_I_MASK 511
 #define COS_LOOKUP_I_SZ 128
-static ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
+static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
 	   16384,   16379,   16364,   16340,
 	   16305,   16261,   16207,   16143,
 	   16069,   15986,   15893,   15791,
Index: mdct.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/mdct.c,v
retrieving revision 1.5
diff -u -r1.5 mdct.c
--- mdct.c	20 Sep 2002 00:10:31 -0000	1.5
+++ mdct.c	23 Sep 2002 09:34:45 -0000
@@ -151,7 +151,7 @@
 /* N/stage point generic N stage butterfly (in place, 2 register) */
 STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
 
-  DATA_TYPE *T         = sincos_lookup0;
+  const DATA_TYPE *T         = sincos_lookup0;
   DATA_TYPE *x1        = x + points      - 8;
   DATA_TYPE *x2        = x + (points>>1) - 8;
   REG_TYPE   r0;
@@ -250,7 +250,7 @@
 
 }
 
-static unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
+static const unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
 
 STIN int bitrev12(int x){
   return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
@@ -261,8 +261,8 @@
   int          bit   = 0;
   DATA_TYPE   *w0    = x;
   DATA_TYPE   *w1    = x = w0+(n>>1);
-  DATA_TYPE   *T     = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
-  DATA_TYPE   *Ttop  = T+1024;
+  const DATA_TYPE   *T     = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
+  const DATA_TYPE   *Ttop  = T+1024;
   DATA_TYPE    r2;
 
   do{
@@ -346,8 +346,8 @@
   int n4=n>>2;
   DATA_TYPE *iX;
   DATA_TYPE *oX;
-  DATA_TYPE *T;
-  DATA_TYPE *V;
+  const DATA_TYPE *T;
+  const DATA_TYPE *V;
   int shift;
   int step;
 
Index: mdct_lookup.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/mdct_lookup.h,v
retrieving revision 1.5
diff -u -r1.5 mdct_lookup.h
--- mdct_lookup.h	20 Sep 2002 00:10:31 -0000	1.5
+++ mdct_lookup.h	23 Sep 2002 09:34:46 -0000
@@ -17,7 +17,7 @@
 
 
 /* {sin(2*i*PI/4096), cos(2*i*PI/4096)}, with i = 0 to 512 */
-static ogg_int32_t sincos_lookup0[1026] = {
+static const ogg_int32_t sincos_lookup0[1026] = {
   0x00000000, 0x7fffffff, 0x003243f5, 0x7ffff621, 0x006487e3, 0x7fffd886,
   0x0096cbc1, 0x7fffa72c, 0x00c90f88, 0x7fff6216, 0x00fb5330, 0x7fff0943,
   0x012d96b1, 0x7ffe9cb2, 0x015fda03, 0x7ffe1c65, 0x01921d20, 0x7ffd885a,
@@ -192,7 +192,7 @@
 };
 
 /* {sin((2*i+1)*PI/4096), cos((2*i+1)*PI/4096)}, with i = 0 to 511 */
-static ogg_int32_t sincos_lookup1[1024] = {
+static const ogg_int32_t sincos_lookup1[1024] = {
   0x001921fb, 0x7ffffd88, 0x004b65ee, 0x7fffe9cb, 0x007da9d4, 0x7fffc251,
   0x00afeda8, 0x7fff8719, 0x00e23160, 0x7fff3824, 0x011474f6, 0x7ffed572,
   0x0146b860, 0x7ffe5f03, 0x0178fb99, 0x7ffdd4d7, 0x01ab3e97, 0x7ffd36ee,
Index: window.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/window.c,v
retrieving revision 1.2
diff -u -r1.2 window.c
--- window.c	3 Sep 2002 03:15:19 -0000	1.2
+++ window.c	23 Sep 2002 09:34:50 -0000
@@ -20,7 +20,7 @@
 #include "os.h"
 #include "misc.h"
 
-static ogg_int32_t vwin64[32]={
+static const ogg_int32_t vwin64[32]={
   0x001f0003, 0x01168c98, 0x030333c8, 0x05dfe3a4, 
   0x09a49562, 0x0e45df18, 0x13b47ef2, 0x19dcf676, 
   0x20a74d83, 0x27f7137c, 0x2fabb05a, 0x37a11059, 
@@ -31,7 +31,7 @@
   0x7fdd78a4, 0x7ff6ec6c, 0x7ffed0e8, 0x7ffffc3e, 
 };
 
-static ogg_int32_t vwin128[64]={
+static const ogg_int32_t vwin128[64]={
   0x0007c04d, 0x0045bb89, 0x00c18b87, 0x017ae294, 
   0x02714a4e, 0x03a4217a, 0x05129952, 0x06bbb24f, 
   0x089e38a1, 0x0ab8c073, 0x0d09a228, 0x0f8ef6bd, 
@@ -50,7 +50,7 @@
   0x7ffdcf38, 0x7fff6dab, 0x7fffed00, 0x7fffffc3, 
 };
 
-static ogg_int32_t vwin256[128]={
+static const ogg_int32_t vwin256[128]={
   0x0001f018, 0x00117066, 0x00306e9e, 0x005ee5f1, 
   0x009ccf26, 0x00ea208b, 0x0146cdea, 0x01b2c87f, 
   0x022dfedf, 0x02b85ced, 0x0351cbbd, 0x03fa317f, 
@@ -85,7 +85,7 @@
   0x7fffdcd1, 0x7ffff6d5, 0x7ffffecf, 0x7ffffffb, 
 };
 
-static ogg_int32_t vwin512[256]={
+static const ogg_int32_t vwin512[256]={
   0x00007c06, 0x00045c32, 0x000c1c62, 0x0017bc4c, 
   0x00273b7a, 0x003a9955, 0x0051d51c, 0x006cede7, 
   0x008be2a9, 0x00aeb22a, 0x00d55b0d, 0x00ffdbcc, 
@@ -152,7 +152,7 @@
   0x7ffffdcc, 0x7fffff6c, 0x7fffffec, 0x7fffffff, 
   };
 
-static ogg_int32_t vwin1024[512]={
+static const ogg_int32_t vwin1024[512]={
   0x00001f02, 0x0001170e, 0x00030724, 0x0005ef40, 
   0x0009cf59, 0x000ea767, 0x0014775e, 0x001b3f2e, 
   0x0022fec8, 0x002bb618, 0x00356508, 0x00400b81, 
@@ -283,7 +283,7 @@
   0x7fffffdc, 0x7ffffff6, 0x7ffffffe, 0x7fffffff, 
 };
 
-static ogg_int32_t vwin2048[1024]={
+static const ogg_int32_t vwin2048[1024]={
   0x000007c0, 0x000045c4, 0x0000c1ca, 0x00017bd3, 
   0x000273de, 0x0003a9eb, 0x00051df9, 0x0006d007, 
   0x0008c014, 0x000aee1e, 0x000d5a25, 0x00100428, 
@@ -542,7 +542,7 @@
   0x7ffffffd, 0x7ffffffe, 0x7fffffff, 0x7fffffff, 
 };
 
-static ogg_int32_t vwin4096[2048]={
+static const ogg_int32_t vwin4096[2048]={
   0x000001f0, 0x00001171, 0x00003072, 0x00005ef5, 
   0x00009cf8, 0x0000ea7c, 0x00014780, 0x0001b405, 
   0x0002300b, 0x0002bb91, 0x00035698, 0x0004011e, 
@@ -1057,7 +1057,7 @@
   0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 
 };
 
-static ogg_int32_t vwin8192[4096]={
+static const ogg_int32_t vwin8192[4096]={
   0x0000007c, 0x0000045c, 0x00000c1d, 0x000017bd, 
   0x0000273e, 0x00003a9f, 0x000051e0, 0x00006d02, 
   0x00008c03, 0x0000aee5, 0x0000d5a7, 0x00010049, 
@@ -2084,7 +2084,7 @@
   0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 
 };
 
-ogg_int32_t *_vorbis_window(int type, int left){
+const ogg_int32_t *_vorbis_window(int type, int left){
 
   switch(type){
   case 0:
@@ -2115,7 +2115,7 @@
   }
 }
 
-void _vorbis_apply_window(ogg_int32_t *d,ogg_int32_t *window[2],long *blocksizes,
+void _vorbis_apply_window(ogg_int32_t *d,const ogg_int32_t *window[2],long *blocksizes,
 			  int lW,int W,int nW){
 
   long n=blocksizes[W];
Index: window.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/window.h,v
retrieving revision 1.2
diff -u -r1.2 window.h
--- window.h	3 Sep 2002 03:15:19 -0000	1.2
+++ window.h	23 Sep 2002 09:34:50 -0000
@@ -18,8 +18,8 @@
 #ifndef _V_WINDOW_
 #define _V_WINDOW_
 
-extern ogg_int32_t *_vorbis_window(int type,int left);
-extern void _vorbis_apply_window(ogg_int32_t *d,ogg_int32_t *window[2],
+extern const ogg_int32_t *_vorbis_window(int type,int left);
+extern void _vorbis_apply_window(ogg_int32_t *d,const ogg_int32_t *window[2],
 				 long *blocksizes,
 				 int lW,int W,int nW);
 



More information about the Tremor mailing list