[FFmpeg-cvslog] lavfi: simplify signature for avfilter_get_audio_buffer() and friends

Stefano Sabatini git at videolan.org
Thu May 10 23:33:12 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Tue Aug 30 23:22:29 2011 +0200| [7ef0adcc2e800cb1357d4d5d7ce878c0f9a36c01] | committer: Anton Khirnov

lavfi: simplify signature for avfilter_get_audio_buffer() and friends

The additional parameters are just complicating the function interface.

Assume that a requested samples buffer will *always* have the format
specified in the requested link.

This breaks audio filtering API and ABI in theory, but since it's
unusable right now this shouldn't be a problem.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavfilter/avfilter.c |   11 ++++-------
 libavfilter/avfilter.h |   16 ++++------------
 libavfilter/defaults.c |   24 ++++++++++--------------
 3 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 9f81be7..e301ddb 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -367,16 +367,15 @@ fail:
 }
 
 AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
-                                             enum AVSampleFormat sample_fmt, int nb_samples,
-                                             uint64_t channel_layout)
+                                             int nb_samples)
 {
     AVFilterBufferRef *ret = NULL;
 
     if (link->dstpad->get_audio_buffer)
-        ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout);
+        ret = link->dstpad->get_audio_buffer(link, perms, nb_samples);
 
     if (!ret)
-        ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout);
+        ret = avfilter_default_get_audio_buffer(link, perms, nb_samples);
 
     if (ret)
         ret->type = AVMEDIA_TYPE_AUDIO;
@@ -593,9 +592,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
                samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
 
         link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms,
-                                                          samplesref->format,
-                                                          samplesref->audio->nb_samples,
-                                                          samplesref->audio->channel_layout);
+                                                          samplesref->audio->nb_samples);
         link->cur_buf->pts                = samplesref->pts;
         link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
 
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 19ac057..cf95b4b 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -387,8 +387,7 @@ struct AVFilterPad {
      * Input audio pads only.
      */
     AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
-                                           enum AVSampleFormat sample_fmt, int nb_samples,
-                                           uint64_t channel_layout);
+                                           int nb_samples);
 
     /**
      * Callback called after the slices of a frame are completely sent. If
@@ -473,9 +472,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
 
 /** default handler for get_audio_buffer() for audio inputs */
 AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
-                                                     enum AVSampleFormat sample_fmt,
-                                                     int nb_samples,
-                                                     uint64_t channel_layout);
+                                                     int nb_samples);
 
 /**
  * A helper for query_formats() which sets all links to the same list of
@@ -505,8 +502,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
 
 /** get_audio_buffer() handler for filters which simply pass audio along */
 AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
-                                                  enum AVSampleFormat sample_fmt, int nb_samples,
-                                                  uint64_t channel_layout);
+                                                  int nb_samples);
 
 /**
  * Filter definition. This defines the pads a filter contains, and all the
@@ -689,16 +685,12 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int
  * @param link           the output link to the filter from which the buffer will
  *                       be requested
  * @param perms          the required access permissions
- * @param sample_fmt     the format of each sample in the buffer to allocate
  * @param nb_samples     the number of samples per channel
- * @param channel_layout the number and type of channels per sample in the buffer to allocate
- * @param planar         audio data layout - planar or packed
  * @return               A reference to the samples. This must be unreferenced with
  *                       avfilter_unref_buffer when you are finished with it.
  */
 AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
-                                             enum AVSampleFormat sample_fmt, int nb_samples,
-                                             uint64_t channel_layout);
+                                             int nb_samples);
 
 /**
  * Create an audio buffer reference wrapped around an already
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 7c75ab9..df05c06 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -58,25 +58,24 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
 }
 
 AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
-                                                     enum AVSampleFormat sample_fmt, int nb_samples,
-                                                     uint64_t channel_layout)
+                                                     int nb_samples)
 {
     AVFilterBufferRef *samplesref = NULL;
     uint8_t **data;
-    int planar      = av_sample_fmt_is_planar(sample_fmt);
-    int nb_channels = av_get_channel_layout_nb_channels(channel_layout);
+    int planar      = av_sample_fmt_is_planar(link->format);
+    int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
     int planes      = planar ? nb_channels : 1;
     int linesize;
 
     if (!(data = av_mallocz(sizeof(*data) * planes)))
         goto fail;
 
-    if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, sample_fmt, 0) < 0)
+    if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0)
         goto fail;
 
     samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
-                                                           nb_samples, sample_fmt,
-                                                           channel_layout);
+                                                           nb_samples, link->format,
+                                                           link->channel_layout);
     if (!samplesref)
         goto fail;
 
@@ -142,9 +141,8 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa
         outlink = inlink->dst->outputs[0];
 
     if (outlink) {
-        outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE, samplesref->format,
-                                                             samplesref->audio->nb_samples,
-                                                             samplesref->audio->channel_layout);
+        outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE,
+                                                             samplesref->audio->nb_samples);
         outlink->out_buf->pts                = samplesref->pts;
         outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate;
         avfilter_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
@@ -246,9 +244,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms,
 }
 
 AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
-                                                  enum AVSampleFormat sample_fmt, int nb_samples,
-                                                  uint64_t channel_layout)
+                                                  int nb_samples)
 {
-    return avfilter_get_audio_buffer(link->dst->outputs[0], perms, sample_fmt,
-                                     nb_samples, channel_layout);
+    return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples);
 }



More information about the ffmpeg-cvslog mailing list