[FFmpeg-soc] [soc]: r4259 - libavfilter/diffs/02_ffmpeg_filters.diff

vitor subversion at mplayerhq.hu
Fri May 8 12:33:52 CEST 2009


Author: vitor
Date: Fri May  8 12:33:52 2009
New Revision: 4259

Log:
Plug some memory leaks.

Patch by Martin Storsjö - $firstname@$firstname.st

Modified:
   libavfilter/diffs/02_ffmpeg_filters.diff

Modified: libavfilter/diffs/02_ffmpeg_filters.diff
==============================================================================
--- libavfilter/diffs/02_ffmpeg_filters.diff	Fri May  8 12:11:47 2009	(r4258)
+++ libavfilter/diffs/02_ffmpeg_filters.diff	Fri May  8 12:33:52 2009	(r4259)
@@ -1,6 +1,6 @@
 Index: ffmpeg.c
 ===================================================================
---- ffmpeg.c	(revision 18726)
+--- ffmpeg.c	(revision 18769)
 +++ ffmpeg.c	(working copy)
 @@ -40,6 +40,13 @@
  #include "libavutil/avstring.h"
@@ -16,17 +16,18 @@ Index: ffmpeg.c
  #if HAVE_SYS_RESOURCE_H
  #include <sys/types.h>
  #include <sys/resource.h>
-@@ -147,6 +154,9 @@
+@@ -147,6 +154,10 @@
  static int loop_input = 0;
  static int loop_output = AVFMT_NOOUTPUTLOOP;
  static int qp_hist = 0;
 +#if CONFIG_AVFILTER
 +static char *vfilters = NULL;
++AVFilterGraph *filt_graph_all = NULL;
 +#endif
  
  static int intra_only = 0;
  static int audio_sample_rate = 44100;
-@@ -287,6 +297,13 @@
+@@ -287,6 +298,13 @@
                                  is not defined */
      int64_t       pts;       /* current pts */
      int is_start;            /* is 1 at the start and after a discontinuity */
@@ -40,7 +41,7 @@ Index: ffmpeg.c
  } AVInputStream;
  
  typedef struct AVInputFile {
-@@ -302,6 +319,183 @@
+@@ -302,6 +320,185 @@
  static struct termios oldtty;
  #endif
  
@@ -115,11 +116,12 @@ Index: ffmpeg.c
 +{
 +    AVFilterContext *curr_filter;
 +    /** filter graph containing all filters including input & output */
-+    AVFilterGraph *filt_graph_all = av_mallocz(sizeof(AVFilterGraph));
 +    AVCodecContext *codec = ost->st->codec;
 +    AVCodecContext *icodec = ist->st->codec;
 +    char args[255];
 +
++    filt_graph_all = av_mallocz(sizeof(AVFilterGraph));
++
 +    avfilter_register_all();
 +
 +    if(!(ist->input_video_filter = avfilter_open(avfilter_get_by_name("buffer"), "src")))
@@ -195,6 +197,7 @@ Index: ffmpeg.c
 +
 +        if (avfilter_graph_parse(filt_graph_all, vfilters, inputs, outputs, NULL) < 0)
 +            return -1;
++        av_freep(&vfilters);
 +    } else {
 +        if(avfilter_link(curr_filter, 0, ist->out_video_filter, 0) < 0)
 +            return -1;
@@ -224,7 +227,18 @@ Index: ffmpeg.c
  static void term_exit(void)
  {
  #if HAVE_TERMIOS_H
-@@ -892,6 +1086,9 @@
+@@ -442,6 +639,10 @@
+     av_free(audio_out2);
+     av_free(samples);
+ 
++#if CONFIG_AVFILTER
++    avfilter_uninit();
++#endif
++
+     if (received_sigterm) {
+         fprintf(stderr,
+             "Received signal %d: terminating.\n",
+@@ -892,6 +1093,9 @@
      if (nb_frames <= 0)
          return;
  
@@ -234,7 +248,7 @@ Index: ffmpeg.c
      if (ost->video_crop) {
          if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
              fprintf(stderr, "error cropping picture\n");
-@@ -903,6 +1100,7 @@
+@@ -903,6 +1107,7 @@
      } else {
          formatted_picture = in_picture;
      }
@@ -242,7 +256,7 @@ Index: ffmpeg.c
  
      final_picture = formatted_picture;
      padding_src = formatted_picture;
-@@ -920,12 +1118,14 @@
+@@ -920,12 +1125,14 @@
          }
      }
  
@@ -257,7 +271,7 @@ Index: ffmpeg.c
  
      if (ost->video_pad) {
          av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
-@@ -1193,6 +1393,10 @@
+@@ -1193,6 +1400,10 @@
      static unsigned int samples_size= 0;
      AVSubtitle subtitle, *subtitle_to_free;
      int got_subtitle;
@@ -268,7 +282,7 @@ Index: ffmpeg.c
      AVPacket avpkt;
  
      if(ist->next_pts == AV_NOPTS_VALUE)
-@@ -1313,6 +1517,15 @@
+@@ -1313,6 +1524,15 @@
                                      &buffer_to_free);
          }
  
@@ -284,7 +298,7 @@ Index: ffmpeg.c
          // preprocess audio (volume)
          if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) {
              if (audio_volume != 256) {
-@@ -1334,10 +1547,18 @@
+@@ -1334,10 +1554,18 @@
              if (pts > now)
                  usleep(pts - now);
          }
@@ -304,7 +318,7 @@ Index: ffmpeg.c
              for(i=0;i<nb_ostreams;i++) {
                  int frame_size;
  
-@@ -1360,6 +1581,9 @@
+@@ -1360,6 +1588,9 @@
                              do_audio_out(os, ost, ist, data_buf, data_size);
                              break;
                          case CODEC_TYPE_VIDEO:
@@ -314,7 +328,7 @@ Index: ffmpeg.c
                              do_video_out(os, ost, ist, &picture, &frame_size);
                              if (vstats_filename && frame_size)
                                  do_video_stats(os, ost, frame_size);
-@@ -1420,7 +1644,17 @@
+@@ -1420,7 +1651,17 @@
                          av_free_packet(&opkt);
                      }
                  }
@@ -332,7 +346,7 @@ Index: ffmpeg.c
          av_free(buffer_to_free);
          /* XXX: allocate the subtitles in the codec ? */
          if (subtitle_to_free) {
-@@ -1857,11 +2091,22 @@
+@@ -1857,11 +2098,22 @@
                          fprintf(stderr, "Cannot get resampling context\n");
                          av_exit(1);
                      }
@@ -355,7 +369,20 @@ Index: ffmpeg.c
                  break;
              case CODEC_TYPE_SUBTITLE:
                  ost->encoding_needed = 1;
-@@ -3879,6 +4124,9 @@
+@@ -2246,6 +2498,12 @@
+             avcodec_close(ist->st->codec);
+         }
+     }
++#if CONFIG_AVFILTER
++    if (filt_graph_all) {
++        avfilter_graph_destroy(filt_graph_all);
++        av_freep(&filt_graph_all);
++    }
++#endif
+ 
+     /* finished ! */
+     ret = 0;
+@@ -3879,6 +4137,9 @@
      { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" },
      { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" },
      { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" },


More information about the FFmpeg-soc mailing list