From 3d5d46233cd81f78138a6d7418d480af04d3f6c8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 1 Feb 2015 11:08:17 +0100 Subject: [PATCH] opus: Factor out imdct15 into a standalone component It will be reused by the AAC decoder. --- configure | 2 ++ libavcodec/Makefile | 4 +-- libavcodec/aarch64/Makefile | 4 +-- .../{opus_imdct_init.c => imdct15_init.c} | 19 ++++++------ .../{opus_imdct_neon.S => imdct15_neon.S} | 0 libavcodec/{opus_imdct.c => imdct15.c} | 30 ++++++++++--------- libavcodec/{opus_imdct.h => imdct15.h} | 18 +++++------ libavcodec/opus_celt.c | 10 +++---- 8 files changed, 46 insertions(+), 41 deletions(-) rename libavcodec/aarch64/{opus_imdct_init.c => imdct15_init.c} (66%) rename libavcodec/aarch64/{opus_imdct_neon.S => imdct15_neon.S} (100%) rename libavcodec/{opus_imdct.c => imdct15.c} (91%) rename libavcodec/{opus_imdct.h => imdct15.h} (74%) diff --git a/configure b/configure index 1d87816057..17a7d7945e 100755 --- a/configure +++ b/configure @@ -1578,6 +1578,7 @@ CONFIG_EXTRA=" huffyuvencdsp idctdsp iirfilter + imdct15 intrax8 lgplv3 lpc @@ -1872,6 +1873,7 @@ nellymoser_encoder_select="audio_frame_queue mdct sinewin" nuv_decoder_select="idctdsp lzo" on2avc_decoder_select="mdct" opus_decoder_deps="avresample" +opus_decoder_select="imdct15" png_decoder_deps="zlib" png_encoder_deps="zlib" png_encoder_select="huffyuvencdsp" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index bd38411d77..a38f84042c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -57,6 +57,7 @@ OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o OBJS-$(CONFIG_IDCTDSP) += idctdsp.o simple_idct.o jrevdct.o OBJS-$(CONFIG_IIRFILTER) += iirfilter.o +OBJS-$(CONFIG_IMDCT15) += imdct15.o OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o OBJS-$(CONFIG_LPC) += lpc.o @@ -294,8 +295,7 @@ OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o \ - opus_imdct.o opus_silk.o \ - vorbis_data.o + opus_silk.o vorbis_data.o OBJS-$(CONFIG_PAF_AUDIO_DECODER) += pafaudio.o OBJS-$(CONFIG_PAF_VIDEO_DECODER) += pafvideo.o OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index 964428e35d..2afff297dc 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -3,11 +3,11 @@ OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o +OBJS-$(CONFIG_IMDCT15) += aarch64/imdct15_init.o OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o -OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opus_imdct_init.o OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o OBJS-$(CONFIG_VC1_DECODER) += aarch64/vc1dsp_init_aarch64.o OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_init.o @@ -21,8 +21,8 @@ NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o \ NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \ aarch64/hpeldsp_neon.o NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o +NEON-OBJS-$(CONFIG_IMDCT15) += aarch64/imdct15_neon.o NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o -NEON-OBJS-$(CONFIG_OPUS_DECODER) += aarch64/opus_imdct_neon.o NEON-OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_neon.o diff --git a/libavcodec/aarch64/opus_imdct_init.c b/libavcodec/aarch64/imdct15_init.c similarity index 66% rename from libavcodec/aarch64/opus_imdct_init.c rename to libavcodec/aarch64/imdct15_init.c index 1a776dca00..38018f2b4a 100644 --- a/libavcodec/aarch64/opus_imdct_init.c +++ b/libavcodec/aarch64/imdct15_init.c @@ -21,21 +21,22 @@ #include "libavutil/cpu.h" #include "libavutil/aarch64/cpu.h" #include "libavutil/internal.h" -#include "libavcodec/opus_imdct.h" + +#include "libavcodec/imdct15.h" #include "asm-offsets.h" -AV_CHECK_OFFSET(CeltIMDCTContext, exptab, CELT_EXPTAB); -AV_CHECK_OFFSET(CeltIMDCTContext, fft_n, CELT_FFT_N); -AV_CHECK_OFFSET(CeltIMDCTContext, len2, CELT_LEN2); -AV_CHECK_OFFSET(CeltIMDCTContext, len4, CELT_LEN4); -AV_CHECK_OFFSET(CeltIMDCTContext, tmp, CELT_TMP); -AV_CHECK_OFFSET(CeltIMDCTContext, twiddle_exptab, CELT_TWIDDLE); +AV_CHECK_OFFSET(IMDCT15Context, exptab, CELT_EXPTAB); +AV_CHECK_OFFSET(IMDCT15Context, fft_n, CELT_FFT_N); +AV_CHECK_OFFSET(IMDCT15Context, len2, CELT_LEN2); +AV_CHECK_OFFSET(IMDCT15Context, len4, CELT_LEN4); +AV_CHECK_OFFSET(IMDCT15Context, tmp, CELT_TMP); +AV_CHECK_OFFSET(IMDCT15Context, twiddle_exptab, CELT_TWIDDLE); -void ff_celt_imdct_half_neon(CeltIMDCTContext *s, float *dst, const float *src, +void ff_celt_imdct_half_neon(IMDCT15Context *s, float *dst, const float *src, ptrdiff_t stride, float scale); -void ff_celt_imdct_init_aarch64(CeltIMDCTContext *s) +void ff_imdct15_init_aarch64(IMDCT15Context *s) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/aarch64/opus_imdct_neon.S b/libavcodec/aarch64/imdct15_neon.S similarity index 100% rename from libavcodec/aarch64/opus_imdct_neon.S rename to libavcodec/aarch64/imdct15_neon.S diff --git a/libavcodec/opus_imdct.c b/libavcodec/imdct15.c similarity index 91% rename from libavcodec/opus_imdct.c rename to libavcodec/imdct15.c index 38674edd32..e02e9cedf6 100644 --- a/libavcodec/opus_imdct.c +++ b/libavcodec/imdct15.c @@ -33,8 +33,8 @@ #include "libavutil/common.h" #include "avfft.h" +#include "imdct15.h" #include "opus.h" -#include "opus_imdct.h" // minimal iMDCT size to make SIMD opts easier #define CELT_MIN_IMDCT_SIZE 120 @@ -66,9 +66,9 @@ do { \ (d).im = -ri + ir; \ } while (0) -av_cold void ff_celt_imdct_uninit(CeltIMDCTContext **ps) +av_cold void ff_imdct15_uninit(IMDCT15Context **ps) { - CeltIMDCTContext *s = *ps; + IMDCT15Context *s = *ps; int i; if (!s) @@ -84,12 +84,12 @@ av_cold void ff_celt_imdct_uninit(CeltIMDCTContext **ps) av_freep(ps); } -static void celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src, - ptrdiff_t stride, float scale); +static void imdct15_half(IMDCT15Context *s, float *dst, const float *src, + ptrdiff_t stride, float scale); -av_cold int ff_celt_imdct_init(CeltIMDCTContext **ps, int N) +av_cold int ff_imdct15_init(IMDCT15Context **ps, int N) { - CeltIMDCTContext *s; + IMDCT15Context *s; int len2 = 15 * (1 << N); int len = 2 * len2; int i, j; @@ -134,16 +134,17 @@ av_cold int ff_celt_imdct_init(CeltIMDCTContext **ps, int N) for (j = 15; j < 19; j++) s->exptab[0][j] = s->exptab[0][j - 15]; - s->imdct_half = celt_imdct_half; + s->imdct_half = imdct15_half; if (ARCH_AARCH64) - ff_celt_imdct_init_aarch64(s); + ff_imdct15_init_aarch64(s); *ps = s; return 0; + fail: - ff_celt_imdct_uninit(&s); + ff_imdct15_uninit(&s); return AVERROR(ENOMEM); } @@ -180,7 +181,8 @@ static void fft5(FFTComplex *out, const FFTComplex *in, ptrdiff_t stride) out[4].im = in[0].im + z[0][3].im + z[1][2].im + z[2][1].im + z[3][0].im; } -static void fft15(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in, ptrdiff_t stride) +static void fft15(IMDCT15Context *s, FFTComplex *out, const FFTComplex *in, + ptrdiff_t stride) { const FFTComplex *exptab = s->exptab[0]; FFTComplex tmp[5]; @@ -215,7 +217,7 @@ static void fft15(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in, pt /* * FFT of the length 15 * (2^N) */ -static void fft_calc(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in, +static void fft_calc(IMDCT15Context *s, FFTComplex *out, const FFTComplex *in, int N, ptrdiff_t stride) { if (N) { @@ -241,8 +243,8 @@ static void fft_calc(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in, fft15(s, out, in, stride); } -static void celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src, - ptrdiff_t stride, float scale) +static void imdct15_half(IMDCT15Context *s, float *dst, const float *src, + ptrdiff_t stride, float scale) { FFTComplex *z = (FFTComplex *)dst; const int len8 = s->len4 / 2; diff --git a/libavcodec/opus_imdct.h b/libavcodec/imdct15.h similarity index 74% rename from libavcodec/opus_imdct.h rename to libavcodec/imdct15.h index d4bff9a152..ed3f0039e8 100644 --- a/libavcodec/opus_imdct.h +++ b/libavcodec/imdct15.h @@ -16,14 +16,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_OPUS_IMDCT_H -#define AVCODEC_OPUS_IMDCT_H +#ifndef AVCODEC_IMDCT15_H +#define AVCODEC_IMDCT15_H #include #include "avfft.h" -typedef struct CeltIMDCTContext { +typedef struct IMDCT15Context { int fft_n; int len2; int len4; @@ -37,21 +37,21 @@ typedef struct CeltIMDCTContext { /** * Calculate the middle half of the iMDCT */ - void (*imdct_half)(struct CeltIMDCTContext *s, float *dst, const float *src, + void (*imdct_half)(struct IMDCT15Context *s, float *dst, const float *src, ptrdiff_t src_stride, float scale); -} CeltIMDCTContext; +} IMDCT15Context; /** * Init an iMDCT of the length 2 * 15 * (2^N) */ -int ff_celt_imdct_init(CeltIMDCTContext **s, int N); +int ff_imdct15_init(IMDCT15Context **s, int N); /** * Free an iMDCT. */ -void ff_celt_imdct_uninit(CeltIMDCTContext **s); +void ff_imdct15_uninit(IMDCT15Context **s); -void ff_celt_imdct_init_aarch64(CeltIMDCTContext *s); +void ff_imdct15_init_aarch64(IMDCT15Context *s); -#endif /* AVCODEC_OPUS_IMDCT_H */ +#endif /* AVCODEC_IMDCT15_H */ diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index af3e549251..a6220e556c 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -28,8 +28,8 @@ #include "libavutil/float_dsp.h" +#include "imdct15.h" #include "opus.h" -#include "opus_imdct.h" enum CeltSpread { CELT_SPREAD_NONE, @@ -61,7 +61,7 @@ typedef struct CeltFrame { struct CeltContext { // constant values that do not change during context lifetime AVCodecContext *avctx; - CeltIMDCTContext *imdct[4]; + IMDCT15Context *imdct[4]; AVFloatDSPContext dsp; int output_channels; @@ -1983,7 +1983,7 @@ int ff_celt_decode_frame(CeltContext *s, OpusRangeCoder *rc, int silence = 0; int transient = 0; int anticollapse = 0; - CeltIMDCTContext *imdct; + IMDCT15Context *imdct; float imdct_scale = 1.0; if (coded_channels != 1 && coded_channels != 2) { @@ -2179,7 +2179,7 @@ void ff_celt_free(CeltContext **ps) return; for (i = 0; i < FF_ARRAY_ELEMS(s->imdct); i++) - ff_celt_imdct_uninit(&s->imdct[i]); + ff_imdct15_uninit(&s->imdct[i]); av_freep(ps); } @@ -2203,7 +2203,7 @@ int ff_celt_init(AVCodecContext *avctx, CeltContext **ps, int output_channels) s->output_channels = output_channels; for (i = 0; i < FF_ARRAY_ELEMS(s->imdct); i++) { - ret = ff_celt_imdct_init(&s->imdct[i], i + 3); + ret = ff_imdct15_init(&s->imdct[i], i + 3); if (ret < 0) goto fail; }