[FFmpeg-soc] [soc]: r3730 - in eac3: ac3dec.c eac3dec.c
jbr
subversion at mplayerhq.hu
Mon Sep 8 05:48:46 CEST 2008
Author: jbr
Date: Mon Sep 8 05:48:45 2008
New Revision: 3730
Log:
decode and apply SPX coordinates
Modified:
eac3/ac3dec.c
eac3/eac3dec.c
Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c (original)
+++ eac3/ac3dec.c Mon Sep 8 05:48:45 2008
@@ -848,12 +848,15 @@ static int decode_audio_block(AC3DecodeC
if (s->channel_in_spx[ch]) {
if (s->first_spx_coords[ch] || get_bits1(gbc)) {
int bin, spx_blend;
+ int master_spx_coord;
s->first_spx_coords[ch] = 0;
s->spx_coords_exist[ch] = 1;
spx_blend = get_bits(gbc, 5) << 18;
- skip_bits(gbc, 2); // skip master spx coord
+ master_spx_coord = get_bits(gbc, 2) * 3;
bin = s->spx_start_freq;
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
+ int spx_coord_exp, spx_coord_mant;
+
/* calculate blending factors */
int bandsize = s->spx_band_sizes[bnd];
int nratio = (((bin + (bandsize >> 1)) << 23) / s->spx_end_freq) - spx_blend;
@@ -862,8 +865,14 @@ static int decode_audio_block(AC3DecodeC
s->spx_signal_blend[ch][bnd] = ff_sqrt((INT24_MAX - nratio) << 8) * M_SQRT_POW2_15;
bin += bandsize;
- skip_bits(gbc, 4); // skip spx coord exponent
- skip_bits(gbc, 2); // skip spx coord mantissa
+ /* decode coupling coordinates */
+ spx_coord_exp = get_bits(gbc, 4);
+ spx_coord_mant = get_bits(gbc, 2);
+ if (spx_coord_exp == 15)
+ s->spx_coords[ch][bnd] = spx_coord_mant << 26;
+ else
+ s->spx_coords[ch][bnd] = (spx_coord_mant + 4) << 25;
+ s->spx_coords[ch][bnd] >>= (spx_coord_exp + master_spx_coord);
}
} else {
s->spx_coords_exist[ch] = 0;
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Mon Sep 8 05:48:45 2008
@@ -115,20 +115,20 @@ void ff_eac3_apply_spectral_extension(AC
}
}
- /* Apply coefficient and noise scaling based on previously calculated
- RMS energy and blending factors for each band. */
+ /* Apply noise-blended coefficient scaling based on previously
+ calculated RMS energy, blending factors, and SPX coordinates for
+ each band. */
bin = s->spx_start_freq;
for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
int64_t nscale = (s->spx_noise_blend [ch][bnd] * rms_energy[bnd]) >> 23;
- int64_t sscale = s->spx_signal_blend[ch][bnd];
+ int64_t sscale = s->spx_signal_blend[ch][bnd];
+ int64_t spxco = s->spx_coords[ch][bnd];
for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
- int64_t noise = nscale * (av_znrng_get(&s->spx_noise_state) >> 5);
- int64_t signal = sscale * s->fixed_coeffs[ch][bin];
- s->fixed_coeffs[ch][bin++] = (noise + signal) >> 23;
+ int64_t noise = (nscale * (av_znrng_get(&s->spx_noise_state) >> 4)) >> 23;
+ int64_t signal = (sscale * s->fixed_coeffs[ch][bin]) >> 23;
+ s->fixed_coeffs[ch][bin++] = ((noise + signal) * spxco) >> 23;
}
}
-
- /* Scale coefficients using spectral extension coordinates */
}
}
More information about the FFmpeg-soc
mailing list