* Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
* Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav 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,
+ * Libav 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
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
* Apply KBD window to input samples prior to MDCT.
*/
static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input,
- const int16_t *window, int n)
+ const int16_t *window, unsigned int len)
{
- int i;
- int n2 = n >> 1;
-
- for (i = 0; i < n2; i++) {
- output[i] = MUL16(input[i], window[i]) >> 15;
- output[n-i-1] = MUL16(input[n-i-1], window[i]) >> 15;
- }
+ dsp->apply_window_int16(output, input, window, len);
}
/**
- * Left-shift each value in an array by a specified amount.
- * @param tab input array
- * @param n number of values in the array
- * @param lshift left shift amount
- */
-static void lshift_tab(int16_t *tab, int n, unsigned int lshift)
-{
- int i;
-
- if (lshift > 0) {
- for (i = 0; i < n; i++)
- tab[i] <<= lshift;
- }
-}
-
-
-/**
- * Right-shift each value in an array of int32_t by a specified amount.
- * @param src input array
- * @param len number of values in the array
- * @param shift right shift amount
- */
-static void ac3_rshift_int32_c(int32_t *src, unsigned int len, unsigned int shift)
-{
- int i;
-
- if (shift > 0) {
- for (i = 0; i < len; i++)
- src[i] >>= shift;
- }
-}
-
-
-/**
* Normalize the input samples to use the maximum available precision.
* This assumes signed 16-bit input samples.
*
static int normalize_samples(AC3EncodeContext *s)
{
int v = 14 - log2_tab(s, s->windowed_samples, AC3_WINDOW_SIZE);
- lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
+ if (v > 0)
+ s->ac3dsp.ac3_lshift_int16(s->windowed_samples, AC3_WINDOW_SIZE, v);
/* +6 to right-shift from 31-bit to 25-bit */
return v + 6;
}
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
AC3Block *block = &s->blocks[blk];
for (ch = 0; ch < s->channels; ch++) {
- ac3_rshift_int32_c(block->mdct_coef[ch], AC3_MAX_COEFS,
- block->coeff_shift[ch]);
+ s->ac3dsp.ac3_rshift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
+ block->coeff_shift[ch]);
}
}
}
NULL,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
+ .priv_class = &ac3enc_class,
.channel_layouts = ac3_channel_layouts,
};