Bug 1446062 - Vorbis fix. r=jmspeex, a=lizzard FIREFOX_59_0_1_BUILD1 FIREFOX_59_0_1_RELEASE
authorMonty Montgomery <monty@xiph.org>
Thu, 15 Mar 2018 18:12:05 -0400
changeset 455133 3db9e3d52b17563efca181ccbb50deb8660c59ae
parent 455132 341fda7372a70776a8639cae994406a74bbe9450
child 455134 edcc878881482a30db0710c167f090819fa6c0f0
push id1672
push userryanvm@gmail.com
push dateThu, 15 Mar 2018 23:31:28 +0000
treeherdermozilla-release@3db9e3d52b17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmspeex, lizzard
bugs1446062
milestone59.0.1
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
@@ -381,63 +381,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) */
@@ -465,22 +436,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++;
           }
         }
       }
     }