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_FFT_FLOAT 0
00030 #undef CONFIG_AC3ENC_FLOAT
00031 #include "ac3enc.h"
00032
00033 #define AC3ENC_TYPE AC3ENC_TYPE_AC3_FIXED
00034 #include "ac3enc_opts_template.c"
00035 static AVClass ac3enc_class = { "Fixed-Point AC-3 Encoder", av_default_item_name,
00036 ac3fixed_options, LIBAVUTIL_VERSION_INT };
00037
00038 #include "ac3enc_template.c"
00039
00040
00044 av_cold void AC3_NAME(mdct_end)(AC3MDCTContext *mdct)
00045 {
00046 ff_mdct_end(&mdct->fft);
00047 }
00048
00049
00054 av_cold int AC3_NAME(mdct_init)(AVCodecContext *avctx, AC3MDCTContext *mdct,
00055 int nbits)
00056 {
00057 int ret = ff_mdct_init(&mdct->fft, nbits, 0, -1.0);
00058 mdct->window = ff_ac3_window;
00059 return ret;
00060 }
00061
00062
00066 void AC3_NAME(apply_window)(DSPContext *dsp, int16_t *output,
00067 const int16_t *input, const int16_t *window,
00068 unsigned int len)
00069 {
00070 dsp->apply_window_int16(output, input, window, len);
00071 }
00072
00073
00080 static int log2_tab(AC3EncodeContext *s, int16_t *src, int len)
00081 {
00082 int v = s->ac3dsp.ac3_max_msb_abs_int16(src, len);
00083 return av_log2(v);
00084 }
00085
00086
00093 int AC3_NAME(normalize_samples)(AC3EncodeContext *s)
00094 {
00095 int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE);
00096 if (v > 0)
00097 s->ac3dsp.ac3_lshift_int16(s->windowed_samples, AC3_WINDOW_SIZE, v);
00098
00099 return v + 6;
00100 }
00101
00102
00106 void AC3_NAME(scale_coefficients)(AC3EncodeContext *s)
00107 {
00108 int blk, ch;
00109
00110 for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
00111 AC3Block *block = &s->blocks[blk];
00112 for (ch = 1; ch <= s->channels; ch++) {
00113 s->ac3dsp.ac3_rshift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
00114 block->coeff_shift[ch]);
00115 }
00116 }
00117 }
00118
00119
00120 static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx)
00121 {
00122 AC3EncodeContext *s = avctx->priv_data;
00123 s->fixed_point = 1;
00124 return ff_ac3_encode_init(avctx);
00125 }
00126
00127
00128 AVCodec ff_ac3_fixed_encoder = {
00129 "ac3_fixed",
00130 AVMEDIA_TYPE_AUDIO,
00131 CODEC_ID_AC3,
00132 sizeof(AC3EncodeContext),
00133 ac3_fixed_encode_init,
00134 ff_ac3_encode_frame,
00135 ff_ac3_encode_close,
00136 NULL,
00137 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
00138 .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
00139 .priv_class = &ac3enc_class,
00140 .channel_layouts = ff_ac3_channel_layouts,
00141 };