[FFmpeg-devel] [PATCH] lavfi: unify asink_buffer and vsink_buffer API

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Aug 20 19:44:59 CEST 2011


More generic, less code duplication.
---
 avconv.c                    |    5 +-
 ffmpeg.c                    |    5 +-
 ffplay.c                    |    5 +-
 libavdevice/lavfi.c         |   11 ++--
 libavfilter/Makefile        |    2 +-
 libavfilter/asink_abuffer.c |   97 ------------------------------
 libavfilter/asink_abuffer.h |   47 ---------------
 libavfilter/vsink_buffer.c  |  139 ++++++++++++++++++++++++++++++++++---------
 libavfilter/vsink_buffer.h  |   38 +++++++++---
 9 files changed, 155 insertions(+), 194 deletions(-)
 delete mode 100644 libavfilter/asink_abuffer.c
 delete mode 100644 libavfilter/asink_abuffer.h

diff --git a/avconv.c b/avconv.c
index a5edc76..dac5e5a 100644
--- a/avconv.c
+++ b/avconv.c
@@ -345,6 +345,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
     AVCodecContext *codec = ost->st->codec;
     AVCodecContext *icodec = ist->st->codec;
     enum PixelFormat pix_fmts[] = { codec->pix_fmt, PIX_FMT_NONE };
+    AVBufferSinkParams buffersink_params = { .pixel_fmts = pix_fmts };
     AVRational sample_aspect_ratio;
     char args[255];
     int ret;
@@ -365,7 +366,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
     if (ret < 0)
         return ret;
     ret = avfilter_graph_create_filter(&ost->output_video_filter, avfilter_get_by_name("buffersink"),
-                                       "out", NULL, pix_fmts, ost->graph);
+                                       "out", NULL, &buffersink_params, ost->graph);
     if (ret < 0)
         return ret;
     last_filter = ost->input_video_filter;
@@ -1744,7 +1745,7 @@ static int output_packet(InputStream *ist, int ist_index,
             while (frame_available) {
                 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) {
                     AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
-                    if (av_vsink_buffer_get_video_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
+                    if (av_sink_buffer_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
                         goto cont;
                     if (ost->picref) {
                         avfilter_fill_frame_from_video_buffer_ref(&picture, ost->picref);
diff --git a/ffmpeg.c b/ffmpeg.c
index 8e2c29f..3452307 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -359,6 +359,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
     AVCodecContext *codec = ost->st->codec;
     AVCodecContext *icodec = ist->st->codec;
     enum PixelFormat pix_fmts[] = { codec->pix_fmt, PIX_FMT_NONE };
+    AVBufferSinkParams buffersink_params = { .pixel_fmts = pix_fmts };
     AVRational sample_aspect_ratio;
     char args[255];
     int ret;
@@ -379,7 +380,7 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
     if (ret < 0)
         return ret;
     ret = avfilter_graph_create_filter(&ost->output_video_filter, avfilter_get_by_name("buffersink"),
-                                       "out", NULL, pix_fmts, ost->graph);
+                                       "out", NULL, &buffersink_params, ost->graph);
     if (ret < 0)
         return ret;
     last_filter = ost->input_video_filter;
@@ -1736,7 +1737,7 @@ static int output_packet(InputStream *ist, int ist_index,
                 while (frame_available) {
                     if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter) {
                         AVRational ist_pts_tb = ost->output_video_filter->inputs[0]->time_base;
-                        if (av_vsink_buffer_get_video_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
+                        if (av_sink_buffer_get_buffer_ref(ost->output_video_filter, &ost->picref, 0) < 0)
                             goto cont;
                         if (ost->picref) {
                             avfilter_fill_frame_from_video_buffer_ref(&picture, ost->picref);
diff --git a/ffplay.c b/ffplay.c
index c31bcfb..9f5c21f 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1675,6 +1675,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
     char sws_flags_str[128];
     int ret;
     enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
+    AVBufferSinkParams buffersink_params = { .pixel_fmts = pix_fmts };
     AVFilterContext *filt_src = NULL, *filt_out = NULL;
     snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
     graph->scale_sws_opts = av_strdup(sws_flags_str);
@@ -1683,7 +1684,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
                                             NULL, is, graph)) < 0)
         return ret;
     if ((ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out",
-                                            NULL, pix_fmts, graph)) < 0)
+                                            NULL, &buffersink_params, graph)) < 0)
         return ret;
 
     if(vfilters) {
@@ -1758,7 +1759,7 @@ static int video_thread(void *arg)
             last_w = is->video_st->codec->width;
             last_h = is->video_st->codec->height;
         }
-        ret = av_vsink_buffer_get_video_buffer_ref(filt_out, &picref, 0);
+        ret = av_sink_buffer_get_buffer_ref(filt_out, &picref, 0);
         if (picref) {
             avfilter_fill_frame_from_video_buffer_ref(frame, picref);
             pts_int = picref->pts;
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 2249264..7ec5be1 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -173,9 +173,11 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx,
 
     for (i = 0, inout = output_links; inout; i++, inout = inout->next) {
         AVFilterContext *sink;
+        AVBufferSinkParams buffersink_params = { .pixel_fmts = pix_fmts };
+
         if ((ret = avfilter_graph_create_filter(&sink, buffersink,
                                                 inout->name, NULL,
-                                                pix_fmts, lavfi->graph)) < 0)
+                                                &buffersink_params, lavfi->graph)) < 0)
             FAIL(ret);
         lavfi->sinks[i] = sink;
         if ((ret = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0)
@@ -223,8 +225,8 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
     for (i = 0; i < avctx->nb_streams; i++) {
         AVRational tb = lavfi->sinks[i]->inputs[0]->time_base;
         double d;
-        int ret = av_vsink_buffer_get_video_buffer_ref(lavfi->sinks[i],
-                                                       &picref, AV_VSINK_BUF_FLAG_PEEK);
+        int ret = av_sink_buffer_get_buffer_ref(lavfi->sinks[i],
+                                                &picref, AV_SINK_BUF_FLAG_PEEK);
         if (ret < 0)
             return ret;
         d = av_rescale_q(picref->pts, tb, AV_TIME_BASE_Q);
@@ -234,8 +236,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
         }
     }
 
