I don't trust these bitstream reads to floating point math.
From 9b383d6b7a55f8f2187779eac9a17a50ff98592d Mon Sep 17 00:00:00 2001 From: Alex Converse <alex.conve...@gmail.com> Date: Wed, 18 Nov 2009 09:20:41 -0500 Subject: [PATCH 03/10] Replace ceil(log() / M_LN2) with a ceil_log2[] lookup table. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1"
This is a multi-part message in MIME format. --------------1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit --- aacsbr.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) --------------1 Content-Type: text/x-patch; name="0003-Replace-ceil-log-M_LN2-with-a-ceil_log2-lookup-table.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0003-Replace-ceil-log-M_LN2-with-a-ceil_log2-lookup-table.patch" diff --git a/aacsbr.c b/aacsbr.c index 2b3d5e2..8d91673 100644 --- a/aacsbr.c +++ b/aacsbr.c @@ -489,6 +489,10 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) return 0; } +static int8_t ceil_log2[] = { + 0, 0, 1, 2, 2, 3, 3, +}; + static int sbr_grid(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data) { @@ -514,7 +518,7 @@ static int sbr_grid(AACContext *ac, SpectralBandReplication *sbr, for (i = 0; i < ch_data->bs_num_rel[1]; i++) ch_data->bs_rel_bord[1][i] = (get_bits(gb, 2) << 1) + 2; - ch_data->bs_pointer = get_bits(gb, ceil(logf(ch_data->bs_num_env[1] + 1) / M_LN2)); + ch_data->bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1] + 1]); for (i = 0; i < ch_data->bs_num_env[1]; i++) ch_data->bs_freq_res[ch_data->bs_num_env[1] - 1 - i] = get_bits1(gb); @@ -527,7 +531,7 @@ static int sbr_grid(AACContext *ac, SpectralBandReplication *sbr, for (i = 0; i < ch_data->bs_num_rel[0]; i++) ch_data->bs_rel_bord[0][i] = (get_bits(gb, 2) << 1) + 2; - ch_data->bs_pointer = get_bits(gb, ceil(logf(ch_data->bs_num_env[1] + 1) / M_LN2)); + ch_data->bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1] + 1]); for (i = 0; i < ch_data->bs_num_env[1]; i++) ch_data->bs_freq_res[i] = get_bits1(gb); @@ -544,7 +548,7 @@ static int sbr_grid(AACContext *ac, SpectralBandReplication *sbr, for (i = 0; i < ch_data->bs_num_rel[1]; i++) ch_data->bs_rel_bord[1][i] = (get_bits(gb, 2) << 1) + 2; - ch_data->bs_pointer = get_bits(gb, ceil(logf(ch_data->bs_num_env[1] + 1) / M_LN2)); + ch_data->bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1] + 1]); for (i = 0; i < ch_data->bs_num_env[1]; i++) ch_data->bs_freq_res[i] = get_bits1(gb); --------------1--
_______________________________________________ FFmpeg-soc mailing list FFmpeg-soc@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc