Bug 929910 - Update libvorbis to the 1.3.3 release. r=xiphmont
authorRalph Giles <giles@mozilla.com>
Wed, 23 Oct 2013 11:49:00 -0700
changeset 152005 df702b9349506cd00d535864bcced8f8d4029784
parent 152004 f09869b05ae30c67630758ffa29ac3705386f44c
child 152006 d0732dc3f30ec3cd30d574ca01acec015961b480
push idunknown
push userunknown
push dateunknown
reviewersxiphmont
bugs929910, 722924
milestone27.0a1
Bug 929910 - Update libvorbis to the 1.3.3 release. r=xiphmont Note that bug 722924 is fixed in a different way upstream. This commit takes their subsequent patch over ours.
media/libvorbis/README_MOZILLA
media/libvorbis/bug719612.patch
media/libvorbis/bug722924.patch
media/libvorbis/lib/vorbis_codebook.c
media/libvorbis/lib/vorbis_floor0.c
media/libvorbis/lib/vorbis_floor1.c
media/libvorbis/lib/vorbis_info.c
media/libvorbis/update.sh
--- a/media/libvorbis/README_MOZILLA
+++ b/media/libvorbis/README_MOZILLA
@@ -1,11 +1,12 @@
 The source from this directory was copied from the libvorbis
 subversion repository using the update.sh script. The only changes
-made were those applied by update.sh and the addition/upate of
-Makefile.in files for the Mozilla build system.
+made were those applied by update.sh and the addition/update of
+Makefile.in and moz.build files for the Mozilla build system.
 
-The upstream version used was libvorbis svn r18077.
+The upstream version used was libvorbis 1.3.3.
+https://svn.xiph.org/tags/vorbis/libvorbis-1.3.3@18190
 
 Some files are renamed during the copy to prevent clashes with object
 file names with other Mozilla libraries.
 
 alloca.diff - Bug 469639 - Failed to build firefox trunk on OpenSolaris
deleted file mode 100644
--- a/media/libvorbis/bug719612.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/media/libvorbis/lib/vorbis_floor1.c b/media/libvorbis/lib/vorbis_floor1.c
---- a/media/libvorbis/lib/vorbis_floor1.c
-+++ b/media/libvorbis/lib/vorbis_floor1.c
-@@ -162,16 +162,17 @@ static vorbis_info_floor *floor1_unpack 
- 
-   /* read the post list */
-   info->mult=oggpack_read(opb,2)+1;     /* only 1,2,3,4 legal now */
-   rangebits=oggpack_read(opb,4);
-   if(rangebits<0)goto err_out;
- 
-   for(j=0,k=0;j<info->partitions;j++){
-     count+=info->class_dim[info->partitionclass[j]];
-+    if(count>VIF_POSIT) goto err_out;
-     for(;k<count;k++){
-       int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
-       if(t<0 || t>=(1<<rangebits))
-         goto err_out;
-     }
-   }
-   info->postlist[0]=0;
-   info->postlist[1]=1<<rangebits;
deleted file mode 100644
--- a/media/libvorbis/bug722924.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/media/libvorbis/lib/vorbis_codebook.c b/media/libvorbis/lib/vorbis_codebook.c
---- a/media/libvorbis/lib/vorbis_codebook.c
-+++ b/media/libvorbis/lib/vorbis_codebook.c
-@@ -442,17 +442,17 @@ long vorbis_book_decodev_set(codebook *b
-       t     = book->valuelist+entry*book->dim;
-       for (j=0;j<book->dim;)
-         a[i++]=t[j++];
-     }
-   }else{
-     int i,j;
- 
-     for(i=0;i<n;){
--      for (j=0;j<book->dim;)
-+      for (j=0;j<book->dim;j++)
-         a[i++]=0.f;
-     }
-   }
-   return(0);
- }
- 
- long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
-                               oggpack_buffer *b,int n){
--- a/media/libvorbis/lib/vorbis_codebook.c
+++ b/media/libvorbis/lib/vorbis_codebook.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c 18076 2011-09-02 02:44:49Z giles $
+ last mod: $Id: codebook.c 18183 2012-02-03 20:51:27Z xiphmont $
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -362,16 +362,17 @@ long vorbis_book_decode(codebook *book, 
       return(book->dec_index[packed_entry]);
   }
 
   /* if there's no dec_index, the codebook unpacking isn't collapsed */
   return(-1);
 }
 
 /* returns 0 on OK or -1 on eof *************************************/
+/* decode vector / dim granularity gaurding is done in the upper layer */
 long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
   if(book->used_entries>0){
     int step=n/book->dim;
     long *entry = alloca(sizeof(*entry)*step);
     float **t = alloca(sizeof(*t)*step);
     int i,j,o;
 
     for (i = 0; i < step; i++) {
@@ -381,16 +382,17 @@ long vorbis_book_decodevs_add(codebook *
     }
     for(i=0,o=0;i<book->dim;i++,o+=step)
       for (j=0;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);
@@ -426,34 +428,37 @@ long vorbis_book_decodev_add(codebook *b
           break;
         }
       }
     }
   }
   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) */
 long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
   if(book->used_entries>0){
     int i,j,entry;
     float *t;
 
     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;)
