[FFmpeg-devel] [PATCH] lavfi/abuffersink: allow to select sample rates

Stefano Sabatini stefasab at gmail.com
Sun Feb 3 21:14:24 CET 2013


TODO: bump minor, add APIChanges entry
---
 libavfilter/buffersink.h  |    1 +
 libavfilter/sink_buffer.c |    8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 825a36a..6f8ac5c 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -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;
 
 /**
diff --git a/libavfilter/sink_buffer.c b/libavfilter/sink_buffer.c
index 0edf9c5..c1512db 100644
--- a/libavfilter/sink_buffer.c
+++ b/libavfilter/sink_buffer.c
@@ -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;
 } BufferSinkContext;
 
 #define FIFO_INIT_SIZE 8
@@ -348,6 +349,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;
 }
 
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list