ffmpeg/libavfilter/audio.c

109 lines
3.4 KiB
C
Raw Permalink Normal View History

/*
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
* Copyright (c) Stefano Sabatini | stefasab at gmail.com
* Copyright (c) S.N. Hemanth Meenakshisundaram | smeenaks at ucsd.edu
*
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
* 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.
*
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
* 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
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
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
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
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "audio.h"
#include "avfilter.h"
#include "avfilter_internal.h"
#include "framepool.h"
#include "internal.h"
const AVFilterPad ff_audio_default_filterpad[1] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
}
};
AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
}
AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
AVFrame *frame = NULL;
FilterLinkInternal *const li = ff_link_internal(link);
int channels = link->ch_layout.nb_channels;
int align = av_cpu_max_align();
Merge commit '7e350379f87e7f74420b4813170fe808e2313911' * commit '7e350379f87e7f74420b4813170fe808e2313911': lavfi: switch to AVFrame. Conflicts: doc/filters.texi libavfilter/af_ashowinfo.c libavfilter/audio.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/buffersink.c libavfilter/buffersrc.c libavfilter/buffersrc.h libavfilter/f_select.c libavfilter/f_setpts.c libavfilter/fifo.c libavfilter/split.c libavfilter/src_movie.c libavfilter/version.h libavfilter/vf_aspect.c libavfilter/vf_bbox.c libavfilter/vf_blackframe.c libavfilter/vf_delogo.c libavfilter/vf_drawbox.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c libavfilter/vf_fieldorder.c libavfilter/vf_fps.c libavfilter/vf_frei0r.c libavfilter/vf_gradfun.c libavfilter/vf_hqdn3d.c libavfilter/vf_lut.c libavfilter/vf_overlay.c libavfilter/vf_pad.c libavfilter/vf_scale.c libavfilter/vf_showinfo.c libavfilter/vf_transpose.c libavfilter/vf_vflip.c libavfilter/vf_yadif.c libavfilter/video.c libavfilter/vsrc_testsrc.c libavfilter/yadif.h Following are notes about the merge authorship and various technical details. Michael Niedermayer: * Main merge operation, notably avfilter.c and video.c * Switch to AVFrame: - afade - anullsrc - apad - aresample - blackframe - deshake - idet - il - mandelbrot - mptestsrc - noise - setfield - smartblur - tinterlace * various merge changes and fixes in: - ashowinfo - blackdetect - field - fps - select - testsrc - yadif Nicolas George: * Switch to AVFrame: - make rawdec work with refcounted frames. Adapted from commit 759001c534287a96dc96d1e274665feb7059145d by Anton Khirnov. Also, fix the use of || instead of | in a flags check. - make buffer sink and src, audio and video work all together Clément Bœsch: * Switch to AVFrame: - aevalsrc - alphaextract - blend - cellauto - colormatrix - concat - earwax - ebur128 - edgedetect - geq - histeq - histogram - hue - kerndeint - life - movie - mp (with the help of Michael) - overlay - pad - pan - pp - pp - removelogo - sendcmd - showspectrum - showwaves - silencedetect - stereo3d - subtitles - super2xsai - swapuv - thumbnail - tile Hendrik Leppkes: * Switch to AVFrame: - aconvert - amerge - asetnsamples - atempo - biquads Matthieu Bouron: * Switch to AVFrame - alphamerge - decimate - volumedetect Stefano Sabatini: * Switch to AVFrame: - astreamsync - flite - framestep Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Nicolas George <nicolas.george@normalesup.org> Signed-off-by: Clément Bœsch <ubitux@gmail.com> Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com> Signed-off-by: Stefano Sabatini <stefasab@gmail.com> Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-10 01:30:30 +01:00
if (!li->frame_pool) {
li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
nb_samples, link->format, align);
if (!li->frame_pool)
return NULL;
} else {
int pool_channels = 0;
int pool_nb_samples = 0;
int pool_align = 0;
enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE;
if (ff_frame_pool_get_audio_config(li->frame_pool,
&pool_channels, &pool_nb_samples,
&pool_format, &pool_align) < 0) {
return NULL;
}
if (pool_channels != channels || pool_nb_samples < nb_samples ||
pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit(&li->frame_pool);
li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
nb_samples, link->format, align);
if (!li->frame_pool)
return NULL;
}
}
frame = ff_frame_pool_get(li->frame_pool);
if (!frame)
return NULL;
frame->nb_samples = nb_samples;
if (link->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC &&
av_channel_layout_copy(&frame->ch_layout, &link->ch_layout) < 0) {
av_frame_free(&frame);
return NULL;
}
frame->sample_rate = link->sample_rate;
av_samples_set_silence(frame->extended_data, 0, nb_samples, channels, link->format);
return frame;
}
AVFrame *ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
AVFrame *ret = NULL;
if (link->dstpad->get_buffer.audio)
ret = link->dstpad->get_buffer.audio(link, nb_samples);
if (!ret)
ret = ff_default_get_audio_buffer(link, nb_samples);
return ret;
}