mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
cosmetics: rename ac3 bit allocation variables
Originally committed as revision 11194 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
66ecf18e38
commit
5ce2134258
110
libavcodec/ac3.c
110
libavcodec/ac3.c
@ -28,8 +28,8 @@
|
||||
#include "ac3.h"
|
||||
#include "bitstream.h"
|
||||
|
||||
static uint8_t bndtab[51];
|
||||
static uint8_t masktab[253];
|
||||
static uint8_t band_start_tab[51];
|
||||
static uint8_t bin_to_band_tab[253];
|
||||
|
||||
static inline int calc_lowcomp1(int a, int b0, int b1, int c)
|
||||
{
|
||||
@ -53,7 +53,7 @@ static inline int calc_lowcomp(int a, int b0, int b1, int bin)
|
||||
}
|
||||
|
||||
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
int16_t *bndpsd)
|
||||
int16_t *band_psd)
|
||||
{
|
||||
int bin, i, j, k, end1, v;
|
||||
|
||||
@ -64,26 +64,26 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
|
||||
/* PSD integration */
|
||||
j=start;
|
||||
k=masktab[start];
|
||||
k=bin_to_band_tab[start];
|
||||
do {
|
||||
v=psd[j];
|
||||
j++;
|
||||
end1 = FFMIN(bndtab[k+1], end);
|
||||
end1 = FFMIN(band_start_tab[k+1], end);
|
||||
for(i=j;i<end1;i++) {
|
||||
/* logadd */
|
||||
int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255);
|
||||
v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr];
|
||||
j++;
|
||||
}
|
||||
bndpsd[k]=v;
|
||||
band_psd[k]=v;
|
||||
k++;
|
||||
} while (end > bndtab[k]);
|
||||
} while (end > band_start_tab[k]);
|
||||
}
|
||||
|
||||
void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
int start, int end, int fgain, int is_lfe,
|
||||
int deltbae, int deltnseg, uint8_t *deltoffst,
|
||||
uint8_t *deltlen, uint8_t *deltba,
|
||||
void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int start, int end, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
|
||||
uint8_t *dba_lengths, uint8_t *dba_values,
|
||||
int16_t *mask)
|
||||
{
|
||||
int16_t excite[50]; /* excitation */
|
||||
@ -92,24 +92,24 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
int lowcomp, fastleak, slowleak;
|
||||
|
||||
/* excitation function */
|
||||
bndstrt = masktab[start];
|
||||
bndend = masktab[end-1] + 1;
|
||||
bndstrt = bin_to_band_tab[start];
|
||||
bndend = bin_to_band_tab[end-1] + 1;
|
||||
|
||||
if (bndstrt == 0) {
|
||||
lowcomp = 0;
|
||||
lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1], 384);
|
||||
excite[0] = bndpsd[0] - fgain - lowcomp;
|
||||
lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2], 384);
|
||||
excite[1] = bndpsd[1] - fgain - lowcomp;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384);
|
||||
excite[0] = band_psd[0] - fast_gain - lowcomp;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384);
|
||||
excite[1] = band_psd[1] - fast_gain - lowcomp;
|
||||
begin = 7;
|
||||
for (bin = 2; bin < 7; bin++) {
|
||||
if (!(is_lfe && bin == 6))
|
||||
lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1], 384);
|
||||
fastleak = bndpsd[bin] - fgain;
|
||||
slowleak = bndpsd[bin] - s->sgain;
|
||||
lowcomp = calc_lowcomp1(lowcomp, band_psd[bin], band_psd[bin+1], 384);
|
||||
fastleak = band_psd[bin] - fast_gain;
|
||||
slowleak = band_psd[bin] - s->slow_gain;
|
||||
excite[bin] = fastleak - lowcomp;
|
||||
if (!(is_lfe && bin == 6)) {
|
||||
if (bndpsd[bin] <= bndpsd[bin+1]) {
|
||||
if (band_psd[bin] <= band_psd[bin+1]) {
|
||||
begin = bin + 1;
|
||||
break;
|
||||
}
|
||||
@ -121,10 +121,10 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
|
||||
for (bin = begin; bin < end1; bin++) {
|
||||
if (!(is_lfe && bin == 6))
|
||||
lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
|
||||
lowcomp = calc_lowcomp(lowcomp, band_psd[bin], band_psd[bin+1], bin);
|
||||
|
||||
fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
|
||||
slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain);
|
||||
excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
|
||||
}
|
||||
begin = 22;
|
||||
@ -132,39 +132,39 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
/* coupling channel */
|
||||
begin = bndstrt;
|
||||
|
||||
fastleak = (s->cplfleak << 8) + 768;
|
||||
slowleak = (s->cplsleak << 8) + 768;
|
||||
fastleak = (s->cpl_fast_leak << 8) + 768;
|
||||
slowleak = (s->cpl_slow_leak << 8) + 768;
|
||||
}
|
||||
|
||||
for (bin = begin; bin < bndend; bin++) {
|
||||
fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
|
||||
slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
|
||||
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain);
|
||||
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain);
|
||||
excite[bin] = FFMAX(fastleak, slowleak);
|
||||
}
|
||||
|
||||
/* compute masking curve */
|
||||
|
||||
for (bin = bndstrt; bin < bndend; bin++) {
|
||||
tmp = s->dbknee - bndpsd[bin];
|
||||
tmp = s->db_per_bit - band_psd[bin];
|
||||
if (tmp > 0) {
|
||||
excite[bin] += tmp >> 2;
|
||||
}
|
||||
mask[bin] = FFMAX(ff_ac3_hearing_threshold_tab[bin >> s->halfratecod][s->fscod], excite[bin]);
|
||||
mask[bin] = FFMAX(ff_ac3_hearing_threshold_tab[bin >> s->sr_shift][s->sr_code], excite[bin]);
|
||||
}
|
||||
|
||||
/* delta bit allocation */
|
||||
|
||||
if (deltbae == DBA_REUSE || deltbae == DBA_NEW) {
|
||||
if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
|
||||
int band, seg, delta;
|
||||
band = 0;
|
||||
for (seg = 0; seg < deltnseg; seg++) {
|
||||
band += deltoffst[seg];
|
||||
if (deltba[seg] >= 4) {
|
||||
delta = (deltba[seg] - 3) << 7;
|
||||
for (seg = 0; seg < dba_nsegs; seg++) {
|
||||
band += dba_offsets[seg];
|
||||
if (dba_values[seg] >= 4) {
|
||||
delta = (dba_values[seg] - 3) << 7;
|
||||
} else {
|
||||
delta = (deltba[seg] - 4) << 7;
|
||||
delta = (dba_values[seg] - 4) << 7;
|
||||
}
|
||||
for (k = 0; k < deltlen[seg]; k++) {
|
||||
for (k = 0; k < dba_lengths[seg]; k++) {
|
||||
mask[band] += delta;
|
||||
band++;
|
||||
}
|
||||
@ -173,49 +173,49 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
}
|
||||
|
||||
void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
|
||||
int snroffset, int floor, uint8_t *bap)
|
||||
int snr_offset, int floor, uint8_t *bap)
|
||||
{
|
||||
int i, j, k, end1, v, address;
|
||||
|
||||
/* special case, if snr offset is -960, set all bap's to zero */
|
||||
if(snroffset == -960) {
|
||||
if(snr_offset == -960) {
|
||||
memset(bap, 0, 256);
|
||||
return;
|
||||
}
|
||||
|
||||
i = start;
|
||||
j = masktab[start];
|
||||
j = bin_to_band_tab[start];
|
||||
do {
|
||||
v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor;
|
||||
end1 = FFMIN(bndtab[j] + ff_ac3_critical_band_size_tab[j], end);
|
||||
v = (FFMAX(mask[j] - snr_offset - floor, 0) & 0x1FE0) + floor;
|
||||
end1 = FFMIN(band_start_tab[j] + ff_ac3_critical_band_size_tab[j], end);
|
||||
for (k = i; k < end1; k++) {
|
||||
address = av_clip((psd[i] - v) >> 5, 0, 63);
|
||||
bap[i] = ff_ac3_bap_tab[address];
|
||||
i++;
|
||||
}
|
||||
} while (end > bndtab[j++]);
|
||||
} while (end > band_start_tab[j++]);
|
||||
}
|
||||
|
||||
/* AC3 bit allocation. The algorithm is the one described in the AC3
|
||||
spec. */
|
||||
void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
|
||||
int8_t *exp, int start, int end,
|
||||
int snroffset, int fgain, int is_lfe,
|
||||
int deltbae,int deltnseg,
|
||||
uint8_t *deltoffst, uint8_t *deltlen,
|
||||
uint8_t *deltba)
|
||||
int snr_offset, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs,
|
||||
uint8_t *dba_offsets, uint8_t *dba_lengths,
|
||||
uint8_t *dba_values)
|
||||
{
|
||||
int16_t psd[256]; /* scaled exponents */
|
||||
int16_t bndpsd[50]; /* interpolated exponents */
|
||||
int16_t band_psd[50]; /* interpolated exponents */
|
||||
int16_t mask[50]; /* masking value */
|
||||
|
||||
ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, bndpsd);
|
||||
ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd);
|
||||
|
||||
ff_ac3_bit_alloc_calc_mask(s, bndpsd, start, end, fgain, is_lfe,
|
||||
deltbae, deltnseg, deltoffst, deltlen, deltba,
|
||||
ff_ac3_bit_alloc_calc_mask(s, band_psd, start, end, fast_gain, is_lfe,
|
||||
dba_mode, dba_nsegs, dba_offsets, dba_lengths, dba_values,
|
||||
mask);
|
||||
|
||||
ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snroffset, s->floor, bap);
|
||||
ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snr_offset, s->floor, bap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,10 +230,10 @@ void ac3_common_init(void)
|
||||
k = 0;
|
||||
l = 0;
|
||||
for(i=0;i<50;i++) {
|
||||
bndtab[i] = l;
|
||||
band_start_tab[i] = l;
|
||||
v = ff_ac3_critical_band_size_tab[i];
|
||||
for(j=0;j<v;j++) masktab[k++]=i;
|
||||
for(j=0;j<v;j++) bin_to_band_tab[k++]=i;
|
||||
l += v;
|
||||
}
|
||||
bndtab[50] = l;
|
||||
band_start_tab[50] = l;
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ typedef enum {
|
||||
} AC3ChannelMode;
|
||||
|
||||
typedef struct AC3BitAllocParameters {
|
||||
int fscod; /* frequency */
|
||||
int halfratecod;
|
||||
int sgain, sdecay, fdecay, dbknee, floor;
|
||||
int cplfleak, cplsleak;
|
||||
int sr_code;
|
||||
int sr_shift;
|
||||
int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
|
||||
int cpl_fast_leak, cpl_slow_leak;
|
||||
} AC3BitAllocParameters;
|
||||
|
||||
/**
|
||||
@ -80,7 +80,7 @@ typedef struct {
|
||||
*/
|
||||
uint16_t sync_word;
|
||||
uint16_t crc1;
|
||||
uint8_t fscod;
|
||||
uint8_t sr_code;
|
||||
uint8_t frmsizecod;
|
||||
uint8_t bsid;
|
||||
uint8_t bsmod;
|
||||
@ -94,7 +94,7 @@ typedef struct {
|
||||
/** @defgroup derived Derived values
|
||||
* @{
|
||||
*/
|
||||
uint8_t halfratecod;
|
||||
uint8_t sr_shift;
|
||||
uint16_t sample_rate;
|
||||
uint32_t bit_rate;
|
||||
uint8_t channels;
|
||||
@ -117,10 +117,10 @@ void ac3_common_init(void);
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[out] psd signal power for each frequency bin
|
||||
* @param[out] bndpsd signal power for each critical band
|
||||
* @param[out] band_psd signal power for each critical band
|
||||
*/
|
||||
void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
int16_t *bndpsd);
|
||||
int16_t *band_psd);
|
||||
|
||||
/**
|
||||
* Calculates the masking curve.
|
||||
@ -131,22 +131,22 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
|
||||
* curve, usually to give a closer match to a better psychoacoustic model.
|
||||
*
|
||||
* @param[in] s adjustable bit allocation parameters
|
||||
* @param[in] bndpsd signal power for each critical band
|
||||
* @param[in] band_psd signal power for each critical band
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[in] fgain fast gain (estimated signal-to-mask ratio)
|
||||
* @param[in] fast_gain fast gain (estimated signal-to-mask ratio)
|
||||
* @param[in] is_lfe whether or not the channel being processed is the LFE
|
||||
* @param[in] deltbae delta bit allocation exists (none, reuse, or new)
|
||||
* @param[in] deltnseg number of delta segments
|
||||
* @param[in] deltoffst location offsets for each segment
|
||||
* @param[in] deltlen length of each segment
|
||||
* @param[in] deltba delta bit allocation for each segment
|
||||
* @param[in] dba_mode delta bit allocation mode (none, reuse, or new)
|
||||
* @param[in] dba_nsegs number of delta segments
|
||||
* @param[in] dba_offsets location offsets for each segment
|
||||
* @param[in] dba_lengths length of each segment
|
||||
* @param[in] dba_values delta bit allocation for each segment
|
||||
* @param[out] mask calculated masking curve
|
||||
*/
|
||||
void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
int start, int end, int fgain, int is_lfe,
|
||||
int deltbae, int deltnseg, uint8_t *deltoffst,
|
||||
uint8_t *deltlen, uint8_t *deltba,
|
||||
void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int start, int end, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
|
||||
uint8_t *dba_lengths, uint8_t *dba_values,
|
||||
int16_t *mask);
|
||||
|
||||
/**
|
||||
@ -159,17 +159,18 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
|
||||
* @param[in] psd signal power for each frequency bin
|
||||
* @param[in] start starting bin location
|
||||
* @param[in] end ending bin location
|
||||
* @param[in] snroffset SNR adjustment
|
||||
* @param[in] snr_offset SNR adjustment
|
||||
* @param[in] floor noise floor
|
||||
* @param[out] bap bit allocation pointers
|
||||
*/
|
||||
void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
|
||||
int snroffset, int floor, uint8_t *bap);
|
||||
int snr_offset, int floor, uint8_t *bap);
|
||||
|
||||
void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
|
||||
int8_t *exp, int start, int end,
|
||||
int snroffset, int fgain, int is_lfe,
|
||||
int deltbae,int deltnseg,
|
||||
uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba);
|
||||
int snr_offset, int fast_gain, int is_lfe,
|
||||
int dba_mode, int dba_nsegs,
|
||||
uint8_t *dba_offsets, uint8_t *dba_lengths,
|
||||
uint8_t *dba_values);
|
||||
|
||||
#endif /* FFMPEG_AC3_H */
|
||||
|
@ -52,8 +52,8 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
|
||||
return AC3_PARSE_ERROR_BSID;
|
||||
|
||||
hdr->crc1 = get_bits(&gbc, 16);
|
||||
hdr->fscod = get_bits(&gbc, 2);
|
||||
if(hdr->fscod == 3)
|
||||
hdr->sr_code = get_bits(&gbc, 2);
|
||||
if(hdr->sr_code == 3)
|
||||
return AC3_PARSE_ERROR_SAMPLE_RATE;
|
||||
|
||||
hdr->frmsizecod = get_bits(&gbc, 6);
|
||||
@ -75,11 +75,11 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
|
||||
}
|
||||
hdr->lfeon = get_bits1(&gbc);
|
||||
|
||||
hdr->halfratecod = FFMAX(hdr->bsid, 8) - 8;
|
||||
hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->fscod] >> hdr->halfratecod;
|
||||
hdr->bit_rate = (ff_ac3_bitrate_tab[hdr->frmsizecod>>1] * 1000) >> hdr->halfratecod;
|
||||
hdr->sr_shift = FFMAX(hdr->bsid, 8) - 8;
|
||||
hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;
|
||||
hdr->bit_rate = (ff_ac3_bitrate_tab[hdr->frmsizecod>>1] * 1000) >> hdr->sr_shift;
|
||||
hdr->channels = ff_ac3_channels_tab[hdr->acmod] + hdr->lfeon;
|
||||
hdr->frame_size = ff_ac3_frame_size_tab[hdr->frmsizecod][hdr->fscod] * 2;
|
||||
hdr->frame_size = ff_ac3_frame_size_tab[hdr->frmsizecod][hdr->sr_code] * 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -88,8 +88,8 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
|
||||
int *bit_rate, int *samples)
|
||||
{
|
||||
int err;
|
||||
unsigned int fscod, acmod, bsid, lfeon;
|
||||
unsigned int strmtyp, substreamid, frmsiz, fscod2, numblkscod;
|
||||
unsigned int sr_code, acmod, bsid, lfeon;
|
||||
unsigned int strmtyp, substreamid, frmsiz, sr_code2, numblkscod;
|
||||
GetBitContext bits;
|
||||
AC3HeaderInfo hdr;
|
||||
|
||||
@ -117,19 +117,19 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
|
||||
if(frmsiz*2 < AC3_HEADER_SIZE)
|
||||
return 0;
|
||||
|
||||
fscod = get_bits(&bits, 2);
|
||||
if (fscod == 3) {
|
||||
fscod2 = get_bits(&bits, 2);
|
||||
sr_code = get_bits(&bits, 2);
|
||||
if (sr_code == 3) {
|
||||
sr_code2 = get_bits(&bits, 2);
|
||||
numblkscod = 3;
|
||||
|
||||
if(fscod2 == 3)
|
||||
if(sr_code2 == 3)
|
||||
return 0;
|
||||
|
||||
*sample_rate = ff_ac3_sample_rate_tab[fscod2] / 2;
|
||||
*sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2;
|
||||
} else {
|
||||
numblkscod = get_bits(&bits, 2);
|
||||
|
||||
*sample_rate = ff_ac3_sample_rate_tab[fscod];
|
||||
*sample_rate = ff_ac3_sample_rate_tab[sr_code];
|
||||
}
|
||||
|
||||
acmod = get_bits(&bits, 3);
|
||||
|
@ -141,13 +141,13 @@ typedef struct {
|
||||
int nrematbnd; ///< number of rematrixing bands
|
||||
int rematflg[4]; ///< rematrixing flags
|
||||
int expstr[AC3_MAX_CHANNELS]; ///< exponent strategies
|
||||
int snroffst[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets
|
||||
int fgain[AC3_MAX_CHANNELS]; ///< fast gain values (signal-to-mask ratio)
|
||||
int deltbae[AC3_MAX_CHANNELS]; ///< delta bit allocation exists
|
||||
int deltnseg[AC3_MAX_CHANNELS]; ///< number of delta segments
|
||||
uint8_t deltoffst[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
|
||||
uint8_t deltlen[AC3_MAX_CHANNELS][8]; ///< delta segment lengths
|
||||
uint8_t deltba[AC3_MAX_CHANNELS][8]; ///< delta values for each segment
|
||||
int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets
|
||||
int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values (signal-to-mask ratio)
|
||||
int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode
|
||||
int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments
|
||||
uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
|
||||
uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths
|
||||
uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment
|
||||
|
||||
int sampling_rate; ///< sample frequency, in Hz
|
||||
int bit_rate; ///< stream bit rate, in bits-per-second
|
||||
@ -173,7 +173,7 @@ typedef struct {
|
||||
int8_t dexps[AC3_MAX_CHANNELS][256]; ///< decoded exponents
|
||||
uint8_t bap[AC3_MAX_CHANNELS][256]; ///< bit allocation pointers
|
||||
int16_t psd[AC3_MAX_CHANNELS][256]; ///< scaled exponents
|
||||
int16_t bndpsd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents
|
||||
int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents
|
||||
int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values
|
||||
|
||||
DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][256]); ///< transform coefficients
|
||||
@ -344,13 +344,13 @@ static int ac3_parse_header(AC3DecodeContext *ctx)
|
||||
return err;
|
||||
|
||||
/* get decoding parameters from header info */
|
||||
ctx->bit_alloc_params.fscod = hdr.fscod;
|
||||
ctx->bit_alloc_params.sr_code = hdr.sr_code;
|
||||
ctx->acmod = hdr.acmod;
|
||||
cmixlev = gain_levels[clevs[hdr.cmixlev]];
|
||||
surmixlev = gain_levels[slevs[hdr.surmixlev]];
|
||||
ctx->dsurmod = hdr.dsurmod;
|
||||
ctx->lfeon = hdr.lfeon;
|
||||
ctx->bit_alloc_params.halfratecod = hdr.halfratecod;
|
||||
ctx->bit_alloc_params.sr_shift = hdr.sr_shift;
|
||||
ctx->sampling_rate = hdr.sample_rate;
|
||||
ctx->bit_rate = hdr.bit_rate;
|
||||
ctx->nchans = hdr.channels;
|
||||
@ -947,10 +947,10 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
||||
|
||||
/* bit allocation information */
|
||||
if (get_bits1(gb)) {
|
||||
ctx->bit_alloc_params.sdecay = ff_ac3_slow_decay_tab[get_bits(gb, 2)] >> ctx->bit_alloc_params.halfratecod;
|
||||
ctx->bit_alloc_params.fdecay = ff_ac3_fast_decay_tab[get_bits(gb, 2)] >> ctx->bit_alloc_params.halfratecod;
|
||||
ctx->bit_alloc_params.sgain = ff_ac3_slow_gain_tab[get_bits(gb, 2)];
|
||||
ctx->bit_alloc_params.dbknee = ff_ac3_db_per_bit_tab[get_bits(gb, 2)];
|
||||
ctx->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gb, 2)] >> ctx->bit_alloc_params.sr_shift;
|
||||
ctx->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gb, 2)] >> ctx->bit_alloc_params.sr_shift;
|
||||
ctx->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab[get_bits(gb, 2)];
|
||||
ctx->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gb, 2)];
|
||||
ctx->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gb, 3)];
|
||||
for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) {
|
||||
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
|
||||
@ -962,16 +962,16 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
||||
int csnr;
|
||||
csnr = (get_bits(gb, 6) - 15) << 4;
|
||||
for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { /* snr offset and fast gain */
|
||||
ctx->snroffst[ch] = (csnr + get_bits(gb, 4)) << 2;
|
||||
ctx->fgain[ch] = ff_ac3_fast_gain_tab[get_bits(gb, 3)];
|
||||
ctx->snr_offset[ch] = (csnr + get_bits(gb, 4)) << 2;
|
||||
ctx->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gb, 3)];
|
||||
}
|
||||
memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
|
||||
}
|
||||
|
||||
/* coupling leak information */
|
||||
if (ctx->cplinu && get_bits1(gb)) {
|
||||
ctx->bit_alloc_params.cplfleak = get_bits(gb, 3);
|
||||
ctx->bit_alloc_params.cplsleak = get_bits(gb, 3);
|
||||
ctx->bit_alloc_params.cpl_fast_leak = get_bits(gb, 3);
|
||||
ctx->bit_alloc_params.cpl_slow_leak = get_bits(gb, 3);
|
||||
bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2);
|
||||
}
|
||||
|
||||
@ -979,8 +979,8 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
||||
if (get_bits1(gb)) {
|
||||
/* delta bit allocation exists (strategy) */
|
||||
for (ch = !ctx->cplinu; ch <= nfchans; ch++) {
|
||||
ctx->deltbae[ch] = get_bits(gb, 2);
|
||||
if (ctx->deltbae[ch] == DBA_RESERVED) {
|
||||
ctx->dba_mode[ch] = get_bits(gb, 2);
|
||||
if (ctx->dba_mode[ch] == DBA_RESERVED) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
|
||||
return -1;
|
||||
}
|
||||
@ -988,18 +988,18 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
||||
}
|
||||
/* channel delta offset, len and bit allocation */
|
||||
for (ch = !ctx->cplinu; ch <= nfchans; ch++) {
|
||||
if (ctx->deltbae[ch] == DBA_NEW) {
|
||||
ctx->deltnseg[ch] = get_bits(gb, 3);
|
||||
for (seg = 0; seg <= ctx->deltnseg[ch]; seg++) {
|
||||
ctx->deltoffst[ch][seg] = get_bits(gb, 5);
|
||||
ctx->deltlen[ch][seg] = get_bits(gb, 4);
|
||||
ctx->deltba[ch][seg] = get_bits(gb, 3);
|
||||
if (ctx->dba_mode[ch] == DBA_NEW) {
|
||||
ctx->dba_nsegs[ch] = get_bits(gb, 3);
|
||||
for (seg = 0; seg <= ctx->dba_nsegs[ch]; seg++) {
|
||||
ctx->dba_offsets[ch][seg] = get_bits(gb, 5);
|
||||
ctx->dba_lengths[ch][seg] = get_bits(gb, 4);
|
||||
ctx->dba_values[ch][seg] = get_bits(gb, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(blk == 0) {
|
||||
for(ch=0; ch<=ctx->nchans; ch++) {
|
||||
ctx->deltbae[ch] = DBA_NONE;
|
||||
ctx->dba_mode[ch] = DBA_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1009,23 +1009,23 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
|
||||
/* Exponent mapping into PSD and PSD integration */
|
||||
ff_ac3_bit_alloc_calc_psd(ctx->dexps[ch],
|
||||
ctx->startmant[ch], ctx->endmant[ch],
|
||||
ctx->psd[ch], ctx->bndpsd[ch]);
|
||||
ctx->psd[ch], ctx->band_psd[ch]);
|
||||
}
|
||||
if(bit_alloc_stages[ch] > 1) {
|
||||
/* Compute excitation function, Compute masking curve, and
|
||||
Apply delta bit allocation */
|
||||
ff_ac3_bit_alloc_calc_mask(&ctx->bit_alloc_params, ctx->bndpsd[ch],
|
||||
ff_ac3_bit_alloc_calc_mask(&ctx->bit_alloc_params, ctx->band_psd[ch],
|
||||
ctx->startmant[ch], ctx->endmant[ch],
|
||||
ctx->fgain[ch], (ch == ctx->lfe_ch),
|
||||
ctx->deltbae[ch], ctx->deltnseg[ch],
|
||||
ctx->deltoffst[ch], ctx->deltlen[ch],
|
||||
ctx->deltba[ch], ctx->mask[ch]);
|
||||
ctx->fast_gain[ch], (ch == ctx->lfe_ch),
|
||||
ctx->dba_mode[ch], ctx->dba_nsegs[ch],
|
||||
ctx->dba_offsets[ch], ctx->dba_lengths[ch],
|
||||
ctx->dba_values[ch], ctx->mask[ch]);
|
||||
}
|
||||
if(bit_alloc_stages[ch] > 0) {
|
||||
/* Compute bit allocation */
|
||||
ff_ac3_bit_alloc_calc_bap(ctx->mask[ch], ctx->psd[ch],
|
||||
ctx->startmant[ch], ctx->endmant[ch],
|
||||
ctx->snroffst[ch],
|
||||
ctx->snr_offset[ch],
|
||||
ctx->bit_alloc_params.floor,
|
||||
ctx->bap[ch]);
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ typedef struct AC3EncodeContext {
|
||||
unsigned int frame_size; /* current frame size in words */
|
||||
unsigned int bits_written;
|
||||
unsigned int samples_written;
|
||||
int halfratecod;
|
||||
int sr_shift;
|
||||
unsigned int frmsizecod;
|
||||
unsigned int fscod; /* frequency */
|
||||
unsigned int sr_code; /* frequency */
|
||||
unsigned int acmod;
|
||||
int lfe;
|
||||
unsigned int bsmod;
|
||||
@ -53,11 +53,11 @@ typedef struct AC3EncodeContext {
|
||||
int nb_coefs[AC3_MAX_CHANNELS];
|
||||
|
||||
/* bitrate allocation control */
|
||||
int sgaincod, sdecaycod, fdecaycod, dbkneecod, floorcod;
|
||||
int slow_gain_code, slow_decay_code, fast_decay_code, db_per_bit_code, floor_code;
|
||||
AC3BitAllocParameters bit_alloc;
|
||||
int csnroffst;
|
||||
int fgaincod[AC3_MAX_CHANNELS];
|
||||
int fsnroffst[AC3_MAX_CHANNELS];
|
||||
int coarse_snr_offset;
|
||||
int fast_gain_code[AC3_MAX_CHANNELS];
|
||||
int fine_snr_offset[AC3_MAX_CHANNELS];
|
||||
/* mantissa encoding */
|
||||
int mant1_cnt, mant2_cnt, mant4_cnt;
|
||||
} AC3EncodeContext;
|
||||
@ -438,7 +438,7 @@ static void bit_alloc_masking(AC3EncodeContext *s,
|
||||
int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50])
|
||||
{
|
||||
int blk, ch;
|
||||
int16_t bndpsd[NB_BLOCKS][AC3_MAX_CHANNELS][50];
|
||||
int16_t band_psd[NB_BLOCKS][AC3_MAX_CHANNELS][50];
|
||||
|
||||
for(blk=0; blk<NB_BLOCKS; blk++) {
|
||||
for(ch=0;ch<s->nb_all_channels;ch++) {
|
||||
@ -448,10 +448,10 @@ static void bit_alloc_masking(AC3EncodeContext *s,
|
||||
} else {
|
||||
ff_ac3_bit_alloc_calc_psd(encoded_exp[blk][ch], 0,
|
||||
s->nb_coefs[ch],
|
||||
psd[blk][ch], bndpsd[blk][ch]);
|
||||
ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, bndpsd[blk][ch],
|
||||
psd[blk][ch], band_psd[blk][ch]);
|
||||
ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, band_psd[blk][ch],
|
||||
0, s->nb_coefs[ch],
|
||||
ff_ac3_fast_gain_tab[s->fgaincod[ch]],
|
||||
ff_ac3_fast_gain_tab[s->fast_gain_code[ch]],
|
||||
ch == s->lfe_channel,
|
||||
DBA_NONE, 0, NULL, NULL, NULL,
|
||||
mask[blk][ch]);
|
||||
@ -464,12 +464,12 @@ static int bit_alloc(AC3EncodeContext *s,
|
||||
int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50],
|
||||
int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
|
||||
uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
|
||||
int frame_bits, int csnroffst, int fsnroffst)
|
||||
int frame_bits, int coarse_snr_offset, int fine_snr_offset)
|
||||
{
|
||||
int i, ch;
|
||||
int snroffset;
|
||||
int snr_offset;
|
||||
|
||||
snroffset = (((csnroffst - 15) << 4) + fsnroffst) << 2;
|
||||
snr_offset = (((coarse_snr_offset - 15) << 4) + fine_snr_offset) << 2;
|
||||
|
||||
/* compute size */
|
||||
for(i=0;i<NB_BLOCKS;i++) {
|
||||
@ -478,7 +478,7 @@ static int bit_alloc(AC3EncodeContext *s,
|
||||
s->mant4_cnt = 0;
|
||||
for(ch=0;ch<s->nb_all_channels;ch++) {
|
||||
ff_ac3_bit_alloc_calc_bap(mask[i][ch], psd[i][ch], 0,
|
||||
s->nb_coefs[ch], snroffset,
|
||||
s->nb_coefs[ch], snr_offset,
|
||||
s->bit_alloc.floor, bap[i][ch]);
|
||||
frame_bits += compute_mantissa_size(s, bap[i][ch],
|
||||
s->nb_coefs[ch]);
|
||||
@ -486,7 +486,7 @@ static int bit_alloc(AC3EncodeContext *s,
|
||||
}
|
||||
#if 0
|
||||
printf("csnr=%d fsnr=%d frame_bits=%d diff=%d\n",
|
||||
csnroffst, fsnroffst, frame_bits,
|
||||
coarse_snr_offset, fine_snr_offset, frame_bits,
|
||||
16 * s->frame_size - ((frame_bits + 7) & ~7));
|
||||
#endif
|
||||
return 16 * s->frame_size - frame_bits;
|
||||
@ -501,29 +501,29 @@ static int compute_bit_allocation(AC3EncodeContext *s,
|
||||
int frame_bits)
|
||||
{
|
||||
int i, ch;
|
||||
int csnroffst, fsnroffst;
|
||||
int coarse_snr_offset, fine_snr_offset;
|
||||
uint8_t bap1[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
|
||||
int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
|
||||
int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50];
|
||||
static int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };
|
||||
|
||||
/* init default parameters */
|
||||
s->sdecaycod = 2;
|
||||
s->fdecaycod = 1;
|
||||
s->sgaincod = 1;
|
||||
s->dbkneecod = 2;
|
||||
s->floorcod = 4;
|
||||
s->slow_decay_code = 2;
|
||||
s->fast_decay_code = 1;
|
||||
s->slow_gain_code = 1;
|
||||
s->db_per_bit_code = 2;
|
||||
s->floor_code = 4;
|
||||
for(ch=0;ch<s->nb_all_channels;ch++)
|
||||
s->fgaincod[ch] = 4;
|
||||
s->fast_gain_code[ch] = 4;
|
||||
|
||||
/* compute real values */
|
||||
s->bit_alloc.fscod = s->fscod;
|
||||
s->bit_alloc.halfratecod = s->halfratecod;
|
||||
s->bit_alloc.sdecay = ff_ac3_slow_decay_tab[s->sdecaycod] >> s->halfratecod;
|
||||
s->bit_alloc.fdecay = ff_ac3_fast_decay_tab[s->fdecaycod] >> s->halfratecod;
|
||||
s->bit_alloc.sgain = ff_ac3_slow_gain_tab[s->sgaincod];
|
||||
s->bit_alloc.dbknee = ff_ac3_db_per_bit_tab[s->dbkneecod];
|
||||
s->bit_alloc.floor = ff_ac3_floor_tab[s->floorcod];
|
||||
s->bit_alloc.sr_code = s->sr_code;
|
||||
s->bit_alloc.sr_shift = s->sr_shift;
|
||||
s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->sr_shift;
|
||||
s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->sr_shift;
|
||||
s->bit_alloc.slow_gain = ff_ac3_slow_gain_tab[s->slow_gain_code];
|
||||
s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code];
|
||||
s->bit_alloc.floor = ff_ac3_floor_tab[s->floor_code];
|
||||
|
||||
/* header size */
|
||||
frame_bits += 65;
|
||||
@ -568,43 +568,43 @@ static int compute_bit_allocation(AC3EncodeContext *s,
|
||||
/* now the big work begins : do the bit allocation. Modify the snr
|
||||
offset until we can pack everything in the requested frame size */
|
||||
|
||||
csnroffst = s->csnroffst;
|
||||
while (csnroffst >= 0 &&
|
||||
bit_alloc(s, mask, psd, bap, frame_bits, csnroffst, 0) < 0)
|
||||
csnroffst -= SNR_INC1;
|
||||
if (csnroffst < 0) {
|
||||
coarse_snr_offset = s->coarse_snr_offset;
|
||||
while (coarse_snr_offset >= 0 &&
|
||||
bit_alloc(s, mask, psd, bap, frame_bits, coarse_snr_offset, 0) < 0)
|
||||
coarse_snr_offset -= SNR_INC1;
|
||||
if (coarse_snr_offset < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Bit allocation failed, try increasing the bitrate, -ab 384k for example!\n");
|
||||
return -1;
|
||||
}
|
||||
while ((csnroffst + SNR_INC1) <= 63 &&
|
||||
while ((coarse_snr_offset + SNR_INC1) <= 63 &&
|
||||
bit_alloc(s, mask, psd, bap1, frame_bits,
|
||||
csnroffst + SNR_INC1, 0) >= 0) {
|
||||
csnroffst += SNR_INC1;
|
||||
coarse_snr_offset + SNR_INC1, 0) >= 0) {
|
||||
coarse_snr_offset += SNR_INC1;
|
||||
memcpy(bap, bap1, sizeof(bap1));
|
||||
}
|
||||
while ((csnroffst + 1) <= 63 &&
|
||||
bit_alloc(s, mask, psd, bap1, frame_bits, csnroffst + 1, 0) >= 0) {
|
||||
csnroffst++;
|
||||
while ((coarse_snr_offset + 1) <= 63 &&
|
||||
bit_alloc(s, mask, psd, bap1, frame_bits, coarse_snr_offset + 1, 0) >= 0) {
|
||||
coarse_snr_offset++;
|
||||
memcpy(bap, bap1, sizeof(bap1));
|
||||
}
|
||||
|
||||
fsnroffst = 0;
|
||||
while ((fsnroffst + SNR_INC1) <= 15 &&
|
||||
fine_snr_offset = 0;
|
||||
while ((fine_snr_offset + SNR_INC1) <= 15 &&
|
||||
bit_alloc(s, mask, psd, bap1, frame_bits,
|
||||
csnroffst, fsnroffst + SNR_INC1) >= 0) {
|
||||
fsnroffst += SNR_INC1;
|
||||
coarse_snr_offset, fine_snr_offset + SNR_INC1) >= 0) {
|
||||
fine_snr_offset += SNR_INC1;
|
||||
memcpy(bap, bap1, sizeof(bap1));
|
||||
}
|
||||
while ((fsnroffst + 1) <= 15 &&
|
||||
while ((fine_snr_offset + 1) <= 15 &&
|
||||
bit_alloc(s, mask, psd, bap1, frame_bits,
|
||||
csnroffst, fsnroffst + 1) >= 0) {
|
||||
fsnroffst++;
|
||||
coarse_snr_offset, fine_snr_offset + 1) >= 0) {
|
||||
fine_snr_offset++;
|
||||
memcpy(bap, bap1, sizeof(bap1));
|
||||
}
|
||||
|
||||
s->csnroffst = csnroffst;
|
||||
s->coarse_snr_offset = coarse_snr_offset;
|
||||
for(ch=0;ch<s->nb_all_channels;ch++)
|
||||
s->fsnroffst[ch] = fsnroffst;
|
||||
s->fine_snr_offset[ch] = fine_snr_offset;
|
||||
#if defined(DEBUG_BITALLOC)
|
||||
{
|
||||
int j;
|
||||
@ -663,22 +663,22 @@ static int AC3_encode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
found:
|
||||
s->sample_rate = freq;
|
||||
s->halfratecod = i;
|
||||
s->fscod = j;
|
||||
s->bsid = 8 + s->halfratecod;
|
||||
s->sr_shift = i;
|
||||
s->sr_code = j;
|
||||
s->bsid = 8 + s->sr_shift;
|
||||
s->bsmod = 0; /* complete main audio service */
|
||||
|
||||
/* bitrate & frame size */
|
||||
bitrate /= 1000;
|
||||
for(i=0;i<19;i++) {
|
||||
if ((ff_ac3_bitrate_tab[i] >> s->halfratecod) == bitrate)
|
||||
if ((ff_ac3_bitrate_tab[i] >> s->sr_shift) == bitrate)
|
||||
break;
|
||||
}
|
||||
if (i == 19)
|
||||
return -1;
|
||||
s->bit_rate = bitrate;
|
||||
s->frmsizecod = i << 1;
|
||||
s->frame_size_min = ff_ac3_frame_size_tab[s->frmsizecod][s->fscod];
|
||||
s->frame_size_min = ff_ac3_frame_size_tab[s->frmsizecod][s->sr_code];
|
||||
s->bits_written = 0;
|
||||
s->samples_written = 0;
|
||||
s->frame_size = s->frame_size_min;
|
||||
@ -695,7 +695,7 @@ static int AC3_encode_init(AVCodecContext *avctx)
|
||||
s->nb_coefs[s->lfe_channel] = 7; /* fixed */
|
||||
}
|
||||
/* initial snr offset */
|
||||
s->csnroffst = 40;
|
||||
s->coarse_snr_offset = 40;
|
||||
|
||||
/* mdct init */
|
||||
fft_init(MDCT_NBITS - 2);
|
||||
@ -718,7 +718,7 @@ static void output_frame_header(AC3EncodeContext *s, unsigned char *frame)
|
||||
|
||||
put_bits(&s->pb, 16, 0x0b77); /* frame header */
|
||||
put_bits(&s->pb, 16, 0); /* crc1: will be filled later */
|
||||
put_bits(&s->pb, 2, s->fscod);
|
||||
put_bits(&s->pb, 2, s->sr_code);
|
||||
put_bits(&s->pb, 6, s->frmsizecod + (s->frame_size - s->frame_size_min));
|
||||
put_bits(&s->pb, 5, s->bsid);
|
||||
put_bits(&s->pb, 3, s->bsmod);
|
||||
@ -900,20 +900,20 @@ static void output_audio_block(AC3EncodeContext *s,
|
||||
baie = (block_num == 0);
|
||||
put_bits(&s->pb, 1, baie);
|
||||
if (baie) {
|
||||
put_bits(&s->pb, 2, s->sdecaycod);
|
||||
put_bits(&s->pb, 2, s->fdecaycod);
|
||||
put_bits(&s->pb, 2, s->sgaincod);
|
||||
put_bits(&s->pb, 2, s->dbkneecod);
|
||||
put_bits(&s->pb, 3, s->floorcod);
|
||||
put_bits(&s->pb, 2, s->slow_decay_code);
|
||||
put_bits(&s->pb, 2, s->fast_decay_code);
|
||||
put_bits(&s->pb, 2, s->slow_gain_code);
|
||||
put_bits(&s->pb, 2, s->db_per_bit_code);
|
||||
put_bits(&s->pb, 3, s->floor_code);
|
||||
}
|
||||
|
||||
/* snr offset */
|
||||
put_bits(&s->pb, 1, baie); /* always present with bai */
|
||||
if (baie) {
|
||||
put_bits(&s->pb, 6, s->csnroffst);
|
||||
put_bits(&s->pb, 6, s->coarse_snr_offset);
|
||||
for(ch=0;ch<s->nb_all_channels;ch++) {
|
||||
put_bits(&s->pb, 4, s->fsnroffst[ch]);
|
||||
put_bits(&s->pb, 3, s->fgaincod[ch]);
|
||||
put_bits(&s->pb, 4, s->fine_snr_offset[ch]);
|
||||
put_bits(&s->pb, 3, s->fast_gain_code[ch]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user