Re: [FFmpeg-devel] [PATCH 4/8] sbc: implement SBC encoder (low-complexity subband codec)
On Mon, Dec 18, 2017 at 12:45:12PM +0100, Michael Niedermayer wrote: > On Sun, Dec 17, 2017 at 10:47:16PM +0100, Aurelien Jacobs wrote: > > This was originally based on libsbc, and was fully integrated into ffmpeg. > > --- > [...] > > +static inline void sbc_analyze_4b_4s_simd(SBCDSPContext *s, > > + int16_t *x, int32_t *out, int > > out_stride) > > +{ > > +/* Analyze blocks */ > > +s->sbc_analyze_4(x + 12, out, > > ff_sbcdsp_analysis_consts_fixed4_simd_odd); > > +out += out_stride; > > +s->sbc_analyze_4(x + 8, out, > > ff_sbcdsp_analysis_consts_fixed4_simd_even); > > +out += out_stride; > > +s->sbc_analyze_4(x + 4, out, > > ff_sbcdsp_analysis_consts_fixed4_simd_odd); > > +out += out_stride; > > +s->sbc_analyze_4(x + 0, out, > > ff_sbcdsp_analysis_consts_fixed4_simd_even); > > + > > +emms_c(); > > +} > > + > > +static inline void sbc_analyze_4b_8s_simd(SBCDSPContext *s, > > + int16_t *x, int32_t *out, int > > out_stride) > > +{ > > +/* Analyze blocks */ > > +s->sbc_analyze_8(x + 24, out, > > ff_sbcdsp_analysis_consts_fixed8_simd_odd); > > +out += out_stride; > > +s->sbc_analyze_8(x + 16, out, > > ff_sbcdsp_analysis_consts_fixed8_simd_even); > > +out += out_stride; > > +s->sbc_analyze_8(x + 8, out, > > ff_sbcdsp_analysis_consts_fixed8_simd_odd); > > +out += out_stride; > > +s->sbc_analyze_8(x + 0, out, > > ff_sbcdsp_analysis_consts_fixed8_simd_even); > > + > > +emms_c(); > > +} > > + > > +static inline void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s, > > + int16_t *x, int32_t *out, > > + int out_stride); > > + > > +static inline void sbc_analyze_1b_8s_simd_odd(SBCDSPContext *s, > > + int16_t *x, int32_t *out, > > + int out_stride) > > +{ > > +s->sbc_analyze_8(x, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd); > > +s->sbc_analyze_8s = sbc_analyze_1b_8s_simd_even; > > + > > +emms_c(); > > +} > > + > > +static inline void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s, > > + int16_t *x, int32_t *out, > > + int out_stride) > > +{ > > +s->sbc_analyze_8(x, out, ff_sbcdsp_analysis_consts_fixed8_simd_even); > > +s->sbc_analyze_8s = sbc_analyze_1b_8s_simd_odd; > > + > > +emms_c(); > > +} > > at least some of the functions are always called in a loop, the emms_c() could > be called after the loop Ok, I moved all those emms_c() out of the loop. > [...] > > diff --git a/libavcodec/sbcdsp_data.c b/libavcodec/sbcdsp_data.c > > new file mode 100644 > > index 00..1e19b9d9d1 > > --- /dev/null > > +++ b/libavcodec/sbcdsp_data.c > > @@ -0,0 +1,329 @@ > > +/* > > + * Bluetooth low-complexity, subband codec (SBC) > > + * > > + * Copyright (C) 2017 Aurelien Jacobs> > + * Copyright (C) 2008-2010 Nokia Corporation > > + * Copyright (C) 2004-2010 Marcel Holtmann > > + * Copyright (C) 2004-2005 Henryk Ploetz > > + * Copyright (C) 2005-2006 Brad Midgley > > + * > > + * 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 > > + */ > > + > > +/** > > + * @file > > + * miscellaneous SBC tables > > + */ > > + > > +#include "sbcdsp_data.h" > > + > > +#define F_PROTO(x) (int32_t) ((x * 2) * ((int32_t) 1 << 15) + 0.5) > > +#define F_COS(x) (int32_t) ((x) * ((int32_t) 1 << 15) + 0.5) > > this needs more () to protect the argument x and the whole expression > for example F_PROTO(1+1) would produce unexpected results Indeed. Fixed in upcomming updated patch set. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/8] sbc: implement SBC encoder (low-complexity subband codec)
On Sun, Dec 17, 2017 at 10:47:16PM +0100, Aurelien Jacobs wrote: > This was originally based on libsbc, and was fully integrated into ffmpeg. > --- [...] > +static inline void sbc_analyze_4b_4s_simd(SBCDSPContext *s, > + int16_t *x, int32_t *out, int > out_stride) > +{ > +/* Analyze blocks */ > +s->sbc_analyze_4(x + 12, out, ff_sbcdsp_analysis_consts_fixed4_simd_odd); > +out += out_stride; > +s->sbc_analyze_4(x + 8, out, ff_sbcdsp_analysis_consts_fixed4_simd_even); > +out += out_stride; > +s->sbc_analyze_4(x + 4, out, ff_sbcdsp_analysis_consts_fixed4_simd_odd); > +out += out_stride; > +s->sbc_analyze_4(x + 0, out, ff_sbcdsp_analysis_consts_fixed4_simd_even); > + > +emms_c(); > +} > + > +static inline void sbc_analyze_4b_8s_simd(SBCDSPContext *s, > + int16_t *x, int32_t *out, int > out_stride) > +{ > +/* Analyze blocks */ > +s->sbc_analyze_8(x + 24, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd); > +out += out_stride; > +s->sbc_analyze_8(x + 16, out, > ff_sbcdsp_analysis_consts_fixed8_simd_even); > +out += out_stride; > +s->sbc_analyze_8(x + 8, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd); > +out += out_stride; > +s->sbc_analyze_8(x + 0, out, ff_sbcdsp_analysis_consts_fixed8_simd_even); > + > +emms_c(); > +} > + > +static inline void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s, > + int16_t *x, int32_t *out, > + int out_stride); > + > +static inline void sbc_analyze_1b_8s_simd_odd(SBCDSPContext *s, > + int16_t *x, int32_t *out, > + int out_stride) > +{ > +s->sbc_analyze_8(x, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd); > +s->sbc_analyze_8s = sbc_analyze_1b_8s_simd_even; > + > +emms_c(); > +} > + > +static inline void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s, > + int16_t *x, int32_t *out, > + int out_stride) > +{ > +s->sbc_analyze_8(x, out, ff_sbcdsp_analysis_consts_fixed8_simd_even); > +s->sbc_analyze_8s = sbc_analyze_1b_8s_simd_odd; > + > +emms_c(); > +} at least some of the functions are always called in a loop, the emms_c() could be called after the loop [...] > diff --git a/libavcodec/sbcdsp_data.c b/libavcodec/sbcdsp_data.c > new file mode 100644 > index 00..1e19b9d9d1 > --- /dev/null > +++ b/libavcodec/sbcdsp_data.c > @@ -0,0 +1,329 @@ > +/* > + * Bluetooth low-complexity, subband codec (SBC) > + * > + * Copyright (C) 2017 Aurelien Jacobs> + * Copyright (C) 2008-2010 Nokia Corporation > + * Copyright (C) 2004-2010 Marcel Holtmann > + * Copyright (C) 2004-2005 Henryk Ploetz > + * Copyright (C) 2005-2006 Brad Midgley > + * > + * 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 > + */ > + > +/** > + * @file > + * miscellaneous SBC tables > + */ > + > +#include "sbcdsp_data.h" > + > +#define F_PROTO(x) (int32_t) ((x * 2) * ((int32_t) 1 << 15) + 0.5) > +#define F_COS(x) (int32_t) ((x) * ((int32_t) 1 << 15) + 0.5) this needs more () to protect the argument x and the whole expression for example F_PROTO(1+1) would produce unexpected results thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB What does censorship reveal? It reveals fear. -- Julian Assange signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 4/8] sbc: implement SBC encoder (low-complexity subband codec)
This was originally based on libsbc, and was fully integrated into ffmpeg. --- doc/general.texi | 2 +- libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 4 +- libavcodec/sbcdsp.c | 390 + libavcodec/sbcdsp.h | 83 + libavcodec/sbcdsp_data.c | 329 +++ libavcodec/sbcdsp_data.h | 55 ++ libavcodec/sbcenc.c | 440 +++ 8 files changed, 1302 insertions(+), 3 deletions(-) create mode 100644 libavcodec/sbcdsp.c create mode 100644 libavcodec/sbcdsp.h create mode 100644 libavcodec/sbcdsp_data.c create mode 100644 libavcodec/sbcdsp_data.h create mode 100644 libavcodec/sbcenc.c diff --git a/doc/general.texi b/doc/general.texi index 65aee47f2a..e5669b0e93 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1103,7 +1103,7 @@ following image formats are supported: @tab Real low bitrate AC-3 codec @item RealAudio Lossless @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X -@item SBC (low-complexity subband codec) @tab @tab X +@item SBC (low-complexity subband codec) @tab X @tab X @tab Used in Bluetooth A2DP @item Shorten@tab @tab X @item Sierra VMD audio @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 58c8c6e499..d237deeefc 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -582,7 +582,9 @@ OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_SBC_ENCODER) += sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o OBJS-$(CONFIG_MSBC_DECODER)+= sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_MSBC_ENCODER)+= sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o OBJS-$(CONFIG_SVQ1_DECODER)+= svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_ENCODER)+= svq1enc.o svq1.o h263data.o \ h263.o ituh263enc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 3e3b37f638..e5b3c20ec7 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -379,7 +379,7 @@ static void register_all(void) REGISTER_DECODER(MP3ON4FLOAT, mp3on4float); REGISTER_DECODER(MPC7, mpc7); REGISTER_DECODER(MPC8, mpc8); -REGISTER_DECODER(MSBC, msbc); +REGISTER_ENCDEC (MSBC, msbc); REGISTER_ENCDEC (NELLYMOSER,nellymoser); REGISTER_DECODER(ON2AVC,on2avc); REGISTER_ENCDEC (OPUS, opus); @@ -393,7 +393,7 @@ static void register_all(void) REGISTER_DECODER(SHORTEN, shorten); REGISTER_DECODER(SIPR, sipr); REGISTER_DECODER(SMACKAUD, smackaud); -REGISTER_DECODER(SBC, sbc); +REGISTER_ENCDEC (SBC, sbc); REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCODER(SONIC_LS, sonic_ls); REGISTER_DECODER(TAK, tak); diff --git a/libavcodec/sbcdsp.c b/libavcodec/sbcdsp.c new file mode 100644 index 00..16faf5ba9b --- /dev/null +++ b/libavcodec/sbcdsp.c @@ -0,0 +1,390 @@ +/* + * Bluetooth low-complexity, subband codec (SBC) + * + * Copyright (C) 2017 Aurelien Jacobs+ * Copyright (C) 2012-2013 Intel Corporation + * Copyright (C) 2008-2010 Nokia Corporation + * Copyright (C) 2004-2010 Marcel Holtmann + * Copyright (C) 2004-2005 Henryk Ploetz + * Copyright (C) 2005-2006 Brad Midgley + * + * 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 + */ + +/** + * @file + * SBC basic "building bricks" + */ + +#include +#include +#include +#include "libavutil/common.h" +#include "libavutil/intmath.h" +#include "libavutil/intreadwrite.h" +#include "sbc.h" +#include "sbcdsp.h" +#include "sbcdsp_data.h" + +/* + * A reference C code of analysis filter with SIMD-friendly tables + * reordering and code layout. This code can be used to develop platform + * specific SIMD