+      for (j=0;i<n && j<book->dim;){
         a[i++]=t[j++];
+      }
     }
   }else{
     int i,j;
 
     for(i=0;i<n;){
-      for (j=0;j<book->dim;j++)
-        a[i++]=0.f;
+      a[i++]=0.f;
     }
   }
   return(0);
 }
 
 long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
                               oggpack_buffer *b,int n){
 
--- a/media/libvorbis/lib/vorbis_floor0.c
+++ b/media/libvorbis/lib/vorbis_floor0.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: floor backend 0 implementation
- last mod: $Id: floor0.c 17558 2010-10-22 00:24:41Z tterribe $
+ last mod: $Id: floor0.c 18184 2012-02-03 20:55:12Z xiphmont $
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
@@ -172,20 +172,19 @@ static void *floor0_inverse1(vorbis_bloc
       codebook *b=ci->fullbooks+info->books[booknum];
       float last=0.f;
 
       /* the additional b->dim is a guard against any possible stack
          smash; b->dim is provably more than we can overflow the
          vector */
       float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1));
 
-      for(j=0;j<look->m;j+=b->dim)
-        if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
+      if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m)==-1)goto eop;
       for(j=0;j<look->m;){
-        for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
+        for(k=0;j<look->m && k<b->dim;k++,j++)lsp[j]+=last;
         last=lsp[j-1];
       }
 
       lsp[look->m]=amp;
       return(lsp);
     }
   }
  eop:
--- a/media/libvorbis/lib/vorbis_floor1.c
+++ b/media/libvorbis/lib/vorbis_floor1.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c 17688 2010-11-29 23:53:30Z tterribe $
+ last mod: $Id: floor1.c 18151 2012-01-20 07:35:26Z xiphmont $
 
  ********************************************************************/
 
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include <ogg/ogg.h>
 #include "vorbis/codec.h"
--- a/media/libvorbis/lib/vorbis_info.c
+++ b/media/libvorbis/lib/vorbis_info.c
@@ -6,17 +6,17 @@
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c 17584 2010-11-01 19:26:16Z xiphmont $
+ last mod: $Id: info.c 18186 2012-02-03 22:08:44Z xiphmont $
 
  ********************************************************************/
 
 /* general handling of the header and the vorbis_info structure (and
    substructures) */
 
 #include <stdlib.h>
 #include <string.h>
@@ -26,18 +26,18 @@
 #include "codec_internal.h"
 #include "codebook.h"
 #include "registry.h"
 #include "window.h"
 #include "psy.h"
 #include "misc.h"
 #include "os.h"
 
-#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.2"
-#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20101101 (Schaufenugget)"
+#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.3"
+#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20120203 (Omnipresent)"
 
 /* helpers */
 static int ilog2(unsigned int v){
   int ret=0;
   if(v)--v;
   while(v){
     ret++;
     v>>=1;
@@ -545,27 +545,31 @@ err_out:
 }
 
 int vorbis_commentheader_out(vorbis_comment *vc,
                                           ogg_packet *op){
 
   oggpack_buffer opb;
 
   oggpack_writeinit(&opb);
-  if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
+  if(_vorbis_pack_comment(&opb,vc)){
+    oggpack_writeclear(&opb);
+    return OV_EIMPL;
+  }
 
   op->packet = _ogg_malloc(oggpack_bytes(&opb));
   memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
 
   op->bytes=oggpack_bytes(&opb);
   op->b_o_s=0;
   op->e_o_s=0;
   op->granulepos=0;
   op->packetno=1;
 
+  oggpack_writeclear(&opb);
   return 0;
 }
 
 int vorbis_analysis_headerout(vorbis_dsp_state *v,
                               vorbis_comment *vc,
                               ogg_packet *op,
                               ogg_packet *op_comm,
                               ogg_packet *op_code){
--- a/media/libvorbis/update.sh
+++ b/media/libvorbis/update.sh
@@ -41,11 +41,10 @@ cp $1/lib/registry.h ./lib/registry.h
 cp $1/lib/codebook.c ./lib/vorbis_codebook.c
 cp $1/lib/bitrate.c ./lib/vorbis_bitrate.c
 cp $1/lib/block.c ./lib/vorbis_block.c
 cp $1/include/vorbis/codec.h ./include/vorbis/codec.h
 cp $1/todo.txt ./todo.txt
 cp $1/COPYING ./COPYING
 cp $1/README ./README
 cp $1/AUTHORS ./AUTHORS
+
 patch -p3 < ./alloca.diff
-patch -p3 < ./bug719612.patch
-patch -p3 < ./bug722924.patch