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.c"
00031 #include "kbdwin.h"
00032
00033
00037 static av_cold void mdct_end(AC3MDCTContext *mdct)
00038 {
00039 ff_mdct_end(&mdct->fft);
00040 av_freep(&mdct->window);
00041 }
00042
00043
00048 static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
00049 int nbits)
00050 {
00051 float *window;
00052 int i, n, n2;
00053
00054 n = 1 << nbits;
00055 n2 = n >> 1;
00056
00057 window = av_malloc(n * sizeof(*window));
00058 if (!window) {
00059 av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
00060 return AVERROR(ENOMEM);
00061 }
00062 ff_kbd_window_init(window, 5.0, n2);
00063 for (i = 0; i < n2; i++)
00064 window[n-1-i] = window[i];
00065 mdct->window = window;
00066
00067 return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
00068 }
00069
00070
00076 static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
00077 {
00078 mdct->fft.mdct_calc(&mdct->fft, out, in);
00079 }
00080
00081
00085 static void apply_window(DSPContext *dsp, float *output, const float *input,
00086 const float *window, int n)
00087 {
00088 dsp->vector_fmul(output, input, window, n);
00089 }
00090
00091
00095 static int normalize_samples(AC3EncodeContext *s)
00096 {
00097
00098 return 0;
00099 }
00100
00101
00105 static void scale_coefficients(AC3EncodeContext *s)
00106 {
00107 s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer, s->mdct_coef_buffer,
00108 AC3_MAX_COEFS * AC3_MAX_BLOCKS * s->channels);
00109 }
00110
00111
00112 AVCodec ff_ac3_encoder = {
00113 "ac3",
00114 AVMEDIA_TYPE_AUDIO,
00115 CODEC_ID_AC3,
00116 sizeof(AC3EncodeContext),
00117 ac3_encode_init,
00118 ac3_encode_frame,
00119 ac3_encode_close,
00120 NULL,
00121 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
00122 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
00123 .channel_layouts = ac3_channel_layouts,
00124 };