From cc30080b3fb44bebea97533f7dfd5ee7700e4665 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 21 May 2012 14:00:47 -0400 Subject: lavfi: rename vf_split.c to split.c This is in preparation for adding an audio split filter. --- libavfilter/Makefile | 2 +- libavfilter/split.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++ libavfilter/vf_split.c | 108 ------------------------------------------------- 3 files changed, 109 insertions(+), 109 deletions(-) create mode 100644 libavfilter/split.c delete mode 100644 libavfilter/vf_split.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index fc96f42fe9..1a436d2877 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -68,7 +68,7 @@ OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o -OBJS-$(CONFIG_SPLIT_FILTER) += vf_split.o +OBJS-$(CONFIG_SPLIT_FILTER) += split.o OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o diff --git a/libavfilter/split.c b/libavfilter/split.c new file mode 100644 index 0000000000..da6b3ff320 --- /dev/null +++ b/libavfilter/split.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2007 Bobby Bingham + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Video splitter + */ + +#include "avfilter.h" + +static int split_init(AVFilterContext *ctx, const char *args, void *opaque) +{ + int i, nb_outputs = 2; + + if (args) { + nb_outputs = strtol(args, NULL, 0); + if (nb_outputs <= 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n", + nb_outputs); + return AVERROR(EINVAL); + } + } + + for (i = 0; i < nb_outputs; i++) { + char name[32]; + AVFilterPad pad = { 0 }; + + snprintf(name, sizeof(name), "output%d", i); + pad.type = AVMEDIA_TYPE_VIDEO; + pad.name = av_strdup(name); + + avfilter_insert_outpad(ctx, i, &pad); + } + + return 0; +} + +static void split_uninit(AVFilterContext *ctx) +{ + int i; + + for (i = 0; i < ctx->output_count; i++) + av_freep(&ctx->output_pads[i].name); +} + +static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) +{ + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + avfilter_start_frame(ctx->outputs[i], + avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); +} + +static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +{ + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); +} + +static void end_frame(AVFilterLink *inlink) +{ + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + avfilter_end_frame(ctx->outputs[i]); + + avfilter_unref_buffer(inlink->cur_buf); +} + +AVFilter avfilter_vf_split = { + .name = "split", + .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."), + + .init = split_init, + .uninit = split_uninit, + + .inputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .get_video_buffer= avfilter_null_get_video_buffer, + .start_frame = start_frame, + .draw_slice = draw_slice, + .end_frame = end_frame, }, + { .name = NULL}}, + .outputs = (AVFilterPad[]) {{ .name = NULL}}, +}; diff --git a/libavfilter/vf_split.c b/libavfilter/vf_split.c deleted file mode 100644 index da6b3ff320..0000000000 --- a/libavfilter/vf_split.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2007 Bobby Bingham - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * Video splitter - */ - -#include "avfilter.h" - -static int split_init(AVFilterContext *ctx, const char *args, void *opaque) -{ - int i, nb_outputs = 2; - - if (args) { - nb_outputs = strtol(args, NULL, 0); - if (nb_outputs <= 0) { - av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n", - nb_outputs); - return AVERROR(EINVAL); - } - } - - for (i = 0; i < nb_outputs; i++) { - char name[32]; - AVFilterPad pad = { 0 }; - - snprintf(name, sizeof(name), "output%d", i); - pad.type = AVMEDIA_TYPE_VIDEO; - pad.name = av_strdup(name); - - avfilter_insert_outpad(ctx, i, &pad); - } - - return 0; -} - -static void split_uninit(AVFilterContext *ctx) -{ - int i; - - for (i = 0; i < ctx->output_count; i++) - av_freep(&ctx->output_pads[i].name); -} - -static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) -{ - AVFilterContext *ctx = inlink->dst; - int i; - - for (i = 0; i < ctx->output_count; i++) - avfilter_start_frame(ctx->outputs[i], - avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); -} - -static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) -{ - AVFilterContext *ctx = inlink->dst; - int i; - - for (i = 0; i < ctx->output_count; i++) - avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); -} - -static void end_frame(AVFilterLink *inlink) -{ - AVFilterContext *ctx = inlink->dst; - int i; - - for (i = 0; i < ctx->output_count; i++) - avfilter_end_frame(ctx->outputs[i]); - - avfilter_unref_buffer(inlink->cur_buf); -} - -AVFilter avfilter_vf_split = { - .name = "split", - .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."), - - .init = split_init, - .uninit = split_uninit, - - .inputs = (AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer= avfilter_null_get_video_buffer, - .start_frame = start_frame, - .draw_slice = draw_slice, - .end_frame = end_frame, }, - { .name = NULL}}, - .outputs = (AVFilterPad[]) {{ .name = NULL}}, -}; -- cgit v1.2.3 From afeb3590fc5ff01d43b1a1be9df8fac64431ff9e Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 21 May 2012 14:03:42 -0400 Subject: lavfi: add an audio split filter Based on current version of the asplit filter in FFmpeg written by Stefano Sabatini and others. --- Changelog | 1 + doc/filters.texi | 13 +++++++++++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/split.c | 30 ++++++++++++++++++++++++++++-- libavfilter/version.h | 2 +- 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index afde0e9e04..2da60b1166 100644 --- a/Changelog +++ b/Changelog @@ -19,6 +19,7 @@ version : - add libavresample audio conversion library - audio filters support in libavfilter and avconv - add fps filter +- audio split filter version 0.8: diff --git a/doc/filters.texi b/doc/filters.texi index cda235f106..ac780299b4 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -137,6 +137,19 @@ aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo Pass the audio source unchanged to the output. +@section asplit + +Split input audio into several identical outputs. + +The filter accepts a single parameter which specifies the number of outputs. If +unspecified, it defaults to 2. + +For example +@example +avconv -i INPUT -filter_complex asplit=5 OUTPUT +@end example +will create 5 copies of the input audio. + @section asyncts Synchronize audio data with timestamps by squeezing/stretching it and/or dropping samples/adding silence when needed. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 1a436d2877..8649222ed2 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -27,6 +27,7 @@ OBJS = allfilters.o \ OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o +OBJS-$(CONFIG_ASPLIT_FILTER) += split.o OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index b3e57fd74c..316fff1798 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -36,6 +36,7 @@ void avfilter_register_all(void) REGISTER_FILTER (AFORMAT, aformat, af); REGISTER_FILTER (ANULL, anull, af); + REGISTER_FILTER (ASPLIT, asplit, af); REGISTER_FILTER (ASYNCTS, asyncts, af); REGISTER_FILTER (RESAMPLE, resample, af); diff --git a/libavfilter/split.c b/libavfilter/split.c index da6b3ff320..83ad765081 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -20,10 +20,11 @@ /** * @file - * Video splitter + * audio and video splitter */ #include "avfilter.h" +#include "audio.h" static int split_init(AVFilterContext *ctx, const char *args, void *opaque) { @@ -43,7 +44,7 @@ static int split_init(AVFilterContext *ctx, const char *args, void *opaque) AVFilterPad pad = { 0 }; snprintf(name, sizeof(name), "output%d", i); - pad.type = AVMEDIA_TYPE_VIDEO; + pad.type = ctx->filter->inputs[0].type; pad.name = av_strdup(name); avfilter_insert_outpad(ctx, i, &pad); @@ -106,3 +107,28 @@ AVFilter avfilter_vf_split = { { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = NULL}}, }; + +static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) +{ + AVFilterContext *ctx = inlink->dst; + int i; + + for (i = 0; i < ctx->output_count; i++) + ff_filter_samples(inlink->dst->outputs[i], + avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE)); +} + +AVFilter avfilter_af_asplit = { + .name = "asplit", + .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."), + + .init = split_init, + .uninit = split_uninit, + + .inputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .get_audio_buffer = ff_null_get_audio_buffer, + .filter_samples = filter_samples }, + { .name = NULL }}, + .outputs = (const AVFilterPad[]) {{ .name = NULL }}, +}; diff --git a/libavfilter/version.h b/libavfilter/version.h index f352f7b242..f6497db364 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -29,7 +29,7 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 18 +#define LIBAVFILTER_VERSION_MINOR 19 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ -- cgit v1.2.3 From 5ff01259a8b558ba84066125b41832121f2f5864 Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Fri, 20 Apr 2012 14:49:30 -0500 Subject: Convert vector_fmul range of functions to YASM and add AVX versions Signed-off-by: Justin Ruggles --- libavcodec/aacsbrdata.h | 4 +- libavcodec/aactab.c | 4 +- libavcodec/aactab.h | 4 +- libavcodec/dsputil.h | 2 +- libavcodec/ra288.c | 14 ++-- libavcodec/ra288.h | 8 +- libavcodec/sbr.h | 4 +- libavcodec/sinewin.h | 2 +- libavcodec/x86/dsputil_mmx.c | 160 ++++++---------------------------------- libavcodec/x86/dsputil_yasm.asm | 105 ++++++++++++++++++++++++++ 10 files changed, 149 insertions(+), 158 deletions(-) diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index fb02a77f7d..f3090591ed 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -267,8 +267,8 @@ static const int8_t sbr_offset[6][16] = { }; ///< window coefficients for analysis/synthesis QMF banks -static DECLARE_ALIGNED(16, float, sbr_qmf_window_ds)[320]; -static DECLARE_ALIGNED(16, float, sbr_qmf_window_us)[640] = { +static DECLARE_ALIGNED(32, float, sbr_qmf_window_ds)[320]; +static DECLARE_ALIGNED(32, float, sbr_qmf_window_us)[640] = { 0.0000000000, -0.0005525286, -0.0005617692, -0.0004947518, -0.0004875227, -0.0004893791, -0.0005040714, -0.0005226564, -0.0005466565, -0.0005677802, -0.0005870930, -0.0006132747, diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 46886b12df..9176e37d48 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -33,8 +33,8 @@ #include -DECLARE_ALIGNED(16, float, ff_aac_kbd_long_1024)[1024]; -DECLARE_ALIGNED(16, float, ff_aac_kbd_short_128)[128]; +DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024]; +DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128]; const uint8_t ff_aac_num_swb_1024[] = { 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40 diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index c76d65db95..56e5796be9 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -44,8 +44,8 @@ /* @name window coefficients * @{ */ -DECLARE_ALIGNED(16, extern float, ff_aac_kbd_long_1024)[1024]; -DECLARE_ALIGNED(16, extern float, ff_aac_kbd_short_128)[128]; +DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_1024)[1024]; +DECLARE_ALIGNED(32, extern float, ff_aac_kbd_short_128)[128]; // @} /* @name number of scalefactor window bands for long and short transform windows respectively diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 3906119cfd..e0e5083d99 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -398,7 +398,7 @@ typedef struct DSPContext { /* assume len is a multiple of 4, and arrays are 16-byte aligned */ void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize); void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len); - /* assume len is a multiple of 8, and arrays are 16-byte aligned */ + /* assume len is a multiple of 16, and arrays are 32-byte aligned */ void (*vector_fmul)(float *dst, const float *src0, const float *src1, int len); void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len); /* assume len is a multiple of 8, and src arrays are 16-byte aligned */ diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 821e3811ed..d7cda3ccf8 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -38,8 +38,8 @@ typedef struct { AVFrame frame; DSPContext dsp; - DECLARE_ALIGNED(16, float, sp_lpc)[FFALIGN(36, 8)]; ///< LPC coefficients for speech data (spec: A) - DECLARE_ALIGNED(16, float, gain_lpc)[FFALIGN(10, 8)]; ///< LPC coefficients for gain (spec: GB) + DECLARE_ALIGNED(32, float, sp_lpc)[FFALIGN(36, 16)]; ///< LPC coefficients for speech data (spec: A) + DECLARE_ALIGNED(32, float, gain_lpc)[FFALIGN(10, 16)]; ///< LPC coefficients for gain (spec: GB) /** speech data history (spec: SB). * Its first 70 coefficients are updated only at backward filtering. @@ -133,11 +133,11 @@ static void do_hybrid_window(RA288Context *ractx, int i; float buffer1[MAX_BACKWARD_FILTER_ORDER + 1]; float buffer2[MAX_BACKWARD_FILTER_ORDER + 1]; - LOCAL_ALIGNED_16(float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER + - MAX_BACKWARD_FILTER_LEN + - MAX_BACKWARD_FILTER_NONREC, 8)]); + LOCAL_ALIGNED(32, float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER + + MAX_BACKWARD_FILTER_LEN + + MAX_BACKWARD_FILTER_NONREC, 16)]); - ractx->dsp.vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 8)); + ractx->dsp.vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16)); convolve(buffer1, work + order , n , order); convolve(buffer2, work + order + n, non_rec, order); @@ -164,7 +164,7 @@ static void backward_filter(RA288Context *ractx, do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window); if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1)) - ractx->dsp.vector_fmul(lpc, lpc, tab, FFALIGN(order, 8)); + ractx->dsp.vector_fmul(lpc, lpc, tab, FFALIGN(order, 16)); memmove(hist, hist + n, move_size*sizeof(*hist)); } diff --git a/libavcodec/ra288.h b/libavcodec/ra288.h index 1c98c16ea4..5e44c823ea 100644 --- a/libavcodec/ra288.h +++ b/libavcodec/ra288.h @@ -97,7 +97,7 @@ static const int16_t codetable[128][5]={ { 3746, -606, 53, -269, -3301}, { 606, 2018, -1316, 4064, 398} }; -DECLARE_ALIGNED(16, static const float, syn_window)[FFALIGN(111, 8)]={ +DECLARE_ALIGNED(32, static const float, syn_window)[FFALIGN(111, 16)]={ 0.576690972, 0.580838025, 0.585013986, 0.589219987, 0.59345597, 0.597723007, 0.602020264, 0.606384277, 0.610748291, 0.615142822, 0.619598389, 0.624084473, 0.628570557, 0.633117676, 0.637695313, 0.642272949, 0.646911621, 0.651580811, @@ -119,7 +119,7 @@ DECLARE_ALIGNED(16, static const float, syn_window)[FFALIGN(111, 8)]={ 0.142852783, 0.0954284668,0.0477600098 }; -DECLARE_ALIGNED(16, static const float, gain_window)[FFALIGN(38, 8)]={ +DECLARE_ALIGNED(32, static const float, gain_window)[FFALIGN(38, 16)]={ 0.505699992, 0.524200022, 0.54339999, 0.563300014, 0.583953857, 0.60534668, 0.627502441, 0.650482178, 0.674316406, 0.699005127, 0.724578857, 0.75112915, 0.778625488, 0.807128906, 0.836669922, 0.86730957, 0.899078369, 0.932006836, @@ -130,7 +130,7 @@ DECLARE_ALIGNED(16, static const float, gain_window)[FFALIGN(38, 8)]={ }; /** synthesis bandwidth broadening table */ -DECLARE_ALIGNED(16, static const float, syn_bw_tab)[FFALIGN(36, 8)] = { +DECLARE_ALIGNED(32, static const float, syn_bw_tab)[FFALIGN(36, 16)] = { 0.98828125, 0.976699829, 0.965254128, 0.953942537, 0.942763507, 0.931715488, 0.920796931, 0.910006344, 0.899342179, 0.888803005, 0.878387332, 0.868093729, 0.857920766, 0.847867012, 0.837931097, 0.828111589, 0.818407178, 0.808816493, @@ -140,7 +140,7 @@ DECLARE_ALIGNED(16, static const float, syn_bw_tab)[FFALIGN(36, 8)] = { }; /** gain bandwidth broadening table */ -DECLARE_ALIGNED(16, static const float, gain_bw_tab)[FFALIGN(10, 8)] = { +DECLARE_ALIGNED(32, static const float, gain_bw_tab)[FFALIGN(10, 16)] = { 0.90625, 0.821289063, 0.74432373, 0.674499512, 0.61126709, 0.553955078, 0.50201416, 0.454956055, 0.41229248, 0.373657227 }; diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index 23534b16ec..228b158e10 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -78,8 +78,8 @@ typedef struct { * @name State variables * @{ */ - DECLARE_ALIGNED(16, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; - DECLARE_ALIGNED(16, float, analysis_filterbank_samples) [1312]; + DECLARE_ALIGNED(32, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; + DECLARE_ALIGNED(32, float, analysis_filterbank_samples) [1312]; int synthesis_filterbank_samples_offset; ///l_APrev and l_A int e_a[2]; diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h index 8054191867..478036d3c6 100644 --- a/libavcodec/sinewin.h +++ b/libavcodec/sinewin.h @@ -31,7 +31,7 @@ #endif #define SINETABLE(size) \ - SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size] + SINETABLE_CONST DECLARE_ALIGNED(32, float, ff_sine_##size)[size] /** * Generate a sine window. diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 6377a73555..fca09b4e65 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -2348,135 +2348,6 @@ static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2], } } -static void vector_fmul_3dnow(float *dst, const float *src0, const float *src1, - int len) -{ - x86_reg i = (len - 4) * 4; - __asm__ volatile ( - "1: \n\t" - "movq (%2, %0), %%mm0 \n\t" - "movq 8(%2, %0), %%mm1 \n\t" - "pfmul (%3, %0), %%mm0 \n\t" - "pfmul 8(%3, %0), %%mm1 \n\t" - "movq %%mm0, (%1, %0) \n\t" - "movq %%mm1, 8(%1, %0) \n\t" - "sub $16, %0 \n\t" - "jge 1b \n\t" - "femms \n\t" - : "+r"(i) - : "r"(dst), "r"(src0), "r"(src1) - : "memory" - ); -} - -static void vector_fmul_sse(float *dst, const float *src0, const float *src1, - int len) -{ - x86_reg i = (len - 8) * 4; - __asm__ volatile ( - "1: \n\t" - "movaps (%2, %0), %%xmm0 \n\t" - "movaps 16(%2, %0), %%xmm1 \n\t" - "mulps (%3, %0), %%xmm0 \n\t" - "mulps 16(%3, %0), %%xmm1 \n\t" - "movaps %%xmm0, (%1, %0) \n\t" - "movaps %%xmm1, 16(%1, %0) \n\t" - "sub $32, %0 \n\t" - "jge 1b \n\t" - : "+r"(i) - : "r"(dst), "r"(src0), "r"(src1) - : "memory" - ); -} - -static void vector_fmul_reverse_3dnow2(float *dst, const float *src0, - const float *src1, int len) -{ - x86_reg i = len * 4 - 16; - __asm__ volatile ( - "1: \n\t" - "pswapd 8(%1), %%mm0 \n\t" - "pswapd (%1), %%mm1 \n\t" - "pfmul (%3, %0), %%mm0 \n\t" - "pfmul 8(%3, %0), %%mm1 \n\t" - "movq %%mm0, (%2, %0) \n\t" - "movq %%mm1, 8(%2, %0) \n\t" - "add $16, %1 \n\t" - "sub $16, %0 \n\t" - "jge 1b \n\t" - : "+r"(i), "+r"(src1) - : "r"(dst), "r"(src0) - ); - __asm__ volatile ("femms"); -} - -static void vector_fmul_reverse_sse(float *dst, const float *src0, - const float *src1, int len) -{ - x86_reg i = len * 4 - 32; - __asm__ volatile ( - "1: \n\t" - "movaps 16(%1), %%xmm0 \n\t" - "movaps (%1), %%xmm1 \n\t" - "shufps $0x1b, %%xmm0, %%xmm0 \n\t" - "shufps $0x1b, %%xmm1, %%xmm1 \n\t" - "mulps (%3, %0), %%xmm0 \n\t" - "mulps 16(%3, %0), %%xmm1 \n\t" - "movaps %%xmm0, (%2, %0) \n\t" - "movaps %%xmm1, 16(%2, %0) \n\t" - "add $32, %1 \n\t" - "sub $32, %0 \n\t" - "jge 1b \n\t" - : "+r"(i), "+r"(src1) - : "r"(dst), "r"(src0) - ); -} - -static void vector_fmul_add_3dnow(float *dst, const float *src0, - const float *src1, const float *src2, int len) -{ - x86_reg i = (len - 4) * 4; - __asm__ volatile ( - "1: \n\t" - "movq (%2, %0), %%mm0 \n\t" - "movq 8(%2, %0), %%mm1 \n\t" - "pfmul (%3, %0), %%mm0 \n\t" - "pfmul 8(%3, %0), %%mm1 \n\t" - "pfadd (%4, %0), %%mm0 \n\t" - "pfadd 8(%4, %0), %%mm1 \n\t" - "movq %%mm0, (%1, %0) \n\t" - "movq %%mm1, 8(%1, %0) \n\t" - "sub $16, %0 \n\t" - "jge 1b \n\t" - : "+r"(i) - : "r"(dst), "r"(src0), "r"(src1), "r"(src2) - : "memory" - ); - __asm__ volatile ("femms"); -} - -static void vector_fmul_add_sse(float *dst, const float *src0, - const float *src1, const float *src2, int len) -{ - x86_reg i = (len - 8) * 4; - __asm__ volatile ( - "1: \n\t" - "movaps (%2, %0), %%xmm0 \n\t" - "movaps 16(%2, %0), %%xmm1 \n\t" - "mulps (%3, %0), %%xmm0 \n\t" - "mulps 16(%3, %0), %%xmm1 \n\t" - "addps (%4, %0), %%xmm0 \n\t" - "addps 16(%4, %0), %%xmm1 \n\t" - "movaps %%xmm0, (%1, %0) \n\t" - "movaps %%xmm1, 16(%1, %0) \n\t" - "sub $32, %0 \n\t" - "jge 1b \n\t" - : "+r"(i) - : "r"(dst), "r"(src0), "r"(src1), "r"(src2) - : "memory" - ); -} - #if HAVE_6REGS static void vector_fmul_window_3dnow2(float *dst, const float *src0, const float *src1, const float *win, @@ -2631,6 +2502,21 @@ int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); +void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1, + int len); +void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1, + int len); + +void ff_vector_fmul_reverse_sse(float *dst, const float *src0, + const float *src1, int len); +void ff_vector_fmul_reverse_avx(float *dst, const float *src0, + const float *src1, int len); + +void ff_vector_fmul_add_sse(float *dst, const float *src0, const float *src1, + const float *src2, int len); +void ff_vector_fmul_add_avx(float *dst, const float *src0, const float *src1, + const float *src2, int len); + void ff_vector_clip_int32_mmx (int32_t *dst, const int32_t *src, int32_t min, int32_t max, unsigned int len); void ff_vector_clip_int32_sse2 (int32_t *dst, const int32_t *src, @@ -2918,8 +2804,6 @@ static void dsputil_init_3dnow(DSPContext *c, AVCodecContext *avctx, #endif c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow; - c->vector_fmul = vector_fmul_3dnow; - c->vector_fmul_add = vector_fmul_add_3dnow; #if HAVE_7REGS c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov; @@ -2929,7 +2813,6 @@ static void dsputil_init_3dnow(DSPContext *c, AVCodecContext *avctx, static void dsputil_init_3dnow2(DSPContext *c, AVCodecContext *avctx, int mm_flags) { - c->vector_fmul_reverse = vector_fmul_reverse_3dnow2; #if HAVE_6REGS c->vector_fmul_window = vector_fmul_window_3dnow2; #endif @@ -2949,11 +2832,11 @@ static void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx, int mm_flags) c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse; c->ac3_downmix = ac3_downmix_sse; - c->vector_fmul = vector_fmul_sse; - c->vector_fmul_reverse = vector_fmul_reverse_sse; - - if (!(mm_flags & AV_CPU_FLAG_3DNOW)) - c->vector_fmul_add = vector_fmul_add_sse; +#if HAVE_YASM + c->vector_fmul = ff_vector_fmul_sse; + c->vector_fmul_reverse = ff_vector_fmul_reverse_sse; + c->vector_fmul_add = ff_vector_fmul_add_sse; +#endif #if HAVE_6REGS c->vector_fmul_window = vector_fmul_window_sse; @@ -3112,6 +2995,9 @@ static void dsputil_init_avx(DSPContext *c, AVCodecContext *avctx, int mm_flags) } } c->butterflies_float_interleave = ff_butterflies_float_interleave_avx; + c->vector_fmul = ff_vector_fmul_avx; + c->vector_fmul_reverse = ff_vector_fmul_reverse_avx; + c->vector_fmul_add = ff_vector_fmul_add_avx; #endif } diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm index 807c64102b..708ee67678 100644 --- a/libavcodec/x86/dsputil_yasm.asm +++ b/libavcodec/x86/dsputil_yasm.asm @@ -1129,6 +1129,111 @@ VECTOR_CLIP_INT32 11, 1, 1, 0 VECTOR_CLIP_INT32 6, 1, 0, 0 %endif +;----------------------------------------------------------------------------- +; void vector_fmul(float *dst, const float *src0, const float *src1, int len) +;----------------------------------------------------------------------------- +%macro VECTOR_FMUL 0 +cglobal vector_fmul, 4,4,2, dst, src0, src1, len + lea lenq, [lend*4 - 2*mmsize] +ALIGN 16 +.loop + mova m0, [src0q + lenq] + mova m1, [src0q + lenq + mmsize] + mulps m0, m0, [src1q + lenq] + mulps m1, m1, [src1q + lenq + mmsize] + mova [dstq + lenq], m0 + mova [dstq + lenq + mmsize], m1 + + sub lenq, 2*mmsize + jge .loop +%if mmsize == 32 + vzeroupper + RET +%else + REP_RET +%endif +%endmacro + +INIT_XMM sse +VECTOR_FMUL +INIT_YMM avx +VECTOR_FMUL + +;----------------------------------------------------------------------------- +; void vector_fmul_reverse(float *dst, const float *src0, const float *src1, +; int len) +;----------------------------------------------------------------------------- +%macro VECTOR_FMUL_REVERSE 0 +cglobal vector_fmul_reverse, 4,4,2, dst, src0, src1, len + lea lenq, [lend*4 - 2*mmsize] +ALIGN 16 +.loop +%if cpuflag(avx) + vmovaps xmm0, [src1q + 16] + vinsertf128 m0, m0, [src1q], 1 + vshufps m0, m0, m0, q0123 + vmovaps xmm1, [src1q + mmsize + 16] + vinsertf128 m1, m1, [src1q + mmsize], 1 + vshufps m1, m1, m1, q0123 +%else + mova m0, [src1q] + mova m1, [src1q + mmsize] + shufps m0, m0, q0123 + shufps m1, m1, q0123 +%endif + mulps m0, m0, [src0q + lenq + mmsize] + mulps m1, m1, [src0q + lenq] + mova [dstq + lenq + mmsize], m0 + mova [dstq + lenq], m1 + add src1q, 2*mmsize + sub lenq, 2*mmsize + jge .loop +%if mmsize == 32 + vzeroupper + RET +%else + REP_RET +%endif +%endmacro + +INIT_XMM sse +VECTOR_FMUL_REVERSE +INIT_YMM avx +VECTOR_FMUL_REVERSE + +;----------------------------------------------------------------------------- +; vector_fmul_add(float *dst, const float *src0, const float *src1, +; const float *src2, int len) +;----------------------------------------------------------------------------- +%macro VECTOR_FMUL_ADD 0 +cglobal vector_fmul_add, 5,5,2, dst, src0, src1, src2, len + lea lenq, [lend*4 - 2*mmsize] +ALIGN 16 +.loop + mova m0, [src0q + lenq] + mova m1, [src0q + lenq + mmsize] + mulps m0, m0, [src1q + lenq] + mulps m1, m1, [src1q + lenq + mmsize] + addps m0, m0, [src2q + lenq] + addps m1, m1, [src2q + lenq + mmsize] + mova [dstq + lenq], m0 + mova [dstq + lenq + mmsize], m1 + + sub lenq, 2*mmsize + jge .loop +%if mmsize == 32 + vzeroupper + RET +%else + REP_RET +%endif +%endmacro + +INIT_XMM sse +VECTOR_FMUL_ADD +INIT_YMM avx +VECTOR_FMUL_ADD + ;----------------------------------------------------------------------------- ; void ff_butterflies_float_interleave(float *dst, const float *src0, ; const float *src1, int len); -- cgit v1.2.3 From e0d8427dce7bf8fababbe9b0f1269d1da8632da9 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 21 May 2012 14:59:56 -0400 Subject: af_resample: remove an extra space in the log output --- libavfilter/af_resample.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c index 4ad5a8c38e..1fc8c04b4a 100644 --- a/libavfilter/af_resample.c +++ b/libavfilter/af_resample.c @@ -119,7 +119,7 @@ static int config_output(AVFilterLink *outlink) av_get_channel_layout_string(buf2, sizeof(buf2), -1, outlink->channel_layout); av_log(ctx, AV_LOG_VERBOSE, - "fmt:%s srate: %d cl:%s -> fmt:%s srate: %d cl:%s\n", + "fmt:%s srate:%d cl:%s -> fmt:%s srate:%d cl:%s\n", av_get_sample_fmt_name(inlink ->format), inlink ->sample_rate, buf1, av_get_sample_fmt_name(outlink->format), outlink->sample_rate, buf2); -- cgit v1.2.3 From 3ea54294895c94e83a904085b0043cfbbf95eaa7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 21 May 2012 08:47:11 +0200 Subject: ppc: Drop unused header regs.h --- libavcodec/ppc/regs.h | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 libavcodec/ppc/regs.h diff --git a/libavcodec/ppc/regs.h b/libavcodec/ppc/regs.h deleted file mode 100644 index 2edd639531..0000000000 --- a/libavcodec/ppc/regs.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2010 Mans Rullgard - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_PPC_REGS_H -#define AVCODEC_PPC_REGS_H - -#include "libavutil/avutil.h" -#include "config.h" - -#if HAVE_IBM_ASM -# define r(n) AV_TOSTRING(n) -# define f(n) AV_TOSTRING(n) -# define v(n) AV_TOSTRING(n) -#else -# define r(n) AV_TOSTRING(r ## n) -# define f(n) AV_TOSTRING(f ## n) -# define v(n) AV_TOSTRING(v ## n) -#endif - -#endif /* AVCODEC_PPC_REGS_H */ -- cgit v1.2.3 From c89e428ed8c2c31396af2d18cab4342b7d82958f Mon Sep 17 00:00:00 2001 From: Jordi Ortiz Date: Tue, 22 May 2012 13:18:17 +0200 Subject: dwt: check malloc calls Signed-off-by: Diego Biurrun --- libavcodec/dwt.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c index f9577fd1bd..675644dbe6 100644 --- a/libavcodec/dwt.c +++ b/libavcodec/dwt.c @@ -33,10 +33,24 @@ void ff_slice_buffer_init(slice_buffer *buf, int line_count, buf->line_width = line_width; buf->data_count = max_allocated_lines; buf->line = av_mallocz(sizeof(IDWTELEM *) * line_count); + if (!buf->line) + return AVERROR(ENOMEM); buf->data_stack = av_malloc(sizeof(IDWTELEM *) * max_allocated_lines); + if (!buf->data_stack) { + av_free(buf->line); + return AVERROR(ENOMEM); + } - for (i = 0; i < max_allocated_lines; i++) + for (i = 0; i < max_allocated_lines; i++) { buf->data_stack[i] = av_malloc(sizeof(IDWTELEM) * line_width); + if (!buf->data_stack[i]) { + for (i--; i >=0; i--) + av_free(buf->data_stack[i]); + av_free(buf->data_stack); + av_free(buf->line); + return AVERROR(ENOMEM); + } + } buf->data_stack_top = max_allocated_lines - 1; } -- cgit v1.2.3