[FFmpeg-devel] [PATCHv3 1/4] fate: add concat demuxer tests
Signed-off-by: Marton Balint --- tests/Makefile |1 + tests/extended.ffconcat| 114 + tests/fate-run.sh | 20 + tests/fate/concatdec.mak | 21 + tests/ref/fate/concat-demuxer-extended-lavf-mxf|1 + .../ref/fate/concat-demuxer-extended-lavf-mxf_d10 |1 + tests/ref/fate/concat-demuxer-simple1-lavf-mxf | 1713 ++ tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 | 1193 ++ tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2326 tests/simple1.ffconcat | 12 + tests/simple2.ffconcat | 19 + 11 files changed, 5421 insertions(+) create mode 100644 tests/extended.ffconcat create mode 100644 tests/fate/concatdec.mak create mode 100644 tests/ref/fate/concat-demuxer-extended-lavf-mxf create mode 100644 tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 create mode 100644 tests/ref/fate/concat-demuxer-simple1-lavf-mxf create mode 100644 tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 create mode 100644 tests/ref/fate/concat-demuxer-simple2-lavf-ts create mode 100644 tests/simple1.ffconcat create mode 100644 tests/simple2.ffconcat diff --git a/tests/Makefile b/tests/Makefile index 7ee4a46..62544d0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -113,6 +113,7 @@ include $(SRC_PATH)/tests/fate/audio.mak include $(SRC_PATH)/tests/fate/bmp.mak include $(SRC_PATH)/tests/fate/cdxl.mak include $(SRC_PATH)/tests/fate/checkasm.mak +include $(SRC_PATH)/tests/fate/concatdec.mak include $(SRC_PATH)/tests/fate/cover-art.mak include $(SRC_PATH)/tests/fate/demux.mak include $(SRC_PATH)/tests/fate/dfa.mak diff --git a/tests/extended.ffconcat b/tests/extended.ffconcat new file mode 100644 index 000..7359113 --- /dev/null +++ b/tests/extended.ffconcat @@ -0,0 +1,114 @@ +ffconcat version 1.0 + +file %SRCFILE% + +file %SRCFILE% +duration 1 +file_packet_metadata dummy=1 + +file %SRCFILE% +inpoint 00:00.00 +outpoint 00:00.04 + +file %SRCFILE% +inpoint 00:00.04 +outpoint 00:00.08 + +file %SRCFILE% +inpoint 00:00.08 +outpoint 00:00.12 + +file %SRCFILE% +inpoint 00:00.12 +outpoint 00:00.16 + +file %SRCFILE% +inpoint 00:00.16 +outpoint 00:00.20 + +file %SRCFILE% +inpoint 00:00.20 +outpoint 00:00.24 + +file %SRCFILE% +inpoint 00:00.24 +outpoint 00:00.28 + +file %SRCFILE% +inpoint 00:00.28 +outpoint 00:00.32 + +file %SRCFILE% +inpoint 00:00.32 +outpoint 00:00.36 + +file %SRCFILE% +inpoint 00:00.36 +outpoint 00:00.40 + +file %SRCFILE% +inpoint 00:00.40 +outpoint 00:00.44 + +file %SRCFILE% +inpoint 00:00.44 +outpoint 00:00.48 + +file %SRCFILE% +inpoint 00:00.48 +outpoint 00:00.52 + +file %SRCFILE% +inpoint 00:00.52 +outpoint 00:00.56 + +file %SRCFILE% +inpoint 00:00.56 +outpoint 00:00.60 + +file %SRCFILE% +inpoint 00:00.60 +outpoint 00:00.64 + +file %SRCFILE% +inpoint 00:00.64 +outpoint 00:00.68 + +file %SRCFILE% +inpoint 00:00.68 +outpoint 00:00.72 + +file %SRCFILE% +inpoint 00:00.72 +outpoint 00:00.76 + +file %SRCFILE% +inpoint 00:00.76 +outpoint 00:00.80 + +file %SRCFILE% +inpoint 00:00.80 +outpoint 00:00.84 + +file %SRCFILE% +inpoint 00:00.84 +outpoint 00:00.88 + +file %SRCFILE% +inpoint 00:00.88 +outpoint 00:00.92 + +file %SRCFILE% +inpoint 00:00.92 +outpoint 00:00.96 + +file %SRCFILE% +inpoint 00:00.96 +outpoint 00:01.00 + +file %SRCFILE% +outpoint 00:00.40 + +file %SRCFILE% +inpoint 00:00.40 + diff --git a/tests/fate-run.sh b/tests/fate-run.sh index a3938dc..88ec0e6 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -249,6 +249,26 @@ gapless(){ do_md5sum $decfile3 } +concat(){ +template=$1 +sample=$(target_path $2) +mode=$3 +extra_args=$4 + +concatfile="${outdir}/${test}.ffconcat" +packetfile="${outdir}/${test}.ffprobe" +cleanfiles="$concatfile $packetfile" + +awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile + +if [ "$mode" = "md5" ]; then + run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -fflags keepside -safe 0 $extra_args $concatfile > $packetfile + do_md5sum $packetfile +else + run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -fflags keepside -safe 0 $extra_args $concatfile +fi +} + mkdir -p "$outdir" # Disable globbing: command arguments may contain globbing characters and diff --git a/tests/fate/concatdec.mak b/tests/fate/concatdec.mak new file mode 100644 index 000..7bb202b --- /dev/null +++ b/tests/fate/concatdec.mak @@ -0,0 +1,21 @@ +FATE_CONCAT_DEMUXER_SIMPLE1_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += mxf +FATE_CONCAT_DEMUXER_SIMPLE1_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += mxf_d10 + +FATE_C
Re: [FFmpeg-devel] [PATCHv2] swresample/resample: improve bessel function accuracy and speed
On Tue, Nov 3, 2015 at 4:52 PM, Ganesh Ajjanagadde wrote: > On Tue, Nov 3, 2015 at 4:49 PM, Ganesh Ajjanagadde > wrote: >> [...] > > Same as v1, except with appropriate Boost license included inline and > commit message rework to include the perf numbers. Carl pointed out that the copyright message must also be included. Sorry for missing it. Assuming it is added (e.g right above the function), are all legal issues handled, and is this ok to commit? BTW, who is the go-to person in FFmpeg for these kinds of legal things? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH][RFC] avcodec/aacsbr_template: replace qsort with AV_QSORT
On Tue, Nov 3, 2015 at 7:56 PM, Rostislav Pehlivanov wrote: > The binary increase is 16 kbytes per file * 2 (since it's a template for > the fixed and float decoders) = 32 kbytes. This is not very significant at > all, even for the most memory and storage-space constrained (with an MMU) > device. (not to mention that this is using the default compiler > optimizations, GCC is probably smart enough not to inline the functions if > optimization for size has been enabled). > Performance wise this is probably worth it since this is an init function > and you absolutely want to spend the least amount of time doing this. > I'd normally be against not using standard libc functions but since qsort > there is probably as optimized as it can be without inlining and we can > beat it speed wise, it's nice and I'm for it. Ok, pushed. Thanks. > > On 3 November 2015 at 21:13, Ganesh Ajjanagadde wrote: > >> On Tue, Nov 3, 2015 at 3:24 PM, Rostislav Pehlivanov >> wrote: >> > LGTM. >> > Tested the patch, doesn't change the output. >> >> I am personally fine with this, but was hoping for an opinion on >> whether the perf increase here is important enough to justify the >> binary size increase. Hence my ping to the AAC people here. >> >> > >> > On 28 October 2015 at 01:38, Ganesh Ajjanagadde >> > wrote: >> > >> >> When sbr->reset is set in encode_frame, a bunch of qsort calls might get >> >> made. >> >> Thus, there is the potential of calling qsort whenever the spectral >> >> contents change. >> >> >> >> AV_QSORT is substantially faster due to the inlining of the comparison >> >> callback. >> >> Thus, the increase in performance should be worth the increase in binary >> >> size. >> >> >> >> Tested with FATE. >> >> >> >> Signed-off-by: Ganesh Ajjanagadde >> >> >> >> >> >> >> >> >> Please note that I am not not knowledgable about AAC, and above analysis >> >> was based on a quick glance at the code. I could not get benchmarks with >> >> runs > 1 easily (even with stream_loop), hence they are omitted. >> >> Furthermore, it seems like AAC is under active work, so I defer >> >> meaningful benchmarks to the maintainers. >> >> --- >> >> libavcodec/aacsbr_template.c | 14 -- >> >> 1 file changed, 8 insertions(+), 6 deletions(-) >> >> >> >> diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c >> >> index d31b71e..9561ba0 100644 >> >> --- a/libavcodec/aacsbr_template.c >> >> +++ b/libavcodec/aacsbr_template.c >> >> @@ -32,6 +32,8 @@ >> >> * @author Zoran Basaric ( zoran.basa...@imgtec.com ) >> >> */ >> >> >> >> +#include "libavutil/qsort.h" >> >> + >> >> av_cold void AAC_RENAME(ff_aac_sbr_init)(void) >> >> { >> >> static const struct { >> >> @@ -138,8 +140,8 @@ static void >> >> sbr_make_f_tablelim(SpectralBandReplication *sbr) >> >> memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, >> >> (sbr->num_patches - 1) * sizeof(patch_borders[0])); >> >> >> >> -qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], >> >> - sizeof(sbr->f_tablelim[0]), >> >> +AV_QSORT(sbr->f_tablelim, sbr->num_patches + sbr->n[0], >> >> + uint16_t, >> >>qsort_comparison_function_int16); >> >> >> >> sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; >> >> @@ -296,7 +298,7 @@ static int sbr_make_f_master(AACContext *ac, >> >> SpectralBandReplication *sbr, >> >> if (spectrum->bs_stop_freq < 14) { >> >> sbr->k[2] = stop_min; >> >> make_bands(stop_dk, stop_min, 64, 13); >> >> -qsort(stop_dk, 13, sizeof(stop_dk[0]), >> >> qsort_comparison_function_int16); >> >> +AV_QSORT(stop_dk, 13, int16_t, >> qsort_comparison_function_int16); >> >> for (k = 0; k < spectrum->bs_stop_freq; k++) >> >> sbr->k[2] += stop_dk[k]; >> >> } else if (spectrum->bs_stop_freq == 14) { >> >> @@ -389,7 +391,7 @@ static int sbr_make_f_master(AACContext *ac, >> >> SpectralBandReplication *sbr, >> >> >> >> make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); >> >> >> >> -qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), >> >> qsort_comparison_function_int16); >> >> +AV_QSORT(vk0 + 1, num_bands_0, int16_t, >> >> qsort_comparison_function_int16); >> >> vdk0_max = vk0[num_bands_0]; >> >> >> >> vk0[0] = sbr->k[0]; >> >> @@ -430,13 +432,13 @@ static int sbr_make_f_master(AACContext *ac, >> >> SpectralBandReplication *sbr, >> >> >> >> if (vdk1_min < vdk0_max) { >> >> int change; >> >> -qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), >> >> qsort_comparison_function_int16); >> >> +AV_QSORT(vk1 + 1, num_bands_1, int16_t, >> >> qsort_comparison_function_int16); >> >> change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - >> >> vk1[1]) >> 1); >> >> vk1[1] += change; >> >>
[FFmpeg-devel] [PATCH] XMA1 and XMA2 stereo decoders
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 2 ++ libavcodec/allcodecs.c | 2 ++ libavcodec/avcodec.h| 2 ++ libavcodec/codec_desc.c | 14 libavcodec/wmaprodec.c | 94 ++--- libavformat/riff.c | 2 ++ libavformat/riffdec.c | 25 ++--- 7 files changed, 131 insertions(+), 10 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 67fb72a..06d3ddd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -586,6 +586,8 @@ OBJS-$(CONFIG_XBM_ENCODER) += xbmenc.o OBJS-$(CONFIG_XFACE_DECODER) += xfacedec.o xface.o OBJS-$(CONFIG_XFACE_ENCODER) += xfaceenc.o xface.o OBJS-$(CONFIG_XL_DECODER) += xl.o +OBJS-$(CONFIG_XMA1_DECODER)+= wmaprodec.o wma.o wma_common.o +OBJS-$(CONFIG_XMA2_DECODER)+= wmaprodec.o wma.o wma_common.o OBJS-$(CONFIG_XSUB_DECODER)+= xsubdec.o OBJS-$(CONFIG_XSUB_ENCODER)+= xsubenc.o OBJS-$(CONFIG_XWD_DECODER) += xwddec.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 095f812..4a21fe7 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -445,6 +445,8 @@ void avcodec_register_all(void) REGISTER_ENCDEC (WMAV2, wmav2); REGISTER_DECODER(WMAVOICE, wmavoice); REGISTER_DECODER(WS_SND1, ws_snd1); +REGISTER_DECODER(XMA1, xma1); +REGISTER_DECODER(XMA2, xma2); /* PCM codecs */ REGISTER_ENCDEC (PCM_ALAW, pcm_alaw); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 91cd6a8..95cdf5a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -497,6 +497,8 @@ enum AVCodecID { AV_CODEC_ID_DSD_MSBF_PLANAR, AV_CODEC_ID_4GV, AV_CODEC_ID_INTERPLAY_ACM, +AV_CODEC_ID_XMA1, +AV_CODEC_ID_XMA2, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index c611740..9cad3e6 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2629,6 +2629,20 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Interplay ACM"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_XMA1, +.type = AVMEDIA_TYPE_AUDIO, +.name = "xma1", +.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 1"), +.props = AV_CODEC_PROP_LOSSY, +}, +{ +.id= AV_CODEC_ID_XMA2, +.type = AVMEDIA_TYPE_AUDIO, +.name = "xma2", +.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 2"), +.props = AV_CODEC_PROP_LOSSY, +}, /* subtitle codecs */ { diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 19dc335..7471961 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -86,6 +86,8 @@ * subframe in order to reconstruct the output samples. */ +#define DEBUG 1 + #include #include "libavutil/float_dsp.h" @@ -206,9 +208,12 @@ typedef struct WMAProDecodeCtx { int subframe_offset; ///< subframe offset in the bit reservoir uint8_t packet_loss; ///< set in case of bitstream error uint8_t packet_done; ///< set when a packet is fully decoded +uint8_t skip_packets; +int8_t packet_metadata; /* frame decode state */ uint32_t frame_num; ///< current frame number (not used for decoding) +int num_frames; GetBitContextgb;///< bitstream reader context int buf_bit_size; ///< buffer size in bits uint8_t drc_gain; ///< gain for the DRC tool @@ -282,6 +287,9 @@ static av_cold int decode_init(AVCodecContext *avctx) int log2_max_num_subframes; int num_possible_block_sizes; +if (avctx->codec_id == AV_CODEC_ID_XMA1 || avctx->codec_id == AV_CODEC_ID_XMA2) +avctx->block_align = 2048; + if (!avctx->block_align) { av_log(avctx, AV_LOG_ERROR, "block_align is not set\n"); return AVERROR(EINVAL); @@ -296,7 +304,25 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; -if (avctx->extradata_size >= 18) { +if (avctx->codec_id == AV_CODEC_ID_XMA2 && avctx->extradata_size >= 34) { +s->decode_flags= 0x10d6; +channel_mask = AV_RL32(edata_ptr+2); +s->bits_per_sample = 16; +/** dump the extradata */ +for (i = 0; i < avctx->extradata_size; i++) +ff_dlog(avctx, "[%x] ", avctx->extradata[i]); +ff_dlog(avctx, "\n"); + + } else if (avctx->codec_id == AV_
[FFmpeg-devel] [PATCHv3] swresample/resample: improve bessel function accuracy and speed
This improves accuracy for the bessel function at large arguments, and this in turn should improve the quality of the Kaiser window. It also improves the performance of the bessel function and hence build_filter by ~ 20%. Details are given below. Algorithm: taken from the Boost project, who have done a detailed investigation of the accuracy of their method, as compared with e.g the GNU Scientific Library (GSL): http://www.boost.org/doc/libs/1_52_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html. Boost source code (also cited and licensed in the code): https://searchcode.com/codesearch/view/14918379/. Accuracy: sample values may be obtained as follows. i0 denotes the old bessel code, i0_boost the approach here, and i0_real an arbitrary precision result (truncated) from Wolfram Alpha: type "bessel i0(6.0)" to reproduce. These are evaluation points that occur for the default kaiser_beta = 9. Some illustrations: bessel(8.0) i0 (8.00) = 427.564115721804739678191254 i0_boost(8.00) = 427.564115721804796521610115 i0_real (8.00) = 427.564115721804785177396791 bessel(6.0) i0 (6.00) = 67.234406976477956163762428 i0_boost(6.00) = 67.234406976477970374617144 i0_real (6.00) = 67.234406976477975326188025 Reason for accuracy: Main accuracy benefits come at larger bessel arguments, where the Taylor-Maclaurin method is not that good: 23+ iterations (at large arguments, since the series is about 0) can cause significant floating point error accumulation. Benchmarks: Obtained on x86-64, Haswell, GNU/Linux via a loop calling build_filter 1000 times: test: fate-swr-resample-dblp-44100-2626 new: 995894468 decicycles in build_filter(loop 1000), 256 runs, 0 skips 1029719302 decicycles in build_filter(loop 1000), 512 runs, 0 skips 984101131 decicycles in build_filter(loop 1000),1024 runs, 0 skips old: 1250020763 decicycles in build_filter(loop 1000), 256 runs, 0 skips 1246353282 decicycles in build_filter(loop 1000), 512 runs, 0 skips 1220017565 decicycles in build_filter(loop 1000),1024 runs, 0 skips A further ~ 5% may be squeezed by enabling -ftree-vectorize. However, this is a separate issue from this patch. Reviewed-by: Michael Niedermayer Signed-off-by: Ganesh Ajjanagadde --- libswresample/resample.c | 125 +-- 1 file changed, 98 insertions(+), 27 deletions(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index 51cb183..0dd282c 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -28,38 +28,109 @@ #include "libavutil/avassert.h" #include "resample.h" +static inline double eval_poly(const double *coeff, int size, double x) { +double sum = coeff[size-1]; +int i; +for (i = size-2; i >= 0; --i) { +sum *= x; +sum += coeff[i]; +} +return sum; +} + /** * 0th order modified bessel function of the first kind. + * Algorithm taken from the Boost project, source: + * https://searchcode.com/codesearch/view/14918379/ + * Copyright (c) 2006 Xiaogang Zhang + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0 (see notice below). + * Boost Software License - Version 1.0 - August 17th, 2003 +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. */ -static double bessel(double x){ -double lastv=0; -double t, v; -int i; -static const double inv[100]={ - 1.0/( 1* 1), 1.0/( 2* 2), 1.0/( 3* 3), 1.0/( 4* 4), 1.0/( 5* 5), 1.0/( 6* 6), 1.0/( 7* 7), 1.0/( 8* 8), 1.0/( 9* 9), 1.0/(10*10), - 1.0/(11*11), 1.0/(12*12), 1.0/(13*13), 1.0/(14*14), 1.0/(15*15), 1.0/(16*16), 1.0/(17*17), 1.0/(18*18), 1.0/(19*19), 1.0/(20*20), -
Re: [FFmpeg-devel] [PATCH] swresample/resample: speed up build_filter
On Wed, Nov 04, 2015 at 01:11:45AM -0500, Ganesh Ajjanagadde wrote: > This speeds up build_filter by ~ 50%. This gain should be pretty > consistent across all architectures and platforms. > > Essentially, this relies on a observation that the filters have some > even/odd symmetry that may be exploited during the construction of the > polyphase filter bank. In particular, phases (scaled to [0, 1]) in [0.5, 1] > are > easily derived from [0, 0.5] and expensive reevaluation of function > points are unnecessary. This requires some rather annoying even/odd > bookkeeping as can be seen from the patch. > > I vaguely recall from signal processing theory more general symmetries > allowing even greater > optimization of the construction. At a high level, "even functions" > correspond to 2, and one can imagine variations. Nevertheless, for the sake > of some generality and because of existing filters, this is all that is > being exploited. > > Currently, this patch relies on phase_count being even or (trivially) 1, > though this is not an inherent limitation to the approach. This > assumption is safe as phase_count is 1 << phase_bits, and is hence a > power of two. There is no way for user API to set it to a nontrivial odd > number. This assumption has been placed as an assert in the code. > > To repeat, this assumes even symmetry of the filters, which is the most common > way to get generalized linear phase anyway and is true of all currently > supported filters. > > As a side note, accuracy should be identical or perhaps slightly better > due to this "forcing" filter symmetries leading to a better phase > characteristic. As before, I can't test this claim easily, though it may > be of interest. > > Patch tested with FATE. > > Sample benchmark (x86-64, Haswell, GNU/Linux): > > test: swr-resample-dblp-44100-2626 > > new: > 527376779 decicycles in build_filter(loop 1000), 256 runs, 0 skips > 524361765 decicycles in build_filter(loop 1000), 512 runs, 0 skips > 516552574 decicycles in build_filter(loop 1000),1024 runs, 0 skips > > old: > 974178658 decicycles in build_filter(loop 1000), 256 runs, 0 skips > 972794408 decicycles in build_filter(loop 1000), 512 runs, 0 skips > 954350046 decicycles in build_filter(loop 1000),1024 runs, 0 skips > > Note that lower level optimizations are entirely possible, I focussed on > getting the high level semantics correct. In any case, this should > provide a good foundation. > > Signed-off-by: Ganesh Ajjanagadde > --- > libswresample/resample.c | 56 > +--- > 1 file changed, 48 insertions(+), 8 deletions(-) > > diff --git a/libswresample/resample.c b/libswresample/resample.c > index 235c9a9..d5fc5e7 100644 > --- a/libswresample/resample.c > +++ b/libswresample/resample.c > @@ -144,7 +144,7 @@ static int build_filter(ResampleContext *c, void *filter, > double factor, int tap > int filter_type, int kaiser_beta){ > int ph, i; > double x, y, w; > -double *tab = av_malloc_array(tap_count, sizeof(*tab)); > +double *tab = av_malloc_array(tap_count+1, sizeof(*tab)); > const int center= (tap_count-1)/2; > > if (!tab) > @@ -154,9 +154,10 @@ static int build_filter(ResampleContext *c, void > *filter, double factor, int tap > if (factor > 1.0) > factor = 1.0; > > -for(ph=0;ph +av_assert0(phase_count == 1 || phase_count % 2 == 0); > +for(ph = 0; ph <= phase_count / 2; ph++) { > double norm = 0; > -for(i=0;i +for(i=0;i<=tap_count;i++) { > x = M_PI * ((double)(i - center) - (double)ph / phase_count) * > factor; > if (x == 0) y = 1.0; > elsey = sin(x) / x; > @@ -180,26 +181,65 @@ static int build_filter(ResampleContext *c, void > *filter, double factor, int tap > } > > tab[i] = y; > -norm += y; > +if (i < tap_count) > +norm += y; > } > > /* normalize so that an uniform color remains the same */ > switch(c->format){ > case AV_SAMPLE_FMT_S16P: > -for(i=0;i +for(i=0;i ((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * > scale / norm), INT16_MIN, INT16_MAX); > +} > +if (tap_count % 2 == 0) { > +for (i = 0; i < tap_count; i++) > +((int16_t*)filter)[(phase_count-ph) * alloc + > tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i]; > +} > +else { > +for (i = 1; i <= tap_count; i++) > +((int16_t*)filter)[(phase_count-ph) * alloc + > tap_count-i] = > +av_clip(lrintf(tab[i] * scale / (norm - tab[0] + > tab[tap_count])), INT16_MIN, INT16_MAX); > +} > break; > case AV_SAMPLE_FMT_S32P: > -for(i=0;
Re: [FFmpeg-devel] [PATCH] XMA1 and XMA2 stereo decoders
Hi Paul! On 2015-11-04 14:18 +0100, Paul B Mahol wrote: [...] > diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c > index 19dc335..7471961 100644 > --- a/libavcodec/wmaprodec.c > +++ b/libavcodec/wmaprodec.c > @@ -86,6 +86,8 @@ > * subframe in order to reconstruct the output samples. > */ > > +#define DEBUG 1 > + > #include I guess this is a leftover from testing. [...] Alexander ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] swresample: Add support for clipping float/double to -1.0..1.0 range
On Fri, 23 Oct 2015 18:08:00 +0200 Michael Niedermayer wrote: > From: Michael Niedermayer > > Signed-off-by: Michael Niedermayer > --- > libswresample/aarch64/audio_convert_init.c |8 - > libswresample/arm/audio_convert_init.c |8 - > libswresample/audioconvert.c | 44 > ++-- > libswresample/options.c|1 + > libswresample/swresample.c |6 ++-- > libswresample/swresample.h |1 + > libswresample/swresample_internal.h|6 ++-- > libswresample/x86/audio_convert_init.c |8 - > 8 files changed, 71 insertions(+), 11 deletions(-) > > diff --git a/libswresample/aarch64/audio_convert_init.c > b/libswresample/aarch64/audio_convert_init.c > index 60e24ad..dedb1aa 100644 > --- a/libswresample/aarch64/audio_convert_init.c > +++ b/libswresample/aarch64/audio_convert_init.c > @@ -48,12 +48,18 @@ static void conv_fltp_to_s16_nch_neon(uint8_t **dst, > const uint8_t **src, int le > av_cold void swri_audio_convert_init_aarch64(struct AudioConvert *ac, > enum AVSampleFormat out_fmt, > enum AVSampleFormat in_fmt, > - int channels) > + int channels, int flags) > { > int cpu_flags = av_get_cpu_flags(); > > ac->simd_f= NULL; > > +if ( (flags & SWR_FLAG_CLIP) > +&& av_get_packed_sample_fmt(in_fmt) == AV_SAMPLE_FMT_FLT > +&& av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_FLT) { > +return; > +} > + > if (have_neon(cpu_flags)) { > if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || > out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP) > ac->simd_f = conv_flt_to_s16_neon; > diff --git a/libswresample/arm/audio_convert_init.c > b/libswresample/arm/audio_convert_init.c > index ec9e62e..f39978d 100644 > --- a/libswresample/arm/audio_convert_init.c > +++ b/libswresample/arm/audio_convert_init.c > @@ -48,12 +48,18 @@ static void conv_fltp_to_s16_nch_neon(uint8_t **dst, > const uint8_t **src, int le > av_cold void swri_audio_convert_init_arm(struct AudioConvert *ac, > enum AVSampleFormat out_fmt, > enum AVSampleFormat in_fmt, > - int channels) > + int channels, int flags) > { > int cpu_flags = av_get_cpu_flags(); > > ac->simd_f= NULL; > > +if ( (flags & SWR_FLAG_CLIP) > +&& av_get_packed_sample_fmt(in_fmt) == AV_SAMPLE_FMT_FLT > +&& av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_FLT) { > +return; > +} > + > if (have_neon(cpu_flags)) { > if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || > out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP) > ac->simd_f = conv_flt_to_s16_neon; > diff --git a/libswresample/audioconvert.c b/libswresample/audioconvert.c > index 58b0bf3..dc6734a 100644 > --- a/libswresample/audioconvert.c > +++ b/libswresample/audioconvert.c > @@ -77,6 +77,27 @@ CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, > av_clipl_int32(llrint(* > CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, *(const double*)pi) > CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, *(const double*)pi) > > +#define CONV_FUNC_NAME_CLIP(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ ## > dst_fmt ## _clip > +#define CONV_FUNC_CLIP(ofmt, otype, ifmt, expr)\ > +static void CONV_FUNC_NAME_CLIP(ofmt, ifmt)(uint8_t *po, const uint8_t *pi, > int is, int os, uint8_t *end)\ > +{\ > +uint8_t *end2 = end - 3*os;\ > +while(po < end2){\ > +*(otype*)po = expr; pi += is; po += os;\ > +*(otype*)po = expr; pi += is; po += os;\ > +*(otype*)po = expr; pi += is; po += os;\ > +*(otype*)po = expr; pi += is; po += os;\ > +}\ > +while(po < end){\ > +*(otype*)po = expr; pi += is; po += os;\ > +}\ > +} > + > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_FLT, > av_clipf(*(const float*)pi, -1.0, 1.0)) > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_FLT, > av_clipf(*(const float*)pi, -1.0, 1.0)) > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, > av_clipf(*(const double*)pi, -1.0, 1.0)) > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, > av_clipd(*(const double*)pi, -1.0, 1.0)) > + > #define FMT_PAIR_FUNC(out, in) [(out) + AV_SAMPLE_FMT_NB*(in)] = > CONV_FUNC_NAME(out, in) > > static conv_func_type * const > fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB*AV_SAMPLE_FMT_NB] = { > @@ -107,6 +128,15 @@ static conv_func_type * const > fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB*AV_SAM > FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), > }; > > +#define FMT_PAI
Re: [FFmpeg-devel] [PATCHv3 1/4] fate: add concat demuxer tests
Le quartidi 14 brumaire, an CCXXIV, Marton Balint a écrit : > + run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -fflags > keepside -safe 0 $extra_args $concatfile > $packetfile Maybe -of compact, that makes the reference files quite smaller. I had not realized they would be that big, even with a shorter script; if people object, I will not insist on having the full output there. Thanks for your efforts. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] swresample/resample: speed up build_filter
On Wed, Nov 4, 2015 at 9:44 AM, Michael Niedermayer wrote: > On Wed, Nov 04, 2015 at 01:11:45AM -0500, Ganesh Ajjanagadde wrote: >> This speeds up build_filter by ~ 50%. This gain should be pretty >> consistent across all architectures and platforms. >> >> Essentially, this relies on a observation that the filters have some >> even/odd symmetry that may be exploited during the construction of the >> polyphase filter bank. In particular, phases (scaled to [0, 1]) in [0.5, 1] >> are >> easily derived from [0, 0.5] and expensive reevaluation of function >> points are unnecessary. This requires some rather annoying even/odd >> bookkeeping as can be seen from the patch. >> >> I vaguely recall from signal processing theory more general symmetries >> allowing even greater >> optimization of the construction. At a high level, "even functions" >> correspond to 2, and one can imagine variations. Nevertheless, for the sake >> of some generality and because of existing filters, this is all that is >> being exploited. >> >> Currently, this patch relies on phase_count being even or (trivially) 1, >> though this is not an inherent limitation to the approach. This >> assumption is safe as phase_count is 1 << phase_bits, and is hence a >> power of two. There is no way for user API to set it to a nontrivial odd >> number. This assumption has been placed as an assert in the code. >> >> To repeat, this assumes even symmetry of the filters, which is the most >> common >> way to get generalized linear phase anyway and is true of all currently >> supported filters. >> >> As a side note, accuracy should be identical or perhaps slightly better >> due to this "forcing" filter symmetries leading to a better phase >> characteristic. As before, I can't test this claim easily, though it may >> be of interest. >> >> Patch tested with FATE. >> >> Sample benchmark (x86-64, Haswell, GNU/Linux): >> >> test: swr-resample-dblp-44100-2626 >> >> new: >> 527376779 decicycles in build_filter(loop 1000), 256 runs, 0 skips >> 524361765 decicycles in build_filter(loop 1000), 512 runs, 0 skips >> 516552574 decicycles in build_filter(loop 1000),1024 runs, 0 skips >> >> old: >> 974178658 decicycles in build_filter(loop 1000), 256 runs, 0 skips >> 972794408 decicycles in build_filter(loop 1000), 512 runs, 0 skips >> 954350046 decicycles in build_filter(loop 1000),1024 runs, 0 skips >> >> Note that lower level optimizations are entirely possible, I focussed on >> getting the high level semantics correct. In any case, this should >> provide a good foundation. >> >> Signed-off-by: Ganesh Ajjanagadde >> --- >> libswresample/resample.c | 56 >> +--- >> 1 file changed, 48 insertions(+), 8 deletions(-) >> >> diff --git a/libswresample/resample.c b/libswresample/resample.c >> index 235c9a9..d5fc5e7 100644 >> --- a/libswresample/resample.c >> +++ b/libswresample/resample.c >> @@ -144,7 +144,7 @@ static int build_filter(ResampleContext *c, void >> *filter, double factor, int tap >> int filter_type, int kaiser_beta){ >> int ph, i; >> double x, y, w; >> -double *tab = av_malloc_array(tap_count, sizeof(*tab)); >> +double *tab = av_malloc_array(tap_count+1, sizeof(*tab)); >> const int center= (tap_count-1)/2; >> >> if (!tab) >> @@ -154,9 +154,10 @@ static int build_filter(ResampleContext *c, void >> *filter, double factor, int tap >> if (factor > 1.0) >> factor = 1.0; >> >> -for(ph=0;ph> +av_assert0(phase_count == 1 || phase_count % 2 == 0); >> +for(ph = 0; ph <= phase_count / 2; ph++) { >> double norm = 0; >> -for(i=0;i> +for(i=0;i<=tap_count;i++) { >> x = M_PI * ((double)(i - center) - (double)ph / phase_count) * >> factor; >> if (x == 0) y = 1.0; >> elsey = sin(x) / x; >> @@ -180,26 +181,65 @@ static int build_filter(ResampleContext *c, void >> *filter, double factor, int tap >> } >> >> tab[i] = y; >> -norm += y; >> +if (i < tap_count) >> +norm += y; >> } >> >> /* normalize so that an uniform color remains the same */ >> switch(c->format){ >> case AV_SAMPLE_FMT_S16P: >> -for(i=0;i> +for(i=0;i> ((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] >> * scale / norm), INT16_MIN, INT16_MAX); >> +} >> +if (tap_count % 2 == 0) { >> +for (i = 0; i < tap_count; i++) >> +((int16_t*)filter)[(phase_count-ph) * alloc + >> tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i]; >> +} >> +else { >> +for (i = 1; i <= tap_count; i++) >> +((int16_t*)filter)[(phase_count-ph) * alloc + >> tap_count-i] = >> +av_clip(lrintf(tab[i] * scale /
Re: [FFmpeg-devel] [PATCH] swresample: Add support for clipping float/double to -1.0..1.0 range
On Fri, Oct 23, 2015 at 07:18:06PM +0200, wm4 wrote: > On Fri, 23 Oct 2015 18:08:00 +0200 > Michael Niedermayer wrote: > > > From: Michael Niedermayer > > > > Signed-off-by: Michael Niedermayer > > --- > > libswresample/aarch64/audio_convert_init.c |8 - > > libswresample/arm/audio_convert_init.c |8 - > > libswresample/audioconvert.c | 44 > > ++-- > > libswresample/options.c|1 + > > libswresample/swresample.c |6 ++-- > > libswresample/swresample.h |1 + > > libswresample/swresample_internal.h|6 ++-- > > libswresample/x86/audio_convert_init.c |8 - > > 8 files changed, 71 insertions(+), 11 deletions(-) > > > > diff --git a/libswresample/aarch64/audio_convert_init.c > > b/libswresample/aarch64/audio_convert_init.c > > index 60e24ad..dedb1aa 100644 > > --- a/libswresample/aarch64/audio_convert_init.c > > +++ b/libswresample/aarch64/audio_convert_init.c > > @@ -48,12 +48,18 @@ static void conv_fltp_to_s16_nch_neon(uint8_t **dst, > > const uint8_t **src, int le > > av_cold void swri_audio_convert_init_aarch64(struct AudioConvert *ac, > > enum AVSampleFormat out_fmt, > > enum AVSampleFormat in_fmt, > > - int channels) > > + int channels, int flags) > > { > > int cpu_flags = av_get_cpu_flags(); > > > > ac->simd_f= NULL; > > > > +if ( (flags & SWR_FLAG_CLIP) > > +&& av_get_packed_sample_fmt(in_fmt) == AV_SAMPLE_FMT_FLT > > +&& av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_FLT) { > > +return; > > +} > > + > > if (have_neon(cpu_flags)) { > > if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || > > out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP) > > ac->simd_f = conv_flt_to_s16_neon; > > diff --git a/libswresample/arm/audio_convert_init.c > > b/libswresample/arm/audio_convert_init.c > > index ec9e62e..f39978d 100644 > > --- a/libswresample/arm/audio_convert_init.c > > +++ b/libswresample/arm/audio_convert_init.c > > @@ -48,12 +48,18 @@ static void conv_fltp_to_s16_nch_neon(uint8_t **dst, > > const uint8_t **src, int le > > av_cold void swri_audio_convert_init_arm(struct AudioConvert *ac, > > enum AVSampleFormat out_fmt, > > enum AVSampleFormat in_fmt, > > - int channels) > > + int channels, int flags) > > { > > int cpu_flags = av_get_cpu_flags(); > > > > ac->simd_f= NULL; > > > > +if ( (flags & SWR_FLAG_CLIP) > > +&& av_get_packed_sample_fmt(in_fmt) == AV_SAMPLE_FMT_FLT > > +&& av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_FLT) { > > +return; > > +} > > + > > if (have_neon(cpu_flags)) { > > if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || > > out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP) > > ac->simd_f = conv_flt_to_s16_neon; > > diff --git a/libswresample/audioconvert.c b/libswresample/audioconvert.c > > index 58b0bf3..dc6734a 100644 > > --- a/libswresample/audioconvert.c > > +++ b/libswresample/audioconvert.c > > @@ -77,6 +77,27 @@ CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, > > av_clipl_int32(llrint(* > > CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, *(const > > double*)pi) > > CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, *(const > > double*)pi) > > > > +#define CONV_FUNC_NAME_CLIP(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ ## > > dst_fmt ## _clip > > +#define CONV_FUNC_CLIP(ofmt, otype, ifmt, expr)\ > > +static void CONV_FUNC_NAME_CLIP(ofmt, ifmt)(uint8_t *po, const uint8_t > > *pi, int is, int os, uint8_t *end)\ > > +{\ > > +uint8_t *end2 = end - 3*os;\ > > +while(po < end2){\ > > +*(otype*)po = expr; pi += is; po += os;\ > > +*(otype*)po = expr; pi += is; po += os;\ > > +*(otype*)po = expr; pi += is; po += os;\ > > +*(otype*)po = expr; pi += is; po += os;\ > > +}\ > > +while(po < end){\ > > +*(otype*)po = expr; pi += is; po += os;\ > > +}\ > > +} > > + > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_FLT, > > av_clipf(*(const float*)pi, -1.0, 1.0)) > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_FLT, > > av_clipf(*(const float*)pi, -1.0, 1.0)) > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, > > av_clipf(*(const double*)pi, -1.0, 1.0)) > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, > > av_clipd(*(const double*)pi, -1.0, 1.0)) > > + > > #define FMT_PAIR_FUNC(out, in) [(out) + AV_SAMPLE_FMT_NB*(in)] = > > CONV_FUNC_NAME(out, in) > > > > static
Re: [FFmpeg-devel] [PATCH] swresample: Add support for clipping float/double to -1.0..1.0 range
On Wed, 4 Nov 2015 16:15:36 +0100 Michael Niedermayer wrote: > On Fri, Oct 23, 2015 at 07:18:06PM +0200, wm4 wrote: > > On Fri, 23 Oct 2015 18:08:00 +0200 > > Michael Niedermayer wrote: > > > > > From: Michael Niedermayer > > > > > > Signed-off-by: Michael Niedermayer > > > --- > > > libswresample/aarch64/audio_convert_init.c |8 - > > > libswresample/arm/audio_convert_init.c |8 - > > > libswresample/audioconvert.c | 44 > > > ++-- > > > libswresample/options.c|1 + > > > libswresample/swresample.c |6 ++-- > > > libswresample/swresample.h |1 + > > > libswresample/swresample_internal.h|6 ++-- > > > libswresample/x86/audio_convert_init.c |8 - > > > 8 files changed, 71 insertions(+), 11 deletions(-) > > > > > > diff --git a/libswresample/aarch64/audio_convert_init.c > > > b/libswresample/aarch64/audio_convert_init.c > > > index 60e24ad..dedb1aa 100644 > > > --- a/libswresample/aarch64/audio_convert_init.c > > > +++ b/libswresample/aarch64/audio_convert_init.c > > > @@ -48,12 +48,18 @@ static void conv_fltp_to_s16_nch_neon(uint8_t **dst, > > > const uint8_t **src, int le > > > av_cold void swri_audio_convert_init_aarch64(struct AudioConvert *ac, > > > enum AVSampleFormat out_fmt, > > > enum AVSampleFormat in_fmt, > > > - int channels) > > > + int channels, int flags) > > > { > > > int cpu_flags = av_get_cpu_flags(); > > > > > > ac->simd_f= NULL; > > > > > > +if ( (flags & SWR_FLAG_CLIP) > > > +&& av_get_packed_sample_fmt(in_fmt) == AV_SAMPLE_FMT_FLT > > > +&& av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_FLT) { > > > +return; > > > +} > > > + > > > if (have_neon(cpu_flags)) { > > > if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT > > > || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP) > > > ac->simd_f = conv_flt_to_s16_neon; > > > diff --git a/libswresample/arm/audio_convert_init.c > > > b/libswresample/arm/audio_convert_init.c > > > index ec9e62e..f39978d 100644 > > > --- a/libswresample/arm/audio_convert_init.c > > > +++ b/libswresample/arm/audio_convert_init.c > > > @@ -48,12 +48,18 @@ static void conv_fltp_to_s16_nch_neon(uint8_t **dst, > > > const uint8_t **src, int le > > > av_cold void swri_audio_convert_init_arm(struct AudioConvert *ac, > > > enum AVSampleFormat out_fmt, > > > enum AVSampleFormat in_fmt, > > > - int channels) > > > + int channels, int flags) > > > { > > > int cpu_flags = av_get_cpu_flags(); > > > > > > ac->simd_f= NULL; > > > > > > +if ( (flags & SWR_FLAG_CLIP) > > > +&& av_get_packed_sample_fmt(in_fmt) == AV_SAMPLE_FMT_FLT > > > +&& av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_FLT) { > > > +return; > > > +} > > > + > > > if (have_neon(cpu_flags)) { > > > if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT > > > || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP) > > > ac->simd_f = conv_flt_to_s16_neon; > > > diff --git a/libswresample/audioconvert.c b/libswresample/audioconvert.c > > > index 58b0bf3..dc6734a 100644 > > > --- a/libswresample/audioconvert.c > > > +++ b/libswresample/audioconvert.c > > > @@ -77,6 +77,27 @@ CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, > > > AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(* > > > CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, *(const > > > double*)pi) > > > CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, *(const > > > double*)pi) > > > > > > +#define CONV_FUNC_NAME_CLIP(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ > > > ## dst_fmt ## _clip > > > +#define CONV_FUNC_CLIP(ofmt, otype, ifmt, expr)\ > > > +static void CONV_FUNC_NAME_CLIP(ofmt, ifmt)(uint8_t *po, const uint8_t > > > *pi, int is, int os, uint8_t *end)\ > > > +{\ > > > +uint8_t *end2 = end - 3*os;\ > > > +while(po < end2){\ > > > +*(otype*)po = expr; pi += is; po += os;\ > > > +*(otype*)po = expr; pi += is; po += os;\ > > > +*(otype*)po = expr; pi += is; po += os;\ > > > +*(otype*)po = expr; pi += is; po += os;\ > > > +}\ > > > +while(po < end){\ > > > +*(otype*)po = expr; pi += is; po += os;\ > > > +}\ > > > +} > > > + > > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_FLT, > > > av_clipf(*(const float*)pi, -1.0, 1.0)) > > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_FLT, > > > av_clipf(*(const float*)pi, -1.0, 1.0)) > > > +CONV_FUNC_CLIP(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, >
[FFmpeg-devel] [PATCH] avfilter: add anoisesrc
Signed-off-by: Kyle Swanson --- Changelog| 1 + doc/filters.texi | 36 +++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/asrc_anoisesrc.c | 222 +++ libavfilter/version.h| 4 +- 6 files changed, 263 insertions(+), 2 deletions(-) create mode 100644 libavfilter/asrc_anoisesrc.c diff --git a/Changelog b/Changelog index 91955da..ca477de 100644 --- a/Changelog +++ b/Changelog @@ -30,6 +30,7 @@ version : - innoHeim/Rsupport Screen Capture Codec decoder - ADPCM AICA decoder - Interplay ACM demuxer and audio decoder +- anoisesrc audio source version 2.8: diff --git a/doc/filters.texi b/doc/filters.texi index 15ea77a..620d787 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3193,6 +3193,42 @@ ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.' For more information about libflite, check: @url{http://www.speech.cs.cmu.edu/flite/} +@section anoisesrc + +Generate a noise audio signal. + +The filter accepts the following options: + +@table @option + +@item color, colour, c +Specify the color of noise. Available noise colors are white, pink, and brown. Default color is white. + +@item sample_rate, r +Specify the sample rate. Default value is 48000 Hz. + +@item duration, d +Specify the duration of the generated audio stream. Not specifying this option results in noise with an infinite length. + +@item amplitude, a +Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value is 1.0. + +@item seed, s +Specify a value used to seed the PRNG. Default value is 0. + +@end table + +@subsection Examples + +@itemize + +@item +Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5: +@example +anoisesrc=d=60:c=pink:r=44100:a=0.5 +@end example +@end itemize + @section sine Generate an audio signal made of a sine wave with amplitude 1/8. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 1b23085..5f60e15 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -93,6 +93,7 @@ OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += af_volumedetect.o OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o OBJS-$(CONFIG_FLITE_FILTER) += asrc_flite.o +OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index a538b81..e716174 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -115,6 +115,7 @@ void avfilter_register_all(void) REGISTER_FILTER(AEVALSRC, aevalsrc, asrc); REGISTER_FILTER(ANULLSRC, anullsrc, asrc); REGISTER_FILTER(FLITE, flite, asrc); +REGISTER_FILTER(ANOISESRC, anoisesrc, asrc); REGISTER_FILTER(SINE, sine, asrc); REGISTER_FILTER(ANULLSINK, anullsink, asink); diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c new file mode 100644 index 000..d008d67 --- /dev/null +++ b/libavfilter/asrc_anoisesrc.c @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2015 Kyle Swanson . + * + * 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 + */ + +#include + +#include "libavutil/opt.h" +#include "audio.h" +#include "avfilter.h" +#include "internal.h" +#include "libavutil/lfg.h" + +typedef struct { +const AVClass *class; +int sample_rate; +double amplitude; +int64_t dur; +char *color; +int seed; + +int infinite; +double (*filter)(double white, double *buf); +double* buf; +int buf_size; +AVLFG c; +} ANoiseSrcContext; + +#define OFFSET(x) offsetof(ANoiseSrcContext, x) +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption anoisesrc_options[] = { +{ "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000},15,INT_MAX, FLAGS }, +{ "r","set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
Thanks for the updated patch, see comments below. Le quartidi 14 brumaire, an CCXXIV, Kyle Swanson a écrit : > Signed-off-by: Kyle Swanson > --- > Changelog| 1 + > doc/filters.texi | 36 +++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/asrc_anoisesrc.c | 222 > +++ > libavfilter/version.h| 4 +- > 6 files changed, 263 insertions(+), 2 deletions(-) > create mode 100644 libavfilter/asrc_anoisesrc.c > > diff --git a/Changelog b/Changelog > index 91955da..ca477de 100644 > --- a/Changelog > +++ b/Changelog > @@ -30,6 +30,7 @@ version : > - innoHeim/Rsupport Screen Capture Codec decoder > - ADPCM AICA decoder > - Interplay ACM demuxer and audio decoder > +- anoisesrc audio source > > > version 2.8: > diff --git a/doc/filters.texi b/doc/filters.texi > index 15ea77a..620d787 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -3193,6 +3193,42 @@ ffplay -f lavfi flite=text='No more be grieved for > which that thou hast done.' > For more information about libflite, check: > @url{http://www.speech.cs.cmu.edu/flite/} > > +@section anoisesrc > + > +Generate a noise audio signal. > + > +The filter accepts the following options: > + > +@table @option > + > +@item color, colour, c > +Specify the color of noise. Available noise colors are white, pink, and > brown. Default color is white. > + > +@item sample_rate, r > +Specify the sample rate. Default value is 48000 Hz. > + > +@item duration, d > +Specify the duration of the generated audio stream. Not specifying this > option results in noise with an infinite length. > + > +@item amplitude, a > +Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default > value is 1.0. > + > +@item seed, s > +Specify a value used to seed the PRNG. Default value is 0. > + > +@end table > + > +@subsection Examples > + > +@itemize > + > +@item > +Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an > amplitude of 0.5: > +@example > +anoisesrc=d=60:c=pink:r=44100:a=0.5 > +@end example > +@end itemize > + > @section sine > > Generate an audio signal made of a sine wave with amplitude 1/8. > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 1b23085..5f60e15 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -93,6 +93,7 @@ OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += > af_volumedetect.o > OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o > OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o > OBJS-$(CONFIG_FLITE_FILTER) += asrc_flite.o > +OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o > OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o Alphabetic order after renaming the filter. > > OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index a538b81..e716174 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -115,6 +115,7 @@ void avfilter_register_all(void) > REGISTER_FILTER(AEVALSRC, aevalsrc, asrc); > REGISTER_FILTER(ANULLSRC, anullsrc, asrc); > REGISTER_FILTER(FLITE, flite, asrc); > +REGISTER_FILTER(ANOISESRC, anoisesrc, asrc); > REGISTER_FILTER(SINE, sine, asrc); > > REGISTER_FILTER(ANULLSINK, anullsink, asink); > diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c > new file mode 100644 > index 000..d008d67 > --- /dev/null > +++ b/libavfilter/asrc_anoisesrc.c > @@ -0,0 +1,222 @@ > +/* > + * Copyright (c) 2015 Kyle Swanson . > + * > + * 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 > + */ > + > +#include > + > +#include "libavutil/opt.h" > +#include "audio.h" > +#include "avfilter.h" > +#include "internal.h" > +#include "libavutil/lfg.h" > + > +typedef struct { > +const AVClass *class; > +int sample_rate; > +double amplitude; > +int64_t dur; > +char *color; > +int seed; > + > +int infinite; > +double (*filter)(double white, double *buf); > +double* buf; > +int b
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
On 11/4/2015 3:19 PM, Kyle Swanson wrote: > Signed-off-by: Kyle Swanson > diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c > new file mode 100644 > index 000..d008d67 > --- /dev/null > +++ b/libavfilter/asrc_anoisesrc.c > @@ -0,0 +1,222 @@ > +/* > + * Copyright (c) 2015 Kyle Swanson . > + * > + * 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 > + */ > + > +#include > + > +#include "libavutil/opt.h" > +#include "audio.h" > +#include "avfilter.h" > +#include "internal.h" > +#include "libavutil/lfg.h" > + > +typedef struct { > +const AVClass *class; > +int sample_rate; > +double amplitude; > +int64_t dur; > +char *color; > +int seed; uint32_t. Also, why not use av_get_random_seed() when no seed is specified? In that case both this and the AVOptions below should be int64_t, and the range of values -1 to UINT32_MAX, with -1 as default. See f_perms.c > + > +int infinite; > +double (*filter)(double white, double *buf); > +double* buf; > +int buf_size; > +AVLFG c; > +} ANoiseSrcContext; > + > +#define OFFSET(x) offsetof(ANoiseSrcContext, x) > +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > + > +static const AVOption anoisesrc_options[] = { > +{ "sample_rate", "set sample rate", OFFSET(sample_rate), > AV_OPT_TYPE_INT, {.i64 = 48000},15,INT_MAX, FLAGS }, > +{ "r","set sample rate", OFFSET(sample_rate), > AV_OPT_TYPE_INT, {.i64 = 48000},15,INT_MAX, FLAGS }, > +{ "amplitude","set amplitude",OFFSET(amplitude), > AV_OPT_TYPE_DOUBLE,{.dbl = 1.}, 0.,1.,FLAGS }, > +{ "a","set amplitude",OFFSET(amplitude), > AV_OPT_TYPE_DOUBLE,{.dbl = 1.}, 0.,1.,FLAGS }, > +{ "duration", "set duration", OFFSET(dur), > AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS }, > +{ "d","set duration", OFFSET(dur), > AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS }, > +{ "color","set noise color", OFFSET(color), > AV_OPT_TYPE_STRING,{.str = "white"}, CHAR_MIN, CHAR_MAX, FLAGS }, > +{ "colour", "set noise color", OFFSET(color), > AV_OPT_TYPE_STRING,{.str = "white"}, CHAR_MIN, CHAR_MAX, FLAGS }, > +{ "c","set noise color", OFFSET(color), > AV_OPT_TYPE_STRING,{.str = "white"}, CHAR_MIN, CHAR_MAX, FLAGS }, > +{ "seed", "set random seed", OFFSET(seed), > AV_OPT_TYPE_INT, {.i64 = 0},0, UINT_MAX, FLAGS }, > +{ "s","set random seed", OFFSET(seed), > AV_OPT_TYPE_INT, {.i64 = 0},0, UINT_MAX, FLAGS }, > +{NULL} > +}; ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
Hi, On Wed, Nov 4, 2015 at 12:30 PM, Nicolas George wrote: > Thanks for the updated patch, see comments below. > > Le quartidi 14 brumaire, an CCXXIV, Kyle Swanson a écrit : >> Signed-off-by: Kyle Swanson >> --- >> Changelog| 1 + >> doc/filters.texi | 36 +++ >> libavfilter/Makefile | 1 + >> libavfilter/allfilters.c | 1 + >> libavfilter/asrc_anoisesrc.c | 222 >> +++ >> libavfilter/version.h| 4 +- >> 6 files changed, 263 insertions(+), 2 deletions(-) >> create mode 100644 libavfilter/asrc_anoisesrc.c >> >> diff --git a/Changelog b/Changelog >> index 91955da..ca477de 100644 >> --- a/Changelog >> +++ b/Changelog >> @@ -30,6 +30,7 @@ version : >> - innoHeim/Rsupport Screen Capture Codec decoder >> - ADPCM AICA decoder >> - Interplay ACM demuxer and audio decoder >> +- anoisesrc audio source >> >> >> version 2.8: >> diff --git a/doc/filters.texi b/doc/filters.texi >> index 15ea77a..620d787 100644 >> --- a/doc/filters.texi >> +++ b/doc/filters.texi >> @@ -3193,6 +3193,42 @@ ffplay -f lavfi flite=text='No more be grieved for >> which that thou hast done.' >> For more information about libflite, check: >> @url{http://www.speech.cs.cmu.edu/flite/} >> >> +@section anoisesrc >> + >> +Generate a noise audio signal. >> + >> +The filter accepts the following options: >> + >> +@table @option >> + >> +@item color, colour, c >> +Specify the color of noise. Available noise colors are white, pink, and >> brown. Default color is white. >> + >> +@item sample_rate, r >> +Specify the sample rate. Default value is 48000 Hz. >> + >> +@item duration, d >> +Specify the duration of the generated audio stream. Not specifying this >> option results in noise with an infinite length. >> + >> +@item amplitude, a >> +Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default >> value is 1.0. >> + >> +@item seed, s >> +Specify a value used to seed the PRNG. Default value is 0. >> + >> +@end table >> + >> +@subsection Examples >> + >> +@itemize >> + >> +@item >> +Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an >> amplitude of 0.5: >> +@example >> +anoisesrc=d=60:c=pink:r=44100:a=0.5 >> +@end example >> +@end itemize >> + >> @section sine >> >> Generate an audio signal made of a sine wave with amplitude 1/8. >> diff --git a/libavfilter/Makefile b/libavfilter/Makefile >> index 1b23085..5f60e15 100644 >> --- a/libavfilter/Makefile >> +++ b/libavfilter/Makefile >> @@ -93,6 +93,7 @@ OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += >> af_volumedetect.o >> OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o >> OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o > >> OBJS-$(CONFIG_FLITE_FILTER) += asrc_flite.o >> +OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o >> OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o > > Alphabetic order after renaming the filter. Yep. Will fix this. > >> >> OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o >> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c >> index a538b81..e716174 100644 >> --- a/libavfilter/allfilters.c >> +++ b/libavfilter/allfilters.c >> @@ -115,6 +115,7 @@ void avfilter_register_all(void) >> REGISTER_FILTER(AEVALSRC, aevalsrc, asrc); >> REGISTER_FILTER(ANULLSRC, anullsrc, asrc); >> REGISTER_FILTER(FLITE, flite, asrc); >> +REGISTER_FILTER(ANOISESRC, anoisesrc, asrc); >> REGISTER_FILTER(SINE, sine, asrc); >> >> REGISTER_FILTER(ANULLSINK, anullsink, asink); >> diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c >> new file mode 100644 >> index 000..d008d67 >> --- /dev/null >> +++ b/libavfilter/asrc_anoisesrc.c >> @@ -0,0 +1,222 @@ >> +/* >> + * Copyright (c) 2015 Kyle Swanson . >> + * >> + * 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 >> + */ >> + >> +#include >> + >> +#include "libavutil/opt.h" >> +#include "audio.h" >> +#include "avfilter.h" >> +#include "internal.h" >> +#include "libavutil/lfg.h" >> + >> +typedef struct { >> +const AVClass *class;
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
On Wed, Nov 4, 2015 at 1:10 PM, James Almer wrote: > On 11/4/2015 3:19 PM, Kyle Swanson wrote: >> Signed-off-by: Kyle Swanson >> diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c >> new file mode 100644 >> index 000..d008d67 >> --- /dev/null >> +++ b/libavfilter/asrc_anoisesrc.c >> @@ -0,0 +1,222 @@ >> +/* >> + * Copyright (c) 2015 Kyle Swanson . >> + * >> + * 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 >> + */ >> + >> +#include >> + >> +#include "libavutil/opt.h" >> +#include "audio.h" >> +#include "avfilter.h" >> +#include "internal.h" >> +#include "libavutil/lfg.h" >> + >> +typedef struct { >> +const AVClass *class; >> +int sample_rate; >> +double amplitude; >> +int64_t dur; >> +char *color; >> +int seed; > > uint32_t. > > Also, why not use av_get_random_seed() when no seed is specified? > In that case both this and the AVOptions below should be int64_t, and the > range of values -1 to UINT32_MAX, with -1 as default. > > See f_perms.c Good idea. I'll add this. >> + >> +int infinite; >> +double (*filter)(double white, double *buf); >> +double* buf; >> +int buf_size; >> +AVLFG c; >> +} ANoiseSrcContext; >> + >> +#define OFFSET(x) offsetof(ANoiseSrcContext, x) >> +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM >> + >> +static const AVOption anoisesrc_options[] = { >> +{ "sample_rate", "set sample rate", OFFSET(sample_rate), >> AV_OPT_TYPE_INT, {.i64 = 48000},15,INT_MAX, FLAGS }, >> +{ "r","set sample rate", OFFSET(sample_rate), >> AV_OPT_TYPE_INT, {.i64 = 48000},15,INT_MAX, FLAGS }, >> +{ "amplitude","set amplitude",OFFSET(amplitude), >> AV_OPT_TYPE_DOUBLE,{.dbl = 1.}, 0.,1.,FLAGS }, >> +{ "a","set amplitude",OFFSET(amplitude), >> AV_OPT_TYPE_DOUBLE,{.dbl = 1.}, 0.,1.,FLAGS }, >> +{ "duration", "set duration", OFFSET(dur), >> AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >> +{ "d","set duration", OFFSET(dur), >> AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >> +{ "color","set noise color", OFFSET(color), >> AV_OPT_TYPE_STRING,{.str = "white"}, CHAR_MIN, CHAR_MAX, FLAGS }, >> +{ "colour", "set noise color", OFFSET(color), >> AV_OPT_TYPE_STRING,{.str = "white"}, CHAR_MIN, CHAR_MAX, FLAGS }, >> +{ "c","set noise color", OFFSET(color), >> AV_OPT_TYPE_STRING,{.str = "white"}, CHAR_MIN, CHAR_MAX, FLAGS }, >> +{ "seed", "set random seed", OFFSET(seed), >> AV_OPT_TYPE_INT, {.i64 = 0},0, UINT_MAX, FLAGS }, >> +{ "s","set random seed", OFFSET(seed), >> AV_OPT_TYPE_INT, {.i64 = 0},0, UINT_MAX, FLAGS }, >> +{NULL} >> +}; > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
Le quartidi 14 brumaire, an CCXXIV, Kyle Swanson a écrit : > I can change this, but most filters I've seen have used floating point > sample formats. Anyone else have any opinions on this? Floating point is easier, that explains why a lot of code use it. But it is less efficient, and most importantly: it is not bit-exact, and therefore it makes it much harder to do regression tests (either for the source itself or using the source as input for a filter that needs testing): instead of comparing the output to a constant reference, it requires using a mean deviation. > This makes it easier for someone to add different flavors of filtered > noise later on, and define their own sample buffer. I understand this > is a tiny buffer, but why allocate too much memory if we won't need > it? Dynamic allocation has a cost too. With padding and structure overhead, when allocating 1 cell, you end up reserving 24-32 octets, possibly more, while the current code only requires 56 at most. And of course, avoiding the dynamic allocation and the indirection makes the code itself smaller: unless a lot of instances of the source are created, the benefit is larger than the cost. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
On Wed, Nov 4, 2015 at 2:18 PM, Kyle Swanson wrote: > Hi, > > On Wed, Nov 4, 2015 at 12:30 PM, Nicolas George wrote: >> Thanks for the updated patch, see comments below. >> >> Le quartidi 14 brumaire, an CCXXIV, Kyle Swanson a écrit : >>> Signed-off-by: Kyle Swanson >>> --- >>> Changelog| 1 + >>> doc/filters.texi | 36 +++ >>> libavfilter/Makefile | 1 + >>> libavfilter/allfilters.c | 1 + >>> libavfilter/asrc_anoisesrc.c | 222 >>> +++ >>> libavfilter/version.h| 4 +- >>> 6 files changed, 263 insertions(+), 2 deletions(-) >>> create mode 100644 libavfilter/asrc_anoisesrc.c >>> >>> diff --git a/Changelog b/Changelog >>> index 91955da..ca477de 100644 >>> --- a/Changelog >>> +++ b/Changelog >>> @@ -30,6 +30,7 @@ version : >>> - innoHeim/Rsupport Screen Capture Codec decoder >>> - ADPCM AICA decoder >>> - Interplay ACM demuxer and audio decoder >>> +- anoisesrc audio source >>> >>> >>> version 2.8: >>> diff --git a/doc/filters.texi b/doc/filters.texi >>> index 15ea77a..620d787 100644 >>> --- a/doc/filters.texi >>> +++ b/doc/filters.texi >>> @@ -3193,6 +3193,42 @@ ffplay -f lavfi flite=text='No more be grieved for >>> which that thou hast done.' >>> For more information about libflite, check: >>> @url{http://www.speech.cs.cmu.edu/flite/} >>> >>> +@section anoisesrc >>> + >>> +Generate a noise audio signal. >>> + >>> +The filter accepts the following options: >>> + >>> +@table @option >>> + >>> +@item color, colour, c >>> +Specify the color of noise. Available noise colors are white, pink, and >>> brown. Default color is white. >>> + >>> +@item sample_rate, r >>> +Specify the sample rate. Default value is 48000 Hz. >>> + >>> +@item duration, d >>> +Specify the duration of the generated audio stream. Not specifying this >>> option results in noise with an infinite length. >>> + >>> +@item amplitude, a >>> +Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default >>> value is 1.0. >>> + >>> +@item seed, s >>> +Specify a value used to seed the PRNG. Default value is 0. >>> + >>> +@end table >>> + >>> +@subsection Examples >>> + >>> +@itemize >>> + >>> +@item >>> +Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an >>> amplitude of 0.5: >>> +@example >>> +anoisesrc=d=60:c=pink:r=44100:a=0.5 >>> +@end example >>> +@end itemize >>> + >>> @section sine >>> >>> Generate an audio signal made of a sine wave with amplitude 1/8. >>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile >>> index 1b23085..5f60e15 100644 >>> --- a/libavfilter/Makefile >>> +++ b/libavfilter/Makefile >>> @@ -93,6 +93,7 @@ OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += >>> af_volumedetect.o >>> OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o >>> OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o >> >>> OBJS-$(CONFIG_FLITE_FILTER) += asrc_flite.o >>> +OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o >>> OBJS-$(CONFIG_SINE_FILTER) += asrc_sine.o >> >> Alphabetic order after renaming the filter. > > Yep. Will fix this. > >> >>> >>> OBJS-$(CONFIG_ANULLSINK_FILTER) += asink_anullsink.o >>> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c >>> index a538b81..e716174 100644 >>> --- a/libavfilter/allfilters.c >>> +++ b/libavfilter/allfilters.c >>> @@ -115,6 +115,7 @@ void avfilter_register_all(void) >>> REGISTER_FILTER(AEVALSRC, aevalsrc, asrc); >>> REGISTER_FILTER(ANULLSRC, anullsrc, asrc); >>> REGISTER_FILTER(FLITE, flite, asrc); >>> +REGISTER_FILTER(ANOISESRC, anoisesrc, asrc); >>> REGISTER_FILTER(SINE, sine, asrc); >>> >>> REGISTER_FILTER(ANULLSINK, anullsink, asink); >>> diff --git a/libavfilter/asrc_anoisesrc.c b/libavfilter/asrc_anoisesrc.c >>> new file mode 100644 >>> index 000..d008d67 >>> --- /dev/null >>> +++ b/libavfilter/asrc_anoisesrc.c >>> @@ -0,0 +1,222 @@ >>> +/* >>> + * Copyright (c) 2015 Kyle Swanson . >>> + * >>> + * 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 >>> + */ >>> + >>> +#include
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
On 11/4/15, Kyle Swanson wrote: > Hi, > > On Wed, Nov 4, 2015 at 12:30 PM, Nicolas George wrote: >> Thanks for the updated patch, see comments below. >> >> Le quartidi 14 brumaire, an CCXXIV, Kyle Swanson a ecrit : >>> Signed-off-by: Kyle Swanson >>> --- >>> Changelog| 1 + >>> doc/filters.texi | 36 +++ >>> libavfilter/Makefile | 1 + >>> libavfilter/allfilters.c | 1 + >>> libavfilter/asrc_anoisesrc.c | 222 >>> +++ >>> libavfilter/version.h| 4 +- >>> 6 files changed, 263 insertions(+), 2 deletions(-) >>> create mode 100644 libavfilter/asrc_anoisesrc.c [...] >>> >>> +AVFILTER_DEFINE_CLASS(anoisesrc); >>> + >>> +static av_cold int query_formats(AVFilterContext *ctx) >>> +{ >>> +ANoiseSrcContext *s = ctx->priv; >>> +static const int64_t chlayouts[] = { AV_CH_LAYOUT_MONO, -1 }; >>> +int sample_rates[] = { s->sample_rate, -1 }; >> >>> +static const enum AVSampleFormat sample_fmts[] = { >>> +AV_SAMPLE_FMT_DBL, >>> +AV_SAMPLE_FMT_NONE >>> +}; >> >> I already commented on that: please avoid floating-point computations >> unless >> they are absolutely necessary. >> > > I can change this, but most filters I've seen have used floating point > sample formats. Anyone else have any opinions on this? > Using double precision for audio noise source sounds like overkill. So using S16 is fine. Anyway you could add support for both if you really want. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCHv4 1/4] fate: add concat demuxer tests
Signed-off-by: Marton Balint --- tests/Makefile | 1 + tests/extended.ffconcat| 114 tests/fate-run.sh | 20 +++ tests/fate/concatdec.mak | 21 +++ tests/ref/fate/concat-demuxer-extended-lavf-mxf| 1 + .../ref/fate/concat-demuxer-extended-lavf-mxf_d10 | 1 + tests/ref/fate/concat-demuxer-simple1-lavf-mxf | 124 + tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 | 82 +++ tests/ref/fate/concat-demuxer-simple2-lavf-ts | 151 + tests/simple1.ffconcat | 12 ++ tests/simple2.ffconcat | 19 +++ 11 files changed, 546 insertions(+) create mode 100644 tests/extended.ffconcat create mode 100644 tests/fate/concatdec.mak create mode 100644 tests/ref/fate/concat-demuxer-extended-lavf-mxf create mode 100644 tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 create mode 100644 tests/ref/fate/concat-demuxer-simple1-lavf-mxf create mode 100644 tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 create mode 100644 tests/ref/fate/concat-demuxer-simple2-lavf-ts create mode 100644 tests/simple1.ffconcat create mode 100644 tests/simple2.ffconcat diff --git a/tests/Makefile b/tests/Makefile index 7ee4a46..62544d0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -113,6 +113,7 @@ include $(SRC_PATH)/tests/fate/audio.mak include $(SRC_PATH)/tests/fate/bmp.mak include $(SRC_PATH)/tests/fate/cdxl.mak include $(SRC_PATH)/tests/fate/checkasm.mak +include $(SRC_PATH)/tests/fate/concatdec.mak include $(SRC_PATH)/tests/fate/cover-art.mak include $(SRC_PATH)/tests/fate/demux.mak include $(SRC_PATH)/tests/fate/dfa.mak diff --git a/tests/extended.ffconcat b/tests/extended.ffconcat new file mode 100644 index 000..7359113 --- /dev/null +++ b/tests/extended.ffconcat @@ -0,0 +1,114 @@ +ffconcat version 1.0 + +file %SRCFILE% + +file %SRCFILE% +duration 1 +file_packet_metadata dummy=1 + +file %SRCFILE% +inpoint 00:00.00 +outpoint 00:00.04 + +file %SRCFILE% +inpoint 00:00.04 +outpoint 00:00.08 + +file %SRCFILE% +inpoint 00:00.08 +outpoint 00:00.12 + +file %SRCFILE% +inpoint 00:00.12 +outpoint 00:00.16 + +file %SRCFILE% +inpoint 00:00.16 +outpoint 00:00.20 + +file %SRCFILE% +inpoint 00:00.20 +outpoint 00:00.24 + +file %SRCFILE% +inpoint 00:00.24 +outpoint 00:00.28 + +file %SRCFILE% +inpoint 00:00.28 +outpoint 00:00.32 + +file %SRCFILE% +inpoint 00:00.32 +outpoint 00:00.36 + +file %SRCFILE% +inpoint 00:00.36 +outpoint 00:00.40 + +file %SRCFILE% +inpoint 00:00.40 +outpoint 00:00.44 + +file %SRCFILE% +inpoint 00:00.44 +outpoint 00:00.48 + +file %SRCFILE% +inpoint 00:00.48 +outpoint 00:00.52 + +file %SRCFILE% +inpoint 00:00.52 +outpoint 00:00.56 + +file %SRCFILE% +inpoint 00:00.56 +outpoint 00:00.60 + +file %SRCFILE% +inpoint 00:00.60 +outpoint 00:00.64 + +file %SRCFILE% +inpoint 00:00.64 +outpoint 00:00.68 + +file %SRCFILE% +inpoint 00:00.68 +outpoint 00:00.72 + +file %SRCFILE% +inpoint 00:00.72 +outpoint 00:00.76 + +file %SRCFILE% +inpoint 00:00.76 +outpoint 00:00.80 + +file %SRCFILE% +inpoint 00:00.80 +outpoint 00:00.84 + +file %SRCFILE% +inpoint 00:00.84 +outpoint 00:00.88 + +file %SRCFILE% +inpoint 00:00.88 +outpoint 00:00.92 + +file %SRCFILE% +inpoint 00:00.92 +outpoint 00:00.96 + +file %SRCFILE% +inpoint 00:00.96 +outpoint 00:01.00 + +file %SRCFILE% +outpoint 00:00.40 + +file %SRCFILE% +inpoint 00:00.40 + diff --git a/tests/fate-run.sh b/tests/fate-run.sh index a3938dc..38dc334 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -249,6 +249,26 @@ gapless(){ do_md5sum $decfile3 } +concat(){ +template=$1 +sample=$(target_path $2) +mode=$3 +extra_args=$4 + +concatfile="${outdir}/${test}.ffconcat" +packetfile="${outdir}/${test}.ffprobe" +cleanfiles="$concatfile $packetfile" + +awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile + +if [ "$mode" = "md5" ]; then + run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -fflags keepside -safe 0 $extra_args $concatfile > $packetfile + do_md5sum $packetfile +else + run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -of compact=p=0:nk=1 -fflags keepside -safe 0 $extra_args $concatfile +fi +} + mkdir -p "$outdir" # Disable globbing: command arguments may contain globbing characters and diff --git a/tests/fate/concatdec.mak b/tests/fate/concatdec.mak new file mode 100644 index 000..7bb202b --- /dev/null +++ b/tests/fate/concatdec.mak @@ -0,0 +1,21 @@ +FATE_CONCAT_DEMUXER_SIMPLE1_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += mxf +FATE_CONCAT_DEMUXER_SIMPLE1_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
> +static double pink_filter(double white, double *buf) { > +double pink; > + > +/* http://www.musicdsp.org/files/pink.txt */ > +buf[0] = 0.99886 * buf[0] + white * 0.0555179; > +buf[1] = 0.99332 * buf[1] + white * 0.0750759; > +buf[2] = 0.96900 * buf[2] + white * 0.1538520; > +buf[3] = 0.86650 * buf[3] + white * 0.3104856; > +buf[4] = 0.55000 * buf[4] + white * 0.5329522; > +buf[5] = -0.7616 * buf[5] - white * 0.0168980; > +pink = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + > white * 0.5362; > +buf[6] = white * 0.115926; > +return pink * 0.11; > +} > + > +static double brown_filter(double white, double *buf) { > +double brown; > + > +brown = ((0.02 * white) + buf[0]) / 1.02; > +buf[0] = brown; > +return brown * 3.5; > +} Using a fixed-point sample format also means these filters will need to be re-done. Anyone know of a good fixed-point filter algorithms for pink and brown noise? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
On Wed, Nov 4, 2015 at 4:51 PM, Kyle Swanson wrote: >> +static double pink_filter(double white, double *buf) { >> +double pink; >> + >> +/* http://www.musicdsp.org/files/pink.txt */ >> +buf[0] = 0.99886 * buf[0] + white * 0.0555179; >> +buf[1] = 0.99332 * buf[1] + white * 0.0750759; >> +buf[2] = 0.96900 * buf[2] + white * 0.1538520; >> +buf[3] = 0.86650 * buf[3] + white * 0.3104856; >> +buf[4] = 0.55000 * buf[4] + white * 0.5329522; >> +buf[5] = -0.7616 * buf[5] - white * 0.0168980; >> +pink = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + >> white * 0.5362; >> +buf[6] = white * 0.115926; >> +return pink * 0.11; >> +} >> + >> +static double brown_filter(double white, double *buf) { >> +double brown; >> + >> +brown = ((0.02 * white) + buf[0]) / 1.02; >> +buf[0] = brown; >> +return brown * 3.5; >> +} > > Using a fixed-point sample format also means these filters will need > to be re-done. Anyone know of a good fixed-point filter algorithms for > pink and brown noise? You could try converting directly from the above floats by one of a number of standard approaches for float to fixed point. Yes, it is slightly tedious, but it can be done. Alternatively, it should not be hard to find on the web. I personally am ok with your patch with floats, leaving fixed point for future work, but Paul and Nicolas have greater expertise and knowledge of this stuff and their opinion is definitely more important. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] swresample/resample: speed up build_filter
On Wed, Nov 4, 2015 at 10:07 AM, Ganesh Ajjanagadde wrote: > On Wed, Nov 4, 2015 at 9:44 AM, Michael Niedermayer > wrote: >> On Wed, Nov 04, 2015 at 01:11:45AM -0500, Ganesh Ajjanagadde wrote: >>> This speeds up build_filter by ~ 50%. This gain should be pretty >>> consistent across all architectures and platforms. >>> >>> Essentially, this relies on a observation that the filters have some >>> even/odd symmetry that may be exploited during the construction of the >>> polyphase filter bank. In particular, phases (scaled to [0, 1]) in [0.5, 1] >>> are >>> easily derived from [0, 0.5] and expensive reevaluation of function >>> points are unnecessary. This requires some rather annoying even/odd >>> bookkeeping as can be seen from the patch. >>> >>> I vaguely recall from signal processing theory more general symmetries >>> allowing even greater >>> optimization of the construction. At a high level, "even functions" >>> correspond to 2, and one can imagine variations. Nevertheless, for the sake >>> of some generality and because of existing filters, this is all that is >>> being exploited. >>> >>> Currently, this patch relies on phase_count being even or (trivially) 1, >>> though this is not an inherent limitation to the approach. This >>> assumption is safe as phase_count is 1 << phase_bits, and is hence a >>> power of two. There is no way for user API to set it to a nontrivial odd >>> number. This assumption has been placed as an assert in the code. >>> >>> To repeat, this assumes even symmetry of the filters, which is the most >>> common >>> way to get generalized linear phase anyway and is true of all currently >>> supported filters. >>> >>> As a side note, accuracy should be identical or perhaps slightly better >>> due to this "forcing" filter symmetries leading to a better phase >>> characteristic. As before, I can't test this claim easily, though it may >>> be of interest. >>> >>> Patch tested with FATE. >>> >>> Sample benchmark (x86-64, Haswell, GNU/Linux): >>> >>> test: swr-resample-dblp-44100-2626 >>> >>> new: >>> 527376779 decicycles in build_filter(loop 1000), 256 runs, 0 skips >>> 524361765 decicycles in build_filter(loop 1000), 512 runs, 0 skips >>> 516552574 decicycles in build_filter(loop 1000),1024 runs, 0 skips >>> >>> old: >>> 974178658 decicycles in build_filter(loop 1000), 256 runs, 0 skips >>> 972794408 decicycles in build_filter(loop 1000), 512 runs, 0 skips >>> 954350046 decicycles in build_filter(loop 1000),1024 runs, 0 skips >>> >>> Note that lower level optimizations are entirely possible, I focussed on >>> getting the high level semantics correct. In any case, this should >>> provide a good foundation. >>> >>> Signed-off-by: Ganesh Ajjanagadde >>> --- >>> libswresample/resample.c | 56 >>> +--- >>> 1 file changed, 48 insertions(+), 8 deletions(-) >>> >>> diff --git a/libswresample/resample.c b/libswresample/resample.c >>> index 235c9a9..d5fc5e7 100644 >>> --- a/libswresample/resample.c >>> +++ b/libswresample/resample.c >>> @@ -144,7 +144,7 @@ static int build_filter(ResampleContext *c, void >>> *filter, double factor, int tap >>> int filter_type, int kaiser_beta){ >>> int ph, i; >>> double x, y, w; >>> -double *tab = av_malloc_array(tap_count, sizeof(*tab)); >>> +double *tab = av_malloc_array(tap_count+1, sizeof(*tab)); >>> const int center= (tap_count-1)/2; >>> >>> if (!tab) >>> @@ -154,9 +154,10 @@ static int build_filter(ResampleContext *c, void >>> *filter, double factor, int tap >>> if (factor > 1.0) >>> factor = 1.0; >>> >>> -for(ph=0;ph>> +av_assert0(phase_count == 1 || phase_count % 2 == 0); >>> +for(ph = 0; ph <= phase_count / 2; ph++) { >>> double norm = 0; >>> -for(i=0;i>> +for(i=0;i<=tap_count;i++) { >>> x = M_PI * ((double)(i - center) - (double)ph / phase_count) * >>> factor; >>> if (x == 0) y = 1.0; >>> elsey = sin(x) / x; >>> @@ -180,26 +181,65 @@ static int build_filter(ResampleContext *c, void >>> *filter, double factor, int tap >>> } >>> >>> tab[i] = y; >>> -norm += y; >>> +if (i < tap_count) >>> +norm += y; >>> } >>> >>> /* normalize so that an uniform color remains the same */ >>> switch(c->format){ >>> case AV_SAMPLE_FMT_S16P: >>> -for(i=0;i>> +for(i=0;i>> ((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] >>> * scale / norm), INT16_MIN, INT16_MAX); >>> +} >>> +if (tap_count % 2 == 0) { >>> +for (i = 0; i < tap_count; i++) >>> +((int16_t*)filter)[(phase_count-ph) * alloc + >>> tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i]; >>> +} >>> +else { >>> +fo
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
> Alternatively, it should not be hard to find on the web. I personally > am ok with your patch with floats, leaving fixed point for future > work, but Paul and Nicolas have greater expertise and knowledge of > this stuff and their opinion is definitely more important. FWIW, SoX and Audacity both use this same filter for pink noise. Both are generated with floating point samples. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add anoisesrc
On 11/4/15, Kyle Swanson wrote: >> Alternatively, it should not be hard to find on the web. I personally >> am ok with your patch with floats, leaving fixed point for future >> work, but Paul and Nicolas have greater expertise and knowledge of >> this stuff and their opinion is definitely more important. > > FWIW, SoX and Audacity both use this same filter for pink noise. Both > are generated with floating point samples. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > For now, you could add integer support for white noise only, and for others later. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/mp3dec: prefer "fast_seek" to TOC seek for CBR files.
"Fast seek" uses linear interpolation to find the position of the requested seek time. For CBR this is more direct than using the mp3 TOC and bypassing the TOC avoids problems when the TOC is corrupted (e.g. https://crbug.com/545914). For VBR, fast seek is not precise, so continue to prefer the TOC when available. --- libavformat/mp3dec.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 32ca00c..7946261 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -515,8 +515,10 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, filesize = size - s->internal->data_offset; } -if ( (mp3->is_cbr || fast_seek) -&& (mp3->usetoc == 0 || !mp3->xing_toc) +// Always use "fast seek" (linear interpolation) for CBR. For CBR this is +// a precise method and more direct than using TOC. For VBR this is not +// perfectly accurate, so prefer TOC if available. +if ((mp3->is_cbr || (fast_seek && (mp3->usetoc == 0 || !mp3->xing_toc))) && st->duration > 0 && filesize > 0) { ie = &ie1; -- 2.6.0.rc2.230.g3dd15c0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] swresample/resample: speed up build_filter for Blackman-Nuttall filter
This uses the trigonometric double and triple angle formulae to avoid repeated (expensive) evaluation of libc's cos(). Sample benchmark (x86-64, Haswell, GNU/Linux) old: 1104466600 decicycles in build_filter(loop 1000), 256 runs, 0 skips 1096765286 decicycles in build_filter(loop 1000), 512 runs, 0 skips 1070479590 decicycles in build_filter(loop 1000),1024 runs, 0 skips new: 588861423 decicycles in build_filter(loop 1000), 256 runs, 0 skips 591262754 decicycles in build_filter(loop 1000), 512 runs, 0 skips 577355145 decicycles in build_filter(loop 1000),1024 runs, 0 skips This results in small differences with the old expression: difference (worst case on [0, 2*M_PI]), argmax 0.008: max diff (relative): 0.157289807188 blackman_old(0.008): 0.000363951585488813192382 blackman_new(0.008): 0.000363951585488755946507 These are judged to be insignificant for the performance gain. PSNR to reference file is unchanged up to second decimal point for instance. Signed-off-by: Ganesh Ajjanagadde --- libswresample/resample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index a2cbb48..5d32cc2 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -171,7 +171,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap break;} case SWR_FILTER_TYPE_BLACKMAN_NUTTALL: w = 2.0*x / (factor*tap_count) + M_PI; -y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w); +y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * (2*cos(w)*cos(w)-1) - 0.0106411 * (4*cos(w)*cos(w)*cos(w) - 3*cos(w)); break; case SWR_FILTER_TYPE_KAISER: w = 2.0*x / (factor*tap_count*M_PI); -- 2.6.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] swresample/options: change rematrix_maxval default to 1.0
This changes the default to not clip, and thus matches libavresample as well. Documentation has been accordingly updated (with some typo fixes). API users have complained about this, see e.g https://github.com/mpv-player/mpv/commit/bf69edb1c2bac2ac11343d8e086f0540a0e4b5df. Signed-off-by: Ganesh Ajjanagadde --- doc/resampler.texi | 5 +++-- libswresample/options.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/resampler.texi b/doc/resampler.texi index 2c448ae..698b433 100644 --- a/doc/resampler.texi +++ b/doc/resampler.texi @@ -66,8 +66,9 @@ Set rematrix volume. Default value is 1.0. @item rematrix_maxval Set maximum output value for rematrixing. -This can be used to prevent clipping vs. preventing volumn reduction -A value of 1.0 prevents cliping. +This can be used to prevent clipping vs. preventing volume reduction +A value of 1.0 prevents clipping. +Default is 1.0. @item flags, swr_flags Set flags used by the converter. Default value is 0. diff --git a/libswresample/options.c b/libswresample/options.c index 2bf8ab1..6b6fd96 100644 --- a/libswresample/options.c +++ b/libswresample/options.c @@ -62,7 +62,7 @@ static const AVOption options[]={ {"lfe_mix_level", "set LFE mix level" , OFFSET(lfe_mix_level ), AV_OPT_TYPE_FLOAT, {.dbl=0 }, -32, 32, PARAM}, {"rmvol", "set rematrix volume" , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0 }, -1000 , 1000 , PARAM}, {"rematrix_volume" , "set rematrix volume" , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0 }, -1000 , 1000 , PARAM}, -{"rematrix_maxval" , "set rematrix maxval" , OFFSET(rematrix_maxval), AV_OPT_TYPE_FLOAT, {.dbl=0.0 }, 0 , 1000 , PARAM}, +{"rematrix_maxval" , "set rematrix maxval" , OFFSET(rematrix_maxval), AV_OPT_TYPE_FLOAT, {.dbl=1.0 }, 0 , 1000 , PARAM}, {"flags", "set flags" , OFFSET(flags ), AV_OPT_TYPE_FLAGS, {.i64=0 }, 0 , UINT_MAX , PARAM, "flags"}, {"swr_flags", "set flags" , OFFSET(flags ), AV_OPT_TYPE_FLAGS, {.i64=0 }, 0 , UINT_MAX , PARAM, "flags"}, -- 2.6.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel