summaryrefslogtreecommitdiff
path: root/libavcodec/ac3dsp.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-03-11 02:49:55 +0000
committerMans Rullgard <mans@mansr.com>2011-03-29 19:31:45 +0100
commit6d9f52b2cd760eacf6cc6b7d694b0b00d991f1de (patch)
treeb6275771445a9cf058d92cb5fb2847698a3414a8 /libavcodec/ac3dsp.c
parentd38345878cbb89e4d8d33bd79f47836d4e9cd637 (diff)
ac3: move ff_ac3_bit_alloc_calc_bap to ac3dsp
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/ac3dsp.c')
-rw-r--r--libavcodec/ac3dsp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 42b44f7db8..77250a351b 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -20,6 +20,7 @@
*/
#include "avcodec.h"
+#include "ac3.h"
#include "ac3dsp.h"
static void ac3_exponent_min_c(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
@@ -101,6 +102,31 @@ static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
} while (len > 0);
}
+static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
+ int start, int end,
+ int snr_offset, int floor,
+ const uint8_t *bap_tab, uint8_t *bap)
+{
+ int bin, band;
+
+ /* special case, if snr offset is -960, set all bap's to zero */
+ if (snr_offset == -960) {
+ memset(bap, 0, AC3_MAX_COEFS);
+ return;
+ }
+
+ bin = start;
+ band = ff_ac3_bin_to_band_tab[start];
+ do {
+ int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
+ int band_end = FFMIN(ff_ac3_band_start_tab[band+1], end);
+ for (; bin < band_end; bin++) {
+ int address = av_clip((psd[bin] - m) >> 5, 0, 63);
+ bap[bin] = bap_tab[address];
+ }
+ } while (end > ff_ac3_band_start_tab[band++]);
+}
+
av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
{
c->ac3_exponent_min = ac3_exponent_min_c;
@@ -108,6 +134,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
c->ac3_lshift_int16 = ac3_lshift_int16_c;
c->ac3_rshift_int32 = ac3_rshift_int32_c;
c->float_to_fixed24 = float_to_fixed24_c;
+ c->bit_alloc_calc_bap = ac3_bit_alloc_calc_bap_c;
if (ARCH_ARM)
ff_ac3dsp_init_arm(c, bit_exact);