Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2013-05-08 21:25:52 +0400
committerTimothy B. Terriberry <tterribe@xiph.org>2013-05-08 21:37:10 +0400
commitdc58579c2c7e060084554018e9a2e8c25097a255 (patch)
treed9ce39180d3eb8dfeb76df4378c56fd44d32f6f8 /silk/resampler_structs.h
parentc41a81680c745f3a472af1771fbdb5830694e6a4 (diff)
Fix several memory errors in the SILK resampler.
1) The memcpy's were using sizeof(opus_int32), but the type of the local buffer was opus_int16. 2) Because the size was wrong, this potentially allowed the source and destination regions of the memcpy overlap. I _believe_ that nSamplesIn is at least fs_in_khZ, which is at least 8. Since RESAMPLER_ORDER_FIR_12 is only 8, I don't think that's a problem once you fix the type size. 3) The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the data stored in it was actually _twice_ the input batch size (nSamplesIn<<1). Because this never blew up in testing, I suspect that in practice the batch sizes are reasonable enough that none of these things was ever a problem, but proving that seems non-obvious. This patch just converts the whole thing to use CELT's vararrays. This fixes the buffer size problems (since we allocate a buffer with the actual size we use) and gets these large buffers off the stack on devices using the pseudo-stack. It also fixes the memcpy problems by changing the sizeof to opus_int16. It turns out sFIR, which saved state between calls, was being used elsewhere as opus_int32, so this converts it to a union to make this sharing explicit.
Diffstat (limited to 'silk/resampler_structs.h')
-rw-r--r--silk/resampler_structs.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/silk/resampler_structs.h b/silk/resampler_structs.h
index 4c28bd0a..d1a0b951 100644
--- a/silk/resampler_structs.h
+++ b/silk/resampler_structs.h
@@ -37,7 +37,10 @@ extern "C" {
typedef struct _silk_resampler_state_struct{
opus_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */
- opus_int32 sFIR[ SILK_RESAMPLER_MAX_FIR_ORDER ];
+ union{
+ opus_int32 i32[ SILK_RESAMPLER_MAX_FIR_ORDER ];
+ opus_int16 i16[ SILK_RESAMPLER_MAX_FIR_ORDER ];
+ } sFIR;
opus_int16 delayBuf[ 48 ];
opus_int resampler_function;
opus_int batchSize;