[FFmpeg-devel] [PATCH 6/7] ffmpeg: dynamically allocate bitstream_filters

Aurélien Jacobs aurel
Fri Aug 13 20:24:19 CEST 2010


From: Aurelien Jacobs <aurel at gnuage.org>

---
 ffmpeg.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 9e55f01..3674836 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -243,7 +243,8 @@ static short *samples;
 static AVBitStreamFilterContext *video_bitstream_filters=NULL;
 static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
 static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
-static AVBitStreamFilterContext *bitstream_filters[MAX_FILES][MAX_STREAMS];
+static AVBitStreamFilterContext **bitstream_filters[MAX_FILES] = {NULL};
+static int nb_bitstream_filters[MAX_FILES] = {0};
 
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
 
@@ -605,6 +606,7 @@ static int ffmpeg_exit(int ret)
         }
         av_metadata_free(&s->metadata);
         av_free(s);
+        av_free(bitstream_filters[i]);
     }
     for(i=0;i<nb_input_files;i++) {
         av_close_input_file(input_files[i]);
@@ -3388,6 +3390,7 @@ static void new_video_stream(AVFormatContext *oc)
         ffmpeg_exit(1);
     }
     avcodec_get_context_defaults2(st->codec, AVMEDIA_TYPE_VIDEO);
+    GROW_ARRAY(bitstream_filters[nb_output_files], oc->nb_streams);
     bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
     video_bitstream_filters= NULL;
 
@@ -3527,6 +3530,7 @@ static void new_audio_stream(AVFormatContext *oc)
     }
     avcodec_get_context_defaults2(st->codec, AVMEDIA_TYPE_AUDIO);
 
+    GROW_ARRAY(bitstream_filters[nb_output_files], oc->nb_streams);
     bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters;
     audio_bitstream_filters= NULL;
 
@@ -3600,6 +3604,7 @@ static void new_subtitle_stream(AVFormatContext *oc)
     }
     avcodec_get_context_defaults2(st->codec, AVMEDIA_TYPE_SUBTITLE);
 
+    GROW_ARRAY(bitstream_filters[nb_output_files], oc->nb_streams);
     bitstream_filters[nb_output_files][oc->nb_streams - 1]= subtitle_bitstream_filters;
     subtitle_bitstream_filters= NULL;
 
-- 
1.7.1




More information about the ffmpeg-devel mailing list