Bug 1446062: Vorbis fix r=jmspeex a=abillings
authorMonty Montgomery <monty@xiph.org>
Thu, 15 Mar 2018 18:12:05 -0400
changeset 408370 6b4e98424f0dcc024fcad48608ada351e4075e59
parent 408336 748f4a1baef345a1db72774393b3e45fcd40a9a1
child 408371 16e69d4df5dcef04f1d3f4b6fcf9284d321bce6f
push id100936
push userccoroiu@mozilla.com
push dateThu, 15 Mar 2018 23:46:46 +0000
treeherdermozilla-inbound@91a98a3ddd28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmspeex, abillings
bugs1446062
milestone61.0a1
first release with
nightly linux32
6b4e98424f0d / 61.0a1 / 20180315223216 / files
nightly linux64
6b4e98424f0d / 61.0a1 / 20180315223216 / files
nightly mac
6b4e98424f0d / 61.0a1 / 20180315223216 / files
nightly win32
6b4e98424f0d / 61.0a1 / 20180315223216 / files
nightly win64
6b4e98424f0d / 61.0a1 / 20180315223216 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1446062: Vorbis fix r=jmspeex a=abillings
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++;
           }
         }
       }
     }