[xiph-commits] r16184 - trunk/vorbose/src

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Jun 24 21:42:27 PDT 2009


Author: xiphmont
Date: 2009-06-24 21:42:26 -0700 (Wed, 24 Jun 2009)
New Revision: 16184

Modified:
   trunk/vorbose/src/codebook.c
   trunk/vorbose/src/codec.h
   trunk/vorbose/src/floor.c
   trunk/vorbose/src/info.c
   trunk/vorbose/src/res.c
Log:
Add checks for invalid residue books, repeated floor1 post values



Modified: trunk/vorbose/src/codebook.c
===================================================================
--- trunk/vorbose/src/codebook.c	2009-06-25 04:11:27 UTC (rev 16183)
+++ trunk/vorbose/src/codebook.c	2009-06-25 04:42:26 UTC (rev 16184)
@@ -281,6 +281,7 @@
 
   /* Do we have a mapping to unpack? */
   ogg2pack_read(opb,4,&maptype);
+  s->maptype=maptype;
   if(maptype>0){
     unsigned long q_min,q_del,q_bits,q_seq;
 

Modified: trunk/vorbose/src/codec.h
===================================================================
--- trunk/vorbose/src/codec.h	2009-06-25 04:11:27 UTC (rev 16183)
+++ trunk/vorbose/src/codec.h	2009-06-25 04:42:26 UTC (rev 16184)
@@ -90,6 +90,7 @@
   int          dim;
   int          entries;
   int          used_entries;
+  int          maptype;
   ogg_int32_t *dec_table;
 } codebook;
 

Modified: trunk/vorbose/src/floor.c
===================================================================
--- trunk/vorbose/src/floor.c	2009-06-25 04:11:27 UTC (rev 16183)
+++ trunk/vorbose/src/floor.c	2009-06-25 04:42:26 UTC (rev 16184)
@@ -236,29 +236,42 @@
     printf("             post range       : %d bits\n"
 	   "             post values      : ",info->mult);
   
-  count=0;
-  for(j=0,k=0;j<info->partitions;j++){
-    count+=info->class[info->partitionclass[j]].class_dim; 
-    for(;k<count;k++){
-      int t;
-      ogg2pack_read(opb,rangebits,&ret);
-      t=ret;
+  {
+    int postlist[VIF_POSIT+2];
+    postlist[0]=0;
+    postlist[1]=1<<rangebits;
+    count=0;
+    for(j=0,k=0;j<info->partitions;j++){
+      count+=info->class[info->partitionclass[j]].class_dim; 
+      for(;k<count;k++){
+        int t,l;
+        ogg2pack_read(opb,rangebits,&ret);
+        postlist[k+2]=t=ret;
       
-      if(headerinfo_p){
-	if(k!=0 && k%4==0)
-	  printf("\n                                ");
-	printf("%5d",t);
-	if(k+1<count || j+1<info->partitions)
-	  printf(",");
+        if(headerinfo_p){
+          if(k!=0 && k%4==0)
+            printf("\n                                ");
+          printf("%5d",t);
+          if(k+1<count || j+1<info->partitions)
+            printf(",");
+        }
+        
+        if(t>=(1<<rangebits)){
+          if(headerinfo_p || warn_p)
+            printf("\nWARN header: Post value (%d) out of range.\n\n",t);
+          goto err;
+        }
+
+        for(l=0;l<k;l++)
+          if(postlist[l]==t){
+            if(headerinfo_p || warn_p)
+              printf("\nWARN header: Post value (%d) is repeated.\n\n",t);
+            goto err;
+          }
       }
-      
-      if(t>=(1<<rangebits)){
-	if(headerinfo_p || warn_p)
-	  printf("\nWARN header: Post value (%d) out of range.\n\n",t);
-	goto err;
-      }
     }
   }
+
   if(headerinfo_p)
     printf("\n             -----------------\n");
 

Modified: trunk/vorbose/src/info.c
===================================================================
--- trunk/vorbose/src/info.c	2009-06-25 04:11:27 UTC (rev 16183)
+++ trunk/vorbose/src/info.c	2009-06-25 04:42:26 UTC (rev 16184)
@@ -48,8 +48,8 @@
     printf("             Block sizes        : %d/%d samples\n\n",
 	   vi->blocksizes[0],vi->blocksizes[1]);
   }
-  if((warn_p || headerinfo_p) && rate<64000 && vi->blocksizes[1]>2048){
-    printf("WARN header: blocksizes greater than 2048 are limited to\n"
+  if((warn_p || headerinfo_p) && rate<64000 && vi->blocksizes[1]>4096){
+    printf("WARN header: blocksizes greater than 4096 are limited to\n"
 	   "             sample rates over or equal to 64kHz.\n\n");
     ret=1;
   }

Modified: trunk/vorbose/src/res.c
===================================================================
--- trunk/vorbose/src/res.c	2009-06-25 04:11:27 UTC (rev 16183)
+++ trunk/vorbose/src/res.c	2009-06-25 04:42:26 UTC (rev 16184)
@@ -81,12 +81,6 @@
     for(k=0;k<8;k++){
       if((info->stagemasks[j]>>k)&1){
 	ogg2pack_read(opb,8,&ret);
-	if((signed)ret>=vi->books){
-	  printf("\nWARN header: requested residue book (%lu) greater than\n"
-		 "             highest numbered available codebook (%d)\n\n",
-		 ret,vi->books-1);
-	  goto errout;
-	}
 	info->stagebooks[j*8+k]=ret;
 	if(k+1>info->stages)info->stages=k+1;
 	if(headerinfo_p)
@@ -100,6 +94,31 @@
     if(headerinfo_p)
       printf("\n");
   }
+
+  {
+    int flag = 0;
+    for(j=0;j<info->partitions;j++){
+      for(k=0;k<8;k++){
+        if((info->stagemasks[j]>>k)&1){
+          int ret = info->stagebooks[j*8+k];
+          if((signed)ret>=vi->books){
+            printf("\nWARN header: requested residue book (%lu) greater than\n"
+		 "             highest numbered available codebook (%d)\n\n",
+                   ret,vi->books-1);
+            flag=1;
+          }
+          if(vi->book_param[ret].maptype==0){
+            printf("\nWARN header: requested residue book (%lu) has no value mapping!\n"
+                   "             (maptype == 0)\n\n",
+                   ret);
+            flag=1;
+          }
+        }
+      }
+    }
+    if(flag)goto errout;
+  }
+
   if(headerinfo_p)
     printf("             ------------------\n");    
   



More information about the commits mailing list