Signed-off-by: Stefano Sabatini <stefano.sabatini-lala@poste.it>
| ... | ... |
@@ -144,6 +144,17 @@ anullsrc=48000:mono |
| 144 | 144 |
|
| 145 | 145 |
Below is a description of the currently available audio sinks. |
| 146 | 146 |
|
| 147 |
+@section abuffersink |
|
| 148 |
+ |
|
| 149 |
+Buffer audio frames, and make them available to the end of filter chain. |
|
| 150 |
+ |
|
| 151 |
+This sink is mainly intended for programmatic use, in particular |
|
| 152 |
+through the interface defined in @file{libavfilter/asink_abuffer.h}.
|
|
| 153 |
+ |
|
| 154 |
+It requires a pointer to a ABufferSinkContext structure, which defines the |
|
| 155 |
+incoming buffers' format, to be passed as the opaque parameter to |
|
| 156 |
+@code{avfilter_init_filter} for initialization.
|
|
| 157 |
+ |
|
| 147 | 158 |
@section anullsink |
| 148 | 159 |
|
| 149 | 160 |
Null audio sink, do absolutely nothing with the input audio. It is |
| ... | ... |
@@ -22,6 +22,7 @@ OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o |
| 22 | 22 |
|
| 23 | 23 |
OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o |
| 24 | 24 |
|
| 25 |
+OBJS-$(CONFIG_ABUFFERSINK_FILTER) += asink_abuffer.o |
|
| 25 | 26 |
OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o |
| 26 | 27 |
|
| 27 | 28 |
OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o |
| 44 | 45 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,101 @@ |
| 0 |
+/* |
|
| 1 |
+ * Copyright (c) 2011 Stefano Sabatini |
|
| 2 |
+ * Copyright (c) 2011 Mina Nagy Zaki |
|
| 3 |
+ * |
|
| 4 |
+ * This file is part of FFmpeg. |
|
| 5 |
+ * |
|
| 6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
| 7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 8 |
+ * License as published by the Free Software Foundation; either |
|
| 9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 10 |
+ * |
|
| 11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
| 12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 14 |
+ * Lesser General Public License for more details. |
|
| 15 |
+ * |
|
| 16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
| 18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 19 |
+ */ |
|
| 20 |
+ |
|
| 21 |
+/** |
|
| 22 |
+ * @file |
|
| 23 |
+ * audio buffer sink |
|
| 24 |
+ */ |
|
| 25 |
+ |
|
| 26 |
+#include "avfilter.h" |
|
| 27 |
+#include "asink_abuffer.h" |
|
| 28 |
+ |
|
| 29 |
+static void filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) |
|
| 30 |
+{
|
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+static int init(AVFilterContext *ctx, const char *args, void *opaque) |
|
| 34 |
+{
|
|
| 35 |
+ if (!opaque) {
|
|
| 36 |
+ av_log(ctx, AV_LOG_ERROR, "Opaque field required, please pass" |
|
| 37 |
+ " an initialized ABufferSinkContext"); |
|
| 38 |
+ return AVERROR(EINVAL); |
|
| 39 |
+ } |
|
| 40 |
+ memcpy(ctx->priv, opaque, sizeof(ABufferSinkContext)); |
|
| 41 |
+ |
|
| 42 |
+ return 0; |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+static int query_formats(AVFilterContext *ctx) |
|
| 46 |
+{
|
|
| 47 |
+ ABufferSinkContext *abuffersink = ctx->priv; |
|
| 48 |
+ AVFilterFormats *formats; |
|
| 49 |
+ int ret; |
|
| 50 |
+ |
|
| 51 |
+ formats = NULL; |
|
| 52 |
+ if ((ret = avfilter_add_format(&formats, abuffersink->sample_fmt)) < 0) |
|
| 53 |
+ return ret; |
|
| 54 |
+ avfilter_set_common_sample_formats(ctx, formats); |
|
| 55 |
+ |
|
| 56 |
+ formats = NULL; |
|
| 57 |
+ if ((ret = avfilter_add_format(&formats, abuffersink->channel_layout)) < 0) |
|
| 58 |
+ return ret; |
|
| 59 |
+ avfilter_set_common_channel_layouts(ctx, formats); |
|
| 60 |
+ |
|
| 61 |
+ formats = NULL; |
|
| 62 |
+ if ((ret = avfilter_add_format(&formats, abuffersink->planar)) < 0) |
|
| 63 |
+ return ret; |
|
| 64 |
+ avfilter_set_common_packing_formats(ctx, formats); |
|
| 65 |
+ |
|
| 66 |
+ return 0; |
|
| 67 |
+} |
|
| 68 |
+ |
|
| 69 |
+int av_asink_abuffer_get_audio_buffer_ref(AVFilterContext *abuffersink, |
|
| 70 |
+ AVFilterBufferRef **samplesref, |
|
| 71 |
+ int av_unused flags) |
|
| 72 |
+{
|
|
| 73 |
+ int ret; |
|
| 74 |
+ AVFilterLink * const inlink = abuffersink->inputs[0]; |
|
| 75 |
+ |
|
| 76 |
+ if ((ret = avfilter_request_frame(inlink))) |
|
| 77 |
+ return ret; |
|
| 78 |
+ if (!inlink->cur_buf) |
|
| 79 |
+ return AVERROR(EINVAL); |
|
| 80 |
+ *samplesref = inlink->cur_buf; |
|
| 81 |
+ inlink->cur_buf = NULL; |
|
| 82 |
+ |
|
| 83 |
+ return 0; |
|
| 84 |
+} |
|
| 85 |
+ |
|
| 86 |
+AVFilter avfilter_asink_abuffersink = {
|
|
| 87 |
+ .name = "abuffersink", |
|
| 88 |
+ .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
|
|
| 89 |
+ .init = init, |
|
| 90 |
+ .priv_size = sizeof(ABufferSinkContext), |
|
| 91 |
+ .query_formats = query_formats, |
|
| 92 |
+ |
|
| 93 |
+ .inputs = (AVFilterPad[]) {{ .name = "default",
|
|
| 94 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
| 95 |
+ .filter_samples = filter_samples, |
|
| 96 |
+ .min_perms = AV_PERM_READ, }, |
|
| 97 |
+ { .name = NULL }},
|
|
| 98 |
+ .outputs = (AVFilterPad[]) {{ .name = NULL }},
|
|
| 99 |
+}; |
|
| 100 |
+ |
| 0 | 101 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,47 @@ |
| 0 |
+/* |
|
| 1 |
+ * This file is part of FFmpeg. |
|
| 2 |
+ * |
|
| 3 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
| 4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 5 |
+ * License as published by the Free Software Foundation; either |
|
| 6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 7 |
+ * |
|
| 8 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
| 9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 11 |
+ * Lesser General Public License for more details. |
|
| 12 |
+ * |
|
| 13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 14 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
| 15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 16 |
+ */ |
|
| 17 |
+ |
|
| 18 |
+#ifndef AVFILTER_ASINK_ABUFFER_H |
|
| 19 |
+#define AVFILTER_ASINK_ABUFFER_H |
|
| 20 |
+ |
|
| 21 |
+/** |
|
| 22 |
+ * @file |
|
| 23 |
+ * audio buffer sink API |
|
| 24 |
+ */ |
|
| 25 |
+ |
|
| 26 |
+#include "avfilter.h" |
|
| 27 |
+ |
|
| 28 |
+typedef struct {
|
|
| 29 |
+ enum AVSampleFormat sample_fmt; |
|
| 30 |
+ int64_t channel_layout; |
|
| 31 |
+ int planar; |
|
| 32 |
+} ABufferSinkContext; |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 35 |
+/** |
|
| 36 |
+ * Get an audio buffer from abuffersink and put it in samplesref. |
|
| 37 |
+ * |
|
| 38 |
+ * @param abuffersink pointer to an abuffersink context |
|
| 39 |
+ * @param flags unused |
|
| 40 |
+ * @return >= 0 in case of success, a negative AVERROR code in case of failure |
|
| 41 |
+ */ |
|
| 42 |
+int av_asink_abuffer_get_audio_buffer_ref(AVFilterContext *abuffersink, |
|
| 43 |
+ AVFilterBufferRef **samplesref, |
|
| 44 |
+ int av_unused flags); |
|
| 45 |
+ |
|
| 46 |
+#endif /* AVFILTER_ASINK_ABUFFER_H */ |
| ... | ... |
@@ -29,8 +29,8 @@ |
| 29 | 29 |
#include "libavutil/rational.h" |
| 30 | 30 |
|
| 31 | 31 |
#define LIBAVFILTER_VERSION_MAJOR 2 |
| 32 |
-#define LIBAVFILTER_VERSION_MINOR 27 |
|
| 33 |
-#define LIBAVFILTER_VERSION_MICRO 5 |
|
| 32 |
+#define LIBAVFILTER_VERSION_MINOR 28 |
|
| 33 |
+#define LIBAVFILTER_VERSION_MICRO 0 |
|
| 34 | 34 |
|
| 35 | 35 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| 36 | 36 |
LIBAVFILTER_VERSION_MINOR, \ |