Originally committed as revision 11193 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
@@ -72,7 +72,7 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd, | |||||
for(i=j;i<end1;i++) { | for(i=j;i<end1;i++) { | ||||
/* logadd */ | /* logadd */ | ||||
int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255); | int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255); | ||||
v = FFMAX(v, psd[j]) + ff_ac3_latab[adr]; | |||||
v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr]; | |||||
j++; | j++; | ||||
} | } | ||||
bndpsd[k]=v; | bndpsd[k]=v; | ||||
@@ -149,7 +149,7 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd, | |||||
if (tmp > 0) { | if (tmp > 0) { | ||||
excite[bin] += tmp >> 2; | excite[bin] += tmp >> 2; | ||||
} | } | ||||
mask[bin] = FFMAX(ff_ac3_hth[bin >> s->halfratecod][s->fscod], excite[bin]); | |||||
mask[bin] = FFMAX(ff_ac3_hearing_threshold_tab[bin >> s->halfratecod][s->fscod], excite[bin]); | |||||
} | } | ||||
/* delta bit allocation */ | /* delta bit allocation */ | ||||
@@ -187,10 +187,10 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end, | |||||
j = masktab[start]; | j = masktab[start]; | ||||
do { | do { | ||||
v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor; | v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor; | ||||
end1 = FFMIN(bndtab[j] + ff_ac3_bndsz[j], end); | |||||
end1 = FFMIN(bndtab[j] + ff_ac3_critical_band_size_tab[j], end); | |||||
for (k = i; k < end1; k++) { | for (k = i; k < end1; k++) { | ||||
address = av_clip((psd[i] - v) >> 5, 0, 63); | address = av_clip((psd[i] - v) >> 5, 0, 63); | ||||
bap[i] = ff_ac3_baptab[address]; | |||||
bap[i] = ff_ac3_bap_tab[address]; | |||||
i++; | i++; | ||||
} | } | ||||
} while (end > bndtab[j++]); | } while (end > bndtab[j++]); | ||||
@@ -231,7 +231,7 @@ void ac3_common_init(void) | |||||
l = 0; | l = 0; | ||||
for(i=0;i<50;i++) { | for(i=0;i<50;i++) { | ||||
bndtab[i] = l; | bndtab[i] = l; | ||||
v = ff_ac3_bndsz[i]; | |||||
v = ff_ac3_critical_band_size_tab[i]; | |||||
for(j=0;j<v;j++) masktab[k++]=i; | for(j=0;j<v;j++) masktab[k++]=i; | ||||
l += v; | l += v; | ||||
} | } | ||||
@@ -76,10 +76,10 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr) | |||||
hdr->lfeon = get_bits1(&gbc); | hdr->lfeon = get_bits1(&gbc); | ||||
hdr->halfratecod = FFMAX(hdr->bsid, 8) - 8; | hdr->halfratecod = FFMAX(hdr->bsid, 8) - 8; | ||||
hdr->sample_rate = ff_ac3_freqs[hdr->fscod] >> hdr->halfratecod; | |||||
hdr->bit_rate = (ff_ac3_bitratetab[hdr->frmsizecod>>1] * 1000) >> hdr->halfratecod; | |||||
hdr->channels = ff_ac3_channels[hdr->acmod] + hdr->lfeon; | |||||
hdr->frame_size = ff_ac3_frame_sizes[hdr->frmsizecod][hdr->fscod] * 2; | |||||
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->channels = ff_ac3_channels_tab[hdr->acmod] + hdr->lfeon; | |||||
hdr->frame_size = ff_ac3_frame_size_tab[hdr->frmsizecod][hdr->fscod] * 2; | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -125,11 +125,11 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, | |||||
if(fscod2 == 3) | if(fscod2 == 3) | ||||
return 0; | return 0; | ||||
*sample_rate = ff_ac3_freqs[fscod2] / 2; | |||||
*sample_rate = ff_ac3_sample_rate_tab[fscod2] / 2; | |||||
} else { | } else { | ||||
numblkscod = get_bits(&bits, 2); | numblkscod = get_bits(&bits, 2); | ||||
*sample_rate = ff_ac3_freqs[fscod]; | |||||
*sample_rate = ff_ac3_sample_rate_tab[fscod]; | |||||
} | } | ||||
acmod = get_bits(&bits, 3); | acmod = get_bits(&bits, 3); | ||||
@@ -137,7 +137,7 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, | |||||
*samples = eac3_blocks[numblkscod] * 256; | *samples = eac3_blocks[numblkscod] * 256; | ||||
*bit_rate = frmsiz * (*sample_rate) * 16 / (*samples); | *bit_rate = frmsiz * (*sample_rate) * 16 / (*samples); | ||||
*channels = ff_ac3_channels[acmod] + lfeon; | |||||
*channels = ff_ac3_channels_tab[acmod] + lfeon; | |||||
return frmsiz * 2; | return frmsiz * 2; | ||||
} | } | ||||
@@ -947,11 +947,11 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk) | |||||
/* bit allocation information */ | /* bit allocation information */ | ||||
if (get_bits1(gb)) { | if (get_bits1(gb)) { | ||||
ctx->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gb, 2)] >> ctx->bit_alloc_params.halfratecod; | |||||
ctx->bit_alloc_params.fdecay = ff_fdecaytab[get_bits(gb, 2)] >> ctx->bit_alloc_params.halfratecod; | |||||
ctx->bit_alloc_params.sgain = ff_sgaintab[get_bits(gb, 2)]; | |||||
ctx->bit_alloc_params.dbknee = ff_dbkneetab[get_bits(gb, 2)]; | |||||
ctx->bit_alloc_params.floor = ff_floortab[get_bits(gb, 3)]; | |||||
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.floor = ff_ac3_floor_tab[get_bits(gb, 3)]; | |||||
for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) { | for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) { | ||||
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); | bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); | ||||
} | } | ||||
@@ -963,7 +963,7 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk) | |||||
csnr = (get_bits(gb, 6) - 15) << 4; | csnr = (get_bits(gb, 6) - 15) << 4; | ||||
for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { /* snr offset and fast gain */ | for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { /* snr offset and fast gain */ | ||||
ctx->snroffst[ch] = (csnr + get_bits(gb, 4)) << 2; | ctx->snroffst[ch] = (csnr + get_bits(gb, 4)) << 2; | ||||
ctx->fgain[ch] = ff_fgaintab[get_bits(gb, 3)]; | |||||
ctx->fgain[ch] = ff_ac3_fast_gain_tab[get_bits(gb, 3)]; | |||||
} | } | ||||
memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); | memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); | ||||
} | } | ||||
@@ -451,7 +451,7 @@ static void bit_alloc_masking(AC3EncodeContext *s, | |||||
psd[blk][ch], bndpsd[blk][ch]); | psd[blk][ch], bndpsd[blk][ch]); | ||||
ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, bndpsd[blk][ch], | ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, bndpsd[blk][ch], | ||||
0, s->nb_coefs[ch], | 0, s->nb_coefs[ch], | ||||
ff_fgaintab[s->fgaincod[ch]], | |||||
ff_ac3_fast_gain_tab[s->fgaincod[ch]], | |||||
ch == s->lfe_channel, | ch == s->lfe_channel, | ||||
DBA_NONE, 0, NULL, NULL, NULL, | DBA_NONE, 0, NULL, NULL, NULL, | ||||
mask[blk][ch]); | mask[blk][ch]); | ||||
@@ -519,11 +519,11 @@ static int compute_bit_allocation(AC3EncodeContext *s, | |||||
/* compute real values */ | /* compute real values */ | ||||
s->bit_alloc.fscod = s->fscod; | s->bit_alloc.fscod = s->fscod; | ||||
s->bit_alloc.halfratecod = s->halfratecod; | s->bit_alloc.halfratecod = s->halfratecod; | ||||
s->bit_alloc.sdecay = ff_sdecaytab[s->sdecaycod] >> s->halfratecod; | |||||
s->bit_alloc.fdecay = ff_fdecaytab[s->fdecaycod] >> s->halfratecod; | |||||
s->bit_alloc.sgain = ff_sgaintab[s->sgaincod]; | |||||
s->bit_alloc.dbknee = ff_dbkneetab[s->dbkneecod]; | |||||
s->bit_alloc.floor = ff_floortab[s->floorcod]; | |||||
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]; | |||||
/* header size */ | /* header size */ | ||||
frame_bits += 65; | frame_bits += 65; | ||||
@@ -657,7 +657,7 @@ static int AC3_encode_init(AVCodecContext *avctx) | |||||
/* frequency */ | /* frequency */ | ||||
for(i=0;i<3;i++) { | for(i=0;i<3;i++) { | ||||
for(j=0;j<3;j++) | for(j=0;j<3;j++) | ||||
if ((ff_ac3_freqs[j] >> i) == freq) | |||||
if ((ff_ac3_sample_rate_tab[j] >> i) == freq) | |||||
goto found; | goto found; | ||||
} | } | ||||
return -1; | return -1; | ||||
@@ -671,14 +671,14 @@ static int AC3_encode_init(AVCodecContext *avctx) | |||||
/* bitrate & frame size */ | /* bitrate & frame size */ | ||||
bitrate /= 1000; | bitrate /= 1000; | ||||
for(i=0;i<19;i++) { | for(i=0;i<19;i++) { | ||||
if ((ff_ac3_bitratetab[i] >> s->halfratecod) == bitrate) | |||||
if ((ff_ac3_bitrate_tab[i] >> s->halfratecod) == bitrate) | |||||
break; | break; | ||||
} | } | ||||
if (i == 19) | if (i == 19) | ||||
return -1; | return -1; | ||||
s->bit_rate = bitrate; | s->bit_rate = bitrate; | ||||
s->frmsizecod = i << 1; | s->frmsizecod = i << 1; | ||||
s->frame_size_min = ff_ac3_frame_sizes[s->frmsizecod][s->fscod]; | |||||
s->frame_size_min = ff_ac3_frame_size_tab[s->frmsizecod][s->fscod]; | |||||
s->bits_written = 0; | s->bits_written = 0; | ||||
s->samples_written = 0; | s->samples_written = 0; | ||||
s->frame_size = s->frame_size_min; | s->frame_size = s->frame_size_min; | ||||
@@ -30,7 +30,7 @@ | |||||
* Possible frame sizes. | * Possible frame sizes. | ||||
* from ATSC A/52 Table 5.18 Frame Size Code Table. | * from ATSC A/52 Table 5.18 Frame Size Code Table. | ||||
*/ | */ | ||||
const uint16_t ff_ac3_frame_sizes[38][3] = { | |||||
const uint16_t ff_ac3_frame_size_tab[38][3] = { | |||||
{ 64, 69, 96 }, | { 64, 69, 96 }, | ||||
{ 64, 70, 96 }, | { 64, 70, 96 }, | ||||
{ 80, 87, 120 }, | { 80, 87, 120 }, | ||||
@@ -75,15 +75,15 @@ const uint16_t ff_ac3_frame_sizes[38][3] = { | |||||
* Maps audio coding mode (acmod) to number of full-bandwidth channels. | * Maps audio coding mode (acmod) to number of full-bandwidth channels. | ||||
* from ATSC A/52 Table 5.8 Audio Coding Mode | * from ATSC A/52 Table 5.8 Audio Coding Mode | ||||
*/ | */ | ||||
const uint8_t ff_ac3_channels[8] = { | |||||
const uint8_t ff_ac3_channels_tab[8] = { | |||||
2, 1, 2, 3, 3, 4, 4, 5 | 2, 1, 2, 3, 3, 4, 4, 5 | ||||
}; | }; | ||||
/* possible frequencies */ | /* possible frequencies */ | ||||
const uint16_t ff_ac3_freqs[3] = { 48000, 44100, 32000 }; | |||||
const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 }; | |||||
/* possible bitrates */ | /* possible bitrates */ | ||||
const uint16_t ff_ac3_bitratetab[19] = { | |||||
const uint16_t ff_ac3_bitrate_tab[19] = { | |||||
32, 40, 48, 56, 64, 80, 96, 112, 128, | 32, 40, 48, 56, 64, 80, 96, 112, 128, | ||||
160, 192, 224, 256, 320, 384, 448, 512, 576, 640 | 160, 192, 224, 256, 320, 384, 448, 512, 576, 640 | ||||
}; | }; | ||||
@@ -126,7 +126,7 @@ const int16_t ff_ac3_window[256] = { | |||||
32767,32767,32767,32767,32767,32767,32767,32767, | 32767,32767,32767,32767,32767,32767,32767,32767, | ||||
}; | }; | ||||
const uint8_t ff_ac3_latab[260]= { | |||||
const uint8_t ff_ac3_log_add_tab[260]= { | |||||
0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37, | 0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37, | ||||
0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f, | 0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f, | ||||
0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27, | 0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27, | ||||
@@ -155,7 +155,7 @@ const uint8_t ff_ac3_latab[260]= { | |||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | ||||
}; | }; | ||||
const uint16_t ff_ac3_hth[50][3]= { | |||||
const uint16_t ff_ac3_hearing_threshold_tab[50][3]= { | |||||
{ 0x04d0,0x04f0,0x0580 }, | { 0x04d0,0x04f0,0x0580 }, | ||||
{ 0x04d0,0x04f0,0x0580 }, | { 0x04d0,0x04f0,0x0580 }, | ||||
{ 0x0440,0x0460,0x04b0 }, | { 0x0440,0x0460,0x04b0 }, | ||||
@@ -208,7 +208,7 @@ const uint16_t ff_ac3_hth[50][3]= { | |||||
{ 0x0840,0x0840,0x04e0 }, | { 0x0840,0x0840,0x04e0 }, | ||||
}; | }; | ||||
const uint8_t ff_ac3_baptab[64]= { | |||||
const uint8_t ff_ac3_bap_tab[64]= { | |||||
0, 1, 1, 1, 1, 1, 2, 2, 3, 3, | 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, | ||||
3, 4, 4, 5, 5, 6, 6, 6, 6, 7, | 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, | ||||
7, 7, 7, 8, 8, 8, 8, 9, 9, 9, | 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, | ||||
@@ -218,31 +218,31 @@ const uint8_t ff_ac3_baptab[64]= { | |||||
15, 15, 15, 15, | 15, 15, 15, 15, | ||||
}; | }; | ||||
const uint8_t ff_sdecaytab[4]={ | |||||
const uint8_t ff_ac3_slow_decay_tab[4]={ | |||||
0x0f, 0x11, 0x13, 0x15, | 0x0f, 0x11, 0x13, 0x15, | ||||
}; | }; | ||||
const uint8_t ff_fdecaytab[4]={ | |||||
const uint8_t ff_ac3_fast_decay_tab[4]={ | |||||
0x3f, 0x53, 0x67, 0x7b, | 0x3f, 0x53, 0x67, 0x7b, | ||||
}; | }; | ||||
const uint16_t ff_sgaintab[4]= { | |||||
const uint16_t ff_ac3_slow_gain_tab[4]= { | |||||
0x540, 0x4d8, 0x478, 0x410, | 0x540, 0x4d8, 0x478, 0x410, | ||||
}; | }; | ||||
const uint16_t ff_dbkneetab[4]= { | |||||
const uint16_t ff_ac3_db_per_bit_tab[4]= { | |||||
0x000, 0x700, 0x900, 0xb00, | 0x000, 0x700, 0x900, 0xb00, | ||||
}; | }; | ||||
const int16_t ff_floortab[8]= { | |||||
const int16_t ff_ac3_floor_tab[8]= { | |||||
0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800, | 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800, | ||||
}; | }; | ||||
const uint16_t ff_fgaintab[8]= { | |||||
const uint16_t ff_ac3_fast_gain_tab[8]= { | |||||
0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400, | 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400, | ||||
}; | }; | ||||
const uint8_t ff_ac3_bndsz[50]={ | |||||
const uint8_t ff_ac3_critical_band_size_tab[50]={ | |||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, | ||||
3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24 | 3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24 | ||||
@@ -24,20 +24,20 @@ | |||||
#include "common.h" | #include "common.h" | ||||
extern const uint16_t ff_ac3_frame_sizes[38][3]; | |||||
extern const uint8_t ff_ac3_channels[8]; | |||||
extern const uint16_t ff_ac3_freqs[3]; | |||||
extern const uint16_t ff_ac3_bitratetab[19]; | |||||
extern const uint16_t ff_ac3_frame_size_tab[38][3]; | |||||
extern const uint8_t ff_ac3_channels_tab[8]; | |||||
extern const uint16_t ff_ac3_sample_rate_tab[3]; | |||||
extern const uint16_t ff_ac3_bitrate_tab[19]; | |||||
extern const int16_t ff_ac3_window[256]; | extern const int16_t ff_ac3_window[256]; | ||||
extern const uint8_t ff_ac3_latab[260]; | |||||
extern const uint16_t ff_ac3_hth[50][3]; | |||||
extern const uint8_t ff_ac3_baptab[64]; | |||||
extern const uint8_t ff_sdecaytab[4]; | |||||
extern const uint8_t ff_fdecaytab[4]; | |||||
extern const uint16_t ff_sgaintab[4]; | |||||
extern const uint16_t ff_dbkneetab[4]; | |||||
extern const int16_t ff_floortab[8]; | |||||
extern const uint16_t ff_fgaintab[8]; | |||||
extern const uint8_t ff_ac3_bndsz[50]; | |||||
extern const uint8_t ff_ac3_log_add_tab[260]; | |||||
extern const uint16_t ff_ac3_hearing_threshold_tab[50][3]; | |||||
extern const uint8_t ff_ac3_bap_tab[64]; | |||||
extern const uint8_t ff_ac3_slow_decay_tab[4]; | |||||
extern const uint8_t ff_ac3_fast_decay_tab[4]; | |||||
extern const uint16_t ff_ac3_slow_gain_tab[4]; | |||||
extern const uint16_t ff_ac3_db_per_bit_tab[4]; | |||||
extern const int16_t ff_ac3_floor_tab[8]; | |||||
extern const uint16_t ff_ac3_fast_gain_tab[8]; | |||||
extern const uint8_t ff_ac3_critical_band_size_tab[50]; | |||||
#endif /* FFMPEG_AC3TAB_H */ | #endif /* FFMPEG_AC3TAB_H */ |