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

Stefano Sabatini git at videolan.org
Mon Sep 12 19:11:37 CEST 2011


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

lavfi: simplify signature for avfilter_get_audio_buffer() and friends

The additional parameters were never used and are complicating the
function interface. Also, they were inconsistent with the way the
video API works.

So this assumes that a requested samples buffer will have *always* the
format specified in the requested link.

This breaks audio filtering API and ABI.

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

 doc/APIchanges             |    4 ++++
 libavfilter/af_aresample.c |    5 +----
 libavfilter/avfilter.c     |   14 +++++---------
 libavfilter/avfilter.h     |   17 ++++++-----------
 libavfilter/defaults.c     |   25 ++++++++++---------------
 libavfilter/src_movie.c    |    4 +---
 6 files changed, 27 insertions(+), 42 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index d600294..425a337 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-09-xx - xxxxxxx - lavfi 2.x.0
+  Simplify signature for avfilter_get_audio_buffer(), make it
+  consistent with avfilter_get_video_buffer().
+
 2011-09-06 - xxxxxxx - lavfi 2.39.0
   Rename libavfilter/vsink_buffer.h to libavfilter/buffersink.h.
 
diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index 31e1b5a..fa26788 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -270,10 +270,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
 
         aresample->outsamplesref = avfilter_get_audio_buffer(outlink,
                                                             AV_PERM_WRITE | AV_PERM_REUSE2,
-                                                            inlink->format,
-                                                            requested_out_nb_samples,
-                                                            insamplesref->audio->channel_layout,
-                                                            insamplesref->audio->planar);
+                                                             requested_out_nb_samples);
 
         avfilter_copy_buffer_ref_props(aresample->outsamplesref, insamplesref);
         aresample->outsamplesref->pts =
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index d736986..3480150 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -447,17 +447,16 @@ fail:
     return NULL;
 }
 
-AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
-                                             enum AVSampleFormat sample_fmt, int nb_samples,
-                                             int64_t channel_layout, int planar)
+AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link,
+                                             int perms, 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, planar);
+        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, planar);
+        ret = avfilter_default_get_audio_buffer(link, perms, nb_samples);
 
     if (ret)
         ret->type = AVMEDIA_TYPE_AUDIO;
@@ -664,10 +663,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->planar);
+                                                          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 b0811ac..51f1a6b 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -390,9 +390,7 @@ struct AVFilterPad {
      *
      * Input audio pads only.
      */
-    AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
-                                           enum AVSampleFormat sample_fmt, int nb_samples,
-                                           int64_t channel_layout, int planar);
+    AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, int nb_samples);
 
     /**
      * Callback called after the slices of a frame are completely sent. If
@@ -476,9 +474,8 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
                                                      int perms, int w, int h);
 
 /** 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,
-                                                     int64_t channel_layout, int planar);
+AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link,
+                                                     int perms, int nb_samples);
 
 /**
  * Helpers for query_formats() which set all links to the same list of
@@ -510,9 +507,8 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
                                                   int perms, int w, int h);
 
 /** 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 size,
-                                                  int64_t channel_layout, int planar);
+AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link,
+                                                  int perms, int nb_samples);
 
 /**
  * Filter definition. This defines the pads a filter contains, and all the
@@ -739,8 +735,7 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int lin
  *                       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,
-                                             int64_t channel_layout, int planar);
+                                             int nb_samples);
 
 /**
  * Create an audio buffer reference wrapped around an already
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 503036d..c231f75 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -81,24 +81,23 @@ 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,
-                                                     int64_t channel_layout, int planar)
+                                                     int nb_samples)
 {
     AVFilterBufferRef *samplesref = NULL;
     int linesize[8];
     uint8_t *data[8];
-    int nb_channels = av_get_channel_layout_nb_channels(channel_layout);
+    int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
 
     /* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
     if (av_samples_alloc(data, linesize,
-                         nb_channels, nb_samples, sample_fmt,
-                         planar, 16) < 0)
+                         nb_channels, nb_samples, link->format,
+                         link->planar, 16) < 0)
         return NULL;
 
     samplesref =
         avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
-                                                  nb_samples, sample_fmt,
-                                                  channel_layout, planar);
+                                                  nb_samples, link->format,
+                                                  link->channel_layout, link->planar);
     if (!samplesref) {
         av_free(data[0]);
         return NULL;
@@ -160,10 +159,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,
-                                                             samplesref->audio->planar);
+        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));
@@ -259,10 +256,8 @@ 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 size,
-                                                  int64_t channel_layout, int packed)
+                                                  int nb_samples)
 {
-    return avfilter_get_audio_buffer(link->dst->outputs[0], perms, sample_fmt,
-                                     size, channel_layout, packed);
+    return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples);
 }
 
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index c266654..a90e738 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -424,9 +424,7 @@ static int amovie_get_samples(AVFilterLink *outlink)
     if (decoded_data_size > 0) {
         int nb_samples = decoded_data_size / movie->bps / movie->codec_ctx->channels;
         movie->samplesref =
-            avfilter_get_audio_buffer(outlink, AV_PERM_WRITE,
-                                      movie->codec_ctx->sample_fmt, nb_samples,
-                                      movie->codec_ctx->channel_layout, 0);
+            avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
         memcpy(movie->samplesref->data[0], movie->samples_buf, decoded_data_size);
         movie->samplesref->pts = movie->pkt.pts;
         movie->samplesref->pos = movie->pkt.pos;



More information about the ffmpeg-cvslog mailing list