]> git.sesse.net Git - ffmpeg/commitdiff
swr: limit buffer size for silence injection
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 13 Jan 2013 14:57:56 +0000 (15:57 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 13 Jan 2013 15:04:41 +0000 (16:04 +0100)
This reduces memory usage for unreasonable large silence injections

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/swresample.c

index 6f1c41bc5c377c3d4886b0f5016c9b1614ad115b..19423024ba3afa3c3b794d47c1b6b798cc1c5988 100644 (file)
@@ -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;