-    av_vsink_buffer_get_video_buffer_ref(lavfi->sinks[min_pts_sink_idx],
-                                         &picref, 0);
+    av_sink_buffer_get_buffer_ref(lavfi->sinks[min_pts_sink_idx], &picref, 0);
 
     size = avpicture_get_size(picref->format, picref->video->w, picref->video->h);
     if ((ret = av_new_packet(pkt, size)) < 0)
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 23c0298..bd64ba5 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -28,7 +28,7 @@ OBJS-$(CONFIG_ASHOWINFO_FILTER)              += af_ashowinfo.o
 OBJS-$(CONFIG_AMOVIE_FILTER)                 += movie.o
 OBJS-$(CONFIG_ANULLSRC_FILTER)               += asrc_anullsrc.o
 
-OBJS-$(CONFIG_ABUFFERSINK_FILTER)            += asink_abuffer.o
+OBJS-$(CONFIG_ABUFFERSINK_FILTER)            += vsink_buffer.o
 OBJS-$(CONFIG_ANULLSINK_FILTER)              += asink_anullsink.o
 
 OBJS-$(CONFIG_BLACKFRAME_FILTER)             += vf_blackframe.o
diff --git a/libavfilter/asink_abuffer.c b/libavfilter/asink_abuffer.c
deleted file mode 100644
index 25950d8..0000000
--- a/libavfilter/asink_abuffer.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2011 Stefano Sabatini
- * Copyright (c) 2011 Mina Nagy Zaki
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * audio buffer sink
- */
-
-#include "avfilter.h"
-#include "asink_abuffer.h"
-
-static void filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
-{
-}
-
-static int init(AVFilterContext *ctx, const char *args, void *opaque)
-{
-    if (!opaque) {
-        av_log(ctx, AV_LOG_ERROR, "Opaque field required, please pass"
-                                  " an initialized ABufferSinkContext");
-        return AVERROR(EINVAL);
-    }
-    memcpy(ctx->priv, opaque, sizeof(ABufferSinkContext));
-
-    return 0;
-}
-
-static int query_formats(AVFilterContext *ctx)
-{
-    ABufferSinkContext *abuffersink = ctx->priv;
-    AVFilterFormats *formats = NULL;
-
-    if (!(formats = avfilter_make_format_list(abuffersink->sample_fmts)))
-        return AVERROR(ENOMEM);
-    avfilter_set_common_sample_formats(ctx, formats);
-
-    if (!(formats = avfilter_make_format64_list(abuffersink->channel_layouts)))
-        return AVERROR(ENOMEM);
-    avfilter_set_common_channel_layouts(ctx, formats);
-
-    if (!(formats = avfilter_make_format_list(abuffersink->packing_fmts)))
-        return AVERROR(ENOMEM);
-    avfilter_set_common_packing_formats(ctx, formats);
-
-    return 0;
-}
-
-int av_asink_abuffer_get_audio_buffer_ref(AVFilterContext *abuffersink,
-                                          AVFilterBufferRef **samplesref,
-                                          int av_unused flags)
-{
-    int ret;
-    AVFilterLink * const inlink = abuffersink->inputs[0];
-
-    if ((ret = avfilter_request_frame(inlink)))
-        return ret;
-    if (!inlink->cur_buf)
-        return AVERROR(EINVAL);
-    *samplesref = inlink->cur_buf;
-    inlink->cur_buf = NULL;
-
-    return 0;
-}
-
-AVFilter avfilter_asink_abuffersink = {
-    .name      = "abuffersink",
-    .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
-    .init      = init,
-    .priv_size = sizeof(ABufferSinkContext),
-    .query_formats = query_formats,
-
-    .inputs    = (AVFilterPad[]) {{ .name           = "default",
-                                    .type           = AVMEDIA_TYPE_AUDIO,
-                                    .filter_samples = filter_samples,
-                                    .min_perms      = AV_PERM_READ, },
-                                  { .name = NULL }},
-    .outputs   = (AVFilterPad[]) {{ .name = NULL }},
-};
-
diff --git a/libavfilter/asink_abuffer.h b/libavfilter/asink_abuffer.h
deleted file mode 100644
index 37341fb..0000000
--- a/libavfilter/asink_abuffer.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVFILTER_ASINK_ABUFFER_H
-#define AVFILTER_ASINK_ABUFFER_H
-
-/**
- * @file
- * audio buffer sink API
- */
-
-#include "avfilter.h"
-
-typedef struct {
-    const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMTS
-    const int64_t *channel_layouts;         ///< list of allowed channel layouts, terminated by -1
-    const int *packing_fmts;                ///< list of allowed packing formats
-} ABufferSinkContext;
-
-
-/**
- * Get an audio buffer from abuffersink and put it in samplesref.
- *
- * @param abuffersink pointer to an abuffersink context
- * @param flags unused
- * @return >= 0 in case of success, a negative AVERROR code in case of failure
- */
-int av_asink_abuffer_get_audio_buffer_ref(AVFilterContext *abuffersink,
-                                          AVFilterBufferRef **samplesref,
-                                          int av_unused flags);
-
-#endif /* AVFILTER_ASINK_ABUFFER_H */
diff --git a/libavfilter/vsink_buffer.c b/libavfilter/vsink_buffer.c
index e0f0334..25b5112 100644
--- a/libavfilter/vsink_buffer.c
+++ b/libavfilter/vsink_buffer.c
@@ -28,32 +28,32 @@
 #include "vsink_buffer.h"
 
 typedef struct {
-    AVFifoBuffer *fifo;          ///< FIFO buffer of video frame references
-    enum PixelFormat *pix_fmts;  ///< accepted pixel formats, must be terminated with -1
+    AVFifoBuffer *fifo;                      ///< FIFO buffer of video frame references
+
+    /* only used for video */
+    const enum PixelFormat *pixel_fmts;     ///< list of accepted pixel formats, must be terminated with -1
+
+    /* only used for audio */
+    const enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
+    const int64_t *channel_layouts;         ///< list of accepted channel layouts, terminated by -1
+    const int *packing_fmts;                ///< list of accepted packing formats, terminated by -1
 } BufferSinkContext;
 
 #define FIFO_INIT_SIZE 8
 
