From 7bcdd1b5d896816f6d403f86cd315819d0d03d07 Mon Sep 17 00:00:00 2001 From: Sigrid Date: Wed, 23 Dec 2020 12:18:07 +0100 Subject: [PATCH] =?UTF-8?q?libvorbis:=201.3.5=20=E2=86=92=201.3.7=20(fixes?= =?UTF-8?q?=20a=20bunch=20of=20CVE=20and=20other=20small=20issues)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/src/cmd/audio/libvorbis/COPYING | 18 ++--- sys/src/cmd/audio/libvorbis/analysis.c | 3 +- sys/src/cmd/audio/libvorbis/backends.h | 3 +- sys/src/cmd/audio/libvorbis/barkmel.c | 3 +- sys/src/cmd/audio/libvorbis/bitrate.c | 3 +- sys/src/cmd/audio/libvorbis/bitrate.h | 3 +- sys/src/cmd/audio/libvorbis/block.c | 3 +- .../libvorbis/books/coupled/res_books_51.h | 3 +- .../books/coupled/res_books_stereo.h | 3 +- .../audio/libvorbis/books/floor/floor_books.h | 3 +- .../books/uncoupled/res_books_uncoupled.h | 3 +- sys/src/cmd/audio/libvorbis/codebook.c | 51 +++----------- sys/src/cmd/audio/libvorbis/codebook.h | 3 +- sys/src/cmd/audio/libvorbis/codec_internal.h | 3 +- sys/src/cmd/audio/libvorbis/envelope.c | 3 +- sys/src/cmd/audio/libvorbis/envelope.h | 3 +- sys/src/cmd/audio/libvorbis/floor0.c | 3 +- sys/src/cmd/audio/libvorbis/floor1.c | 3 +- sys/src/cmd/audio/libvorbis/highlevel.h | 3 +- sys/src/cmd/audio/libvorbis/info.c | 55 +++++++++------ sys/src/cmd/audio/libvorbis/lookup.c | 3 +- sys/src/cmd/audio/libvorbis/lookup.h | 3 +- sys/src/cmd/audio/libvorbis/lookup_data.h | 3 +- sys/src/cmd/audio/libvorbis/lpc.c | 3 +- sys/src/cmd/audio/libvorbis/lpc.h | 3 +- sys/src/cmd/audio/libvorbis/lsp.c | 6 +- sys/src/cmd/audio/libvorbis/lsp.h | 3 +- sys/src/cmd/audio/libvorbis/mapping0.c | 5 +- sys/src/cmd/audio/libvorbis/masking.h | 3 +- sys/src/cmd/audio/libvorbis/mdct.c | 8 +-- sys/src/cmd/audio/libvorbis/mdct.h | 3 +- sys/src/cmd/audio/libvorbis/misc.h | 3 +- sys/src/cmd/audio/libvorbis/modes/floor_all.h | 3 +- sys/src/cmd/audio/libvorbis/modes/psych_11.h | 3 +- sys/src/cmd/audio/libvorbis/modes/psych_16.h | 3 +- sys/src/cmd/audio/libvorbis/modes/psych_44.h | 3 +- sys/src/cmd/audio/libvorbis/modes/psych_8.h | 3 +- .../cmd/audio/libvorbis/modes/residue_16.h | 3 +- .../cmd/audio/libvorbis/modes/residue_44.h | 3 +- .../cmd/audio/libvorbis/modes/residue_44p51.h | 3 +- .../cmd/audio/libvorbis/modes/residue_44u.h | 3 +- sys/src/cmd/audio/libvorbis/modes/residue_8.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_11.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_16.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_22.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_32.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_44.h | 3 +- .../cmd/audio/libvorbis/modes/setup_44p51.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_44u.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_8.h | 3 +- sys/src/cmd/audio/libvorbis/modes/setup_X.h | 3 +- sys/src/cmd/audio/libvorbis/os.h | 16 ++--- sys/src/cmd/audio/libvorbis/psy.c | 27 ++++---- sys/src/cmd/audio/libvorbis/psy.h | 3 +- sys/src/cmd/audio/libvorbis/psytune.c | 67 +++++++++---------- sys/src/cmd/audio/libvorbis/registry.c | 3 +- sys/src/cmd/audio/libvorbis/registry.h | 3 +- sys/src/cmd/audio/libvorbis/res0.c | 6 +- sys/src/cmd/audio/libvorbis/scales.h | 3 +- sys/src/cmd/audio/libvorbis/sharedbook.c | 38 ++++++++--- sys/src/cmd/audio/libvorbis/smallft.c | 3 +- sys/src/cmd/audio/libvorbis/smallft.h | 3 +- sys/src/cmd/audio/libvorbis/synthesis.c | 5 +- sys/src/cmd/audio/libvorbis/tone.c | 4 +- sys/src/cmd/audio/libvorbis/vorbis/codec.h | 3 +- .../cmd/audio/libvorbis/vorbis/vorbisenc.h | 3 +- .../cmd/audio/libvorbis/vorbis/vorbisfile.h | 3 +- sys/src/cmd/audio/libvorbis/vorbisenc.c | 6 +- sys/src/cmd/audio/libvorbis/vorbisfile.c | 28 ++++---- sys/src/cmd/audio/libvorbis/window.c | 3 +- sys/src/cmd/audio/libvorbis/window.h | 3 +- 71 files changed, 223 insertions(+), 285 deletions(-) diff --git a/sys/src/cmd/audio/libvorbis/COPYING b/sys/src/cmd/audio/libvorbis/COPYING index 928afad34..fb456a87b 100644 --- a/sys/src/cmd/audio/libvorbis/COPYING +++ b/sys/src/cmd/audio/libvorbis/COPYING @@ -1,4 +1,4 @@ -Copyright (c) 2002, Xiph.org Foundation +Copyright (c) 2002-2020 Xiph.org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -18,11 +18,11 @@ this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sys/src/cmd/audio/libvorbis/analysis.c b/sys/src/cmd/audio/libvorbis/analysis.c index 01aa6f30d..14919737e 100644 --- a/sys/src/cmd/audio/libvorbis/analysis.c +++ b/sys/src/cmd/audio/libvorbis/analysis.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: single-block PCM analysis mode dispatch - last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/backends.h b/sys/src/cmd/audio/libvorbis/backends.h index ff5bcc95f..670b0b902 100644 --- a/sys/src/cmd/audio/libvorbis/backends.h +++ b/sys/src/cmd/audio/libvorbis/backends.h @@ -6,13 +6,12 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: libvorbis backend and mapping structures; needed for static mode headers - last mod: $Id: backends.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/barkmel.c b/sys/src/cmd/audio/libvorbis/barkmel.c index 37b6c4c7b..f833c3021 100644 --- a/sys/src/cmd/audio/libvorbis/barkmel.c +++ b/sys/src/cmd/audio/libvorbis/barkmel.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: bark scale utility - last mod: $Id: barkmel.c 19454 2015-03-02 22:39:28Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/bitrate.c b/sys/src/cmd/audio/libvorbis/bitrate.c index 3a71b1dc2..132553cbe 100644 --- a/sys/src/cmd/audio/libvorbis/bitrate.c +++ b/sys/src/cmd/audio/libvorbis/bitrate.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: bitrate tracking and management - last mod: $Id: bitrate.c 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/bitrate.h b/sys/src/cmd/audio/libvorbis/bitrate.h index db48fcb64..48fa15059 100644 --- a/sys/src/cmd/audio/libvorbis/bitrate.h +++ b/sys/src/cmd/audio/libvorbis/bitrate.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: bitrate tracking and management - last mod: $Id: bitrate.h 13293 2007-07-24 00:09:47Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/block.c b/sys/src/cmd/audio/libvorbis/block.c index c5658bcd1..1800db663 100644 --- a/sys/src/cmd/audio/libvorbis/block.c +++ b/sys/src/cmd/audio/libvorbis/block.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: PCM data vector blocking, windowing and dis/reassembly - last mod: $Id: block.c 19457 2015-03-03 00:15:29Z giles $ Handle windowing, overlap-add, etc of the PCM vectors. This is made more amusing by Vorbis' current two allowed block sizes. diff --git a/sys/src/cmd/audio/libvorbis/books/coupled/res_books_51.h b/sys/src/cmd/audio/libvorbis/books/coupled/res_books_51.h index 93910ff48..eb569c6f0 100644 --- a/sys/src/cmd/audio/libvorbis/books/coupled/res_books_51.h +++ b/sys/src/cmd/audio/libvorbis/books/coupled/res_books_51.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** * * function: static codebooks for 5.1 surround - * last modified: $Id: res_books_51.h 19057 2014-01-22 12:32:31Z xiphmont $ * ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/books/coupled/res_books_stereo.h b/sys/src/cmd/audio/libvorbis/books/coupled/res_books_stereo.h index 9a9049f6e..7b53cb972 100644 --- a/sys/src/cmd/audio/libvorbis/books/coupled/res_books_stereo.h +++ b/sys/src/cmd/audio/libvorbis/books/coupled/res_books_stereo.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: static codebooks autogenerated by huff/huffbuld - last modified: $Id: res_books_stereo.h 19057 2014-01-22 12:32:31Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/books/floor/floor_books.h b/sys/src/cmd/audio/libvorbis/books/floor/floor_books.h index e925313f7..d26664f76 100644 --- a/sys/src/cmd/audio/libvorbis/books/floor/floor_books.h +++ b/sys/src/cmd/audio/libvorbis/books/floor/floor_books.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: static codebooks autogenerated by huff/huffbuld - last modified: $Id: floor_books.h 19057 2014-01-22 12:32:31Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/books/uncoupled/res_books_uncoupled.h b/sys/src/cmd/audio/libvorbis/books/uncoupled/res_books_uncoupled.h index 736353b67..107e22f9e 100644 --- a/sys/src/cmd/audio/libvorbis/books/uncoupled/res_books_uncoupled.h +++ b/sys/src/cmd/audio/libvorbis/books/uncoupled/res_books_uncoupled.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: static codebooks autogenerated by huff/huffbuld - last modified: $Id: res_books_uncoupled.h 19057 2014-01-22 12:32:31Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/codebook.c b/sys/src/cmd/audio/libvorbis/codebook.c index 6a4dfe380..1dc2ccf00 100644 --- a/sys/src/cmd/audio/libvorbis/codebook.c +++ b/sys/src/cmd/audio/libvorbis/codebook.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: basic codebook pack/unpack/code/decode operations - last mod: $Id: codebook.c 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ @@ -391,7 +390,7 @@ long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){ t[i] = book->valuelist+entry[i]*book->dim; } for(i=0,o=0;idim;i++,o+=step) - for (j=0;jdim>8){ - for(i=0;ivaluelist+entry*book->dim; - for (j=0;jdim;) - a[i++]+=t[j++]; - } - }else{ - for(i=0;ivaluelist+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;ivaluelist+entry*book->dim; + for(j=0;idim;) + a[i++]+=t[j++]; } } return(0); @@ -477,12 +447,13 @@ long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch, 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;ivaluelist+entry*book->dim; - for (j=0;jdim;j++){ + for (j=0;idim;j++){ a[chptr++][i]+=t[j]; if(chptr==ch){ chptr=0; diff --git a/sys/src/cmd/audio/libvorbis/codebook.h b/sys/src/cmd/audio/libvorbis/codebook.h index 537d6c12d..7d4e2aae4 100644 --- a/sys/src/cmd/audio/libvorbis/codebook.h +++ b/sys/src/cmd/audio/libvorbis/codebook.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: basic shared codebook operations - last mod: $Id: codebook.h 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/codec_internal.h b/sys/src/cmd/audio/libvorbis/codec_internal.h index de1bccaed..2ecf5e5c7 100644 --- a/sys/src/cmd/audio/libvorbis/codec_internal.h +++ b/sys/src/cmd/audio/libvorbis/codec_internal.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: libvorbis codec headers - last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/envelope.c b/sys/src/cmd/audio/libvorbis/envelope.c index 05e2757fb..3a5be63e8 100644 --- a/sys/src/cmd/audio/libvorbis/envelope.c +++ b/sys/src/cmd/audio/libvorbis/envelope.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: PCM data envelope analysis - last mod: $Id: envelope.c 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/envelope.h b/sys/src/cmd/audio/libvorbis/envelope.h index fd15fb32a..2ef60a82c 100644 --- a/sys/src/cmd/audio/libvorbis/envelope.h +++ b/sys/src/cmd/audio/libvorbis/envelope.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: PCM data envelope analysis and manipulation - last mod: $Id: envelope.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/floor0.c b/sys/src/cmd/audio/libvorbis/floor0.c index 213cce4ec..f4a6d4d55 100644 --- a/sys/src/cmd/audio/libvorbis/floor0.c +++ b/sys/src/cmd/audio/libvorbis/floor0.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: floor backend 0 implementation - last mod: $Id: floor0.c 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/floor1.c b/sys/src/cmd/audio/libvorbis/floor1.c index d8bd4645c..c4fe3ea7e 100644 --- a/sys/src/cmd/audio/libvorbis/floor1.c +++ b/sys/src/cmd/audio/libvorbis/floor1.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: floor backend 1 implementation - last mod: $Id: floor1.c 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/highlevel.h b/sys/src/cmd/audio/libvorbis/highlevel.h index e38f370fd..7690e3ebf 100644 --- a/sys/src/cmd/audio/libvorbis/highlevel.h +++ b/sys/src/cmd/audio/libvorbis/highlevel.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: highlevel encoder setup struct separated out for vorbisenc clarity - last mod: $Id: highlevel.h 17195 2010-05-05 21:49:51Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/info.c b/sys/src/cmd/audio/libvorbis/info.c index 44bb85d39..f2e39e387 100644 --- a/sys/src/cmd/audio/libvorbis/info.c +++ b/sys/src/cmd/audio/libvorbis/info.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: maintain the info structure, info <-> header packets - last mod: $Id: info.c 19441 2015-01-21 01:17:41Z xiphmont $ ********************************************************************/ @@ -20,7 +19,6 @@ #include #include -#include #include #include "vorbis/codec.h" #include "codec_internal.h" @@ -31,8 +29,8 @@ #include "misc.h" #include "os.h" -#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.5" -#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20150105 (⛄⛄⛄⛄)" +#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.7" +#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20200704 (Reducing Environment)" /* helpers */ static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){ @@ -48,6 +46,10 @@ static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ } } +static int _v_toupper(int c) { + return (c >= 'a' && c <= 'z') ? (c & ~('a' - 'A')) : c; +} + void vorbis_comment_init(vorbis_comment *vc){ memset(vc,0,sizeof(*vc)); } @@ -65,12 +67,13 @@ void vorbis_comment_add(vorbis_comment *vc,const char *comment){ } void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){ - char *comment=malloc(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */ + /* Length for key and value +2 for = and \0 */ + char *comment=_ogg_malloc(strlen(tag)+strlen(contents)+2); strcpy(comment, tag); strcat(comment, "="); strcat(comment, contents); vorbis_comment_add(vc, comment); - free(comment); + _ogg_free(comment); } /* This is more or less the same as strncasecmp - but that doesn't exist @@ -78,7 +81,7 @@ void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *con static int tagcompare(const char *s1, const char *s2, int n){ int c=0; while(c < n){ - if(toupper(s1[c]) != toupper(s2[c])) + if(_v_toupper(s1[c]) != _v_toupper(s2[c])) return !0; c++; } @@ -89,29 +92,30 @@ char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count){ long i; int found = 0; int taglen = strlen(tag)+1; /* +1 for the = we append */ - char *fulltag = malloc(taglen+ 1); + char *fulltag = _ogg_malloc(taglen+1); strcpy(fulltag, tag); strcat(fulltag, "="); for(i=0;icomments;i++){ if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ - if(count == found){ - free(fulltag); + if(count == found) { /* We return a pointer to the data, not a copy */ + _ogg_free(fulltag); return vc->user_comments[i] + taglen; - }else + } else { found++; + } } } - free(fulltag); + _ogg_free(fulltag); return NULL; /* didn't find anything */ } int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){ int i,count=0; int taglen = strlen(tag)+1; /* +1 for the = we append */ - char *fulltag = malloc(taglen+1); + char *fulltag = _ogg_malloc(taglen+1); strcpy(fulltag,tag); strcat(fulltag, "="); @@ -119,7 +123,8 @@ int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){ if(!tagcompare(vc->user_comments[i], fulltag, taglen)) count++; } - free(fulltag); + + _ogg_free(fulltag); return count; } @@ -201,6 +206,7 @@ void vorbis_info_clear(vorbis_info *vi){ static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ codec_setup_info *ci=vi->codec_setup; + int bs; if(!ci)return(OV_EFAULT); vi->version=oggpack_read(opb,32); @@ -209,12 +215,16 @@ static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ vi->channels=oggpack_read(opb,8); vi->rate=oggpack_read(opb,32); - vi->bitrate_upper=oggpack_read(opb,32); - vi->bitrate_nominal=oggpack_read(opb,32); - vi->bitrate_lower=oggpack_read(opb,32); + vi->bitrate_upper=(ogg_int32_t)oggpack_read(opb,32); + vi->bitrate_nominal=(ogg_int32_t)oggpack_read(opb,32); + vi->bitrate_lower=(ogg_int32_t)oggpack_read(opb,32); - ci->blocksizes[0]=1<blocksizes[1]=1<blocksizes[0]=1<blocksizes[1]=1<rate<1)goto err_out; if(vi->channels<1)goto err_out; @@ -586,7 +596,8 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v, oggpack_buffer opb; private_state *b=v->backend_state; - if(!b||vi->channels<=0){ + if(!b||vi->channels<=0||vi->channels>256){ + b = NULL; ret=OV_EFAULT; goto err_out; } @@ -645,7 +656,7 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v, memset(op_code,0,sizeof(*op_code)); if(b){ - oggpack_writeclear(&opb); + if(vi->channels>0)oggpack_writeclear(&opb); if(b->header)_ogg_free(b->header); if(b->header1)_ogg_free(b->header1); if(b->header2)_ogg_free(b->header2); diff --git a/sys/src/cmd/audio/libvorbis/lookup.c b/sys/src/cmd/audio/libvorbis/lookup.c index 3321ed3db..7cd01a44d 100644 --- a/sys/src/cmd/audio/libvorbis/lookup.c +++ b/sys/src/cmd/audio/libvorbis/lookup.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: lookup based functions - last mod: $Id: lookup.c 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/lookup.h b/sys/src/cmd/audio/libvorbis/lookup.h index f8b5b8273..ec05014f4 100644 --- a/sys/src/cmd/audio/libvorbis/lookup.h +++ b/sys/src/cmd/audio/libvorbis/lookup.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: lookup based functions - last mod: $Id: lookup.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/lookup_data.h b/sys/src/cmd/audio/libvorbis/lookup_data.h index 2424a1b38..7935715a7 100644 --- a/sys/src/cmd/audio/libvorbis/lookup_data.h +++ b/sys/src/cmd/audio/libvorbis/lookup_data.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: lookup data; generated by lookups.pl; edit there - last mod: $Id: lookup_data.h 16037 2009-05-26 21:10:58Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/lpc.c b/sys/src/cmd/audio/libvorbis/lpc.c index 488041afc..b4213a5dd 100644 --- a/sys/src/cmd/audio/libvorbis/lpc.c +++ b/sys/src/cmd/audio/libvorbis/lpc.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: LPC low level routines - last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/lpc.h b/sys/src/cmd/audio/libvorbis/lpc.h index 39d237601..4f59e6d32 100644 --- a/sys/src/cmd/audio/libvorbis/lpc.h +++ b/sys/src/cmd/audio/libvorbis/lpc.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: LPC low level routines - last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/lsp.c b/sys/src/cmd/audio/libvorbis/lsp.c index e564656b3..896cc09ee 100644 --- a/sys/src/cmd/audio/libvorbis/lsp.c +++ b/sys/src/cmd/audio/libvorbis/lsp.c @@ -6,19 +6,19 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: LSP (also called LSF) conversion routines - last mod: $Id: lsp.c 19453 2015-03-02 22:35:34Z xiphmont $ The LSP generation code is taken (with minimal modification and a few bugfixes) from "On the Computation of the LSP Frequencies" by Joseph Rothweiler (see http://www.rothweiler.us for contact info). + The paper is available at: - http://www.myown1.com/joe/lsf + https://web.archive.org/web/20110810174000/http://home.myfairpoint.net/vzenxj75/myown1/joe/lsf/index.html ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/lsp.h b/sys/src/cmd/audio/libvorbis/lsp.h index bacfb0971..68b38daf1 100644 --- a/sys/src/cmd/audio/libvorbis/lsp.h +++ b/sys/src/cmd/audio/libvorbis/lsp.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: LSP (also called LSF) conversion routines - last mod: $Id: lsp.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/mapping0.c b/sys/src/cmd/audio/libvorbis/mapping0.c index 73a8c8730..34cd1b44b 100644 --- a/sys/src/cmd/audio/libvorbis/mapping0.c +++ b/sys/src/cmd/audio/libvorbis/mapping0.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: channel mapping 0 implementation - last mod: $Id: mapping0.c 19441 2015-01-21 01:17:41Z xiphmont $ ********************************************************************/ @@ -93,7 +92,6 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb) int i,b; vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(*info)); codec_setup_info *ci=vi->codec_setup; - memset(info,0,sizeof(*info)); if(vi->channels<=0)goto err_out; b=oggpack_read(opb,1); @@ -717,6 +715,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ float **pcmbundle=malloc(sizeof(*pcmbundle)*vi->channels); int *zerobundle=malloc(sizeof(*zerobundle)*vi->channels); + int *nonzero =malloc(sizeof(*nonzero)*vi->channels); void **floormemo=malloc(sizeof(*floormemo)*vi->channels); diff --git a/sys/src/cmd/audio/libvorbis/masking.h b/sys/src/cmd/audio/libvorbis/masking.h index 3576ab788..7a196a37e 100644 --- a/sys/src/cmd/audio/libvorbis/masking.h +++ b/sys/src/cmd/audio/libvorbis/masking.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: masking curve data for psychoacoustics - last mod: $Id: masking.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/mdct.c b/sys/src/cmd/audio/libvorbis/mdct.c index d6db82227..09c905826 100644 --- a/sys/src/cmd/audio/libvorbis/mdct.c +++ b/sys/src/cmd/audio/libvorbis/mdct.c @@ -6,13 +6,12 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: normalized modified discrete cosine transform power of two length transform only [64 <= n ] - last mod: $Id: mdct.c 16227 2009-07-08 06:58:46Z xiphmont $ Original algorithm adapted long ago from _The use of multirate filter banks for coding of high quality digital audio_, by T. Sporer, @@ -495,8 +494,7 @@ void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){ int n2=n>>1; int n4=n>>2; int n8=n>>3; - DATA_TYPE *wbuf=malloc(n*sizeof(DATA_TYPE)); /* forward needs working space */ - DATA_TYPE *w=wbuf; + DATA_TYPE *w=malloc(n*sizeof(*w)); /* forward needs working space */ DATA_TYPE *w2=w+n2; /* rotate */ @@ -561,5 +559,5 @@ void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){ w+=2; T+=2; } - free(wbuf); + free(w); } diff --git a/sys/src/cmd/audio/libvorbis/mdct.h b/sys/src/cmd/audio/libvorbis/mdct.h index 3ed94333c..ceaea617a 100644 --- a/sys/src/cmd/audio/libvorbis/mdct.h +++ b/sys/src/cmd/audio/libvorbis/mdct.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: modified discrete cosine transform prototypes - last mod: $Id: mdct.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/misc.h b/sys/src/cmd/audio/libvorbis/misc.h index 73b451989..eac5160e8 100644 --- a/sys/src/cmd/audio/libvorbis/misc.h +++ b/sys/src/cmd/audio/libvorbis/misc.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: miscellaneous prototypes - last mod: $Id: misc.h 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/floor_all.h b/sys/src/cmd/audio/libvorbis/modes/floor_all.h index 4292be326..2e3d4a501 100644 --- a/sys/src/cmd/audio/libvorbis/modes/floor_all.h +++ b/sys/src/cmd/audio/libvorbis/modes/floor_all.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: key floor settings - last mod: $Id: floor_all.h 17050 2010-03-26 01:34:42Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/psych_11.h b/sys/src/cmd/audio/libvorbis/modes/psych_11.h index 844a8ed3c..9d8ed357e 100644 --- a/sys/src/cmd/audio/libvorbis/modes/psych_11.h +++ b/sys/src/cmd/audio/libvorbis/modes/psych_11.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 11kHz settings - last mod: $Id: psych_11.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/psych_16.h b/sys/src/cmd/audio/libvorbis/modes/psych_16.h index 1c10b3954..49cbf7c4b 100644 --- a/sys/src/cmd/audio/libvorbis/modes/psych_16.h +++ b/sys/src/cmd/audio/libvorbis/modes/psych_16.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 16kHz settings - last mod: $Id: psych_16.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/psych_44.h b/sys/src/cmd/audio/libvorbis/modes/psych_44.h index f05c03265..d15509b71 100644 --- a/sys/src/cmd/audio/libvorbis/modes/psych_44.h +++ b/sys/src/cmd/audio/libvorbis/modes/psych_44.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: key psychoacoustic settings for 44.1/48kHz - last mod: $Id: psych_44.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/psych_8.h b/sys/src/cmd/audio/libvorbis/modes/psych_8.h index 0e2dd5737..a19817f76 100644 --- a/sys/src/cmd/audio/libvorbis/modes/psych_8.h +++ b/sys/src/cmd/audio/libvorbis/modes/psych_8.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 8kHz psychoacoustic settings - last mod: $Id: psych_8.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/residue_16.h b/sys/src/cmd/audio/libvorbis/modes/residue_16.h index dcaca5451..15e161c86 100644 --- a/sys/src/cmd/audio/libvorbis/modes/residue_16.h +++ b/sys/src/cmd/audio/libvorbis/modes/residue_16.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel residue templates 16/22kHz - last mod: $Id: residue_16.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/residue_44.h b/sys/src/cmd/audio/libvorbis/modes/residue_44.h index 236c18341..3f982695a 100644 --- a/sys/src/cmd/audio/libvorbis/modes/residue_44.h +++ b/sys/src/cmd/audio/libvorbis/modes/residue_44.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel residue templates for 32/44.1/48kHz - last mod: $Id: residue_44.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/residue_44p51.h b/sys/src/cmd/audio/libvorbis/modes/residue_44p51.h index a52cc5245..8ac5f65e6 100644 --- a/sys/src/cmd/audio/libvorbis/modes/residue_44p51.h +++ b/sys/src/cmd/audio/libvorbis/modes/residue_44p51.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel residue templates for 32/44.1/48kHz uncoupled - last mod: $Id: residue_44p51.h 19013 2013-11-12 04:04:50Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/residue_44u.h b/sys/src/cmd/audio/libvorbis/modes/residue_44u.h index 92c4a09ce..2f3595e49 100644 --- a/sys/src/cmd/audio/libvorbis/modes/residue_44u.h +++ b/sys/src/cmd/audio/libvorbis/modes/residue_44u.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel residue templates for 32/44.1/48kHz uncoupled - last mod: $Id: residue_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/residue_8.h b/sys/src/cmd/audio/libvorbis/modes/residue_8.h index 94c6d84c4..b836f79c8 100644 --- a/sys/src/cmd/audio/libvorbis/modes/residue_8.h +++ b/sys/src/cmd/audio/libvorbis/modes/residue_8.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel residue templates 8/11kHz - last mod: $Id: residue_8.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_11.h b/sys/src/cmd/audio/libvorbis/modes/setup_11.h index 4c2d619ca..5ade5dd16 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_11.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_11.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 11kHz settings - last mod: $Id: setup_11.h 16894 2010-02-12 20:32:12Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_16.h b/sys/src/cmd/audio/libvorbis/modes/setup_16.h index 336007f98..8b2daafa3 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_16.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_16.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 16kHz settings - last mod: $Id: setup_16.h 16894 2010-02-12 20:32:12Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_22.h b/sys/src/cmd/audio/libvorbis/modes/setup_22.h index 4fd5e5711..eef5a4e7d 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_22.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_22.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 22kHz settings - last mod: $Id: setup_22.h 17026 2010-03-25 05:00:27Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_32.h b/sys/src/cmd/audio/libvorbis/modes/setup_32.h index 2275ac961..f87cb767d 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_32.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_32.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel settings for 32kHz - last mod: $Id: setup_32.h 16894 2010-02-12 20:32:12Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_44.h b/sys/src/cmd/audio/libvorbis/modes/setup_44.h index 3b88a89ac..12d592808 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_44.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_44.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel settings for 44.1/48kHz - last mod: $Id: setup_44.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_44p51.h b/sys/src/cmd/audio/libvorbis/modes/setup_44p51.h index 67d997960..4d49173ff 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_44p51.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_44p51.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel settings for 44.1/48kHz 5.1 surround modes - last mod: $Id: setup_44p51.h 19013 2013-11-12 04:04:50Z giles $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_44u.h b/sys/src/cmd/audio/libvorbis/modes/setup_44u.h index 568b5f895..2dd8bf701 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_44u.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_44u.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: toplevel settings for 44.1/48kHz uncoupled modes - last mod: $Id: setup_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_8.h b/sys/src/cmd/audio/libvorbis/modes/setup_8.h index 14c48374f..16b02e01b 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_8.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_8.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: 8kHz settings - last mod: $Id: setup_8.h 16894 2010-02-12 20:32:12Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/modes/setup_X.h b/sys/src/cmd/audio/libvorbis/modes/setup_X.h index a69f5d40a..27807c10b 100644 --- a/sys/src/cmd/audio/libvorbis/modes/setup_X.h +++ b/sys/src/cmd/audio/libvorbis/modes/setup_X.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: catch-all toplevel settings for q modes only - last mod: $Id: setup_X.h 16894 2010-02-12 20:32:12Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/os.h b/sys/src/cmd/audio/libvorbis/os.h index 987875334..138cd7e9d 100644 --- a/sys/src/cmd/audio/libvorbis/os.h +++ b/sys/src/cmd/audio/libvorbis/os.h @@ -8,12 +8,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: #ifdef jail to whip a few platforms into the UNIX ideal. - last mod: $Id: os.h 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ @@ -31,7 +30,7 @@ # ifdef __GNUC__ # define STIN static __inline__ -# elif _WIN32 +# elif defined(_WIN32) # define STIN static __inline # else # define STIN static @@ -65,7 +64,7 @@ void *_alloca(size_t size); # define FAST_HYPOT hypot #endif -#endif +#endif /* _V_IFDEFJAIL_H_ */ #ifdef HAVE_ALLOCA_H # include @@ -85,7 +84,7 @@ void *_alloca(size_t size); /* Special i386 GCC implementation */ -#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) +#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) && !defined(__SSE2_MATH__) # define VORBIS_FPU_CONTROL /* both GCC and MSVC are kinda stupid about rounding/casting to int. Because of encapsulation constraints (GCC can't see inside the asm @@ -124,8 +123,7 @@ static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise, /* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the * 64 bit compiler and doesn't work on arm. */ -#if defined(_MSC_VER) && !defined(_WIN64) && \ - !defined(_WIN32_WCE) && !defined(_M_ARM) +#if defined(_MSC_VER) && defined(_M_IX86) && !defined(_WIN32_WCE) # define VORBIS_FPU_CONTROL typedef ogg_int16_t vorbis_fpu_control; @@ -152,7 +150,7 @@ static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ /* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be done safely because all x86_64 CPUs supports SSE2. */ -#if (defined(_MSC_VER) && defined(_WIN64)) || (defined(__GNUC__) && defined (__x86_64__)) +#if (defined(_MSC_VER) && defined(_M_X64)) || (defined(__GNUC__) && defined (__SSE2_MATH__)) # define VORBIS_FPU_CONTROL typedef ogg_int16_t vorbis_fpu_control; @@ -179,7 +177,7 @@ static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ typedef int vorbis_fpu_control; -static int vorbis_ftoi(double f){ +STIN int vorbis_ftoi(double f){ /* Note: MSVC and GCC (at least on some systems) round towards zero, thus, the floor() call is required to ensure correct roudning of negative numbers */ diff --git a/sys/src/cmd/audio/libvorbis/psy.c b/sys/src/cmd/audio/libvorbis/psy.c index 19183ccf5..192f4a75b 100644 --- a/sys/src/cmd/audio/libvorbis/psy.c +++ b/sys/src/cmd/audio/libvorbis/psy.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: psychoacoustics not including preecho - last mod: $Id: psy.c 18077 2011-09-02 02:49:00Z giles $ ********************************************************************/ @@ -602,11 +601,12 @@ static void bark_noise_hybridmp(int n,const long *b, XY[i] = tXY; } - for (i = 0, x = 0.f;; i++, x += 1.f) { + for (i = 0, x = 0.f; i < n; i++, x += 1.f) { lo = b[i] >> 16; - if( lo>=0 ) break; hi = b[i] & 0xffff; + if( lo>=0 || -lo>=n ) break; + if( hi>=n ) break; tN = N[hi] + N[-lo]; tX = X[hi] - X[-lo]; @@ -618,17 +618,17 @@ static void bark_noise_hybridmp(int n,const long *b, B = tN * tXY - tX * tY; D = tN * tXX - tX * tX; R = (A + x * B) / D; - if (R < 0.f) - R = 0.f; + if (R < 0.f) R = 0.f; noise[i] = R - offset; } - for ( ;; i++, x += 1.f) { + for ( ; i < n; i++, x += 1.f) { lo = b[i] >> 16; hi = b[i] & 0xffff; - if(hi>=n)break; + if( lo<0 || lo>=n ) break; + if( hi>=n ) break; tN = N[hi] - N[lo]; tX = X[hi] - X[lo]; @@ -644,6 +644,7 @@ static void bark_noise_hybridmp(int n,const long *b, noise[i] = R - offset; } + for ( ; i < n; i++, x += 1.f) { R = (A + x * B) / D; @@ -657,10 +658,11 @@ static void bark_noise_hybridmp(int n,const long *b, return; } - for (i = 0, x = 0.f;; i++, x += 1.f) { + for (i = 0, x = 0.f; i < n; i++, x += 1.f) { hi = i + fixed / 2; lo = hi - fixed; - if(lo>=0)break; + if ( hi>=n ) break; + if ( lo>=0 ) break; tN = N[hi] + N[-lo]; tX = X[hi] - X[-lo]; @@ -676,11 +678,12 @@ static void bark_noise_hybridmp(int n,const long *b, if (R - offset < noise[i]) noise[i] = R - offset; } - for ( ;; i++, x += 1.f) { + for ( ; i < n; i++, x += 1.f) { hi = i + fixed / 2; lo = hi - fixed; - if(hi>=n)break; + if ( hi>=n ) break; + if ( lo<0 ) break; tN = N[hi] - N[lo]; tX = X[hi] - X[lo]; diff --git a/sys/src/cmd/audio/libvorbis/psy.h b/sys/src/cmd/audio/libvorbis/psy.h index c1ea82440..d9a04e8b7 100644 --- a/sys/src/cmd/audio/libvorbis/psy.h +++ b/sys/src/cmd/audio/libvorbis/psy.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: random psychoacoustics (not including preecho) - last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/psytune.c b/sys/src/cmd/audio/libvorbis/psytune.c index 64c13171f..67223e511 100644 --- a/sys/src/cmd/audio/libvorbis/psytune.c +++ b/sys/src/cmd/audio/libvorbis/psytune.c @@ -6,13 +6,12 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: simple utility that runs audio through the psychoacoustics without encoding - last mod: $Id: psytune.c 16037 2009-05-26 21:10:58Z xiphmont $ ********************************************************************/ @@ -41,11 +40,11 @@ static vorbis_info_psy_global _psy_set0G={ 0, /* decaydBpms */ 8, /* lines per eighth octave */ - + /* thresh sample period, preecho clamp trigger threshhold, range, minenergy */ 256, {26.f,26.f,26.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -90.f, - -6.f, - + -6.f, + 0, 0., @@ -68,7 +67,7 @@ static vp_couple _vp_couple0[]={ static vorbis_info_psy _psy_set0={ ATH_Bark_dB_lineaggressive, - + -100.f, -140.f, 6.f, /* floor master att */ @@ -148,7 +147,7 @@ static vorbis_info_psy _psy_set0={ .900f, 0.f, /*11500*/ .900f, 1.f, /*16000*/ }, - + 95.f, /* even decade + 5 is important; saves an rint() later in a tight loop) */ -44., @@ -159,7 +158,7 @@ static vorbis_info_psy _psy_set0={ static vorbis_info_floor1 _floor_set0={1, {0}, - + {32}, {0}, {0}, @@ -171,12 +170,12 @@ static vorbis_info_floor1 _floor_set0={1, 88,31,243, 14,54,143,460, - - 6,3,10, 22,18,26, 41,36,47, - 69,61,78, 112,99,126, 185,162,211, + + 6,3,10, 22,18,26, 41,36,47, + 69,61,78, 112,99,126, 185,162,211, 329,282,387, 672,553,825 }, - + 60,30,400, 20,8,1,18., 20,600, @@ -184,8 +183,8 @@ static vorbis_info_floor1 _floor_set0={1, static vorbis_info_mapping0 mapping_info={1,{0,1},{0},{0},{0},0, 1, {0},{1}}; -static codec_setup_info codec_setup0={ {0,0}, - 1,1,1,1,1,0,1, +static codec_setup_info codec_setup0={ {0,0}, + 1,1,1,1,1,0,1, {NULL}, {0},{&mapping_info}, {0},{NULL}, @@ -194,7 +193,7 @@ static codec_setup_info codec_setup0={ {0,0}, {NULL}, {&_psy_set0}, &_psy_set0G}; - + static int noisy=0; void analysis(char *base,int i,float *v,int n,int bark,int dB){ if(noisy){ @@ -212,7 +211,7 @@ void analysis(char *base,int i,float *v,int n,int bark,int dB){ fprintf(of,"%g ",toBARK(22050.f*j/n)); else fprintf(of,"%g ",(float)j); - + if(dB){ fprintf(of,"%g\n",todB(v+j)); }else{ @@ -269,7 +268,7 @@ int main(int argc,char *argv[]){ framesize=atoi(argv[0]); argv++; } - + vi.channels=2; vi.codec_setup=&codec_setup0; @@ -292,7 +291,7 @@ int main(int argc,char *argv[]){ /* we cheat on the WAV header; we just bypass 44 bytes and never verify that it matches 16bit/stereo/44.1kHz. */ - + fread(buffer,1,44,stdin); fwrite(buffer,1,44,stdout); memset(buffer,0,framesize*2); @@ -302,10 +301,10 @@ int main(int argc,char *argv[]){ fprintf(stderr,"Processing for frame size %d...\n",framesize); while(!eos){ - long bytes=fread(buffer2,1,framesize*2,stdin); + long bytes=fread(buffer2,1,framesize*2,stdin); if(byteslocal_ampmax[i])local_ampmax[i]=temp; } if(local_ampmax[i]>ampmax)ampmax=local_ampmax[i]; - + mdct_forward(&m_look,pcm[i],mdct); for(j=0;j1500) fprintf(stderr,"%ld ",frameno+i); - + analysis("res",frameno+i,pcm[i],framesize/2,1,0); analysis("codedflr",frameno+i,flr[i],framesize/2,1,1); } @@ -416,7 +415,7 @@ int main(int argc,char *argv[]){ &vi, pcm, nonzero); - + for(i=0;i<2;i++) analysis("quant",frameno+i,pcm[i],framesize/2,1,0); @@ -426,7 +425,7 @@ int main(int argc,char *argv[]){ &mapping_info, pcm, nonzero); - + for(i=0;i<2;i++) analysis("coupled",frameno+i,pcm[i],framesize/2,1,0); @@ -434,11 +433,11 @@ int main(int argc,char *argv[]){ for(i=mapping_info.coupling_steps-1;i>=0;i--){ float *pcmM=pcm[mapping_info.coupling_mag[i]]; float *pcmA=pcm[mapping_info.coupling_ang[i]]; - + for(j=0;j0) if(ang>0){ pcmM[j]=mag; @@ -457,7 +456,7 @@ int main(int argc,char *argv[]){ } } } - + for(i=0;i<2;i++) analysis("decoupled",frameno+i,pcm[i],framesize/2,1,0); @@ -479,7 +478,7 @@ int main(int argc,char *argv[]){ } - + /* write data. Use the part of buffer we're about to shift out */ for(i=0;i<2;i++){ char *ptr=buffer+i*2; @@ -503,7 +502,7 @@ int main(int argc,char *argv[]){ ptr+=4; } } - + fprintf(stderr,"*"); fwrite(buffer,1,framesize*2,stdout); memmove(buffer,buffer2,framesize*2); diff --git a/sys/src/cmd/audio/libvorbis/registry.c b/sys/src/cmd/audio/libvorbis/registry.c index 3961ed140..db0f67b2e 100644 --- a/sys/src/cmd/audio/libvorbis/registry.c +++ b/sys/src/cmd/audio/libvorbis/registry.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: registry for time, floor, res backends and channel mappings - last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/registry.h b/sys/src/cmd/audio/libvorbis/registry.h index 3ae04776d..b823aa609 100644 --- a/sys/src/cmd/audio/libvorbis/registry.h +++ b/sys/src/cmd/audio/libvorbis/registry.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: registry for time, floor, res backends and channel mappings - last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/res0.c b/sys/src/cmd/audio/libvorbis/res0.c index ae516b878..d603eeb30 100644 --- a/sys/src/cmd/audio/libvorbis/res0.c +++ b/sys/src/cmd/audio/libvorbis/res0.c @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: residue backend 0, 1 and 2 implementation - last mod: $Id: res0.c 19441 2015-01-21 01:17:41Z xiphmont $ ********************************************************************/ @@ -31,9 +30,6 @@ #include "misc.h" #include "os.h" -//#define TRAIN_RES 1 -//#define TRAIN_RESAUX 1 - #if defined(TRAIN_RES) || defined (TRAIN_RESAUX) #include #endif diff --git a/sys/src/cmd/audio/libvorbis/scales.h b/sys/src/cmd/audio/libvorbis/scales.h index 613f796e7..3c2ae48d9 100644 --- a/sys/src/cmd/audio/libvorbis/scales.h +++ b/sys/src/cmd/audio/libvorbis/scales.h @@ -6,12 +6,11 @@ * 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/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: linear scale -> dB, Bark and Mel scales - last mod: $Id: scales.h 16227 2009-07-08 06:58:46Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/sharedbook.c b/sys/src/cmd/audio/libvorbis/sharedbook.c index 9c480dbe1..c67dae91d 100644 --- a/sys/src/cmd/audio/libvorbis/sharedbook.c +++ b/sys/src/cmd/audio/libvorbis/sharedbook.c @@ -6,16 +6,16 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: basic shared codebook operations - last mod: $Id: sharedbook.c 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ #include +#include #include #include #include @@ -50,7 +50,7 @@ long _float32_pack(float val){ sign=0x80000000; val= -val; } - exp= floor(log(val)/log(2.f)+.001); //+epsilon + exp= floor(log(val)/log(2.f)+.001); /* +epsilon */ mant=rint(ldexp(val,(VQ_FMAN-1)-exp)); exp=(exp+VQ_FEXP_BIAS)<>VQ_FMAN; if(sign)mant= -mant; - return(ldexp(mant,exp-(VQ_FMAN-1)-VQ_FEXP_BIAS)); + exp=exp-(VQ_FMAN-1)-VQ_FEXP_BIAS; + /* clamp excessive exponent values */ + if (exp>63){ + exp=63; + } + if (exp<-63){ + exp=-63; + } + return(ldexp(mant,exp)); } /* given a list of word lengths, generate a list of codewords. Works @@ -158,25 +166,34 @@ ogg_uint32_t *_make_words(char *l,long n,long sparsecount){ that's portable and totally safe against roundoff, but I haven't thought of it. Therefore, we opt on the side of caution */ long _book_maptype1_quantvals(const static_codebook *b){ - long vals=floor(pow((float)b->entries,1.f/b->dim)); + long vals; + if(b->entries<1){ + return(0); + } + vals=floor(pow((float)b->entries,1.f/b->dim)); /* the above *should* be reliable, but we'll not assume that FP is ever reliable when bitstream sync is at stake; verify via integer means that vals really is the greatest value of dim for which vals^b->bim <= b->entries */ /* treat the above as an initial guess */ + if(vals<1){ + vals=1; + } while(1){ long acc=1; long acc1=1; int i; for(i=0;idim;i++){ + if(b->entries/valsentries && acc1>b->entries){ + if(i>=b->dim && acc<=b->entries && acc1>b->entries){ return(vals); }else{ - if(acc>b->entries){ + if(idim || acc>b->entries){ vals--; }else{ vals++; @@ -285,7 +302,7 @@ int vorbis_book_init_encode(codebook *c,const static_codebook *s){ c->used_entries=s->entries; c->dim=s->dim; c->codelist=_make_words(s->lengthlist,s->entries,0); - //c->valuelist=_book_unquantize(s,s->entries,NULL); + /* c->valuelist=_book_unquantize(s,s->entries,NULL); */ c->quantvals=_book_maptype1_quantvals(s); c->minval=(int)rint(_float32_unpack(s->q_min)); c->delta=(int)rint(_float32_unpack(s->q_delta)); @@ -338,7 +355,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){ ogg_uint32_t **codep; if(codes==NULL)goto err_out; - codep = malloc(sizeof(*codep)*n); + codep=malloc(sizeof(*codep)*n); for(i=0;imode_param[mode]){ return(OV_EBADPACKET); } - + vb->W=ci->mode_param[mode]->blockflag; if(vb->W){ vb->lW=oggpack_read(opb,1); diff --git a/sys/src/cmd/audio/libvorbis/tone.c b/sys/src/cmd/audio/libvorbis/tone.c index 73afc67d4..5b8b02060 100644 --- a/sys/src/cmd/audio/libvorbis/tone.c +++ b/sys/src/cmd/audio/libvorbis/tone.c @@ -12,7 +12,7 @@ int main (int argc,char *argv[]){ int i,j; double *f; double *amp; - + if(argc<2)usage(); f=alloca(sizeof(*f)*(argc-1)); @@ -21,7 +21,7 @@ int main (int argc,char *argv[]){ i=0; while(argv[i+1]){ char *pos=strchr(argv[i+1],','); - + f[i]=atof(argv[i+1]); if(pos) amp[i]=atof(pos+1)*32767.f; diff --git a/sys/src/cmd/audio/libvorbis/vorbis/codec.h b/sys/src/cmd/audio/libvorbis/vorbis/codec.h index 8643af742..d2cd6679a 100644 --- a/sys/src/cmd/audio/libvorbis/vorbis/codec.h +++ b/sys/src/cmd/audio/libvorbis/vorbis/codec.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * ******************************************************************** function: libvorbis codec headers - last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/vorbis/vorbisenc.h b/sys/src/cmd/audio/libvorbis/vorbis/vorbisenc.h index 02332b50c..085b15e66 100644 --- a/sys/src/cmd/audio/libvorbis/vorbis/vorbisenc.h +++ b/sys/src/cmd/audio/libvorbis/vorbis/vorbisenc.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: vorbis encode-engine setup - last mod: $Id: vorbisenc.h 17021 2010-03-24 09:29:41Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/vorbis/vorbisfile.h b/sys/src/cmd/audio/libvorbis/vorbis/vorbisfile.h index 9271331e7..3d65393f5 100644 --- a/sys/src/cmd/audio/libvorbis/vorbis/vorbisfile.h +++ b/sys/src/cmd/audio/libvorbis/vorbis/vorbisfile.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $ ********************************************************************/ diff --git a/sys/src/cmd/audio/libvorbis/vorbisenc.c b/sys/src/cmd/audio/libvorbis/vorbisenc.c index b5d621e90..cf3806a6e 100644 --- a/sys/src/cmd/audio/libvorbis/vorbisenc.c +++ b/sys/src/cmd/audio/libvorbis/vorbisenc.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: simple programmatic interface for encoder mode setup - last mod: $Id: vorbisenc.c 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ @@ -685,6 +684,7 @@ int vorbis_encode_setup_init(vorbis_info *vi){ highlevel_encode_setup *hi=&ci->hi; if(ci==NULL)return(OV_EINVAL); + if(vi->channels<1||vi->channels>255)return(OV_EINVAL); if(!hi->impulse_block_p)i0=1; /* too low/high an ATH floater is nonsensical, but doesn't break anything */ @@ -1211,7 +1211,7 @@ int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg){ hi->req, hi->managed, &new_base); - if(!hi->setup)return OV_EIMPL; + if(!new_template)return OV_EIMPL; hi->setup=new_template; hi->base_setting=new_base; vorbis_encode_setup_setting(vi,vi->channels,vi->rate); diff --git a/sys/src/cmd/audio/libvorbis/vorbisfile.c b/sys/src/cmd/audio/libvorbis/vorbisfile.c index 68dc2c398..ec471f035 100644 --- a/sys/src/cmd/audio/libvorbis/vorbisfile.c +++ b/sys/src/cmd/audio/libvorbis/vorbisfile.c @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id: vorbisfile.c 19457 2015-03-03 00:15:29Z giles $ ********************************************************************/ @@ -265,6 +264,10 @@ static ogg_int64_t _get_prev_page_serial(OggVorbis_File *vf, ogg_int64_t begin, } } } + /*We started from the beginning of the stream and found nothing. + This should be impossible unless the contents of the stream changed out + from under us after we read from it.*/ + if(!begin&&vf->offset<0)return OV_EBADLINK; } /* we're not interested in the page... just the serialno and granpos. */ @@ -1231,7 +1234,6 @@ double ov_time_total(OggVorbis_File *vf,int i){ int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ ogg_stream_state work_os; - int ret; if(vf->ready_stateseekable) @@ -1254,8 +1256,12 @@ int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ vf->current_serialno); /* must set serialno */ vorbis_synthesis_restart(&vf->vd); - ret=_seek_helper(vf,pos); - if(ret)goto seek_error; + if(_seek_helper(vf,pos)) { + /* dump the machine so we're in a known state */ + vf->pcm_offset=-1; + _decode_clear(vf); + return OV_EBADLINK; + } /* we need to make sure the pcm_offset is set, but we don't want to advance the raw cursor past good packets just to get to the first @@ -1389,13 +1395,6 @@ int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ vf->bittrack=0.f; vf->samptrack=0.f; return(0); - - seek_error: - /* dump the machine so we're in a known state */ - vf->pcm_offset=-1; - ogg_stream_clear(&work_os); - _decode_clear(vf); - return OV_EBADLINK; } /* Page granularity seek (faster than sample granularity because we @@ -1965,6 +1964,7 @@ long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, long samples; if(vf->ready_stateready_state==INITSET){ @@ -1990,6 +1990,8 @@ long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, long channels=ov_info(vf,-1)->channels; long bytespersample=word * channels; vorbis_fpu_control fpu; + + if(channels<1||channels>255)return(OV_EINVAL); if(samples>length/bytespersample)samples=length/bytespersample; if(samples <= 0) @@ -2420,9 +2422,9 @@ static int _ov_d_seek_lap(OggVorbis_File *vf,double pos, /* splice */ _ov_splice(pcm,lappcm,n1,n2,ch1,ch2,w1,w2); - ret = 0; /* done */ + ret = 0; done: for(i=0;i