[Tremor] Patches for Embedded Devices, Addendum

Colin Ward colin.a.ward at csiro.au
Wed Dec 8 20:18:30 PST 2004


   Of course, I forgot to attach the patches.  ;-)

--
Colin Ward
Senior Sofware Engineer, Symbian OS
CSIRO, Australia

-------------- next part --------------
Index: floor0.c
===================================================================
--- floor0.c	(revision 8355)
+++ floor0.c	(working copy)
@@ -25,6 +25,7 @@
 #include "codebook.h"
 #include "misc.h"
 #include "os.h"
+#include "block.h"
 
 #define LSP_FRACBITS 14
 
@@ -47,7 +48,7 @@
    16.16 format 
    returns in m.8 format */
 
-static long ADJUST_SQRT2[2]={8192,5792};
+static const long ADJUST_SQRT2[2]={8192,5792};
 static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){
   long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); 
   long d=a&INVSQ_LOOKUP_I_MASK;                              /*  0.10 */
@@ -293,7 +294,7 @@
   }
 }
 
-static void floor0_free_look(vorbis_look_floor *i){
+static void floor0_free_look(const vorbis_look_floor *i){
   vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
   if(look){
 
@@ -377,7 +378,7 @@
   return look;
 }
 
-static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
+static void *floor0_inverse1(vorbis_block *vb,const vorbis_look_floor *i){
   vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
   vorbis_info_floor0 *info=look->vi;
   int j,k;
@@ -409,7 +410,7 @@
   return(NULL);
 }
 
-static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
+static int floor0_inverse2(vorbis_block *vb,const vorbis_look_floor *i,
 			   void *memo,ogg_int32_t *out){
   vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
   vorbis_info_floor0 *info=look->vi;
@@ -428,7 +429,7 @@
 }
 
 /* export hooks */
-vorbis_func_floor floor0_exportbundle={
+const vorbis_func_floor floor0_exportbundle={
   &floor0_unpack,&floor0_look,&floor0_free_info,
   &floor0_free_look,&floor0_inverse1,&floor0_inverse2
 };
Index: floor1.c
===================================================================
--- floor1.c	(revision 8355)
+++ floor1.c	(working copy)
@@ -24,6 +24,7 @@
 #include "registry.h"
 #include "codebook.h"
 #include "misc.h"
+#include "block.h"
 
 #define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
 
@@ -50,7 +51,7 @@
   }
 }
 
-static void floor1_free_look(vorbis_look_floor *i){
+static void floor1_free_look(const vorbis_look_floor *i){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
   if(look){
     memset(look,0,sizeof(*look));
@@ -307,7 +308,7 @@
   }
 }
 
-static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
+static void *floor1_inverse1(vorbis_block *vb,const vorbis_look_floor *in){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
   vorbis_info_floor1 *info=look->vi;
   codec_setup_info   *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
@@ -394,7 +395,7 @@
   return(NULL);
 }
 
-static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
+static int floor1_inverse2(vorbis_block *vb,const vorbis_look_floor *in,void *memo,
 			  ogg_int32_t *out){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
   vorbis_info_floor1 *info=look->vi;
@@ -431,7 +432,7 @@
 }
 
 /* export hooks */
-vorbis_func_floor floor1_exportbundle={
+const vorbis_func_floor floor1_exportbundle={
   &floor1_unpack,&floor1_look,&floor1_free_info,
   &floor1_free_look,&floor1_inverse1,&floor1_inverse2
 };
Index: registry.c
===================================================================
--- registry.c	(revision 8355)
+++ registry.c	(working copy)
@@ -31,18 +31,18 @@
 extern vorbis_func_residue   residue2_exportbundle;
 extern vorbis_func_mapping   mapping0_exportbundle;
 
-vorbis_func_floor     *_floor_P[]={
+const vorbis_func_floor     * const _floor_P[]={
   &floor0_exportbundle,
   &floor1_exportbundle,
 };
 
-vorbis_func_residue   *_residue_P[]={
+const vorbis_func_residue   * const _residue_P[]={
   &residue0_exportbundle,
   &residue1_exportbundle,
   &residue2_exportbundle,
 };
 
-vorbis_func_mapping   *_mapping_P[]={
+const vorbis_func_mapping   * const _mapping_P[]={
   &mapping0_exportbundle,
 };
 
Index: os_types.h
===================================================================
--- os_types.h	(revision 8355)
+++ os_types.h	(working copy)
@@ -32,7 +32,7 @@
 #define _ogg_realloc realloc
 #define _ogg_free    free
 
-#ifdef _WIN32 
+#ifdef _WIN32
 
 #  ifndef __GNUC__
    /* MSVC/Borland */
@@ -40,6 +40,7 @@
    typedef __int32 ogg_int32_t;
    typedef unsigned __int32 ogg_uint32_t;
    typedef __int16 ogg_int16_t;
+#  define inline __inline
 #  else
    /* Cygwin */
    #include <_G_config.h>
Index: mapping0.c
===================================================================
--- mapping0.c	(revision 8355)
+++ mapping0.c	(working copy)
@@ -27,6 +27,7 @@
 #include "window.h"
 #include "registry.h"
 #include "misc.h"
+#include "os.h"
 
 /* simplistic, wasteful way of doing this (unique lookup for each
    mode/submapping); there should be a central repository for
@@ -41,12 +42,12 @@
   vorbis_info_mode *mode;
   vorbis_info_mapping0 *map;
 
-  vorbis_look_floor **floor_look;
+  const vorbis_look_floor **floor_look;
 
   vorbis_look_residue **residue_look;
 
-  vorbis_func_floor **floor_func;
-  vorbis_func_residue **residue_func;
+  const vorbis_func_floor **floor_func;
+  const vorbis_func_residue **residue_func;
 
   int ch;
   long lastframe; /* if a different mode is called, we need to 
@@ -93,8 +94,8 @@
 
   look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look));
 
-  look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func));
-  look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func));
+  look->floor_func=(const vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func));
+  look->residue_func=(const vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func));
   
   for(i=0;i<info->submaps;i++){
     int floornum=info->floorsubmap[i];
@@ -176,7 +177,6 @@
   return(NULL);
 }
 
-static int seq=0;
 static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
   vorbis_dsp_state     *vd=vb->vd;
   vorbis_info          *vi=vd->vi;
@@ -307,13 +307,12 @@
   //for(j=0;j<vi->channels;j++)
   //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0);
 
-  seq+=vi->channels;
   /* all done! */
   return(0);
 }
 
 /* export hooks */
-vorbis_func_mapping mapping0_exportbundle={
+const vorbis_func_mapping mapping0_exportbundle={
   &mapping0_unpack,
   &mapping0_look,
   &mapping0_free_info,
Index: registry.h
===================================================================
--- registry.h	(revision 8355)
+++ registry.h	(working copy)
@@ -33,8 +33,8 @@
 # define EXTERN extern
 #endif
 
-EXTERN vorbis_func_floor     *_floor_P[];
-EXTERN vorbis_func_residue   *_residue_P[];
-EXTERN vorbis_func_mapping   *_mapping_P[];
+EXTERN const vorbis_func_floor     * const _floor_P[];
+EXTERN const vorbis_func_residue   * const _residue_P[];
+EXTERN const vorbis_func_mapping   * const _mapping_P[];
 
 #endif
Index: backends.h
===================================================================
--- backends.h	(revision 8355)
+++ backends.h	(working copy)
@@ -36,9 +36,9 @@
   vorbis_look_floor     *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
 				   vorbis_info_floor *);
   void (*free_info) (vorbis_info_floor *);
-  void (*free_look) (vorbis_look_floor *);
-  void *(*inverse1)  (struct vorbis_block *,vorbis_look_floor *);
-  int   (*inverse2)  (struct vorbis_block *,vorbis_look_floor *,
+  void (*free_look) (const vorbis_look_floor *);
+  void *(*inverse1)  (struct vorbis_block *,const vorbis_look_floor *);
+  int   (*inverse2)  (struct vorbis_block *,const vorbis_look_floor *,
 		     void *buffer,ogg_int32_t *);
 } vorbis_func_floor;
 
Index: os.h
===================================================================
--- os.h	(revision 8355)
+++ os.h	(working copy)
@@ -36,13 +36,18 @@
 #  define M_PI (3.1415926536f)
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__SYMBIAN32__)
 #  include <malloc.h>
-#  define rint(x)   (floor((x)+0.5f)) 
+#  define rint(x)   (floor((x)+0.5f))
 #  define NO_FLOAT_MATH_LIB
 #  define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
 #endif
 
+#if defined(__SYMBIAN32__) && defined(__WINS__)
+void *_alloca(size_t size);
+#  define alloca _alloca
+#endif
+
 #ifdef HAVE_ALLOCA_H
 #  include <alloca.h>
 #endif
Index: res012.c
===================================================================
--- res012.c	(revision 8355)
+++ res012.c	(working copy)
@@ -25,6 +25,7 @@
 #include "codebook.h"
 #include "misc.h"
 #include "os.h"
+#include "block.h"
 
 typedef struct {
   vorbis_info_residue0 *info;
@@ -309,7 +310,7 @@
 }
 
 
-vorbis_func_residue residue0_exportbundle={
+const vorbis_func_residue residue0_exportbundle={
   &res0_unpack,
   &res0_look,
   &res0_free_info,
@@ -317,7 +318,7 @@
   &res0_inverse
 };
 
-vorbis_func_residue residue1_exportbundle={
+const vorbis_func_residue residue1_exportbundle={
   &res0_unpack,
   &res0_look,
   &res0_free_info,
@@ -325,7 +326,7 @@
   &res1_inverse
 };
 
-vorbis_func_residue residue2_exportbundle={
+const vorbis_func_residue residue2_exportbundle={
   &res0_unpack,
   &res0_look,
   &res0_free_info,
Index: mdct.c
===================================================================
--- mdct.c	(revision 8355)
+++ mdct.c	(working copy)
@@ -246,7 +246,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);
-------------- next part --------------
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
 *                                                                  *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
 *                                                                  *
 ********************************************************************

 function: PCM data vector blocking, windowing and dis/reassembly

 ********************************************************************/

#ifndef _V_BLOCK_H_
#define _V_BLOCK_H_

void *_vorbis_block_alloc(vorbis_block *vb,long bytes);

void _vorbis_block_ripcord(vorbis_block *vb);

#endif


More information about the Tremor mailing list