mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
aacenc: cosmetics, indentation, and comment clarification
Correct bad indentation in aaccoder Clarify and correct comments in 3GPP psymodel, other cosmetics.
This commit is contained in:
parent
b7c96769c5
commit
4afedfd8e5
@ -146,34 +146,34 @@ static av_always_inline float quantize_and_encode_band_cost_template(
|
|||||||
curidx *= range;
|
curidx *= range;
|
||||||
curidx += quants[j] + off;
|
curidx += quants[j] + off;
|
||||||
}
|
}
|
||||||
curbits = ff_aac_spectral_bits[cb-1][curidx];
|
curbits = ff_aac_spectral_bits[cb-1][curidx];
|
||||||
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
|
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
|
||||||
if (BT_UNSIGNED) {
|
if (BT_UNSIGNED) {
|
||||||
for (k = 0; k < dim; k++) {
|
for (k = 0; k < dim; k++) {
|
||||||
float t = fabsf(in[i+k]);
|
float t = fabsf(in[i+k]);
|
||||||
float di;
|
float di;
|
||||||
if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow
|
if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow
|
||||||
if (t >= CLIPPED_ESCAPE) {
|
if (t >= CLIPPED_ESCAPE) {
|
||||||
di = t - CLIPPED_ESCAPE;
|
di = t - CLIPPED_ESCAPE;
|
||||||
curbits += 21;
|
curbits += 21;
|
||||||
} else {
|
|
||||||
int c = av_clip(quant(t, Q), 0, 8191);
|
|
||||||
di = t - c*cbrtf(c)*IQ;
|
|
||||||
curbits += av_log2(c)*2 - 4 + 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
di = t - vec[k]*IQ;
|
int c = av_clip(quant(t, Q), 0, 8191);
|
||||||
|
di = t - c*cbrtf(c)*IQ;
|
||||||
|
curbits += av_log2(c)*2 - 4 + 1;
|
||||||
}
|
}
|
||||||
if (vec[k] != 0.0f)
|
} else {
|
||||||
curbits++;
|
di = t - vec[k]*IQ;
|
||||||
rd += di*di;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (k = 0; k < dim; k++) {
|
|
||||||
float di = in[i+k] - vec[k]*IQ;
|
|
||||||
rd += di*di;
|
|
||||||
}
|
}
|
||||||
|
if (vec[k] != 0.0f)
|
||||||
|
curbits++;
|
||||||
|
rd += di*di;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (k = 0; k < dim; k++) {
|
||||||
|
float di = in[i+k] - vec[k]*IQ;
|
||||||
|
rd += di*di;
|
||||||
|
}
|
||||||
|
}
|
||||||
cost += rd * lambda + curbits;
|
cost += rd * lambda + curbits;
|
||||||
resbits += curbits;
|
resbits += curbits;
|
||||||
if (cost >= uplim)
|
if (cost >= uplim)
|
||||||
@ -575,7 +575,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
|
|||||||
int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
|
int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
|
||||||
q1 = qnrg + 30;
|
q1 = qnrg + 30;
|
||||||
q0 = qnrg - 30;
|
q0 = qnrg - 30;
|
||||||
//av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);
|
//av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);
|
||||||
if (q0 < q0low) {
|
if (q0 < q0low) {
|
||||||
q1 += q0low - q0;
|
q1 += q0low - q0;
|
||||||
q0 = q0low;
|
q0 = q0low;
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
* constants for 3GPP AAC psychoacoustic model
|
* constants for 3GPP AAC psychoacoustic model
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define PSY_3GPP_SPREAD_HI 1.5f // spreading factor for ascending threshold spreading (15 dB/Bark)
|
#define PSY_3GPP_THR_SPREAD_HI 1.5f // spreading factor for low-to-hi threshold spreading (15 dB/Bark)
|
||||||
#define PSY_3GPP_SPREAD_LOW 3.0f // spreading factor for descending threshold spreading (30 dB/Bark)
|
#define PSY_3GPP_THR_SPREAD_LOW 3.0f // spreading factor for hi-to-low threshold spreading (30 dB/Bark)
|
||||||
|
|
||||||
#define PSY_3GPP_RPEMIN 0.01f
|
#define PSY_3GPP_RPEMIN 0.01f
|
||||||
#define PSY_3GPP_RPELEV 2.0f
|
#define PSY_3GPP_RPELEV 2.0f
|
||||||
@ -256,8 +256,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
|
|||||||
for (g = 0; g < ctx->num_bands[j] - 1; g++) {
|
for (g = 0; g < ctx->num_bands[j] - 1; g++) {
|
||||||
AacPsyCoeffs *coeff = &coeffs[g];
|
AacPsyCoeffs *coeff = &coeffs[g];
|
||||||
float bark_width = coeffs[g+1].barks - coeffs->barks;
|
float bark_width = coeffs[g+1].barks - coeffs->barks;
|
||||||
coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_LOW);
|
coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_LOW);
|
||||||
coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_HI);
|
coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_HI);
|
||||||
}
|
}
|
||||||
start = 0;
|
start = 0;
|
||||||
for (g = 0; g < ctx->num_bands[j]; g++) {
|
for (g = 0; g < ctx->num_bands[j]; g++) {
|
||||||
@ -395,9 +395,9 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
|
|||||||
AacPsyChannel *pch = &pctx->ch[channel];
|
AacPsyChannel *pch = &pctx->ch[channel];
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int i, w, g;
|
int i, w, g;
|
||||||
const int num_bands = ctx->num_bands[wi->num_windows == 8];
|
const int num_bands = ctx->num_bands[wi->num_windows == 8];
|
||||||
const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8];
|
const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8];
|
||||||
AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
|
AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
|
||||||
|
|
||||||
//calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
|
//calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
|
||||||
for (w = 0; w < wi->num_windows*16; w += 16) {
|
for (w = 0; w < wi->num_windows*16; w += 16) {
|
||||||
@ -410,17 +410,19 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
|
|||||||
start += band_sizes[g];
|
start += band_sizes[g];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"
|
//modify thresholds and energies - spread, threshold in quiet, pre-echo control
|
||||||
for (w = 0; w < wi->num_windows*16; w += 16) {
|
for (w = 0; w < wi->num_windows*16; w += 16) {
|
||||||
|
|
||||||
AacPsyBand *bands = &pch->band[w];
|
AacPsyBand *bands = &pch->band[w];
|
||||||
|
//5.4.2.3 "Spreading" & 5.4.3 "Spreaded Energy Calculation"
|
||||||
for (g = 1; g < num_bands; g++)
|
for (g = 1; g < num_bands; g++)
|
||||||
bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]);
|
bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]);
|
||||||
for (g = num_bands - 2; g >= 0; g--)
|
for (g = num_bands - 2; g >= 0; g--)
|
||||||
bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]);
|
bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]);
|
||||||
|
//5.4.2.4 "Threshold in quiet"
|
||||||
for (g = 0; g < num_bands; g++) {
|
for (g = 0; g < num_bands; g++) {
|
||||||
AacPsyBand *band = &bands[g];
|
AacPsyBand *band = &bands[g];
|
||||||
band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);
|
band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);
|
||||||
|
//5.4.2.5 "Pre-echo control"
|
||||||
if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))
|
if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))
|
||||||
band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,
|
band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,
|
||||||
PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
|
PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
|
||||||
@ -436,6 +438,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
|
|||||||
psy_band->energy = band->energy;
|
psy_band->energy = band->energy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pch->prev_band, pch->band, sizeof(pch->band));
|
memcpy(pch->prev_band, pch->band, sizeof(pch->band));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user