[FFmpeg-cvslog] swr: limit buffer size for silence injection

Michael Niedermayer git at videolan.org
Sun Jan 13 16:04:53 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jan 13 15:57:56 2013 +0100| [a34aee4646284eae67c1317d7baf82c2b3012aba] | committer: Michael Niedermayer

swr: limit buffer size for silence injection

This reduces memory usage for unreasonable large silence injections

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a34aee4646284eae67c1317d7baf82c2b3012aba
---

 libswresample/swresample.c |    7 +++++++
 1 file changed, 7 insertions(+)

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;
 



More information about the ffmpeg-cvslog mailing list