aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ac3dsp.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-03-11 17:16:27 +0000
committerMans Rullgard <mans@mansr.com>2011-03-30 01:21:56 +0100
commit52fd16a264d1eb14b1a84b7b38041da1756fb216 (patch)
tree9ed5f74a9043e4099d8d5a1b95fdc457632c75ac /libavcodec/ac3dsp.c
parent6f718471eaae9d25c4fd2dd8d8defa412e2d041c (diff)
downloadffmpeg-52fd16a264d1eb14b1a84b7b38041da1756fb216.tar.gz
ac3enc: move compute_mantissa_size() to ac3dsp
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/ac3dsp.c')
-rw-r--r--libavcodec/ac3dsp.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 77250a351b..cd4d30b8f2 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -127,6 +127,28 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
} while (end > ff_ac3_band_start_tab[band++]);
}
+static int ac3_compute_mantissa_size_c(int mant_cnt[5], uint8_t *bap,
+ int nb_coefs)
+{
+ int bits, b, i;
+
+ bits = 0;
+ for (i = 0; i < nb_coefs; i++) {
+ b = bap[i];
+ if (b <= 4) {
+ // bap=1 to bap=4 will be counted in compute_mantissa_size_final
+ mant_cnt[b]++;
+ } else if (b <= 13) {
+ // bap=5 to bap=13 use (bap-1) bits
+ bits += b - 1;
+ } else {
+ // bap=14 uses 14 bits and bap=15 uses 16 bits
+ bits += (b == 14) ? 14 : 16;
+ }
+ }
+ return bits;
+}
+
av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
{
c->ac3_exponent_min = ac3_exponent_min_c;
@@ -135,6 +157,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
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;
+ c->compute_mantissa_size = ac3_compute_mantissa_size_c;
if (ARCH_ARM)
ff_ac3dsp_init_arm(c, bit_exact);