00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00029 #define CONFIG_AC3ENC_FLOAT 1
00030 #include "ac3enc.h"
00031 #include "eac3enc.h"
00032 #include "kbdwin.h"
00033
00034
00035 #if CONFIG_AC3_ENCODER
00036 #define AC3ENC_TYPE AC3ENC_TYPE_AC3
00037 #include "ac3enc_opts_template.c"
00038 static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name,
00039 ac3_options, LIBAVUTIL_VERSION_INT };
00040 #endif
00041
00042 #include "ac3enc_template.c"
00043
00044
00048 av_cold void ff_ac3_float_mdct_end(AC3MDCTContext *mdct)
00049 {
00050 ff_mdct_end(&mdct->fft);
00051 av_freep(&mdct->window);
00052 }
00053
00054
00059 av_cold int ff_ac3_float_mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
00060 int nbits)
00061 {
00062 float *window;
00063 int i, n, n2;
00064
00065 n = 1 << nbits;
00066 n2 = n >> 1;
00067
00068 window = av_malloc(n * sizeof(*window));
00069 if (!window) {
00070 av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
00071 return AVERROR(ENOMEM);
00072 }
00073 ff_kbd_window_init(window, 5.0, n2);
00074 for (i = 0; i < n2; i++)
00075 window[n-1-i] = window[i];
00076 mdct->window = window;
00077
00078 return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
00079 }
00080
00081
00085 void ff_ac3_float_apply_window(DSPContext *dsp, float *output,
00086 const float *input, const float *window,
00087 unsigned int len)
00088 {
00089 dsp->vector_fmul(output, input, window, len);
00090 }
00091
00092
00096 void ff_ac3_float_scale_coefficients(AC3EncodeContext *s)
00097 {
00098 int chan_size = AC3_MAX_COEFS * AC3_MAX_BLOCKS;
00099 s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + chan_size,
00100 s->mdct_coef_buffer + chan_size,
00101 chan_size * s->channels);
00102 }
00103
00104
00105 #if CONFIG_AC3_ENCODER
00106 AVCodec ff_ac3_float_encoder = {
00107 "ac3_float",
00108 AVMEDIA_TYPE_AUDIO,
00109 CODEC_ID_AC3,
00110 sizeof(AC3EncodeContext),
00111 ff_ac3_encode_init,
00112 ff_ac3_encode_frame,
00113 ff_ac3_encode_close,
00114 NULL,
00115 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
00116 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
00117 .priv_class = &ac3enc_class,
00118 .channel_layouts = ff_ac3_channel_layouts,
00119 };
00120 #endif