From a0a06a9832fc27d8d932af8927197c8a0150a4c7 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 11 Aug 2020 22:04:41 -0700 Subject: [PATCH] Reduce OpusFile RAM by only allowing mono/stereo (#295) --- src/opusfile/internal.h | 2 +- src/opusfile/opusfile.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/opusfile/internal.h b/src/opusfile/internal.h index e73989c..1c47eec 100644 --- a/src/opusfile/internal.h +++ b/src/opusfile/internal.h @@ -109,7 +109,7 @@ void op_fatal_impl(const char *_str,const char *_file,int _line); (OP_MIN(_offset,OP_INT64_MAX-(_amount))+(_amount)) /*The maximum channel count for any mapping we'll actually decode.*/ -# define OP_NCHANNELS_MAX (8) +# define OP_NCHANNELS_MAX (2) /*Initial state.*/ # define OP_NOTOPEN (0) diff --git a/src/opusfile/opusfile.c b/src/opusfile/opusfile.c index 23f05ef..bfd3c9e 100644 --- a/src/opusfile/opusfile.c +++ b/src/opusfile/opusfile.c @@ -3001,7 +3001,7 @@ static const float OP_STEREO_DOWNMIX[OP_NCHANNELS_MAX-2][OP_NCHANNELS_MAX][2]={ #endif #if defined(OP_FIXED_POINT) - +#if 0 /*Matrices for downmixing from the supported channel counts to stereo. The matrices with 5 or more channels are normalized to a total volume of 2.0, since most mixes sound too quiet if normalized to 1.0 (as there is generally @@ -3037,7 +3037,7 @@ static const opus_int16 OP_STEREO_DOWNMIX_Q14 {3183,5515},{4502,4502} } }; - +#endif int op_read(OggOpusFile *_of,opus_int16 *_pcm,int _buf_size,int *_li){ return op_read_native(_of,_pcm,_buf_size,_li); } @@ -3055,6 +3055,7 @@ static int op_stereo_filter(OggOpusFile *_of,void *_dst,int _dst_sz, for(i=0;i<_nsamples;i++)dst[2*i+0]=dst[2*i+1]=_src[i]; } else{ +#if 0 for(i=0;i<_nsamples;i++){ opus_int32 l; opus_int32 r; @@ -3070,6 +3071,8 @@ static int op_stereo_filter(OggOpusFile *_of,void *_dst,int _dst_sz, dst[2*i+0]=(opus_int16)OP_CLAMP(-32768,l+8192>>14,32767); dst[2*i+1]=(opus_int16)OP_CLAMP(-32768,r+8192>>14,32767); } +#endif + // noop, removed for RAM savings } } return _nsamples;