-static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int common_init(AVFilterContext *ctx)
 {
     BufferSinkContext *buf = ctx->priv;
 
-    if (!opaque) {
-        av_log(ctx, AV_LOG_ERROR, "No opaque field provided, which is required.\n");
-        return AVERROR(EINVAL);
-    }
-
     buf->fifo = av_fifo_alloc(FIFO_INIT_SIZE*sizeof(AVFilterBufferRef *));
     if (!buf->fifo) {
         av_log(ctx, AV_LOG_ERROR, "Failed to allocate fifo\n");
         return AVERROR(ENOMEM);
     }
-
-    buf->pix_fmts = opaque;
     return 0;
 }
 
-static av_cold void uninit(AVFilterContext *ctx)
+static av_cold void common_uninit(AVFilterContext *ctx)
 {
     BufferSinkContext *buf = ctx->priv;
     AVFilterBufferRef *picref;
@@ -88,21 +88,13 @@ static void end_frame(AVFilterLink *inlink)
                           &inlink->cur_buf, sizeof(AVFilterBufferRef *), NULL);
 }
 
-static int query_formats(AVFilterContext *ctx)
-{
-    BufferSinkContext *buf = ctx->priv;
-
-    avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(buf->pix_fmts));
-    return 0;
-}
-
-int av_vsink_buffer_get_video_buffer_ref(AVFilterContext *ctx,
-                                         AVFilterBufferRef **picref, int flags)
+int av_sink_buffer_get_buffer_ref(AVFilterContext *ctx,
+                                  AVFilterBufferRef **bufref, int flags)
 {
     BufferSinkContext *buf = ctx->priv;
     AVFilterLink *inlink = ctx->inputs[0];
     int ret;
-    *picref = NULL;
+    *bufref = NULL;
 
     /* no picref available, fetch it from the filterchain */
     if (!av_fifo_size(buf->fifo)) {
@@ -113,22 +105,48 @@ int av_vsink_buffer_get_video_buffer_ref(AVFilterContext *ctx,
     if (!av_fifo_size(buf->fifo))
         return AVERROR(EINVAL);
 
-    if (flags & AV_VSINK_BUF_FLAG_PEEK)
-        *picref = (AVFilterBufferRef *)av_fifo_peek2(buf->fifo, 0);
+    if (flags & AV_SINK_BUF_FLAG_PEEK)
+        *bufref = (AVFilterBufferRef *)av_fifo_peek2(buf->fifo, 0);
     else
-        av_fifo_generic_read(buf->fifo, picref, sizeof(*picref), NULL);
+        av_fifo_generic_read(buf->fifo, bufref, sizeof(*bufref), NULL);
 
     return 0;
 }
 
+#if CONFIG_BUFFERSINK_FILTER
+
+static av_cold int vsink_init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+    BufferSinkContext *buf = ctx->priv;
+    AVBufferSinkParams *params;
+
+    if (!opaque) {
+        av_log(ctx, AV_LOG_ERROR, "No opaque field provided, an AVBufferSinkParams struct is required\n");
+        return AVERROR(EINVAL);
+    } else
+        params = (AVBufferSinkParams *)opaque;
+
+    buf->pixel_fmts = params->pixel_fmts;
+
+    return common_init(ctx);
+}
+
+static int vsink_query_formats(AVFilterContext *ctx)
+{
+    BufferSinkContext *buf = ctx->priv;
+
+    avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(buf->pixel_fmts));
+    return 0;
+}
+
 AVFilter avfilter_vsink_buffersink = {
     .name      = "buffersink",
     .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
     .priv_size = sizeof(BufferSinkContext),
-    .init      = init,
-    .uninit    = uninit,
+    .init      = vsink_init,
+    .uninit    = common_uninit,
 
-    .query_formats = query_formats,
+    .query_formats = vsink_query_formats,
 
     .inputs    = (AVFilterPad[]) {{ .name          = "default",
                                     .type          = AVMEDIA_TYPE_VIDEO,
@@ -137,3 +155,68 @@ AVFilter avfilter_vsink_buffersink = {
                                   { .name = NULL }},
     .outputs   = (AVFilterPad[]) {{ .name = NULL }},
 };
+
+#endif /* CONFIG_BUFFERSINK_FILTER */
+
+#if CONFIG_ABUFFERSINK_FILTER
+
+static void filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
+{
+    end_frame(link);
+}
+
+static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+    BufferSinkContext *buf = ctx->priv;
+    AVABufferSinkParams *params;
+
+    if (!opaque) {
+        av_log(ctx, AV_LOG_ERROR, "No opaque field provided, an AVABufferSinkParams struct is required\n");
+        return AVERROR(EINVAL);
+    } else
+        params = (AVABufferSinkParams *)opaque;
+
+    buf->sample_fmts     = params->sample_fmts;
+    buf->channel_layouts = params->channel_layouts;
+    buf->packing_fmts    = params->packing_fmts;
+
+    return common_init(ctx);
+}
+
+static int asink_query_formats(AVFilterContext *ctx)
+{
+    BufferSinkContext *buf = ctx->priv;
+    AVFilterFormats *formats = NULL;
+
+    if (!(formats = avfilter_make_format_list(buf->sample_fmts)))
+        return AVERROR(ENOMEM);
+    avfilter_set_common_sample_formats(ctx, formats);
+
+    if (!(formats = avfilter_make_format64_list(buf->channel_layouts)))
+        return AVERROR(ENOMEM);
+    avfilter_set_common_channel_layouts(ctx, formats);
+
+    if (!(formats = avfilter_make_format_list(buf->packing_fmts)))
+        return AVERROR(ENOMEM);
+    avfilter_set_common_packing_formats(ctx, formats);
+
+    return 0;
+}
+
+AVFilter avfilter_asink_abuffersink = {
+    .name      = "abuffersink",
+    .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
+    .init      = asink_init,
+    .uninit    = common_uninit,
+    .priv_size = sizeof(BufferSinkContext),
+    .query_formats = asink_query_formats,
+
+    .inputs    = (AVFilterPad[]) {{ .name           = "default",
+                                    .type           = AVMEDIA_TYPE_AUDIO,
+                                    .filter_samples = filter_samples,
+                                    .min_perms      = AV_PERM_READ, },
+                                  { .name = NULL }},
+    .outputs   = (AVFilterPad[]) {{ .name = NULL }},
+};
+
+#endif /* CONFIG_ABUFFERSINK_FILTER */
diff --git a/libavfilter/vsink_buffer.h b/libavfilter/vsink_buffer.h
index 88b4c1d..9af910f 100644
--- a/libavfilter/vsink_buffer.h
+++ b/libavfilter/vsink_buffer.h
@@ -21,27 +21,45 @@
 
 /**
  * @file
- * memory buffer sink API for video
+ * memory buffer sink API for video and video
  */
 
 #include "avfilter.h"
 
 /**
- * Tell av_vsink_buffer_get_video_buffer_ref() to read the picref, but not
- * remove it from the buffer. This is useful if you need only to read
- * the picref, without to fetch it.
+ * Struct to use for initializing a buffersink context.
  */
-#define AV_VSINK_BUF_FLAG_PEEK 1
+typedef struct {
+    const enum PixelFormat *pixel_fmts; ///< list of allowed sample formats, terminated by PIX_FMT_NONE
+} AVBufferSinkParams;
 
 /**
- * Get a video buffer data from buffer_sink and put it in picref.
+ * Struct to use for initializing an abuffersink context.
+ */
+typedef struct {
+    const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
+    const int64_t *channel_layouts;         ///< list of allowed channel layouts, terminated by -1
+    const int *packing_fmts;                ///< list of allowed packing formats
+} AVABufferSinkParams;
+
+/**
+ * Tell av_sink_buffer_get_buffer_ref() to read video/samples buffer
+ * reference, but not remove it from the buffer. This is useful if you
+ * need only to read a video/samples buffer, without to fetch it.
+ */
+#define AV_SINK_BUF_FLAG_PEEK 1
+
+/**
+ * Get an audio/video buffer data from buffer_sink and put it in bufref.
+ *
+ * This function works with both audio and video buffer sinks.
  *
- * @param buffer_sink pointer to a buffer sink context
- * @param flags a combination of AV_VSINK_BUF_FLAG_* flags
+ * @param buffer_sink pointer to a buffersink or abuffersink context
+ * @param flags a combination of AV_SINK_BUF_FLAG_* flags
  * @return >= 0 in case of success, a negative AVERROR code in case of
  * failure
  */
-int av_vsink_buffer_get_video_buffer_ref(AVFilterContext *buffer_sink,
-                                         AVFilterBufferRef **picref, int flags);
+int av_sink_buffer_get_buffer_ref(AVFilterContext *buffer_sink,
+                                   AVFilterBufferRef **bufref, int flags);
 
 #endif /* AVFILTER_VSINK_BUFFER_H */
-- 
1.7.2.5



More information about the ffmpeg-devel mailing list