]> git.sesse.net Git - ffmpeg/commitdiff
lavfi/abuffersink: add sample_rates field to AVABufferSinkParams
authorStefano Sabatini <stefasab@gmail.com>
Sun, 3 Feb 2013 18:33:58 +0000 (19:33 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Sun, 24 Feb 2013 22:21:28 +0000 (23:21 +0100)
Allow to select sample rates.

doc/APIchanges
libavfilter/buffersink.h
libavfilter/sink_buffer.c
libavfilter/version.h

index ca52aa4eefcbb6541e623a874a5bbc4cd5b8c27b..8535d9fe36332a9d06fc4ae9512353f439a48ab7 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2012-10-22
 
 API changes, most recent first:
 
+2013-02-24 - xxxxxx - lavfi 3.41.100 - buffersink.h
+  Add sample_rates field to AVABufferSinkParams.
+
 2013-01-17 - a1a707f - lavf 54.61.100
   Add av_codec_get_tag2().
 
index 825a36a0a40134edc3b8780b7431d990bf06e738..6f8ac5cdf10a8be2b40d1748df3e1de4db05d7c5 100644 (file)
@@ -48,6 +48,7 @@ typedef struct {
     const int64_t *channel_layouts;         ///< list of allowed channel layouts, terminated by -1
     const int *channel_counts;              ///< list of allowed channel counts, terminated by -1
     int all_channel_counts;                 ///< if not 0, accept any channel count or layout
+    int *sample_rates;                      ///< list of allowed sample rates, terminated by -1
 } AVABufferSinkParams;
 
 /**
index 0edf9c5e0b25a3d55f9d657ec4a59f321e5db8e2..ea0cf06e93e49074279d34c0ec4020d02bc8863e 100644 (file)
@@ -62,6 +62,7 @@ typedef struct {
     enum AVSampleFormat *sample_fmts;       ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
     int64_t *channel_layouts;               ///< list of accepted channel layouts, terminated by -1
     int all_channel_counts;
+    int *sample_rates;                      ///< list of accepted sample rates, terminated by -1
 } BufferSinkContext;
 
 #define FIFO_INIT_SIZE 8
@@ -303,6 +304,11 @@ static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaq
         if (!buf->sample_fmts)
             return AVERROR(ENOMEM);
     }
+    if (params && params->sample_rates) {
+        buf->sample_rates = ff_copy_int_list(params->sample_rates);
+        if (!buf->sample_rates)
+            return AVERROR(ENOMEM);
+    }
     if (params && (params->channel_layouts || params->channel_counts)) {
         if (params->all_channel_counts) {
             av_log(ctx, AV_LOG_ERROR,
@@ -324,6 +330,7 @@ static av_cold void asink_uninit(AVFilterContext *ctx)
     BufferSinkContext *buf = ctx->priv;
 
     av_freep(&buf->sample_fmts);
+    av_freep(&buf->sample_rates);
     av_freep(&buf->channel_layouts);
     common_uninit(ctx);
 }
@@ -348,6 +355,13 @@ static int asink_query_formats(AVFilterContext *ctx)
         ff_set_common_channel_layouts(ctx, layouts);
     }
 
+    if (buf->sample_rates) {
+        formats = ff_make_format_list(buf->sample_rates);
+        if (!formats)
+            return AVERROR(ENOMEM);
+        ff_set_common_samplerates(ctx, formats);
+    }
+
     return 0;
 }
 
index a6a2024a249c6d88ce65ebf258d0ec9c419a53e7..93bdf91d36a710a690f85a53d07aaf63c6cebe0f 100644 (file)
@@ -29,7 +29,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  3
-#define LIBAVFILTER_VERSION_MINOR  40
+#define LIBAVFILTER_VERSION_MINOR  41
 #define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \