ffmpeg/libavfilter/af_amerge.c

337 lines
12 KiB
C
Raw Normal View History

2011-11-06 21:28:05 +01:00
/*
* Copyright (c) 2011 Nicolas George <nicolas.george@normalesup.org>
*
* 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 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 merging filter
*/
2012-06-03 21:32:22 +02:00
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
2011-11-06 21:28:05 +01:00
#include "libswresample/swresample.h" // only for SWR_CH_MAX
#include "avfilter.h"
#include "audio.h"
2012-05-31 21:47:10 +02:00
#include "bufferqueue.h"
2011-11-06 21:28:05 +01:00
#include "internal.h"
typedef struct {
2012-06-03 21:32:22 +02:00
const AVClass *class;
int nb_inputs;
2011-11-06 21:28:05 +01:00
int route[SWR_CH_MAX]; /**< channels routing, see copy_samples */
int bps;
2012-05-31 21:47:10 +02:00
struct amerge_input {
struct FFBufQueue queue;
int nb_ch; /**< number of channels for the input */
2012-05-31 21:47:10 +02:00
int nb_samples;
int pos;
2012-06-03 21:32:22 +02:00
} *in;
2011-11-06 21:28:05 +01:00
} AMergeContext;
2012-06-03 21:32:22 +02:00
#define OFFSET(x) offsetof(AMergeContext, x)
static const AVOption amerge_options[] = {
{ "inputs", "specify the number of inputs", OFFSET(nb_inputs),
AV_OPT_TYPE_INT, { .dbl = 2 }, 2, SWR_CH_MAX },
{0}
2012-06-03 21:32:22 +02:00
};
AVFILTER_DEFINE_CLASS(amerge);
2012-06-03 21:32:22 +02:00
2011-11-06 21:28:05 +01:00
static av_cold void uninit(AVFilterContext *ctx)
{
AMergeContext *am = ctx->priv;
2012-05-31 21:47:10 +02:00
int i;
2011-11-06 21:28:05 +01:00
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++)
2012-05-31 21:47:10 +02:00
ff_bufqueue_discard_all(&am->in[i].queue);
2012-06-03 21:32:22 +02:00
av_freep(&am->in);
2011-11-06 21:28:05 +01:00
}
static int query_formats(AVFilterContext *ctx)
{
AMergeContext *am = ctx->priv;
2012-06-03 21:32:22 +02:00
int64_t inlayout[SWR_CH_MAX], outlayout = 0;
2011-11-06 21:28:05 +01:00
AVFilterFormats *formats;
Merge remote-tracking branch 'qatar/master' * qatar/master: (26 commits) fate: use diff -b in oneline comparison Add missing version bumps and APIchanges/Changelog entries. lavfi: move buffer management function to a separate file. lavfi: move formats-related functions from default.c to formats.c lavfi: move video-related functions to a separate file. fate: make smjpeg a demux test fate: separate sierra-vmd audio and video tests fate: separate smacker audio and video tests libmp3lame: set supported channel layouts. avconv: automatically insert asyncts when -async is used. avconv: add support for audio filters. lavfi: add asyncts filter. lavfi: add aformat filter lavfi: add an audio buffer sink. lavfi: add an audio buffer source. buffersrc: add av_buffersrc_write_frame(). buffersrc: fix invalid read in uninit if the fifo hasn't been allocated lavfi: rename vsrc_buffer.c to buffersrc.c avfiltergraph: reindent lavfi: add channel layout/sample rate negotiation. ... Conflicts: Changelog doc/APIchanges doc/filters.texi ffmpeg.c ffprobe.c libavcodec/libmp3lame.c libavfilter/Makefile libavfilter/af_aformat.c libavfilter/allfilters.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/buffersrc.c libavfilter/defaults.c libavfilter/formats.c libavfilter/src_buffer.c libavfilter/version.h libavfilter/vf_yadif.c libavfilter/vsrc_buffer.c libavfilter/vsrc_buffer.h libavutil/avutil.h tests/fate/audio.mak tests/fate/demux.mak tests/fate/video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-16 02:27:31 +02:00
AVFilterChannelLayouts *layouts;
2012-06-03 21:32:22 +02:00
int i, overlap = 0, nb_ch = 0;
2011-11-06 21:28:05 +01:00
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++) {
Merge remote-tracking branch 'qatar/master' * qatar/master: (26 commits) fate: use diff -b in oneline comparison Add missing version bumps and APIchanges/Changelog entries. lavfi: move buffer management function to a separate file. lavfi: move formats-related functions from default.c to formats.c lavfi: move video-related functions to a separate file. fate: make smjpeg a demux test fate: separate sierra-vmd audio and video tests fate: separate smacker audio and video tests libmp3lame: set supported channel layouts. avconv: automatically insert asyncts when -async is used. avconv: add support for audio filters. lavfi: add asyncts filter. lavfi: add aformat filter lavfi: add an audio buffer sink. lavfi: add an audio buffer source. buffersrc: add av_buffersrc_write_frame(). buffersrc: fix invalid read in uninit if the fifo hasn't been allocated lavfi: rename vsrc_buffer.c to buffersrc.c avfiltergraph: reindent lavfi: add channel layout/sample rate negotiation. ... Conflicts: Changelog doc/APIchanges doc/filters.texi ffmpeg.c ffprobe.c libavcodec/libmp3lame.c libavfilter/Makefile libavfilter/af_aformat.c libavfilter/allfilters.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/buffersrc.c libavfilter/defaults.c libavfilter/formats.c libavfilter/src_buffer.c libavfilter/version.h libavfilter/vf_yadif.c libavfilter/vsrc_buffer.c libavfilter/vsrc_buffer.h libavutil/avutil.h tests/fate/audio.mak tests/fate/demux.mak tests/fate/video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-16 02:27:31 +02:00
if (!ctx->inputs[i]->in_channel_layouts ||
!ctx->inputs[i]->in_channel_layouts->nb_channel_layouts) {
2011-11-06 21:28:05 +01:00
av_log(ctx, AV_LOG_ERROR,
"No channel layout for input %d\n", i + 1);
return AVERROR(EINVAL);
}
Merge remote-tracking branch 'qatar/master' * qatar/master: (26 commits) fate: use diff -b in oneline comparison Add missing version bumps and APIchanges/Changelog entries. lavfi: move buffer management function to a separate file. lavfi: move formats-related functions from default.c to formats.c lavfi: move video-related functions to a separate file. fate: make smjpeg a demux test fate: separate sierra-vmd audio and video tests fate: separate smacker audio and video tests libmp3lame: set supported channel layouts. avconv: automatically insert asyncts when -async is used. avconv: add support for audio filters. lavfi: add asyncts filter. lavfi: add aformat filter lavfi: add an audio buffer sink. lavfi: add an audio buffer source. buffersrc: add av_buffersrc_write_frame(). buffersrc: fix invalid read in uninit if the fifo hasn't been allocated lavfi: rename vsrc_buffer.c to buffersrc.c avfiltergraph: reindent lavfi: add channel layout/sample rate negotiation. ... Conflicts: Changelog doc/APIchanges doc/filters.texi ffmpeg.c ffprobe.c libavcodec/libmp3lame.c libavfilter/Makefile libavfilter/af_aformat.c libavfilter/allfilters.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/buffersrc.c libavfilter/defaults.c libavfilter/formats.c libavfilter/src_buffer.c libavfilter/version.h libavfilter/vf_yadif.c libavfilter/vsrc_buffer.c libavfilter/vsrc_buffer.h libavutil/avutil.h tests/fate/audio.mak tests/fate/demux.mak tests/fate/video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-16 02:27:31 +02:00
inlayout[i] = ctx->inputs[i]->in_channel_layouts->channel_layouts[0];
if (ctx->inputs[i]->in_channel_layouts->nb_channel_layouts > 1) {
2011-11-06 21:28:05 +01:00
char buf[256];
av_get_channel_layout_string(buf, sizeof(buf), 0, inlayout[i]);
av_log(ctx, AV_LOG_INFO, "Using \"%s\" for input %d\n", buf, i + 1);
}
am->in[i].nb_ch = av_get_channel_layout_nb_channels(inlayout[i]);
2012-06-03 21:32:22 +02:00
if (outlayout & inlayout[i])
overlap++;
outlayout |= inlayout[i];
nb_ch += am->in[i].nb_ch;
2011-11-06 21:28:05 +01:00
}
2012-06-03 21:32:22 +02:00
if (nb_ch > SWR_CH_MAX) {
2011-11-06 21:28:05 +01:00
av_log(ctx, AV_LOG_ERROR, "Too many channels (max %d)\n", SWR_CH_MAX);
return AVERROR(EINVAL);
}
2012-06-03 21:32:22 +02:00
if (overlap) {
2011-11-06 21:28:05 +01:00
av_log(ctx, AV_LOG_WARNING,
"Inputs overlap: output layout will be meaningless\n");
2012-06-03 21:32:22 +02:00
for (i = 0; i < nb_ch; i++)
2011-11-06 21:28:05 +01:00
am->route[i] = i;
2012-06-03 21:32:22 +02:00
outlayout = av_get_default_channel_layout(nb_ch);
2011-11-06 21:28:05 +01:00
if (!outlayout)
2012-06-03 21:32:22 +02:00
outlayout = ((int64_t)1 << nb_ch) - 1;
2011-11-06 21:28:05 +01:00
} else {
2012-06-03 21:32:22 +02:00
int *route[SWR_CH_MAX];
2011-11-06 21:28:05 +01:00
int c, out_ch_number = 0;
2012-06-03 21:32:22 +02:00
route[0] = am->route;
for (i = 1; i < am->nb_inputs; i++)
route[i] = route[i - 1] + am->in[i - 1].nb_ch;
2011-11-06 21:28:05 +01:00
for (c = 0; c < 64; c++)
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++)
2011-11-06 21:28:05 +01:00
if ((inlayout[i] >> c) & 1)
*(route[i]++) = out_ch_number++;
}
formats = ff_make_format_list(ff_packed_sample_fmts_array);
ff_set_common_formats(ctx, formats);
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++) {
Merge remote-tracking branch 'qatar/master' * qatar/master: (26 commits) fate: use diff -b in oneline comparison Add missing version bumps and APIchanges/Changelog entries. lavfi: move buffer management function to a separate file. lavfi: move formats-related functions from default.c to formats.c lavfi: move video-related functions to a separate file. fate: make smjpeg a demux test fate: separate sierra-vmd audio and video tests fate: separate smacker audio and video tests libmp3lame: set supported channel layouts. avconv: automatically insert asyncts when -async is used. avconv: add support for audio filters. lavfi: add asyncts filter. lavfi: add aformat filter lavfi: add an audio buffer sink. lavfi: add an audio buffer source. buffersrc: add av_buffersrc_write_frame(). buffersrc: fix invalid read in uninit if the fifo hasn't been allocated lavfi: rename vsrc_buffer.c to buffersrc.c avfiltergraph: reindent lavfi: add channel layout/sample rate negotiation. ... Conflicts: Changelog doc/APIchanges doc/filters.texi ffmpeg.c ffprobe.c libavcodec/libmp3lame.c libavfilter/Makefile libavfilter/af_aformat.c libavfilter/allfilters.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/buffersrc.c libavfilter/defaults.c libavfilter/formats.c libavfilter/src_buffer.c libavfilter/version.h libavfilter/vf_yadif.c libavfilter/vsrc_buffer.c libavfilter/vsrc_buffer.h libavutil/avutil.h tests/fate/audio.mak tests/fate/demux.mak tests/fate/video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-16 02:27:31 +02:00
layouts = NULL;
ff_add_channel_layout(&layouts, inlayout[i]);
ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts);
2011-11-06 21:28:05 +01:00
}
Merge remote-tracking branch 'qatar/master' * qatar/master: (26 commits) fate: use diff -b in oneline comparison Add missing version bumps and APIchanges/Changelog entries. lavfi: move buffer management function to a separate file. lavfi: move formats-related functions from default.c to formats.c lavfi: move video-related functions to a separate file. fate: make smjpeg a demux test fate: separate sierra-vmd audio and video tests fate: separate smacker audio and video tests libmp3lame: set supported channel layouts. avconv: automatically insert asyncts when -async is used. avconv: add support for audio filters. lavfi: add asyncts filter. lavfi: add aformat filter lavfi: add an audio buffer sink. lavfi: add an audio buffer source. buffersrc: add av_buffersrc_write_frame(). buffersrc: fix invalid read in uninit if the fifo hasn't been allocated lavfi: rename vsrc_buffer.c to buffersrc.c avfiltergraph: reindent lavfi: add channel layout/sample rate negotiation. ... Conflicts: Changelog doc/APIchanges doc/filters.texi ffmpeg.c ffprobe.c libavcodec/libmp3lame.c libavfilter/Makefile libavfilter/af_aformat.c libavfilter/allfilters.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/buffersrc.c libavfilter/defaults.c libavfilter/formats.c libavfilter/src_buffer.c libavfilter/version.h libavfilter/vf_yadif.c libavfilter/vsrc_buffer.c libavfilter/vsrc_buffer.h libavutil/avutil.h tests/fate/audio.mak tests/fate/demux.mak tests/fate/video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-16 02:27:31 +02:00
layouts = NULL;
ff_add_channel_layout(&layouts, outlayout);
ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts);
ff_set_common_samplerates(ctx, ff_all_samplerates());
2011-11-06 21:28:05 +01:00
return 0;
}
static int config_output(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AMergeContext *am = ctx->priv;
2012-06-03 21:32:22 +02:00
AVBPrint bp;
2011-11-06 21:28:05 +01:00
int i;
2012-06-03 21:32:22 +02:00
for (i = 1; i < am->nb_inputs; i++) {
if (ctx->inputs[i]->sample_rate != ctx->inputs[0]->sample_rate) {
av_log(ctx, AV_LOG_ERROR,
"Inputs must have the same sample rate "
"(%"PRIi64" for in%d vs %"PRIi64")\n",
ctx->inputs[i]->sample_rate, i, ctx->inputs[0]->sample_rate);
return AVERROR(EINVAL);
}
2011-11-06 21:28:05 +01:00
}
am->bps = av_get_bytes_per_sample(ctx->outputs[0]->format);
outlink->sample_rate = ctx->inputs[0]->sample_rate;
outlink->time_base = ctx->inputs[0]->time_base;
2012-06-03 21:32:22 +02:00
av_bprint_init(&bp, 0, 1);
for (i = 0; i < am->nb_inputs; i++) {
av_bprintf(&bp, "%sin%d:", i ? " + " : "", i);
av_bprint_channel_layout(&bp, -1, ctx->inputs[i]->channel_layout);
2011-11-06 21:28:05 +01:00
}
2012-06-03 21:32:22 +02:00
av_bprintf(&bp, " -> out:");
av_bprint_channel_layout(&bp, -1, ctx->outputs[0]->channel_layout);
av_log(ctx, AV_LOG_INFO, "%s\n", bp.str);
2011-11-06 21:28:05 +01:00
return 0;
}
static int request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AMergeContext *am = ctx->priv;
int i, ret;
2011-11-06 21:28:05 +01:00
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++)
2012-05-31 21:47:10 +02:00
if (!am->in[i].nb_samples)
if ((ret = avfilter_request_frame(ctx->inputs[i])) < 0)
return ret;
2011-11-06 21:28:05 +01:00
return 0;
}
/**
2012-06-03 21:32:22 +02:00
* Copy samples from several input streams to one output stream.
* @param nb_inputs number of inputs
* @param in inputs; used only for the nb_ch field;
2011-11-06 21:28:05 +01:00
* @param route routing values;
* input channel i goes to output channel route[i];
* i < in[0].nb_ch are the channels from the first output;
* i >= in[0].nb_ch are the channels from the second output
2011-11-06 21:28:05 +01:00
* @param ins pointer to the samples of each inputs, in packed format;
* will be left at the end of the copied samples
* @param outs pointer to the samples of the output, in packet format;
* must point to a buffer big enough;
* will be left at the end of the copied samples
* @param ns number of samples to copy
* @param bps bytes per sample
*/
2012-06-03 21:32:22 +02:00
static inline void copy_samples(int nb_inputs, struct amerge_input in[],
int *route, uint8_t *ins[],
2011-11-06 21:28:05 +01:00
uint8_t **outs, int ns, int bps)
{
int *route_cur;
2012-06-03 21:32:22 +02:00
int i, c, nb_ch = 0;
2011-11-06 21:28:05 +01:00
2012-06-03 21:32:22 +02:00
for (i = 0; i < nb_inputs; i++)
nb_ch += in[i].nb_ch;
2011-11-06 21:28:05 +01:00
while (ns--) {
route_cur = route;
2012-06-03 21:32:22 +02:00
for (i = 0; i < nb_inputs; i++) {
for (c = 0; c < in[i].nb_ch; c++) {
2011-11-06 21:28:05 +01:00
memcpy((*outs) + bps * *(route_cur++), ins[i], bps);
ins[i] += bps;
}
}
2012-06-03 21:32:22 +02:00
*outs += nb_ch * bps;
2011-11-06 21:28:05 +01:00
}
}
static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
{
AVFilterContext *ctx = inlink->dst;
AMergeContext *am = ctx->priv;
AVFilterLink *const outlink = ctx->outputs[0];
2012-06-03 21:32:22 +02:00
int input_number;
2011-11-06 21:28:05 +01:00
int nb_samples, ns, i;
2012-06-03 21:32:22 +02:00
AVFilterBufferRef *outbuf, *inbuf[SWR_CH_MAX];
uint8_t *ins[SWR_CH_MAX], *outs;
2011-11-06 21:28:05 +01:00
2012-06-03 21:32:22 +02:00
for (input_number = 0; input_number < am->nb_inputs; input_number++)
if (inlink == ctx->inputs[input_number])
break;
av_assert1(input_number < am->nb_inputs);
2012-05-31 21:47:10 +02:00
ff_bufqueue_add(ctx, &am->in[input_number].queue, insamples);
am->in[input_number].nb_samples += insamples->audio->nb_samples;
2012-06-03 21:32:22 +02:00
nb_samples = am->in[0].nb_samples;
for (i = 1; i < am->nb_inputs; i++)
nb_samples = FFMIN(nb_samples, am->in[i].nb_samples);
if (!nb_samples)
2011-11-06 21:28:05 +01:00
return;
2012-05-31 21:47:10 +02:00
outbuf = ff_get_audio_buffer(ctx->outputs[0], AV_PERM_WRITE, nb_samples);
2011-11-06 21:28:05 +01:00
outs = outbuf->data[0];
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++) {
2012-05-31 21:47:10 +02:00
inbuf[i] = ff_bufqueue_peek(&am->in[i].queue, 0);
ins[i] = inbuf[i]->data[0] +
am->in[i].pos * am->in[i].nb_ch * am->bps;
2011-11-06 21:28:05 +01:00
}
2012-05-31 21:47:10 +02:00
outbuf->pts = inbuf[0]->pts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE :
inbuf[0]->pts +
av_rescale_q(am->in[0].pos,
(AVRational){ 1, ctx->inputs[0]->sample_rate },
ctx->outputs[0]->time_base);
2012-05-31 21:47:10 +02:00
avfilter_copy_buffer_ref_props(outbuf, inbuf[0]);
outbuf->audio->nb_samples = nb_samples;
outbuf->audio->channel_layout = outlink->channel_layout;
2011-11-06 21:28:05 +01:00
while (nb_samples) {
ns = nb_samples;
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++)
2012-05-31 21:47:10 +02:00
ns = FFMIN(ns, inbuf[i]->audio->nb_samples - am->in[i].pos);
2011-11-06 21:28:05 +01:00
/* Unroll the most common sample formats: speed +~350% for the loop,
+~13% overall (including two common decoders) */
switch (am->bps) {
case 1:
2012-06-03 21:32:22 +02:00
copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 1);
2011-11-06 21:28:05 +01:00
break;
case 2:
2012-06-03 21:32:22 +02:00
copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 2);
2011-11-06 21:28:05 +01:00
break;
case 4:
2012-06-03 21:32:22 +02:00
copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, 4);
2011-11-06 21:28:05 +01:00
break;
default:
2012-06-03 21:32:22 +02:00
copy_samples(am->nb_inputs, am->in, am->route, ins, &outs, ns, am->bps);
2011-11-06 21:28:05 +01:00
break;
}
nb_samples -= ns;
2012-06-03 21:32:22 +02:00
for (i = 0; i < am->nb_inputs; i++) {
2012-05-31 21:47:10 +02:00
am->in[i].nb_samples -= ns;
am->in[i].pos += ns;
if (am->in[i].pos == inbuf[i]->audio->nb_samples) {
am->in[i].pos = 0;
avfilter_unref_buffer(inbuf[i]);
ff_bufqueue_get(&am->in[i].queue);
inbuf[i] = ff_bufqueue_peek(&am->in[i].queue, 0);
ins[i] = inbuf[i] ? inbuf[i]->data[0] : NULL;
2011-11-06 21:28:05 +01:00
}
}
}
Merge remote-tracking branch 'qatar/master' * qatar/master: (25 commits) rv40dsp x86: MMX/MMX2/3DNow/SSE2/SSSE3 implementations of MC ape: Use unsigned integer maths arm: dsputil: fix overreads in put/avg_pixels functions h264: K&R formatting cosmetics for header files (part II/II) h264: K&R formatting cosmetics for header files (part I/II) rtmp: Implement check bandwidth notification. rtmp: Support 'rtmp_swfurl', an option which specifies the URL of the SWF player. rtmp: Support 'rtmp_flashver', an option which overrides the version of the Flash plugin. rtmp: Support 'rtmp_tcurl', an option which overrides the URL of the target stream. cmdutils: Add fallback case to switch in check_stream_specifier(). sctp: be consistent with socket option level configure: Add _XOPEN_SOURCE=600 to Solaris preprocessor flags. vcr1enc: drop pointless empty encode_init() wrapper function vcr1: drop pointless write-only AVCodecContext member from VCR1Context vcr1: group encoder code together to save #ifdefs vcr1: cosmetics: K&R prettyprinting, typos, parentheses, dead code, comments mov: make one comment slightly more specific lavr: replace the SSE version of ff_conv_fltp_to_flt_6ch() with SSE4 and AVX lavfi: move audio-related functions to a separate file. lavfi: remove some audio-related function from public API. ... Conflicts: cmdutils.c libavcodec/h264.h libavcodec/h264_mvpred.h libavcodec/vcr1.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/defaults.c libavfilter/internal.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-10 22:41:29 +02:00
ff_filter_samples(ctx->outputs[0], outbuf);
2011-11-06 21:28:05 +01:00
}
2012-06-03 21:32:22 +02:00
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
{
AMergeContext *am = ctx->priv;
int ret, i;
char name[16];
am->class = &amerge_class;
av_opt_set_defaults(am);
ret = av_set_options_string(am, args, "=", ":");
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Error parsing options: '%s'\n", args);
return ret;
}
am->in = av_calloc(am->nb_inputs, sizeof(*am->in));
if (!am->in)
return AVERROR(ENOMEM);
for (i = 0; i < am->nb_inputs; i++) {
AVFilterPad pad = {
.name = name,
.type = AVMEDIA_TYPE_AUDIO,
.filter_samples = filter_samples,
.min_perms = AV_PERM_READ | AV_PERM_PRESERVE,
};
snprintf(name, sizeof(name), "in%d", i);
ff_insert_inpad(ctx, i, &pad);
2012-06-03 21:32:22 +02:00
}
return 0;
}
2011-11-06 21:28:05 +01:00
AVFilter avfilter_af_amerge = {
.name = "amerge",
.description = NULL_IF_CONFIG_SMALL("Merge two audio streams into "
"a single multi-channel stream."),
.priv_size = sizeof(AMergeContext),
2012-06-03 21:32:22 +02:00
.init = init,
2011-11-06 21:28:05 +01:00
.uninit = uninit,
.query_formats = query_formats,
2012-06-03 21:32:22 +02:00
.inputs = (const AVFilterPad[]) { { .name = NULL } },
2011-11-06 21:28:05 +01:00
.outputs = (const AVFilterPad[]) {
{ .name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.config_props = config_output,
.request_frame = request_frame, },
{ .name = NULL }
},
};