[xiph-cvs] cvs commit: Tremor codebook.c codebook.h misc.h
Monty
xiphmont at xiph.org
Wed Apr 9 01:29:41 PDT 2003
xiphmont 03/04/09 04:29:41
Modified: . Tag: lowmem-branch codebook.c codebook.h misc.h
Log:
Codebook needs minor cleanup... but all the opt work is in place and tested.
Revision Changes Path
No revision
<p>No revision
<p>1.2.6.3 +43 -53 Tremor/codebook.c
Index: codebook.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codebook.c,v
retrieving revision 1.2.6.2
retrieving revision 1.2.6.3
diff -u -r1.2.6.2 -r1.2.6.3
--- codebook.c 9 Apr 2003 00:24:59 -0000 1.2.6.2
+++ codebook.c 9 Apr 2003 08:29:41 -0000 1.2.6.3
@@ -80,20 +80,18 @@
static ogg_int32_t _float32_unpack(long val,int *point){
long mant=val&0x1fffff;
int sign=val&0x80000000;
- long exp =((val&0x7fe00000L)>>21)-788;
+
+ *point=((val&0x7fe00000L)>>21)-788;
if(mant){
while(!(mant&0x40000000)){
mant<<=1;
- exp-=1;
+ *point-=1;
}
if(sign)mant= -mant;
}else{
- sign=0;
- exp=-9999;
+ *point=-9999;
}
-
- *point=exp;
return mant;
}
@@ -181,7 +179,7 @@
return 0;
}
-#include <stdio.h>
+//#include <stdio.h>
static int _make_decode_table(codebook *s,char *lengthlist,long quantvals,
oggpack_buffer *opb,int maptype){
int i;
@@ -193,7 +191,7 @@
if(_make_words(lengthlist,s->entries,work,quantvals,s,opb,maptype))return 1;
if(s->dec_nodeb==4){
- fprintf(stderr,"32/32\n");
+ //fprintf(stderr,"32/32\n");
return 0;
}
@@ -203,14 +201,14 @@
if(s->dec_leafw==1){
switch(s->dec_nodeb){
case 1:
- fprintf(stderr,"8/8\n");
+ //fprintf(stderr,"8/8\n");
for(i=0;i<s->used_entries*2-2;i++)
((unsigned char *)s->dec_table)[i]=
((work[i] & 0x80000000UL) >> 24) | work[i];
break;
case 2:
- fprintf(stderr,"16/16\n");
+ //fprintf(stderr,"16/16\n");
for(i=0;i<s->used_entries*2-2;i++)
((ogg_uint16_t *)s->dec_table)[i]=
((work[i] & 0x80000000UL) >> 16) | work[i];
@@ -223,7 +221,7 @@
long top=s->used_entries*3-2;
if(s->dec_nodeb==1){
unsigned char *out=(unsigned char *)s->dec_table;
- fprintf(stderr,"8/16\n");
+ //fprintf(stderr,"8/16\n");
for(i=s->used_entries*2-4;i>=0;i-=2){
if(work[i]&0x80000000UL){
@@ -255,7 +253,7 @@
}
}else{
ogg_uint16_t *out=(ogg_uint16_t *)s->dec_table;
- fprintf(stderr,"16/32\n");
+ //fprintf(stderr,"16/32\n");
for(i=s->used_entries*2-4;i>=0;i-=2){
if(work[i]&0x80000000UL){
if(work[i+1]&0x80000000UL){
@@ -409,13 +407,13 @@
/* Do we have a mapping to unpack? */
if((maptype=oggpack_read(opb,4))>0){
- s->q_min=oggpack_read(opb,32);
- s->q_del=oggpack_read(opb,32);
+ s->q_min=_float32_unpack(oggpack_read(opb,32),&s->q_minp);
+ s->q_del=_float32_unpack(oggpack_read(opb,32),&s->q_delp);
s->q_bits=oggpack_read(opb,4)+1;
s->q_seq=oggpack_read(opb,1);
}
- fprintf(stderr,"%ld/%ld x%d b%d (maptype:%d, ",s->used_entries,s->entries,s->dim,s->q_bits,maptype);
+ //fprintf(stderr,"%ld/%ld x%d b%d (maptype:%d, ",s->used_entries,s->entries,s->dim,s->q_bits,maptype);
switch(maptype){
case 0:
@@ -428,7 +426,7 @@
s->dec_nodeb=_determine_node_bytes(s->used_entries,_ilog(s->entries)/8+1);
s->dec_leafw=_determine_leaf_words(s->dec_nodeb,_ilog(s->entries)/8+1);
s->dec_type=0;
- fprintf(stderr,"dec_type:0) ");
+ //fprintf(stderr,"dec_type:0) ");
if(_make_decode_table(s,lengthlist,quantvals,opb,maptype)) goto _errout;
break;
@@ -448,7 +446,7 @@
if(total1<=4 && total1<=total2){
/* use dec_type 1: vector of packed values */
- fprintf(stderr,"dec_type:1) ");
+ //fprintf(stderr,"dec_type:1) ");
/* need quantized values before */
s->q_val=alloca(sizeof(ogg_uint16_t)*quantvals);
@@ -475,7 +473,7 @@
}else{
/* use dec_type 2: packed vector of column offsets */
- fprintf(stderr,"dec_type:2) ");
+ //fprintf(stderr,"dec_type:2) ");
/* need quantized values before */
if(s->q_bits<=8){
@@ -509,7 +507,7 @@
if( (s->q_bits*s->dim+8)/8 <=4){ /* remember flag bit */
/* use dec_type 1: vector of packed values */
- fprintf(stderr,"dec_type:1) ");
+ //fprintf(stderr,"dec_type:1) ");
s->dec_type=1;
s->dec_nodeb=_determine_node_bytes(s->used_entries,(s->q_bits*s->dim+8)/8);
@@ -518,7 +516,7 @@
}else{
/* use dec_type 3: scalar offset into packed value array */
- fprintf(stderr,"dec_type:3) ");
+ //fprintf(stderr,"dec_type:3) ");
s->dec_type=3;
s->dec_nodeb=_determine_node_bytes(s->used_entries,_ilog(s->used_entries-1)/8+1);
@@ -641,7 +639,7 @@
return decode_packed_entry_number(book,b);
}
-int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, ogg_int32_t *p){
+int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, int point){
ogg_uint32_t entry = decode_packed_entry_number(s,b);
int i;
if(oggpack_eop(b))return(-1);
@@ -688,16 +686,24 @@
/* we have the unpacked multiplicands; compute final vals */
{
- int mpoint,dpoint;
- ogg_int32_t m=_float32_unpack(s->q_min,&mpoint);
- ogg_int32_t d=_float32_unpack(s->q_del,&dpoint);
- for(i=0;i<s->dim;i++){
- v[i]=VFLOAT_MULTI(d,dpoint,v[i],p+i);
- v[i]=VFLOAT_ADD(m,mpoint,v[i],p[i],p+i);
- }
+ int shiftM=point-s->q_delp-s->q_bits;
+ ogg_int32_t add=point-s->q_minp;
+ ogg_int32_t del=s->q_del>>s->q_bits;
+ if(add>0)
+ add= s->q_min >> add;
+ else
+ add= s->q_min << -add;
+
+ if(shiftM>0)
+ for(i=0;i<s->dim;i++)
+ v[i]= add + ((v[i] * del) >> shiftM);
+ else
+ for(i=0;i<s->dim;i++)
+ v[i]= add + ((v[i] * del) << -shiftM);
+
if(s->q_seq)
for(i=1;i<s->dim;i++)
- v[i]=VFLOAT_ADD(v[i-1],p[i-1],v[i],p[i],p+i);
+ v[i]+=v[i-1];
}
return 0;
@@ -708,16 +714,12 @@
oggpack_buffer *b,int n,int point){
int step=n/book->dim;
ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- ogg_int32_t *p = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
int i,j,o;
for (j=0;j<step;j++){
- if(decode_map(book,b,v,p))return -1;
+ if(decode_map(book,b,v,point))return -1;
for(i=0,o=j;i<book->dim;i++,o+=step)
- if(point-p[i]>0)
- a[o]+=v[i]>>(point-p[i]);
- else
- a[o]+=v[i]<<(p[i]-point);
+ a[o]+=v[i];
}
return 0;
}
@@ -725,16 +727,12 @@
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- ogg_int32_t *p = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
int i,j;
for(i=0;i<n;){
- if(decode_map(book,b,v,p))return -1;
+ if(decode_map(book,b,v,point))return -1;
for (j=0;j<book->dim;j++)
- if(point-p[j]>0)
- a[i++]+=v[j]>>(point-p[j]);
- else
- a[i++]+=v[j]<<(p[j]-point);
+ a[i++]+=v[j];
}
return 0;
@@ -743,16 +741,12 @@
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- ogg_int32_t *p = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
int i,j;
for(i=0;i<n;){
- if(decode_map(book,b,v,p))return -1;
+ if(decode_map(book,b,v,point))return -1;
for (j=0;j<book->dim;j++)
- if(point-p[j]>0)
- a[i++]=v[j]>>(point-p[j]);
- else
- a[i++]=v[j]<<(p[j]-point);
+ a[i++]=v[j];
}
return 0;
@@ -763,17 +757,13 @@
oggpack_buffer *b,int n,int point){
ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- ogg_int32_t *p = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
long i,j;
int chptr=0;
for(i=offset;i<offset+n;){
- if(decode_map(book,b,v,p))return -1;
+ if(decode_map(book,b,v,point))return -1;
for (j=0;j<book->dim;j++){
- if(point-p[j]>0)
- a[chptr++][i]+=v[j]>>(point-p[j]);
- else
- a[chptr++][i]+=v[j]<<(p[j]-point);
+ a[chptr++][i]+=v[j];
if(chptr==ch){
chptr=0;
i++;
<p><p>1.2.6.3 +8 -6 Tremor/codebook.h
Index: codebook.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/codebook.h,v
retrieving revision 1.2.6.2
retrieving revision 1.2.6.3
diff -u -r1.2.6.2 -r1.2.6.3
--- codebook.h 9 Apr 2003 00:24:59 -0000 1.2.6.2
+++ codebook.h 9 Apr 2003 08:29:41 -0000 1.2.6.3
@@ -34,12 +34,14 @@
2 = packed vector of column offsets, maptype 1
3 = scalar offset into value array, maptype 2 */
- ogg_uint32_t q_min;
- ogg_uint32_t q_del;
- int q_seq;
- int q_bits;
- int q_pack;
- void *q_val;
+ ogg_int32_t q_min;
+ int q_minp;
+ ogg_int32_t q_del;
+ int q_delp;
+ int q_seq;
+ int q_bits;
+ int q_pack;
+ void *q_val;
} codebook;
<p><p>1.8.2.2 +4 -0 Tremor/misc.h
Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/Tremor/misc.h,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -r1.8.2.1 -r1.8.2.2
--- misc.h 5 Apr 2003 01:45:15 -0000 1.8.2.1
+++ misc.h 9 Apr 2003 08:29:41 -0000 1.8.2.2
@@ -21,6 +21,9 @@
#include "os_types.h"
#define _VDBG_GRAPHFILE "_0.m"
+
+
+#ifdef _VDBG_GRAPHFILE
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line);
extern void _VDBG_free(void *ptr,char *file,long line);
@@ -33,6 +36,7 @@
#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__)
#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__)
#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__)
+#endif
#include "asm_arm.h"
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list