aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vorbis_dec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-01-27 15:20:43 +0000
committerMans Rullgard <mans@mansr.com>2011-01-28 00:07:35 +0000
commit9d06d7bce3babb82ed650c13ed13a57f6f626a71 (patch)
tree022760430dcd336114b22b841e8a0dcb51dbd62c /libavcodec/vorbis_dec.c
parent97b04f5ed3ab3a62e57f0c16841fb8f10d0a174c (diff)
downloadffmpeg-9d06d7bce3babb82ed650c13ed13a57f6f626a71.tar.gz
Remove the add bias hack for the C version of DSPContext.float_to_int16_*().
Diffstat (limited to 'libavcodec/vorbis_dec.c')
-rw-r--r--libavcodec/vorbis_dec.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c
index cdb485a9c9..69b784c668 100644
--- a/libavcodec/vorbis_dec.c
+++ b/libavcodec/vorbis_dec.c
@@ -153,8 +153,7 @@ typedef struct vorbis_context_s {
float *channel_residues;
float *channel_floors;
float *saved;
- uint_fast32_t add_bias; // for float->int conversion
- uint_fast32_t exp_bias;
+ float scale_bias; // for float->int conversion
} vorbis_context;
/* Helper functions */
@@ -932,8 +931,8 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
vc->saved = av_mallocz((vc->blocksize[1] / 4) * vc->audio_channels * sizeof(float));
vc->previous_window = 0;
- ff_mdct_init(&vc->mdct[0], bl0, 1, vc->exp_bias ? -(1 << 15) : -1.0);
- ff_mdct_init(&vc->mdct[1], bl1, 1, vc->exp_bias ? -(1 << 15) : -1.0);
+ ff_mdct_init(&vc->mdct[0], bl0, 1, -vc->scale_bias);
+ ff_mdct_init(&vc->mdct[1], bl1, 1, -vc->scale_bias);
AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
@@ -963,13 +962,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
vc->avccontext = avccontext;
dsputil_init(&vc->dsp, avccontext);
- if (vc->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- vc->add_bias = 385;
- vc->exp_bias = 0;
- } else {
- vc->add_bias = 0;
- vc->exp_bias = 15 << 23;
- }
+ vc->scale_bias = 32768.0f;
if (!headers_len) {
av_log(avccontext, AV_LOG_ERROR, "Extradata missing.\n");
@@ -1453,18 +1446,6 @@ void vorbis_inverse_coupling(float *mag, float *ang, int blocksize)
}
}
-static void copy_normalize(float *dst, float *src, int len, int exp_bias,
- float add_bias)
-{
- int i;
- if (exp_bias) {
- memcpy(dst, src, len * sizeof(float));
- } else {
- for (i = 0; i < len; i++)
- dst[i] = src[i] + add_bias;
- }
-}
-
// Decode the audio packet using the functions above
static int vorbis_parse_audio_packet(vorbis_context *vc)
@@ -1484,7 +1465,6 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
uint_fast8_t res_chan[255];
uint_fast8_t res_num = 0;
int_fast16_t retlen = 0;
- float fadd_bias = vc->add_bias;
if (get_bits1(gb)) {
av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
@@ -1595,13 +1575,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
const float *win = vc->win[blockflag & previous_window];
if (blockflag == previous_window) {
- vc->dsp.vector_fmul_window(ret, saved, buf, win, fadd_bias, blocksize / 4);
+ vc->dsp.vector_fmul_window(ret, saved, buf, win, 0, blocksize / 4);
} else if (blockflag > previous_window) {
- vc->dsp.vector_fmul_window(ret, saved, buf, win, fadd_bias, bs0 / 4);
- copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4, vc->exp_bias, fadd_bias);
+ vc->dsp.vector_fmul_window(ret, saved, buf, win, 0, bs0 / 4);
+ memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
} else {
- copy_normalize(ret, saved, (bs1 - bs0) / 4, vc->exp_bias, fadd_bias);
- vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, fadd_bias, bs0 / 4);
+ memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
+ vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, 0, bs0 / 4);
}
memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float));
}