Bug 1446062 - Vorbis fix. r=jmspeex, a=lizzard draft FIREFOX_52_7_2esr_BUILD1 FIREFOX_52_7_2esr_RELEASE
authorMonty Montgomery <monty@xiph.org>
Thu, 15 Mar 2018 18:12:05 -0400
changeset 776249 494e5d5278ba6f5fdda9a2bb9ac7ca772653ee4a
parent 776248 f2eb8ad26a29ec9715a1994b982cbe35a3ba3a12
child 776250 5cd5586a2f48424a9031a3fa4c782954a9df9a52
push id104831
push userbmo:jgilbert@mozilla.com
push dateMon, 02 Apr 2018 19:53:20 +0000
reviewersjmspeex, lizzard
bugs1446062
milestone52.7.2
Bug 1446062 - Vorbis fix. r=jmspeex, a=lizzard
media/libvorbis/lib/vorbis_codebook.c
--- a/media/libvorbis/lib/vorbis_codebook.c
+++ b/media/libvorbis/lib/vorbis_codebook.c
@@ -382,63 +382,34 @@ long vorbis_book_decodevs_add(codebook *
     int i,j,o;
 
     for (i = 0; i < step; i++) {
       entry[i]=decode_packed_entry_number(book,b);
       if(entry[i]==-1)return(-1);
       t[i] = book->valuelist+entry[i]*book->dim;
     }
     for(i=0,o=0;i<book->dim;i++,o+=step)
-      for (j=0;j<step;j++)
+      for (j=0;o+j<n && j<step;j++)
         a[o+j]+=t[j][i];
   }
   return(0);
 }
 
 /* decode vector / dim granularity gaurding is done in the upper layer */
 long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
   if(book->used_entries>0){
     int i,j,entry;
     float *t;
 
-    if(book->dim>8){
-      for(i=0;i<n;){
-        entry = decode_packed_entry_number(book,b);
-        if(entry==-1)return(-1);
-        t     = book->valuelist+entry*book->dim;
-        for (j=0;j<book->dim;)
-          a[i++]+=t[j++];
-      }
-    }else{
-      for(i=0;i<n;){
-        entry = decode_packed_entry_number(book,b);
-        if(entry==-1)return(-1);
-        t     = book->valuelist+entry*book->dim;
-        j=0;
-        switch((int)book->dim){
-        case 8:
-          a[i++]+=t[j++];
-        case 7:
-          a[i++]+=t[j++];
-        case 6:
-          a[i++]+=t[j++];
-        case 5:
-          a[i++]+=t[j++];
-        case 4:
-          a[i++]+=t[j++];
-        case 3:
-          a[i++]+=t[j++];
-        case 2:
-          a[i++]+=t[j++];
-        case 1:
-          a[i++]+=t[j++];
-        case 0:
-          break;
-        }
-      }
+    for(i=0;i<n;){
+      entry = decode_packed_entry_number(book,b);
+      if(entry==-1)return(-1);
+      t     = book->valuelist+entry*book->dim;
+      for(j=0;i<n && j<book->dim;)
+        a[i++]+=t[j++];
     }
   }
   return(0);
 }
 
 /* unlike the others, we guard against n not being an integer number
    of <dim> internally rather than in the upper layer (called only by
    floor0) */
@@ -466,22 +437,23 @@ long vorbis_book_decodev_set(codebook *b
 }
 
 long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
                               oggpack_buffer *b,int n){
 
   long i,j,entry;
   int chptr=0;
   if(book->used_entries>0){
-    for(i=offset/ch;i<(offset+n)/ch;){
+    int m=(offset+n)/ch;
+    for(i=offset/ch;i<m;){
       entry = decode_packed_entry_number(book,b);
       if(entry==-1)return(-1);
       {
         const float *t = book->valuelist+entry*book->dim;
-        for (j=0;j<book->dim;j++){
+        for (j=0;i<m && j<book->dim;j++){
           a[chptr++][i]+=t[j];
           if(chptr==ch){
             chptr=0;
             i++;
           }
         }
       }
     }