[FFmpeg-cvslog] lavfi/audio: don't set cur_buf in ff_filter_samples().

Anton Khirnov git at videolan.org
Thu Jun 21 22:41:01 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Jun 17 10:21:49 2012 +0200| [e026c9b390102fc8b77e6d49ba7a6db7b7c80324] | committer: Anton Khirnov

lavfi/audio: don't set cur_buf in ff_filter_samples().

It's redundant, since the input buffer is passed as a parameter to the
filter_samples() callback, and can lead to stale pointers remaining on
the link.

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

 libavfilter/audio.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index a6fef9d..72e2ced 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -176,6 +176,7 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
 {
     void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
     AVFilterPad *dst = link->dstpad;
+    AVFilterBufferRef *buf_out;
 
     FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
 
@@ -189,21 +190,21 @@ void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
                "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n",
                samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
 
-        link->cur_buf = ff_default_get_audio_buffer(link, dst->min_perms,
-                                                    samplesref->audio->nb_samples);
-        link->cur_buf->pts                = samplesref->pts;
-        link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
+        buf_out = ff_default_get_audio_buffer(link, dst->min_perms,
+                                              samplesref->audio->nb_samples);
+        buf_out->pts                = samplesref->pts;
+        buf_out->audio->sample_rate = samplesref->audio->sample_rate;
 
         /* Copy actual data into new samples buffer */
-        av_samples_copy(link->cur_buf->extended_data, samplesref->extended_data,
+        av_samples_copy(buf_out->extended_data, samplesref->extended_data,
                         0, 0, samplesref->audio->nb_samples,
                         av_get_channel_layout_nb_channels(link->channel_layout),
                         link->format);
 
         avfilter_unref_buffer(samplesref);
     } else
-        link->cur_buf = samplesref;
+        buf_out = samplesref;
 
-    filter_samples(link, link->cur_buf);
+    filter_samples(link, buf_out);
 }
 



More information about the ffmpeg-cvslog mailing list