summaryrefslogtreecommitdiff
authorMichael Niedermayer <michaelni@gmx.at>2013-01-13 14:57:56 (GMT)
committer Michael Niedermayer <michaelni@gmx.at>2013-01-13 15:04:41 (GMT)
commita34aee4646284eae67c1317d7baf82c2b3012aba (patch)
treee154a7b35365c0f121d8d57a520875edea9bccda
parentb481d09bd9c7b3cba617a7811d7015ea0472e4ee (diff)
downloadffmpeg-a34aee4646284eae67c1317d7baf82c2b3012aba.zip
ffmpeg-a34aee4646284eae67c1317d7baf82c2b3012aba.tar.gz
ffmpeg-a34aee4646284eae67c1317d7baf82c2b3012aba.tar.bz2
swr: limit buffer size for silence injection
This reduces memory usage for unreasonable large silence injections Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat
-rw-r--r--libswresample/swresample.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 6f1c41b..1942302 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -818,6 +818,13 @@ int swr_inject_silence(struct SwrContext *s, int count){
if(count <= 0)
return 0;
+#define MAX_SILENCE_STEP 16384
+ while (count > MAX_SILENCE_STEP) {
+ if ((ret = swr_inject_silence(s, MAX_SILENCE_STEP)) < 0)
+ return ret;
+ count -= MAX_SILENCE_STEP;
+ }
+
if((ret=swri_realloc_audio(&s->silence, count))<0)
return ret;