You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
opus: Factor out imdct15 into a standalone component
It will be reused by the AAC decoder.
This commit is contained in:
committed by
Janne Grunau
parent
28df0151b6
commit
3d5d46233c
2
configure
vendored
2
configure
vendored
@@ -1578,6 +1578,7 @@ CONFIG_EXTRA="
|
|||||||
huffyuvencdsp
|
huffyuvencdsp
|
||||||
idctdsp
|
idctdsp
|
||||||
iirfilter
|
iirfilter
|
||||||
|
imdct15
|
||||||
intrax8
|
intrax8
|
||||||
lgplv3
|
lgplv3
|
||||||
lpc
|
lpc
|
||||||
@@ -1872,6 +1873,7 @@ nellymoser_encoder_select="audio_frame_queue mdct sinewin"
|
|||||||
nuv_decoder_select="idctdsp lzo"
|
nuv_decoder_select="idctdsp lzo"
|
||||||
on2avc_decoder_select="mdct"
|
on2avc_decoder_select="mdct"
|
||||||
opus_decoder_deps="avresample"
|
opus_decoder_deps="avresample"
|
||||||
|
opus_decoder_select="imdct15"
|
||||||
png_decoder_deps="zlib"
|
png_decoder_deps="zlib"
|
||||||
png_encoder_deps="zlib"
|
png_encoder_deps="zlib"
|
||||||
png_encoder_select="huffyuvencdsp"
|
png_encoder_select="huffyuvencdsp"
|
||||||
|
@@ -57,6 +57,7 @@ OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
|
|||||||
OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o
|
OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o
|
||||||
OBJS-$(CONFIG_IDCTDSP) += idctdsp.o simple_idct.o jrevdct.o
|
OBJS-$(CONFIG_IDCTDSP) += idctdsp.o simple_idct.o jrevdct.o
|
||||||
OBJS-$(CONFIG_IIRFILTER) += iirfilter.o
|
OBJS-$(CONFIG_IIRFILTER) += iirfilter.o
|
||||||
|
OBJS-$(CONFIG_IMDCT15) += imdct15.o
|
||||||
OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o
|
OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o
|
||||||
OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o
|
OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o
|
||||||
OBJS-$(CONFIG_LPC) += lpc.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_NUV_DECODER) += nuv.o rtjpeg.o
|
||||||
OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
|
OBJS-$(CONFIG_ON2AVC_DECODER) += on2avc.o on2avcdata.o
|
||||||
OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o \
|
OBJS-$(CONFIG_OPUS_DECODER) += opusdec.o opus.o opus_celt.o \
|
||||||
opus_imdct.o opus_silk.o \
|
opus_silk.o vorbis_data.o
|
||||||
vorbis_data.o
|
|
||||||
OBJS-$(CONFIG_PAF_AUDIO_DECODER) += pafaudio.o
|
OBJS-$(CONFIG_PAF_AUDIO_DECODER) += pafaudio.o
|
||||||
OBJS-$(CONFIG_PAF_VIDEO_DECODER) += pafvideo.o
|
OBJS-$(CONFIG_PAF_VIDEO_DECODER) += pafvideo.o
|
||||||
OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
|
OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
|
||||||
|
@@ -3,11 +3,11 @@ OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o
|
|||||||
OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
|
OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
|
||||||
OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o
|
OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o
|
||||||
OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_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_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o
|
||||||
OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o
|
OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o
|
||||||
OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.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_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
|
||||||
OBJS-$(CONFIG_VC1_DECODER) += aarch64/vc1dsp_init_aarch64.o
|
OBJS-$(CONFIG_VC1_DECODER) += aarch64/vc1dsp_init_aarch64.o
|
||||||
OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_init.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 \
|
NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \
|
||||||
aarch64/hpeldsp_neon.o
|
aarch64/hpeldsp_neon.o
|
||||||
NEON-OBJS-$(CONFIG_HPELDSP) += 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_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
|
||||||
NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_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
|
NEON-OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_neon.o
|
||||||
|
@@ -21,21 +21,22 @@
|
|||||||
#include "libavutil/cpu.h"
|
#include "libavutil/cpu.h"
|
||||||
#include "libavutil/aarch64/cpu.h"
|
#include "libavutil/aarch64/cpu.h"
|
||||||
#include "libavutil/internal.h"
|
#include "libavutil/internal.h"
|
||||||
#include "libavcodec/opus_imdct.h"
|
|
||||||
|
#include "libavcodec/imdct15.h"
|
||||||
|
|
||||||
#include "asm-offsets.h"
|
#include "asm-offsets.h"
|
||||||
|
|
||||||
AV_CHECK_OFFSET(CeltIMDCTContext, exptab, CELT_EXPTAB);
|
AV_CHECK_OFFSET(IMDCT15Context, exptab, CELT_EXPTAB);
|
||||||
AV_CHECK_OFFSET(CeltIMDCTContext, fft_n, CELT_FFT_N);
|
AV_CHECK_OFFSET(IMDCT15Context, fft_n, CELT_FFT_N);
|
||||||
AV_CHECK_OFFSET(CeltIMDCTContext, len2, CELT_LEN2);
|
AV_CHECK_OFFSET(IMDCT15Context, len2, CELT_LEN2);
|
||||||
AV_CHECK_OFFSET(CeltIMDCTContext, len4, CELT_LEN4);
|
AV_CHECK_OFFSET(IMDCT15Context, len4, CELT_LEN4);
|
||||||
AV_CHECK_OFFSET(CeltIMDCTContext, tmp, CELT_TMP);
|
AV_CHECK_OFFSET(IMDCT15Context, tmp, CELT_TMP);
|
||||||
AV_CHECK_OFFSET(CeltIMDCTContext, twiddle_exptab, CELT_TWIDDLE);
|
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);
|
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();
|
int cpu_flags = av_get_cpu_flags();
|
||||||
|
|
@@ -33,8 +33,8 @@
|
|||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
|
|
||||||
#include "avfft.h"
|
#include "avfft.h"
|
||||||
|
#include "imdct15.h"
|
||||||
#include "opus.h"
|
#include "opus.h"
|
||||||
#include "opus_imdct.h"
|
|
||||||
|
|
||||||
// minimal iMDCT size to make SIMD opts easier
|
// minimal iMDCT size to make SIMD opts easier
|
||||||
#define CELT_MIN_IMDCT_SIZE 120
|
#define CELT_MIN_IMDCT_SIZE 120
|
||||||
@@ -66,9 +66,9 @@ do { \
|
|||||||
(d).im = -ri + ir; \
|
(d).im = -ri + ir; \
|
||||||
} while (0)
|
} 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;
|
int i;
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
@@ -84,12 +84,12 @@ av_cold void ff_celt_imdct_uninit(CeltIMDCTContext **ps)
|
|||||||
av_freep(ps);
|
av_freep(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src,
|
static void imdct15_half(IMDCT15Context *s, float *dst, const float *src,
|
||||||
ptrdiff_t stride, float scale);
|
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 len2 = 15 * (1 << N);
|
||||||
int len = 2 * len2;
|
int len = 2 * len2;
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -134,16 +134,17 @@ av_cold int ff_celt_imdct_init(CeltIMDCTContext **ps, int N)
|
|||||||
for (j = 15; j < 19; j++)
|
for (j = 15; j < 19; j++)
|
||||||
s->exptab[0][j] = s->exptab[0][j - 15];
|
s->exptab[0][j] = s->exptab[0][j - 15];
|
||||||
|
|
||||||
s->imdct_half = celt_imdct_half;
|
s->imdct_half = imdct15_half;
|
||||||
|
|
||||||
if (ARCH_AARCH64)
|
if (ARCH_AARCH64)
|
||||||
ff_celt_imdct_init_aarch64(s);
|
ff_imdct15_init_aarch64(s);
|
||||||
|
|
||||||
*ps = s;
|
*ps = s;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
ff_celt_imdct_uninit(&s);
|
ff_imdct15_uninit(&s);
|
||||||
return AVERROR(ENOMEM);
|
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;
|
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];
|
const FFTComplex *exptab = s->exptab[0];
|
||||||
FFTComplex tmp[5];
|
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)
|
* 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)
|
int N, ptrdiff_t stride)
|
||||||
{
|
{
|
||||||
if (N) {
|
if (N) {
|
||||||
@@ -241,7 +243,7 @@ static void fft_calc(CeltIMDCTContext *s, FFTComplex *out, const FFTComplex *in,
|
|||||||
fft15(s, out, in, stride);
|
fft15(s, out, in, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void celt_imdct_half(CeltIMDCTContext *s, float *dst, const float *src,
|
static void imdct15_half(IMDCT15Context *s, float *dst, const float *src,
|
||||||
ptrdiff_t stride, float scale)
|
ptrdiff_t stride, float scale)
|
||||||
{
|
{
|
||||||
FFTComplex *z = (FFTComplex *)dst;
|
FFTComplex *z = (FFTComplex *)dst;
|
@@ -16,14 +16,14 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AVCODEC_OPUS_IMDCT_H
|
#ifndef AVCODEC_IMDCT15_H
|
||||||
#define AVCODEC_OPUS_IMDCT_H
|
#define AVCODEC_IMDCT15_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "avfft.h"
|
#include "avfft.h"
|
||||||
|
|
||||||
typedef struct CeltIMDCTContext {
|
typedef struct IMDCT15Context {
|
||||||
int fft_n;
|
int fft_n;
|
||||||
int len2;
|
int len2;
|
||||||
int len4;
|
int len4;
|
||||||
@@ -37,21 +37,21 @@ typedef struct CeltIMDCTContext {
|
|||||||
/**
|
/**
|
||||||
* Calculate the middle half of the iMDCT
|
* 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);
|
ptrdiff_t src_stride, float scale);
|
||||||
} CeltIMDCTContext;
|
} IMDCT15Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init an iMDCT of the length 2 * 15 * (2^N)
|
* 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.
|
* 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 */
|
@@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
#include "libavutil/float_dsp.h"
|
#include "libavutil/float_dsp.h"
|
||||||
|
|
||||||
|
#include "imdct15.h"
|
||||||
#include "opus.h"
|
#include "opus.h"
|
||||||
#include "opus_imdct.h"
|
|
||||||
|
|
||||||
enum CeltSpread {
|
enum CeltSpread {
|
||||||
CELT_SPREAD_NONE,
|
CELT_SPREAD_NONE,
|
||||||
@@ -61,7 +61,7 @@ typedef struct CeltFrame {
|
|||||||
struct CeltContext {
|
struct CeltContext {
|
||||||
// constant values that do not change during context lifetime
|
// constant values that do not change during context lifetime
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
CeltIMDCTContext *imdct[4];
|
IMDCT15Context *imdct[4];
|
||||||
AVFloatDSPContext dsp;
|
AVFloatDSPContext dsp;
|
||||||
int output_channels;
|
int output_channels;
|
||||||
|
|
||||||
@@ -1983,7 +1983,7 @@ int ff_celt_decode_frame(CeltContext *s, OpusRangeCoder *rc,
|
|||||||
int silence = 0;
|
int silence = 0;
|
||||||
int transient = 0;
|
int transient = 0;
|
||||||
int anticollapse = 0;
|
int anticollapse = 0;
|
||||||
CeltIMDCTContext *imdct;
|
IMDCT15Context *imdct;
|
||||||
float imdct_scale = 1.0;
|
float imdct_scale = 1.0;
|
||||||
|
|
||||||
if (coded_channels != 1 && coded_channels != 2) {
|
if (coded_channels != 1 && coded_channels != 2) {
|
||||||
@@ -2179,7 +2179,7 @@ void ff_celt_free(CeltContext **ps)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(s->imdct); i++)
|
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);
|
av_freep(ps);
|
||||||
}
|
}
|
||||||
@@ -2203,7 +2203,7 @@ int ff_celt_init(AVCodecContext *avctx, CeltContext **ps, int output_channels)
|
|||||||
s->output_channels = output_channels;
|
s->output_channels = output_channels;
|
||||||
|
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(s->imdct); i++) {
|
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)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user