Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n0.8
@@ -960,6 +960,7 @@ CONFIG_LIST=" | |||||
rtpdec | rtpdec | ||||
runtime_cpudetect | runtime_cpudetect | ||||
shared | shared | ||||
sinewin | |||||
small | small | ||||
sram | sram | ||||
static | static | ||||
@@ -1238,8 +1239,8 @@ mdct_select="fft" | |||||
rdft_select="fft" | rdft_select="fft" | ||||
# decoders / encoders / hardware accelerators | # decoders / encoders / hardware accelerators | ||||
aac_decoder_select="mdct rdft" | |||||
aac_encoder_select="mdct" | |||||
aac_decoder_select="mdct rdft sinewin" | |||||
aac_encoder_select="mdct sinewin" | |||||
aac_latm_decoder_select="aac_decoder aac_latm_parser" | aac_latm_decoder_select="aac_decoder aac_latm_parser" | ||||
ac3_decoder_select="mdct ac3_parser" | ac3_decoder_select="mdct ac3_parser" | ||||
ac3_encoder_select="mdct ac3dsp" | ac3_encoder_select="mdct ac3dsp" | ||||
@@ -1247,12 +1248,12 @@ ac3_fixed_encoder_select="ac3dsp" | |||||
alac_encoder_select="lpc" | alac_encoder_select="lpc" | ||||
amrnb_decoder_select="lsp" | amrnb_decoder_select="lsp" | ||||
amrwb_decoder_select="lsp" | amrwb_decoder_select="lsp" | ||||
atrac1_decoder_select="mdct" | |||||
atrac1_decoder_select="mdct sinewin" | |||||
atrac3_decoder_select="mdct" | atrac3_decoder_select="mdct" | ||||
binkaudio_dct_decoder_select="mdct rdft dct" | binkaudio_dct_decoder_select="mdct rdft dct" | ||||
binkaudio_rdft_decoder_select="mdct rdft" | binkaudio_rdft_decoder_select="mdct rdft" | ||||
cavs_decoder_select="golomb" | cavs_decoder_select="golomb" | ||||
cook_decoder_select="mdct" | |||||
cook_decoder_select="mdct sinewin" | |||||
cscd_decoder_suggest="zlib" | cscd_decoder_suggest="zlib" | ||||
dca_decoder_select="mdct" | dca_decoder_select="mdct" | ||||
dnxhd_encoder_select="aandct" | dnxhd_encoder_select="aandct" | ||||
@@ -1315,8 +1316,8 @@ msmpeg4v2_decoder_select="h263_decoder" | |||||
msmpeg4v2_encoder_select="h263_encoder" | msmpeg4v2_encoder_select="h263_encoder" | ||||
msmpeg4v3_decoder_select="h263_decoder" | msmpeg4v3_decoder_select="h263_decoder" | ||||
msmpeg4v3_encoder_select="h263_encoder" | msmpeg4v3_encoder_select="h263_encoder" | ||||
nellymoser_decoder_select="mdct" | |||||
nellymoser_encoder_select="mdct" | |||||
nellymoser_decoder_select="mdct sinewin" | |||||
nellymoser_encoder_select="mdct sinewin" | |||||
png_decoder_select="zlib" | png_decoder_select="zlib" | ||||
png_encoder_select="zlib" | png_encoder_select="zlib" | ||||
qcelp_decoder_select="lsp" | qcelp_decoder_select="lsp" | ||||
@@ -1343,7 +1344,7 @@ tiff_decoder_suggest="zlib" | |||||
tiff_encoder_suggest="zlib" | tiff_encoder_suggest="zlib" | ||||
truehd_decoder_select="mlp_decoder" | truehd_decoder_select="mlp_decoder" | ||||
tscc_decoder_select="zlib" | tscc_decoder_select="zlib" | ||||
twinvq_decoder_select="mdct lsp" | |||||
twinvq_decoder_select="mdct lsp sinewin" | |||||
vc1_decoder_select="h263_decoder" | vc1_decoder_select="h263_decoder" | ||||
vc1_crystalhd_decoder_select="crystalhd" | vc1_crystalhd_decoder_select="crystalhd" | ||||
vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex" | vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex" | ||||
@@ -1356,12 +1357,12 @@ vp6_decoder_select="huffman" | |||||
vp6a_decoder_select="vp6_decoder" | vp6a_decoder_select="vp6_decoder" | ||||
vp6f_decoder_select="vp6_decoder" | vp6f_decoder_select="vp6_decoder" | ||||
vp8_decoder_select="h264pred" | vp8_decoder_select="h264pred" | ||||
wmapro_decoder_select="mdct" | |||||
wmav1_decoder_select="mdct" | |||||
wmav1_encoder_select="mdct" | |||||
wmav2_decoder_select="mdct" | |||||
wmav2_encoder_select="mdct" | |||||
wmavoice_decoder_select="lsp rdft dct mdct" | |||||
wmapro_decoder_select="mdct sinewin" | |||||
wmav1_decoder_select="mdct sinewin" | |||||
wmav1_encoder_select="mdct sinewin" | |||||
wmav2_decoder_select="mdct sinewin" | |||||
wmav2_encoder_select="mdct sinewin" | |||||
wmavoice_decoder_select="lsp rdft dct mdct sinewin" | |||||
wmv1_decoder_select="h263_decoder" | wmv1_decoder_select="h263_decoder" | ||||
wmv1_encoder_select="h263_encoder" | wmv1_encoder_select="h263_encoder" | ||||
wmv2_decoder_select="h263_decoder" | wmv2_decoder_select="h263_decoder" | ||||
@@ -622,11 +622,43 @@ Synchronize read on input. | |||||
@section Advanced options | @section Advanced options | ||||
@table @option | @table @option | ||||
@item -map @var{input_stream_id}[:@var{sync_stream_id}] | |||||
Set stream mapping from input streams to output streams. | |||||
Just enumerate the input streams in the order you want them in the output. | |||||
@var{sync_stream_id} if specified sets the input stream to sync | |||||
against. | |||||
@item -map @var{input_file_id}.@var{input_stream_id}[:@var{sync_file_id}.@var{sync_stream_id}] | |||||
Designate an input stream as a source for the output file. Each input | |||||
stream is identified by the input file index @var{input_file_id} and | |||||
the input stream index @var{input_stream_id} within the input | |||||
file. Both indexes start at 0. If specified, | |||||
@var{sync_file_id}.@var{sync_stream_id} sets which input stream | |||||
is used as a presentation sync reference. | |||||
The @code{-map} options must be specified just after the output file. | |||||
If any @code{-map} options are used, the number of @code{-map} options | |||||
on the command line must match the number of streams in the output | |||||
file. The first @code{-map} option on the command line specifies the | |||||
source for output stream 0, the second @code{-map} option specifies | |||||
the source for output stream 1, etc. | |||||
For example, if you have two audio streams in the first input file, | |||||
these streams are identified by "0.0" and "0.1". You can use | |||||
@code{-map} to select which stream to place in an output file. For | |||||
example: | |||||
@example | |||||
ffmpeg -i INPUT out.wav -map 0.1 | |||||
@end example | |||||
will map the input stream in @file{INPUT} identified by "0.1" to | |||||
the (single) output stream in @file{out.wav}. | |||||
For example, to select the stream with index 2 from input file | |||||
@file{a.mov} (specified by the identifier "0.2"), and stream with | |||||
index 6 from input @file{b.mov} (specified by the identifier "1.6"), | |||||
and copy them to the output file @file{out.mov}: | |||||
@example | |||||
ffmpeg -i a.mov -i b.mov -vcodec copy -acodec copy out.mov -map 0.2 -map 1.6 | |||||
@end example | |||||
To add more streams to the output file, you can use the | |||||
@code{-newaudio}, @code{-newvideo}, @code{-newsubtitle} options. | |||||
@item -map_meta_data @var{outfile}[,@var{metadata}]:@var{infile}[,@var{metadata}] | @item -map_meta_data @var{outfile}[,@var{metadata}]:@var{infile}[,@var{metadata}] | ||||
Deprecated, use @var{-map_metadata} instead. | Deprecated, use @var{-map_metadata} instead. | ||||
@@ -4214,7 +4214,7 @@ static const OptionDef options[] = { | |||||
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" }, | { "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" }, | ||||
{ "i", HAS_ARG, {(void*)opt_input_file}, "input file name", "filename" }, | { "i", HAS_ARG, {(void*)opt_input_file}, "input file name", "filename" }, | ||||
{ "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, | { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, | ||||
{ "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file:stream[:syncfile:syncstream]" }, | |||||
{ "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, | |||||
{ "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile", | { "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile", | ||||
"outfile[,metadata]:infile[,metadata]" }, | "outfile[,metadata]:infile[,metadata]" }, | ||||
{ "map_metadata", HAS_ARG | OPT_EXPERT, {(void*)opt_map_metadata}, "set metadata information of outfile from infile", | { "map_metadata", HAS_ARG | OPT_EXPERT, {(void*)opt_map_metadata}, "set metadata information of outfile from infile", | ||||
@@ -43,6 +43,7 @@ OBJS-$(CONFIG_LSP) += lsp.o | |||||
OBJS-$(CONFIG_MDCT) += mdct.o | OBJS-$(CONFIG_MDCT) += mdct.o | ||||
RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o | RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o | ||||
OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) | OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) | ||||
OBJS-$(CONFIG_SINEWIN) += sinewin.o | |||||
OBJS-$(CONFIG_VAAPI) += vaapi.o | OBJS-$(CONFIG_VAAPI) += vaapi.o | ||||
OBJS-$(CONFIG_VDPAU) += vdpau.o | OBJS-$(CONFIG_VDPAU) += vdpau.o | ||||
@@ -50,14 +51,14 @@ OBJS-$(CONFIG_VDPAU) += vdpau.o | |||||
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o | OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o | ||||
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o | OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o | ||||
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ | OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ | ||||
aacadtsdec.o mpeg4audio.o | |||||
aacadtsdec.o mpeg4audio.o kbdwin.o | |||||
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ | OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ | ||||
aacpsy.o aactab.o \ | aacpsy.o aactab.o \ | ||||
psymodel.o iirfilter.o \ | psymodel.o iirfilter.o \ | ||||
mpeg4audio.o | |||||
mpeg4audio.o kbdwin.o | |||||
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o | OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o | ||||
OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o | OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o | ||||
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o | |||||
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o kbdwin.o | |||||
OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3.o | OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3.o | ||||
OBJS-$(CONFIG_ALAC_DECODER) += alac.o | OBJS-$(CONFIG_ALAC_DECODER) += alac.o | ||||
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o | OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o | ||||
@@ -694,7 +695,7 @@ $(SUBDIR)%_tablegen$(HOSTEXESUF): $(SUBDIR)%_tablegen.c $(SUBDIR)%_tablegen.h $( | |||||
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $(filter %.c,$^) $(HOSTLIBS) | $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $(filter %.c,$^) $(HOSTLIBS) | ||||
GEN_HEADERS = cbrt_tables.h aacps_tables.h aac_tables.h dv_tables.h \ | GEN_HEADERS = cbrt_tables.h aacps_tables.h aac_tables.h dv_tables.h \ | ||||
mdct_tables.h mpegaudio_tables.h motionpixels_tables.h \ | |||||
sinewin_tables.h mpegaudio_tables.h motionpixels_tables.h \ | |||||
pcm_tables.h qdm2_tables.h | pcm_tables.h qdm2_tables.h | ||||
GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS)) | GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS)) | ||||
@@ -706,7 +707,7 @@ $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h | |||||
$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h | $(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h | ||||
$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h | $(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h | ||||
$(SUBDIR)dv.o: $(SUBDIR)dv_tables.h | $(SUBDIR)dv.o: $(SUBDIR)dv_tables.h | ||||
$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h | |||||
$(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h | |||||
$(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h | $(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h | ||||
$(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h | $(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h | ||||
$(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h | $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h | ||||
@@ -87,6 +87,8 @@ | |||||
#include "fft.h" | #include "fft.h" | ||||
#include "fmtconvert.h" | #include "fmtconvert.h" | ||||
#include "lpc.h" | #include "lpc.h" | ||||
#include "kbdwin.h" | |||||
#include "sinewin.h" | |||||
#include "aac.h" | #include "aac.h" | ||||
#include "aactab.h" | #include "aactab.h" | ||||
@@ -1750,7 +1752,7 @@ static void windowing_and_mdct_ltp(AACContext *ac, float *out, | |||||
ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); | ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); | ||||
memset(in + 1024 + 576, 0, 448 * sizeof(float)); | memset(in + 1024 + 576, 0, 448 * sizeof(float)); | ||||
} | } | ||||
ff_mdct_calc(&ac->mdct_ltp, out, in); | |||||
ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); | |||||
} | } | ||||
/** | /** | ||||
@@ -1839,9 +1841,9 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) | |||||
// imdct | // imdct | ||||
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { | if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { | ||||
for (i = 0; i < 1024; i += 128) | for (i = 0; i < 1024; i += 128) | ||||
ff_imdct_half(&ac->mdct_small, buf + i, in + i); | |||||
ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); | |||||
} else | } else | ||||
ff_imdct_half(&ac->mdct, buf, in); | |||||
ac->mdct.imdct_half(&ac->mdct, buf, in); | |||||
/* window overlapping | /* window overlapping | ||||
* NOTE: To simplify the overlapping code, all 'meaningless' short to long | * NOTE: To simplify the overlapping code, all 'meaningless' short to long | ||||
@@ -34,6 +34,8 @@ | |||||
#include "put_bits.h" | #include "put_bits.h" | ||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "mpeg4audio.h" | #include "mpeg4audio.h" | ||||
#include "kbdwin.h" | |||||
#include "sinewin.h" | |||||
#include "aac.h" | #include "aac.h" | ||||
#include "aactab.h" | #include "aactab.h" | ||||
@@ -250,7 +252,7 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, | |||||
for (i = 0; i < 1024; i++) | for (i = 0; i < 1024; i++) | ||||
sce->saved[i] = audio[i * chans]; | sce->saved[i] = audio[i * chans]; | ||||
} | } | ||||
ff_mdct_calc(&s->mdct1024, sce->coeffs, output); | |||||
s->mdct1024.mdct_calc(&s->mdct1024, sce->coeffs, output); | |||||
} else { | } else { | ||||
for (k = 0; k < 1024; k += 128) { | for (k = 0; k < 1024; k += 128) { | ||||
for (i = 448 + k; i < 448 + k + 256; i++) | for (i = 448 + k; i < 448 + k + 256; i++) | ||||
@@ -259,7 +261,7 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, | |||||
: audio[(i-1024)*chans]; | : audio[(i-1024)*chans]; | ||||
s->dsp.vector_fmul (output, output, k ? swindow : pwindow, 128); | s->dsp.vector_fmul (output, output, k ? swindow : pwindow, 128); | ||||
s->dsp.vector_fmul_reverse(output+128, output+128, swindow, 128); | s->dsp.vector_fmul_reverse(output+128, output+128, swindow, 128); | ||||
ff_mdct_calc(&s->mdct128, sce->coeffs + k, output); | |||||
s->mdct128.mdct_calc(&s->mdct128, sce->coeffs + k, output); | |||||
} | } | ||||
for (i = 0; i < 1024; i++) | for (i = 0; i < 1024; i++) | ||||
sce->saved[i] = audio[i * chans]; | sce->saved[i] = audio[i * chans]; | ||||
@@ -1155,7 +1155,7 @@ static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, | |||||
} | } | ||||
z[64+63] = z[32]; | z[64+63] = z[32]; | ||||
ff_imdct_half(mdct, z, z+64); | |||||
mdct->imdct_half(mdct, z, z+64); | |||||
for (k = 0; k < 32; k++) { | for (k = 0; k < 32; k++) { | ||||
W[1][i][k][0] = -z[63-k]; | W[1][i][k][0] = -z[63-k]; | ||||
W[1][i][k][1] = z[k]; | W[1][i][k][1] = z[k]; | ||||
@@ -1190,7 +1190,7 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, | |||||
X[0][i][ n] = -X[0][i][n]; | X[0][i][ n] = -X[0][i][n]; | ||||
X[0][i][32+n] = X[1][i][31-n]; | X[0][i][32+n] = X[1][i][31-n]; | ||||
} | } | ||||
ff_imdct_half(mdct, mdct_buf[0], X[0][i]); | |||||
mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); | |||||
for (n = 0; n < 32; n++) { | for (n = 0; n < 32; n++) { | ||||
v[ n] = mdct_buf[0][63 - 2*n]; | v[ n] = mdct_buf[0][63 - 2*n]; | ||||
v[63 - n] = -mdct_buf[0][62 - 2*n]; | v[63 - n] = -mdct_buf[0][62 - 2*n]; | ||||
@@ -1199,8 +1199,8 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, | |||||
for (n = 1; n < 64; n+=2) { | for (n = 1; n < 64; n+=2) { | ||||
X[1][i][n] = -X[1][i][n]; | X[1][i][n] = -X[1][i][n]; | ||||
} | } | ||||
ff_imdct_half(mdct, mdct_buf[0], X[0][i]); | |||||
ff_imdct_half(mdct, mdct_buf[1], X[1][i]); | |||||
mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); | |||||
mdct->imdct_half(mdct, mdct_buf[1], X[1][i]); | |||||
for (n = 0; n < 64; n++) { | for (n = 0; n < 64; n++) { | ||||
v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; | v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; | ||||
v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; | v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; | ||||
@@ -35,6 +35,7 @@ | |||||
#include "ac3_parser.h" | #include "ac3_parser.h" | ||||
#include "ac3dec.h" | #include "ac3dec.h" | ||||
#include "ac3dec_data.h" | #include "ac3dec_data.h" | ||||
#include "kbdwin.h" | |||||
/** Large enough for maximum possible frame size when the specification limit is ignored */ | /** Large enough for maximum possible frame size when the specification limit is ignored */ | ||||
#define AC3_FRAME_BUFFER_SIZE 32768 | #define AC3_FRAME_BUFFER_SIZE 32768 | ||||
@@ -621,13 +622,13 @@ static inline void do_imdct(AC3DecodeContext *s, int channels) | |||||
float *x = s->tmp_output+128; | float *x = s->tmp_output+128; | ||||
for(i=0; i<128; i++) | for(i=0; i<128; i++) | ||||
x[i] = s->transform_coeffs[ch][2*i]; | x[i] = s->transform_coeffs[ch][2*i]; | ||||
ff_imdct_half(&s->imdct_256, s->tmp_output, x); | |||||
s->imdct_256.imdct_half(&s->imdct_256, s->tmp_output, x); | |||||
s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128); | s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128); | ||||
for(i=0; i<128; i++) | for(i=0; i<128; i++) | ||||
x[i] = s->transform_coeffs[ch][2*i+1]; | x[i] = s->transform_coeffs[ch][2*i+1]; | ||||
ff_imdct_half(&s->imdct_256, s->delay[ch-1], x); | |||||
s->imdct_256.imdct_half(&s->imdct_256, s->delay[ch-1], x); | |||||
} else { | } else { | ||||
ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); | |||||
s->imdct_512.imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]); | |||||
s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128); | s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128); | ||||
memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); | memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float)); | ||||
} | } | ||||
@@ -28,6 +28,7 @@ | |||||
#define CONFIG_AC3ENC_FLOAT 1 | #define CONFIG_AC3ENC_FLOAT 1 | ||||
#include "ac3enc.c" | #include "ac3enc.c" | ||||
#include "kbdwin.h" | |||||
/** | /** | ||||
@@ -74,7 +75,7 @@ static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct, | |||||
*/ | */ | ||||
static void mdct512(AC3MDCTContext *mdct, float *out, float *in) | static void mdct512(AC3MDCTContext *mdct, float *out, float *in) | ||||
{ | { | ||||
ff_mdct_calc(&mdct->fft, out, in); | |||||
mdct->fft.mdct_calc(&mdct->fft, out, in); | |||||
} | } | ||||
@@ -19,6 +19,7 @@ | |||||
*/ | */ | ||||
#include "libavcodec/fft.h" | #include "libavcodec/fft.h" | ||||
#include "libavcodec/rdft.h" | |||||
#include "libavcodec/synth_filter.h" | #include "libavcodec/synth_filter.h" | ||||
void ff_fft_permute_neon(FFTContext *s, FFTComplex *z); | void ff_fft_permute_neon(FFTContext *s, FFTComplex *z); | ||||
@@ -36,6 +36,7 @@ | |||||
#include "get_bits.h" | #include "get_bits.h" | ||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "sinewin.h" | |||||
#include "atrac.h" | #include "atrac.h" | ||||
#include "atrac1data.h" | #include "atrac1data.h" | ||||
@@ -99,7 +100,7 @@ static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits, | |||||
for (i = 0; i < transf_size / 2; i++) | for (i = 0; i < transf_size / 2; i++) | ||||
FFSWAP(float, spec[i], spec[transf_size - 1 - i]); | FFSWAP(float, spec[i], spec[transf_size - 1 - i]); | ||||
} | } | ||||
ff_imdct_half(mdct_context, out, spec); | |||||
mdct_context->imdct_half(mdct_context, out, spec); | |||||
} | } | ||||
@@ -146,7 +146,7 @@ static void IMLT(ATRAC3Context *q, float *pInput, float *pOutput, int odd_band) | |||||
/** | /** | ||||
* Reverse the odd bands before IMDCT, this is an effect of the QMF transform | * Reverse the odd bands before IMDCT, this is an effect of the QMF transform | ||||
* or it gives better compression to do it this way. | * or it gives better compression to do it this way. | ||||
* FIXME: It should be possible to handle this in ff_imdct_calc | |||||
* FIXME: It should be possible to handle this in imdct_calc | |||||
* for that to happen a modification of the prerotation step of | * for that to happen a modification of the prerotation step of | ||||
* all SIMD code and C code is needed. | * all SIMD code and C code is needed. | ||||
* Or fix the functions before so they generate a pre reversed spectrum. | * Or fix the functions before so they generate a pre reversed spectrum. | ||||
@@ -156,7 +156,7 @@ static void IMLT(ATRAC3Context *q, float *pInput, float *pOutput, int odd_band) | |||||
FFSWAP(float, pInput[i], pInput[255-i]); | FFSWAP(float, pInput[i], pInput[255-i]); | ||||
} | } | ||||
ff_imdct_calc(&q->mdct_ctx,pOutput,pInput); | |||||
q->mdct_ctx.imdct_calc(&q->mdct_ctx,pOutput,pInput); | |||||
/* Perform windowing on the output. */ | /* Perform windowing on the output. */ | ||||
dsp.vector_fmul(pOutput, pOutput, mdct_window, 512); | dsp.vector_fmul(pOutput, pOutput, mdct_window, 512); | ||||
@@ -19,6 +19,8 @@ | |||||
#include "libavutil/mem.h" | #include "libavutil/mem.h" | ||||
#include "avfft.h" | #include "avfft.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "rdft.h" | |||||
#include "dct.h" | |||||
/* FFT */ | /* FFT */ | ||||
@@ -101,7 +103,7 @@ RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) | |||||
void av_rdft_calc(RDFTContext *s, FFTSample *data) | void av_rdft_calc(RDFTContext *s, FFTSample *data) | ||||
{ | { | ||||
ff_rdft_calc(s, data); | |||||
s->rdft_calc(s, data); | |||||
} | } | ||||
void av_rdft_end(RDFTContext *s) | void av_rdft_end(RDFTContext *s) | ||||
@@ -128,7 +130,7 @@ DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse) | |||||
void av_dct_calc(DCTContext *s, FFTSample *data) | void av_dct_calc(DCTContext *s, FFTSample *data) | ||||
{ | { | ||||
ff_dct_calc(s, data); | |||||
s->dct_calc(s, data); | |||||
} | } | ||||
void av_dct_end(DCTContext *s) | void av_dct_end(DCTContext *s) | ||||
@@ -32,7 +32,8 @@ | |||||
#define ALT_BITSTREAM_READER_LE | #define ALT_BITSTREAM_READER_LE | ||||
#include "get_bits.h" | #include "get_bits.h" | ||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | |||||
#include "dct.h" | |||||
#include "rdft.h" | |||||
#include "fmtconvert.h" | #include "fmtconvert.h" | ||||
#include "libavutil/intfloat_readwrite.h" | #include "libavutil/intfloat_readwrite.h" | ||||
@@ -223,11 +224,11 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct) | |||||
if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) { | if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) { | ||||
coeffs[0] /= 0.5; | coeffs[0] /= 0.5; | ||||
ff_dct_calc (&s->trans.dct, coeffs); | |||||
s->trans.dct.dct_calc(&s->trans.dct, coeffs); | |||||
s->dsp.vector_fmul_scalar(coeffs, coeffs, s->frame_len / 2, s->frame_len); | s->dsp.vector_fmul_scalar(coeffs, coeffs, s->frame_len / 2, s->frame_len); | ||||
} | } | ||||
else if (CONFIG_BINKAUDIO_RDFT_DECODER) | else if (CONFIG_BINKAUDIO_RDFT_DECODER) | ||||
ff_rdft_calc(&s->trans.rdft, coeffs); | |||||
s->trans.rdft.rdft_calc(&s->trans.rdft, coeffs); | |||||
} | } | ||||
s->fmt_conv.float_to_int16_interleave(out, (const float **)s->coeffs_ptr, | s->fmt_conv.float_to_int16_interleave(out, (const float **)s->coeffs_ptr, | ||||
@@ -54,6 +54,7 @@ | |||||
#include "bytestream.h" | #include "bytestream.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "libavutil/audioconvert.h" | #include "libavutil/audioconvert.h" | ||||
#include "sinewin.h" | |||||
#include "cookdata.h" | #include "cookdata.h" | ||||
@@ -753,7 +754,7 @@ static void imlt_gain(COOKContext *q, float *inbuffer, | |||||
int i; | int i; | ||||
/* Inverse modified discrete cosine transform */ | /* Inverse modified discrete cosine transform */ | ||||
ff_imdct_calc(&q->mdct_ctx, q->mono_mdct_output, inbuffer); | |||||
q->mdct_ctx.imdct_calc(&q->mdct_ctx, q->mono_mdct_output, inbuffer); | |||||
q->imlt_window (q, buffer1, gains_ptr, previous_buffer); | q->imlt_window (q, buffer1, gains_ptr, previous_buffer); | ||||
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) | |||||
double (*func)(double) = do_sin ? sin : cos; | double (*func)(double) = do_sin ? sin : cos; | ||||
printf("/* This file was generated by libavcodec/costablegen */\n"); | printf("/* This file was generated by libavcodec/costablegen */\n"); | ||||
printf("#include \"libavcodec/fft.h\"\n"); | |||||
printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h"); | |||||
for (i = 4; i <= BITS; i++) { | for (i = 4; i <= BITS; i++) { | ||||
int m = 1 << i; | int m = 1 << i; | ||||
double freq = 2*M_PI/m; | double freq = 2*M_PI/m; | ||||
@@ -29,8 +29,7 @@ | |||||
#include <math.h> | #include <math.h> | ||||
#include "libavutil/mathematics.h" | #include "libavutil/mathematics.h" | ||||
#include "fft.h" | |||||
#include "x86/fft.h" | |||||
#include "dct.h" | |||||
#define DCT32_FLOAT | #define DCT32_FLOAT | ||||
#include "dct32.c" | #include "dct32.c" | ||||
@@ -59,7 +58,7 @@ static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data) | |||||
} | } | ||||
data[n/2] *= 2; | data[n/2] *= 2; | ||||
ff_rdft_calc(&ctx->rdft, data); | |||||
ctx->rdft.rdft_calc(&ctx->rdft, data); | |||||
data[0] *= 0.5f; | data[0] *= 0.5f; | ||||
@@ -93,7 +92,7 @@ static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) | |||||
data[n - i] = tmp1 + s; | data[n - i] = tmp1 + s; | ||||
} | } | ||||
ff_rdft_calc(&ctx->rdft, data); | |||||
ctx->rdft.rdft_calc(&ctx->rdft, data); | |||||
data[n] = data[1]; | data[n] = data[1]; | ||||
data[1] = next; | data[1] = next; | ||||
@@ -121,7 +120,7 @@ static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) | |||||
data[1] = 2 * next; | data[1] = 2 * next; | ||||
ff_rdft_calc(&ctx->rdft, data); | |||||
ctx->rdft.rdft_calc(&ctx->rdft, data); | |||||
for (i = 0; i < n / 2; i++) { | for (i = 0; i < n / 2; i++) { | ||||
float tmp1 = data[i ] * inv_n; | float tmp1 = data[i ] * inv_n; | ||||
@@ -152,7 +151,7 @@ static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) | |||||
data[n-i-1] = tmp1 - s; | data[n-i-1] = tmp1 - s; | ||||
} | } | ||||
ff_rdft_calc(&ctx->rdft, data); | |||||
ctx->rdft.rdft_calc(&ctx->rdft, data); | |||||
next = data[1] * 0.5; | next = data[1] * 0.5; | ||||
data[1] *= -1; | data[1] *= -1; | ||||
@@ -176,11 +175,6 @@ static void dct32_func(DCTContext *ctx, FFTSample *data) | |||||
ctx->dct32(data, data); | ctx->dct32(data, data); | ||||
} | } | ||||
void ff_dct_calc(DCTContext *s, FFTSample *data) | |||||
{ | |||||
s->dct_calc(s, data); | |||||
} | |||||
av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) | av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) | ||||
{ | { | ||||
int n = 1 << nbits; | int n = 1 << nbits; | ||||
@@ -0,0 +1,50 @@ | |||||
/* | |||||
* (I)DCT Transforms | |||||
* Copyright (c) 2009 Peter Ross <pross@xvid.org> | |||||
* Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> | |||||
* Copyright (c) 2010 Vitor Sessak | |||||
* | |||||
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA | |||||
*/ | |||||
#ifndef AVCODEC_DCT_H | |||||
#define AVCODEC_DCT_H | |||||
#include "rdft.h" | |||||
struct DCTContext { | |||||
int nbits; | |||||
int inverse; | |||||
RDFTContext rdft; | |||||
const float *costab; | |||||
FFTSample *csc2; | |||||
void (*dct_calc)(struct DCTContext *s, FFTSample *data); | |||||
void (*dct32)(FFTSample *out, const FFTSample *in); | |||||
}; | |||||
/** | |||||
* Set up DCT. | |||||
* @param nbits size of the input array: | |||||
* (1 << nbits) for DCT-II, DCT-III and DST-I | |||||
* (1 << nbits) + 1 for DCT-I | |||||
* | |||||
* @note the first element of the input of DST-I is ignored | |||||
*/ | |||||
int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type); | |||||
void ff_dct_end (DCTContext *s); | |||||
#endif |
@@ -27,6 +27,8 @@ | |||||
#include "libavutil/lfg.h" | #include "libavutil/lfg.h" | ||||
#include "libavutil/log.h" | #include "libavutil/log.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "dct.h" | |||||
#include "rdft.h" | |||||
#include <math.h> | #include <math.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
@@ -327,20 +329,20 @@ int main(int argc, char **argv) | |||||
case TRANSFORM_MDCT: | case TRANSFORM_MDCT: | ||||
if (do_inverse) { | if (do_inverse) { | ||||
imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); | imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); | ||||
ff_imdct_calc(m, tab2, (float *)tab1); | |||||
m->imdct_calc(m, tab2, (float *)tab1); | |||||
err = check_diff((float *)tab_ref, tab2, fft_size, scale); | err = check_diff((float *)tab_ref, tab2, fft_size, scale); | ||||
} else { | } else { | ||||
mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); | mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits); | ||||
ff_mdct_calc(m, tab2, (float *)tab1); | |||||
m->mdct_calc(m, tab2, (float *)tab1); | |||||
err = check_diff((float *)tab_ref, tab2, fft_size / 2, scale); | err = check_diff((float *)tab_ref, tab2, fft_size / 2, scale); | ||||
} | } | ||||
break; | break; | ||||
case TRANSFORM_FFT: | case TRANSFORM_FFT: | ||||
memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); | memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); | ||||
ff_fft_permute(s, tab); | |||||
ff_fft_calc(s, tab); | |||||
s->fft_permute(s, tab); | |||||
s->fft_calc(s, tab); | |||||
fft_ref(tab_ref, tab1, fft_nbits); | fft_ref(tab_ref, tab1, fft_nbits); | ||||
err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0); | err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0); | ||||
@@ -357,7 +359,7 @@ int main(int argc, char **argv) | |||||
memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | ||||
tab2[1] = tab1[fft_size_2].re; | tab2[1] = tab1[fft_size_2].re; | ||||
ff_rdft_calc(r, tab2); | |||||
r->rdft_calc(r, tab2); | |||||
fft_ref(tab_ref, tab1, fft_nbits); | fft_ref(tab_ref, tab1, fft_nbits); | ||||
for (i = 0; i < fft_size; i++) { | for (i = 0; i < fft_size; i++) { | ||||
tab[i].re = tab2[i]; | tab[i].re = tab2[i]; | ||||
@@ -369,7 +371,7 @@ int main(int argc, char **argv) | |||||
tab2[i] = tab1[i].re; | tab2[i] = tab1[i].re; | ||||
tab1[i].im = 0; | tab1[i].im = 0; | ||||
} | } | ||||
ff_rdft_calc(r, tab2); | |||||
r->rdft_calc(r, tab2); | |||||
fft_ref(tab_ref, tab1, fft_nbits); | fft_ref(tab_ref, tab1, fft_nbits); | ||||
tab_ref[0].im = tab_ref[fft_size_2].re; | tab_ref[0].im = tab_ref[fft_size_2].re; | ||||
err = check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0); | err = check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0); | ||||
@@ -377,7 +379,7 @@ int main(int argc, char **argv) | |||||
break; | break; | ||||
case TRANSFORM_DCT: | case TRANSFORM_DCT: | ||||
memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); | memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); | ||||
ff_dct_calc(d, tab); | |||||
d->dct_calc(d, tab); | |||||
if (do_inverse) { | if (do_inverse) { | ||||
idct_ref(tab_ref, tab1, fft_nbits); | idct_ref(tab_ref, tab1, fft_nbits); | ||||
} else { | } else { | ||||
@@ -402,22 +404,22 @@ int main(int argc, char **argv) | |||||
switch (transform) { | switch (transform) { | ||||
case TRANSFORM_MDCT: | case TRANSFORM_MDCT: | ||||
if (do_inverse) { | if (do_inverse) { | ||||
ff_imdct_calc(m, (float *)tab, (float *)tab1); | |||||
m->imdct_calc(m, (float *)tab, (float *)tab1); | |||||
} else { | } else { | ||||
ff_mdct_calc(m, (float *)tab, (float *)tab1); | |||||
m->mdct_calc(m, (float *)tab, (float *)tab1); | |||||
} | } | ||||
break; | break; | ||||
case TRANSFORM_FFT: | case TRANSFORM_FFT: | ||||
memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); | memcpy(tab, tab1, fft_size * sizeof(FFTComplex)); | ||||
ff_fft_calc(s, tab); | |||||
s->fft_calc(s, tab); | |||||
break; | break; | ||||
case TRANSFORM_RDFT: | case TRANSFORM_RDFT: | ||||
memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | ||||
ff_rdft_calc(r, tab2); | |||||
r->rdft_calc(r, tab2); | |||||
break; | break; | ||||
case TRANSFORM_DCT: | case TRANSFORM_DCT: | ||||
memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | memcpy(tab2, tab1, fft_size * sizeof(FFTSample)); | ||||
ff_dct_calc(d, tab2); | |||||
d->dct_calc(d, tab2); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -39,7 +39,14 @@ struct FFTContext { | |||||
/* pre/post rotation tables */ | /* pre/post rotation tables */ | ||||
FFTSample *tcos; | FFTSample *tcos; | ||||
FFTSample *tsin; | FFTSample *tsin; | ||||
/** | |||||
* Do the permutation needed BEFORE calling fft_calc(). | |||||
*/ | |||||
void (*fft_permute)(struct FFTContext *s, FFTComplex *z); | void (*fft_permute)(struct FFTContext *s, FFTComplex *z); | ||||
/** | |||||
* Do a complex FFT with the parameters defined in ff_fft_init(). The | |||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done. | |||||
*/ | |||||
void (*fft_calc)(struct FFTContext *s, FFTComplex *z); | void (*fft_calc)(struct FFTContext *s, FFTComplex *z); | ||||
void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | ||||
void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | ||||
@@ -54,20 +61,13 @@ struct FFTContext { | |||||
#if CONFIG_HARDCODED_TABLES | #if CONFIG_HARDCODED_TABLES | ||||
#define COSTABLE_CONST const | #define COSTABLE_CONST const | ||||
#define SINTABLE_CONST const | |||||
#define SINETABLE_CONST const | |||||
#else | #else | ||||
#define COSTABLE_CONST | #define COSTABLE_CONST | ||||
#define SINTABLE_CONST | |||||
#define SINETABLE_CONST | |||||
#endif | #endif | ||||
#define COSTABLE(size) \ | #define COSTABLE(size) \ | ||||
COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2] | COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2] | ||||
#define SINTABLE(size) \ | |||||
SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2] | |||||
#define SINETABLE(size) \ | |||||
SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size] | |||||
extern COSTABLE(16); | extern COSTABLE(16); | ||||
extern COSTABLE(32); | extern COSTABLE(32); | ||||
extern COSTABLE(64); | extern COSTABLE(64); | ||||
@@ -89,20 +89,6 @@ extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; | |||||
*/ | */ | ||||
void ff_init_ff_cos_tabs(int index); | void ff_init_ff_cos_tabs(int index); | ||||
extern SINTABLE(16); | |||||
extern SINTABLE(32); | |||||
extern SINTABLE(64); | |||||
extern SINTABLE(128); | |||||
extern SINTABLE(256); | |||||
extern SINTABLE(512); | |||||
extern SINTABLE(1024); | |||||
extern SINTABLE(2048); | |||||
extern SINTABLE(4096); | |||||
extern SINTABLE(8192); | |||||
extern SINTABLE(16384); | |||||
extern SINTABLE(32768); | |||||
extern SINTABLE(65536); | |||||
/** | /** | ||||
* Set up a complex FFT. | * Set up a complex FFT. | ||||
* @param nbits log2 of the length of the input array | * @param nbits log2 of the length of the input array | ||||
@@ -115,131 +101,12 @@ void ff_fft_init_mmx(FFTContext *s); | |||||
void ff_fft_init_arm(FFTContext *s); | void ff_fft_init_arm(FFTContext *s); | ||||
void ff_dct_init_mmx(DCTContext *s); | void ff_dct_init_mmx(DCTContext *s); | ||||
/** | |||||
* Do the permutation needed BEFORE calling ff_fft_calc(). | |||||
*/ | |||||
static inline void ff_fft_permute(FFTContext *s, FFTComplex *z) | |||||
{ | |||||
s->fft_permute(s, z); | |||||
} | |||||
/** | |||||
* Do a complex FFT with the parameters defined in ff_fft_init(). The | |||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done. | |||||
*/ | |||||
static inline void ff_fft_calc(FFTContext *s, FFTComplex *z) | |||||
{ | |||||
s->fft_calc(s, z); | |||||
} | |||||
void ff_fft_end(FFTContext *s); | void ff_fft_end(FFTContext *s); | ||||
/* MDCT computation */ | |||||
static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) | |||||
{ | |||||
s->imdct_calc(s, output, input); | |||||
} | |||||
static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) | |||||
{ | |||||
s->imdct_half(s, output, input); | |||||
} | |||||
static inline void ff_mdct_calc(FFTContext *s, FFTSample *output, | |||||
const FFTSample *input) | |||||
{ | |||||
s->mdct_calc(s, output, input); | |||||
} | |||||
/** | |||||
* Maximum window size for ff_kbd_window_init. | |||||
*/ | |||||
#define FF_KBD_WINDOW_MAX 1024 | |||||
/** | |||||
* Generate a Kaiser-Bessel Derived Window. | |||||
* @param window pointer to half window | |||||
* @param alpha determines window shape | |||||
* @param n size of half window, max FF_KBD_WINDOW_MAX | |||||
*/ | |||||
void ff_kbd_window_init(float *window, float alpha, int n); | |||||
/** | |||||
* Generate a sine window. | |||||
* @param window pointer to half window | |||||
* @param n size of half window | |||||
*/ | |||||
void ff_sine_window_init(float *window, int n); | |||||
/** | |||||
* initialize the specified entry of ff_sine_windows | |||||
*/ | |||||
void ff_init_ff_sine_windows(int index); | |||||
extern SINETABLE( 32); | |||||
extern SINETABLE( 64); | |||||
extern SINETABLE( 128); | |||||
extern SINETABLE( 256); | |||||
extern SINETABLE( 512); | |||||
extern SINETABLE(1024); | |||||
extern SINETABLE(2048); | |||||
extern SINETABLE(4096); | |||||
extern SINETABLE_CONST float * const ff_sine_windows[13]; | |||||
int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); | int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); | ||||
void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); | void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); | ||||
void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); | void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); | ||||
void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); | void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); | ||||
void ff_mdct_end(FFTContext *s); | void ff_mdct_end(FFTContext *s); | ||||
/* Real Discrete Fourier Transform */ | |||||
struct RDFTContext { | |||||
int nbits; | |||||
int inverse; | |||||
int sign_convention; | |||||
/* pre/post rotation tables */ | |||||
const FFTSample *tcos; | |||||
SINTABLE_CONST FFTSample *tsin; | |||||
FFTContext fft; | |||||
void (*rdft_calc)(struct RDFTContext *s, FFTSample *z); | |||||
}; | |||||
/** | |||||
* Set up a real FFT. | |||||
* @param nbits log2 of the length of the input array | |||||
* @param trans the type of transform | |||||
*/ | |||||
int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans); | |||||
void ff_rdft_end(RDFTContext *s); | |||||
void ff_rdft_init_arm(RDFTContext *s); | |||||
static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data) | |||||
{ | |||||
s->rdft_calc(s, data); | |||||
} | |||||
/* Discrete Cosine Transform */ | |||||
struct DCTContext { | |||||
int nbits; | |||||
int inverse; | |||||
RDFTContext rdft; | |||||
const float *costab; | |||||
FFTSample *csc2; | |||||
void (*dct_calc)(struct DCTContext *s, FFTSample *data); | |||||
void (*dct32)(FFTSample *out, const FFTSample *in); | |||||
}; | |||||
/** | |||||
* Set up DCT. | |||||
* @param nbits size of the input array: | |||||
* (1 << nbits) for DCT-II, DCT-III and DST-I | |||||
* (1 << nbits) + 1 for DCT-I | |||||
* | |||||
* @note the first element of the input of DST-I is ignored | |||||
*/ | |||||
int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type); | |||||
void ff_dct_calc(DCTContext *s, FFTSample *data); | |||||
void ff_dct_end (DCTContext *s); | |||||
#endif /* AVCODEC_FFT_H */ | #endif /* AVCODEC_FFT_H */ |
@@ -41,6 +41,7 @@ | |||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "libavutil/audioconvert.h" | #include "libavutil/audioconvert.h" | ||||
#include "sinewin.h" | |||||
#include "imcdata.h" | #include "imcdata.h" | ||||
@@ -564,8 +565,8 @@ static void imc_imdct256(IMCContext *q) { | |||||
} | } | ||||
/* FFT */ | /* FFT */ | ||||
ff_fft_permute(&q->fft, q->samples); | |||||
ff_fft_calc (&q->fft, q->samples); | |||||
q->fft.fft_permute(&q->fft, q->samples); | |||||
q->fft.fft_calc (&q->fft, q->samples); | |||||
/* postrotation, window and reorder */ | /* postrotation, window and reorder */ | ||||
for(i = 0; i < COEFFS/2; i++){ | for(i = 0; i < COEFFS/2; i++){ | ||||
@@ -0,0 +1,48 @@ | |||||
/* | |||||
* 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 <assert.h> | |||||
#include <libavutil/mathematics.h> | |||||
#include "libavutil/attributes.h" | |||||
#include "kbdwin.h" | |||||
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation | |||||
av_cold void ff_kbd_window_init(float *window, float alpha, int n) | |||||
{ | |||||
int i, j; | |||||
double sum = 0.0, bessel, tmp; | |||||
double local_window[FF_KBD_WINDOW_MAX]; | |||||
double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); | |||||
assert(n <= FF_KBD_WINDOW_MAX); | |||||
for (i = 0; i < n; i++) { | |||||
tmp = i * (n - i) * alpha2; | |||||
bessel = 1.0; | |||||
for (j = BESSEL_I0_ITER; j > 0; j--) | |||||
bessel = bessel * tmp / (j * j) + 1; | |||||
sum += bessel; | |||||
local_window[i] = sum; | |||||
} | |||||
sum++; | |||||
for (i = 0; i < n; i++) | |||||
window[i] = sqrt(local_window[i] / sum); | |||||
} | |||||
@@ -0,0 +1,35 @@ | |||||
/* | |||||
* 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 | |||||
*/ | |||||
#ifndef AVCODEC_KBDWIN_H | |||||
#define AVCODEC_KBDWIN_H | |||||
/** | |||||
* Maximum window size for ff_kbd_window_init. | |||||
*/ | |||||
#define FF_KBD_WINDOW_MAX 1024 | |||||
/** | |||||
* Generate a Kaiser-Bessel Derived Window. | |||||
* @param window pointer to half window | |||||
* @param alpha determines window shape | |||||
* @param n size of half window, max FF_KBD_WINDOW_MAX | |||||
*/ | |||||
void ff_kbd_window_init(float *window, float alpha, int n); | |||||
#endif |
@@ -30,33 +30,6 @@ | |||||
* MDCT/IMDCT transforms. | * MDCT/IMDCT transforms. | ||||
*/ | */ | ||||
// Generate a Kaiser-Bessel Derived Window. | |||||
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation | |||||
av_cold void ff_kbd_window_init(float *window, float alpha, int n) | |||||
{ | |||||
int i, j; | |||||
double sum = 0.0, bessel, tmp; | |||||
double local_window[FF_KBD_WINDOW_MAX]; | |||||
double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); | |||||
assert(n <= FF_KBD_WINDOW_MAX); | |||||
for (i = 0; i < n; i++) { | |||||
tmp = i * (n - i) * alpha2; | |||||
bessel = 1.0; | |||||
for (j = BESSEL_I0_ITER; j > 0; j--) | |||||
bessel = bessel * tmp / (j * j) + 1; | |||||
sum += bessel; | |||||
local_window[i] = sum; | |||||
} | |||||
sum++; | |||||
for (i = 0; i < n; i++) | |||||
window[i] = sqrt(local_window[i] / sum); | |||||
} | |||||
#include "mdct_tablegen.h" | |||||
/** | /** | ||||
* init MDCT or IMDCT computation. | * init MDCT or IMDCT computation. | ||||
*/ | */ | ||||
@@ -146,7 +119,7 @@ void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input) | |||||
in1 += 2; | in1 += 2; | ||||
in2 -= 2; | in2 -= 2; | ||||
} | } | ||||
ff_fft_calc(s, z); | |||||
s->fft_calc(s, z); | |||||
/* post rotation + reordering */ | /* post rotation + reordering */ | ||||
for(k = 0; k < n8; k++) { | for(k = 0; k < n8; k++) { | ||||
@@ -213,7 +186,7 @@ void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) | |||||
CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]); | CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]); | ||||
} | } | ||||
ff_fft_calc(s, x); | |||||
s->fft_calc(s, x); | |||||
/* post rotation */ | /* post rotation */ | ||||
for(i=0;i<n8;i++) { | for(i=0;i<n8;i++) { | ||||
@@ -33,7 +33,7 @@ | |||||
#include "avcodec.h" | #include "avcodec.h" | ||||
#include "get_bits.h" | #include "get_bits.h" | ||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | |||||
#include "dct.h" | |||||
#define CONFIG_AUDIO_NONSHORT 0 | #define CONFIG_AUDIO_NONSHORT 0 | ||||
@@ -39,6 +39,7 @@ | |||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "fmtconvert.h" | #include "fmtconvert.h" | ||||
#include "sinewin.h" | |||||
#define ALT_BITSTREAM_READER_LE | #define ALT_BITSTREAM_READER_LE | ||||
#include "get_bits.h" | #include "get_bits.h" | ||||
@@ -121,7 +122,7 @@ static void nelly_decode_block(NellyMoserDecodeContext *s, | |||||
memset(&aptr[NELLY_FILL_LEN], 0, | memset(&aptr[NELLY_FILL_LEN], 0, | ||||
(NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float)); | (NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float)); | ||||
ff_imdct_calc(&s->imdct_ctx, s->imdct_out, aptr); | |||||
s->imdct_ctx.imdct_calc(&s->imdct_ctx, s->imdct_out, aptr); | |||||
/* XXX: overlapping and windowing should be part of a more | /* XXX: overlapping and windowing should be part of a more | ||||
generic imdct function */ | generic imdct function */ | ||||
overlap_and_window(s, s->state, aptr, s->imdct_out); | overlap_and_window(s, s->state, aptr, s->imdct_out); | ||||
@@ -39,6 +39,7 @@ | |||||
#include "avcodec.h" | #include "avcodec.h" | ||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "sinewin.h" | |||||
#define BITSTREAM_WRITER_LE | #define BITSTREAM_WRITER_LE | ||||
#include "put_bits.h" | #include "put_bits.h" | ||||
@@ -116,13 +117,13 @@ static void apply_mdct(NellyMoserEncodeContext *s) | |||||
s->dsp.vector_fmul(s->in_buff, s->buf[s->bufsel], ff_sine_128, NELLY_BUF_LEN); | s->dsp.vector_fmul(s->in_buff, s->buf[s->bufsel], ff_sine_128, NELLY_BUF_LEN); | ||||
s->dsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN, ff_sine_128, | s->dsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN, ff_sine_128, | ||||
NELLY_BUF_LEN); | NELLY_BUF_LEN); | ||||
ff_mdct_calc(&s->mdct_ctx, s->mdct_out, s->in_buff); | |||||
s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out, s->in_buff); | |||||
s->dsp.vector_fmul(s->buf[s->bufsel] + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN, | s->dsp.vector_fmul(s->buf[s->bufsel] + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN, | ||||
ff_sine_128, NELLY_BUF_LEN); | ff_sine_128, NELLY_BUF_LEN); | ||||
s->dsp.vector_fmul_reverse(s->buf[s->bufsel] + 2 * NELLY_BUF_LEN, s->buf[1 - s->bufsel], ff_sine_128, | s->dsp.vector_fmul_reverse(s->buf[s->bufsel] + 2 * NELLY_BUF_LEN, s->buf[1 - s->bufsel], ff_sine_128, | ||||
NELLY_BUF_LEN); | NELLY_BUF_LEN); | ||||
ff_mdct_calc(&s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN); | |||||
s->mdct_ctx.mdct_calc(&s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN); | |||||
} | } | ||||
static av_cold int encode_init(AVCodecContext *avctx) | static av_cold int encode_init(AVCodecContext *avctx) | ||||
@@ -1588,7 +1588,7 @@ static void qdm2_calculate_fft (QDM2Context *q, int channel, int sub_packet) | |||||
int i; | int i; | ||||
q->fft.complex[channel][0].re *= 2.0f; | q->fft.complex[channel][0].re *= 2.0f; | ||||
q->fft.complex[channel][0].im = 0.0f; | q->fft.complex[channel][0].im = 0.0f; | ||||
ff_rdft_calc(&q->rdft_ctx, (FFTSample *)q->fft.complex[channel]); | |||||
q->rdft_ctx.rdft_calc(&q->rdft_ctx, (FFTSample *)q->fft.complex[channel]); | |||||
/* add samples to output buffer */ | /* add samples to output buffer */ | ||||
for (i = 0; i < ((q->fft_frame_size + 15) & ~15); i++) | for (i = 0; i < ((q->fft_frame_size + 15) & ~15); i++) | ||||
q->output_buffer[q->channels * i + channel] += ((float *) q->fft.complex[channel])[i] * gain; | q->output_buffer[q->channels * i + channel] += ((float *) q->fft.complex[channel])[i] * gain; | ||||
@@ -21,7 +21,7 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <math.h> | #include <math.h> | ||||
#include "libavutil/mathematics.h" | #include "libavutil/mathematics.h" | ||||
#include "fft.h" | |||||
#include "rdft.h" | |||||
/** | /** | ||||
* @file | * @file | ||||
@@ -65,8 +65,8 @@ static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data) | |||||
const FFTSample *tsin = s->tsin; | const FFTSample *tsin = s->tsin; | ||||
if (!s->inverse) { | if (!s->inverse) { | ||||
ff_fft_permute(&s->fft, (FFTComplex*)data); | |||||
ff_fft_calc(&s->fft, (FFTComplex*)data); | |||||
s->fft.fft_permute(&s->fft, (FFTComplex*)data); | |||||
s->fft.fft_calc(&s->fft, (FFTComplex*)data); | |||||
} | } | ||||
/* i=0 is a special case because of packing, the DC term is real, so we | /* i=0 is a special case because of packing, the DC term is real, so we | ||||
are going to throw the N/2 term (also real) in with it. */ | are going to throw the N/2 term (also real) in with it. */ | ||||
@@ -91,8 +91,8 @@ static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data) | |||||
if (s->inverse) { | if (s->inverse) { | ||||
data[0] *= k1; | data[0] *= k1; | ||||
data[1] *= k1; | data[1] *= k1; | ||||
ff_fft_permute(&s->fft, (FFTComplex*)data); | |||||
ff_fft_calc(&s->fft, (FFTComplex*)data); | |||||
s->fft.fft_permute(&s->fft, (FFTComplex*)data); | |||||
s->fft.fft_calc(&s->fft, (FFTComplex*)data); | |||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,74 @@ | |||||
/* | |||||
* (I)RDFT transforms | |||||
* Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com> | |||||
* | |||||
* 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 | |||||
*/ | |||||
#ifndef AVCODEC_RDFT_H | |||||
#define AVCODEC_RDFT_H | |||||
#include "config.h" | |||||
#include "fft.h" | |||||
#if CONFIG_HARDCODED_TABLES | |||||
# define SINTABLE_CONST const | |||||
#else | |||||
# define SINTABLE_CONST | |||||
#endif | |||||
#define SINTABLE(size) \ | |||||
SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2] | |||||
extern SINTABLE(16); | |||||
extern SINTABLE(32); | |||||
extern SINTABLE(64); | |||||
extern SINTABLE(128); | |||||
extern SINTABLE(256); | |||||
extern SINTABLE(512); | |||||
extern SINTABLE(1024); | |||||
extern SINTABLE(2048); | |||||
extern SINTABLE(4096); | |||||
extern SINTABLE(8192); | |||||
extern SINTABLE(16384); | |||||
extern SINTABLE(32768); | |||||
extern SINTABLE(65536); | |||||
struct RDFTContext { | |||||
int nbits; | |||||
int inverse; | |||||
int sign_convention; | |||||
/* pre/post rotation tables */ | |||||
const FFTSample *tcos; | |||||
SINTABLE_CONST FFTSample *tsin; | |||||
FFTContext fft; | |||||
void (*rdft_calc)(struct RDFTContext *s, FFTSample *z); | |||||
}; | |||||
/** | |||||
* Set up a real FFT. | |||||
* @param nbits log2 of the length of the input array | |||||
* @param trans the type of transform | |||||
*/ | |||||
int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans); | |||||
void ff_rdft_end(RDFTContext *s); | |||||
void ff_rdft_init_arm(RDFTContext *s); | |||||
#endif |
@@ -0,0 +1,20 @@ | |||||
/* | |||||
* 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 "sinewin.h" | |||||
#include "sinewin_tablegen.h" |
@@ -0,0 +1,59 @@ | |||||
/* | |||||
* Copyright (c) 2008 Robert Swain | |||||
* | |||||
* 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 | |||||
*/ | |||||
#ifndef AVCODEC_SINEWIN_H | |||||
#define AVCODEC_SINEWIN_H | |||||
#include "config.h" | |||||
#include "libavutil/mem.h" | |||||
#if CONFIG_HARDCODED_TABLES | |||||
# define SINETABLE_CONST const | |||||
#else | |||||
# define SINETABLE_CONST | |||||
#endif | |||||
#define SINETABLE(size) \ | |||||
SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size] | |||||
/** | |||||
* Generate a sine window. | |||||
* @param window pointer to half window | |||||
* @param n size of half window | |||||
*/ | |||||
void ff_sine_window_init(float *window, int n); | |||||
/** | |||||
* initialize the specified entry of ff_sine_windows | |||||
*/ | |||||
void ff_init_ff_sine_windows(int index); | |||||
extern SINETABLE( 32); | |||||
extern SINETABLE( 64); | |||||
extern SINETABLE( 128); | |||||
extern SINETABLE( 256); | |||||
extern SINETABLE( 512); | |||||
extern SINETABLE(1024); | |||||
extern SINETABLE(2048); | |||||
extern SINETABLE(4096); | |||||
extern SINETABLE_CONST float * const ff_sine_windows[13]; | |||||
#endif |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* Generate a header file for hardcoded MDCT tables | |||||
* Generate a header file for hardcoded sine windows | |||||
* | * | ||||
* Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | ||||
* | * | ||||
@@ -29,7 +29,7 @@ | |||||
#ifndef M_PI | #ifndef M_PI | ||||
#define M_PI 3.14159265358979323846 | #define M_PI 3.14159265358979323846 | ||||
#endif | #endif | ||||
#include "mdct_tablegen.h" | |||||
#include "sinewin_tablegen.h" | |||||
#include "tableprint.h" | #include "tableprint.h" | ||||
int main(void) | int main(void) |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* Header file for hardcoded MDCT tables | |||||
* Header file for hardcoded sine windows | |||||
* | * | ||||
* Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | ||||
* | * | ||||
@@ -36,7 +36,7 @@ SINETABLE(1024); | |||||
SINETABLE(2048); | SINETABLE(2048); | ||||
SINETABLE(4096); | SINETABLE(4096); | ||||
#else | #else | ||||
#include "libavcodec/mdct_tables.h" | |||||
#include "libavcodec/sinewin_tables.h" | |||||
#endif | #endif | ||||
SINETABLE_CONST float * const ff_sine_windows[] = { | SINETABLE_CONST float * const ff_sine_windows[] = { |
@@ -29,7 +29,7 @@ static void synth_filter_float(FFTContext *imdct, | |||||
float *synth_buf= synth_buf_ptr + *synth_buf_offset; | float *synth_buf= synth_buf_ptr + *synth_buf_offset; | ||||
int i, j; | int i, j; | ||||
ff_imdct_half(imdct, synth_buf, in); | |||||
imdct->imdct_half(imdct, synth_buf, in); | |||||
for (i = 0; i < 16; i++){ | for (i = 0; i < 16; i++){ | ||||
float a= synth_buf2[i ]; | float a= synth_buf2[i ]; | ||||
@@ -24,6 +24,7 @@ | |||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "fft.h" | #include "fft.h" | ||||
#include "lsp.h" | #include "lsp.h" | ||||
#include "sinewin.h" | |||||
#include <math.h> | #include <math.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
@@ -608,6 +609,7 @@ static void dec_lpc_spectrum_inv(TwinContext *tctx, float *lsp, | |||||
static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype, | static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype, | ||||
float *in, float *prev, int ch) | float *in, float *prev, int ch) | ||||
{ | { | ||||
FFTContext *mdct = &tctx->mdct_ctx[ftype]; | |||||
const ModeTab *mtab = tctx->mtab; | const ModeTab *mtab = tctx->mtab; | ||||
int bsize = mtab->size / mtab->fmode[ftype].sub; | int bsize = mtab->size / mtab->fmode[ftype].sub; | ||||
int size = mtab->size; | int size = mtab->size; | ||||
@@ -640,7 +642,7 @@ static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype, | |||||
wsize = types_sizes[wtype_to_wsize[sub_wtype]]; | wsize = types_sizes[wtype_to_wsize[sub_wtype]]; | ||||
ff_imdct_half(&tctx->mdct_ctx[ftype], buf1 + bsize*j, in + bsize*j); | |||||
mdct->imdct_half(mdct, buf1 + bsize*j, in + bsize*j); | |||||
tctx->dsp.vector_fmul_window(out2, | tctx->dsp.vector_fmul_window(out2, | ||||
prev_buf + (bsize-wsize)/2, | prev_buf + (bsize-wsize)/2, | ||||
@@ -1448,7 +1448,7 @@ void vorbis_inverse_coupling(float *mag, float *ang, int blocksize) | |||||
static int vorbis_parse_audio_packet(vorbis_context *vc) | static int vorbis_parse_audio_packet(vorbis_context *vc) | ||||
{ | { | ||||
GetBitContext *gb = &vc->gb; | GetBitContext *gb = &vc->gb; | ||||
FFTContext *mdct; | |||||
uint_fast8_t previous_window = vc->previous_window; | uint_fast8_t previous_window = vc->previous_window; | ||||
uint_fast8_t mode_number; | uint_fast8_t mode_number; | ||||
uint_fast8_t blockflag; | uint_fast8_t blockflag; | ||||
@@ -1552,11 +1552,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) | |||||
// Dotproduct, MDCT | // Dotproduct, MDCT | ||||
mdct = &vc->mdct[blockflag]; | |||||
for (j = vc->audio_channels-1;j >= 0; j--) { | for (j = vc->audio_channels-1;j >= 0; j--) { | ||||
ch_floor_ptr = vc->channel_floors + j * blocksize / 2; | ch_floor_ptr = vc->channel_floors + j * blocksize / 2; | ||||
ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2; | ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2; | ||||
vc->dsp.vector_fmul(ch_floor_ptr, ch_floor_ptr, ch_res_ptr, blocksize / 2); | vc->dsp.vector_fmul(ch_floor_ptr, ch_floor_ptr, ch_res_ptr, blocksize / 2); | ||||
ff_imdct_half(&vc->mdct[blockflag], ch_res_ptr, ch_floor_ptr); | |||||
mdct->imdct_half(mdct, ch_res_ptr, ch_floor_ptr); | |||||
} | } | ||||
// Overlap/add, save data for next overlapping FPMATH | // Overlap/add, save data for next overlapping FPMATH | ||||
@@ -935,7 +935,7 @@ static int apply_window_and_mdct(vorbis_enc_context *venc, const signed short *a | |||||
} | } | ||||
for (channel = 0; channel < venc->channels; channel++) | for (channel = 0; channel < venc->channels; channel++) | ||||
ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len, | |||||
venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len, | |||||
venc->samples + channel * window_len * 2); | venc->samples + channel * window_len * 2); | ||||
if (samples) { | if (samples) { | ||||
@@ -20,6 +20,7 @@ | |||||
*/ | */ | ||||
#include "avcodec.h" | #include "avcodec.h" | ||||
#include "sinewin.h" | |||||
#include "wma.h" | #include "wma.h" | ||||
#include "wmadata.h" | #include "wmadata.h" | ||||
@@ -447,6 +447,7 @@ static int wma_decode_block(WMACodecContext *s) | |||||
int coef_nb_bits, total_gain; | int coef_nb_bits, total_gain; | ||||
int nb_coefs[MAX_CHANNELS]; | int nb_coefs[MAX_CHANNELS]; | ||||
float mdct_norm; | float mdct_norm; | ||||
FFTContext *mdct; | |||||
#ifdef TRACE | #ifdef TRACE | ||||
tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num); | tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num); | ||||
@@ -742,12 +743,14 @@ static int wma_decode_block(WMACodecContext *s) | |||||
} | } | ||||
next: | next: | ||||
mdct = &s->mdct_ctx[bsize]; | |||||
for(ch = 0; ch < s->nb_channels; ch++) { | for(ch = 0; ch < s->nb_channels; ch++) { | ||||
int n4, index; | int n4, index; | ||||
n4 = s->block_len / 2; | n4 = s->block_len / 2; | ||||
if(s->channel_coded[ch]){ | if(s->channel_coded[ch]){ | ||||
ff_imdct_calc(&s->mdct_ctx[bsize], s->output, s->coefs[ch]); | |||||
mdct->imdct_calc(mdct, s->output, s->coefs[ch]); | |||||
}else if(!(s->ms_stereo && ch==1)) | }else if(!(s->ms_stereo && ch==1)) | ||||
memset(s->output, 0, sizeof(s->output)); | memset(s->output, 0, sizeof(s->output)); | ||||
@@ -77,6 +77,7 @@ static int encode_init(AVCodecContext * avctx){ | |||||
static void apply_window_and_mdct(AVCodecContext * avctx, const signed short * audio, int len) { | static void apply_window_and_mdct(AVCodecContext * avctx, const signed short * audio, int len) { | ||||
WMACodecContext *s = avctx->priv_data; | WMACodecContext *s = avctx->priv_data; | ||||
int window_index= s->frame_len_bits - s->block_len_bits; | int window_index= s->frame_len_bits - s->block_len_bits; | ||||
FFTContext *mdct = &s->mdct_ctx[window_index]; | |||||
int i, j, channel; | int i, j, channel; | ||||
const float * win = s->windows[window_index]; | const float * win = s->windows[window_index]; | ||||
int window_len = 1 << s->block_len_bits; | int window_len = 1 << s->block_len_bits; | ||||
@@ -89,7 +90,7 @@ static void apply_window_and_mdct(AVCodecContext * avctx, const signed short * a | |||||
s->output[i+window_len] = audio[j] / n * win[window_len - i - 1]; | s->output[i+window_len] = audio[j] / n * win[window_len - i - 1]; | ||||
s->frame_out[channel][i] = audio[j] / n * win[i]; | s->frame_out[channel][i] = audio[j] / n * win[i]; | ||||
} | } | ||||
ff_mdct_calc(&s->mdct_ctx[window_index], s->coefs[channel], s->output); | |||||
mdct->mdct_calc(mdct, s->coefs[channel], s->output); | |||||
} | } | ||||
} | } | ||||
@@ -92,6 +92,7 @@ | |||||
#include "put_bits.h" | #include "put_bits.h" | ||||
#include "wmaprodata.h" | #include "wmaprodata.h" | ||||
#include "dsputil.h" | #include "dsputil.h" | ||||
#include "sinewin.h" | |||||
#include "wma.h" | #include "wma.h" | ||||
/** current decoder limitations */ | /** current decoder limitations */ | ||||
@@ -1222,6 +1223,7 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||||
get_bits_count(&s->gb) - s->subframe_offset); | get_bits_count(&s->gb) - s->subframe_offset); | ||||
if (transmit_coeffs) { | if (transmit_coeffs) { | ||||
FFTContext *mdct = &s->mdct_ctx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS]; | |||||
/** reconstruct the per channel data */ | /** reconstruct the per channel data */ | ||||
inverse_channel_transform(s); | inverse_channel_transform(s); | ||||
for (i = 0; i < s->channels_for_cur_subframe; i++) { | for (i = 0; i < s->channels_for_cur_subframe; i++) { | ||||
@@ -1246,9 +1248,8 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||||
quant, end - start); | quant, end - start); | ||||
} | } | ||||
/** apply imdct (ff_imdct_half == DCTIV with reverse) */ | |||||
ff_imdct_half(&s->mdct_ctx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS], | |||||
s->channel[c].coeffs, s->tmp); | |||||
/** apply imdct (imdct_half == DCTIV with reverse) */ | |||||
mdct->imdct_half(mdct, s->channel[c].coeffs, s->tmp); | |||||
} | } | ||||
} | } | ||||
@@ -36,8 +36,9 @@ | |||||
#include "acelp_filters.h" | #include "acelp_filters.h" | ||||
#include "lsp.h" | #include "lsp.h" | ||||
#include "libavutil/lzo.h" | #include "libavutil/lzo.h" | ||||
#include "avfft.h" | |||||
#include "fft.h" | |||||
#include "dct.h" | |||||
#include "rdft.h" | |||||
#include "sinewin.h" | |||||
#define MAX_BLOCKS 8 ///< maximum number of blocks per frame | #define MAX_BLOCKS 8 ///< maximum number of blocks per frame | ||||
#define MAX_LSPS 16 ///< maximum filter order | #define MAX_LSPS 16 ///< maximum filter order | ||||
@@ -558,7 +559,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, | |||||
int n, idx; | int n, idx; | ||||
/* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */ | /* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */ | ||||
ff_rdft_calc(&s->rdft, lpcs); | |||||
s->rdft.rdft_calc(&s->rdft, lpcs); | |||||
#define log_range(var, assign) do { \ | #define log_range(var, assign) do { \ | ||||
float tmp = log10f(assign); var = tmp; \ | float tmp = log10f(assign); var = tmp; \ | ||||
max = FFMAX(max, tmp); min = FFMIN(min, tmp); \ | max = FFMAX(max, tmp); min = FFMIN(min, tmp); \ | ||||
@@ -601,8 +602,8 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, | |||||
* is a sinus input) by doing a phase shift (in theory, H(sin())=cos()). | * is a sinus input) by doing a phase shift (in theory, H(sin())=cos()). | ||||
* Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the | * Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the | ||||
* "moment" of the LPCs in this filter. */ | * "moment" of the LPCs in this filter. */ | ||||
ff_dct_calc(&s->dct, lpcs); | |||||
ff_dct_calc(&s->dst, lpcs); | |||||
s->dct.dct_calc(&s->dct, lpcs); | |||||
s->dst.dct_calc(&s->dst, lpcs); | |||||
/* Split out the coefficient indexes into phase/magnitude pairs */ | /* Split out the coefficient indexes into phase/magnitude pairs */ | ||||
idx = 255 + av_clip(lpcs[64], -255, 255); | idx = 255 + av_clip(lpcs[64], -255, 255); | ||||
@@ -623,7 +624,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, | |||||
coeffs[1] = last_coeff; | coeffs[1] = last_coeff; | ||||
/* move into real domain */ | /* move into real domain */ | ||||
ff_rdft_calc(&s->irdft, coeffs); | |||||
s->irdft.rdft_calc(&s->irdft, coeffs); | |||||
/* tilt correction and normalize scale */ | /* tilt correction and normalize scale */ | ||||
memset(&coeffs[remainder], 0, sizeof(coeffs[0]) * (128 - remainder)); | memset(&coeffs[remainder], 0, sizeof(coeffs[0]) * (128 - remainder)); | ||||
@@ -693,8 +694,8 @@ static void wiener_denoise(WMAVoiceContext *s, int fcb_type, | |||||
/* apply coefficients (in frequency spectrum domain), i.e. complex | /* apply coefficients (in frequency spectrum domain), i.e. complex | ||||
* number multiplication */ | * number multiplication */ | ||||
memset(&synth_pf[size], 0, sizeof(synth_pf[0]) * (128 - size)); | memset(&synth_pf[size], 0, sizeof(synth_pf[0]) * (128 - size)); | ||||
ff_rdft_calc(&s->rdft, synth_pf); | |||||
ff_rdft_calc(&s->rdft, coeffs); | |||||
s->rdft.rdft_calc(&s->rdft, synth_pf); | |||||
s->rdft.rdft_calc(&s->rdft, coeffs); | |||||
synth_pf[0] *= coeffs[0]; | synth_pf[0] *= coeffs[0]; | ||||
synth_pf[1] *= coeffs[1]; | synth_pf[1] *= coeffs[1]; | ||||
for (n = 1; n < 64; n++) { | for (n = 1; n < 64; n++) { | ||||
@@ -702,7 +703,7 @@ static void wiener_denoise(WMAVoiceContext *s, int fcb_type, | |||||
synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1]; | synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1]; | ||||
synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1]; | synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1]; | ||||
} | } | ||||
ff_rdft_calc(&s->irdft, synth_pf); | |||||
s->irdft.rdft_calc(&s->irdft, synth_pf); | |||||
} | } | ||||
/* merge filter output with the history of previous runs */ | /* merge filter output with the history of previous runs */ | ||||
@@ -18,6 +18,7 @@ | |||||
#include "libavutil/cpu.h" | #include "libavutil/cpu.h" | ||||
#include "libavcodec/dsputil.h" | #include "libavcodec/dsputil.h" | ||||
#include "libavcodec/dct.h" | |||||
#include "fft.h" | #include "fft.h" | ||||
av_cold void ff_fft_init_mmx(FFTContext *s) | av_cold void ff_fft_init_mmx(FFTContext *s) | ||||