History

aacenc: cosmetics, indentation, and comment clarification

Correct bad indentation in aaccoder Clarify and correct comments in 3GPP psymodel, other cosmetics.

Nathan Caldwell committed 15 years ago

Commit 4afedfd1 parent b7c96762 files · +37 −34Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/aaccoder.c +25 −25
  2. libavcodec/aacpsy.c +12 −9
libavcodec/aaccoder.c+25−25
@@ -146,34 +146,34 @@ static av_always_inline float quantize_and_encode_band_cost_template( · 145 unmodified lines
146 curidx *= range;146 curidx *= range;
147 curidx += quants[j] + off;147 curidx += quants[j] + off;
148 }148 }
149 curbits = ff_aac_spectral_bits[cb-1][curidx];149 curbits = ff_aac_spectral_bits[cb-1][curidx];
150 vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];150 vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
151 if (BT_UNSIGNED) {151 if (BT_UNSIGNED) {
152 for (k = 0; k < dim; k++) {152 for (k = 0; k < dim; k++) {
153 float t = fabsf(in[i+k]);153 float t = fabsf(in[i+k]);
154 float di;154 float di;
155 if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow155 if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow
156 if (t >= CLIPPED_ESCAPE) {156 if (t >= CLIPPED_ESCAPE) {
157 di = t - CLIPPED_ESCAPE;157 di = t - CLIPPED_ESCAPE;
158 curbits += 21;158 curbits += 21;
159 } else {
160 int c = av_clip(quant(t, Q), 0, 8191);
161 di = t - c*cbrtf(c)*IQ;
162 curbits += av_log2(c)*2 - 4 + 1;
163 }
164 } else {159 } else {
165 di = t - vec[k]*IQ;160 int c = av_clip(quant(t, Q), 0, 8191);
161 di = t - c*cbrtf(c)*IQ;
162 curbits += av_log2(c)*2 - 4 + 1;
166 }163 }
167 if (vec[k] != 0.0f)164 } else {
168 curbits++;165 di = t - vec[k]*IQ;
169 rd += di*di;
170 }
171 } else {
172 for (k = 0; k < dim; k++) {
173 float di = in[i+k] - vec[k]*IQ;
174 rd += di*di;
175 }166 }
167 if (vec[k] != 0.0f)
168 curbits++;
169 rd += di*di;
176 }170 }
171 } else {
172 for (k = 0; k < dim; k++) {
173 float di = in[i+k] - vec[k]*IQ;
174 rd += di*di;
175 }
176 }
177 cost += rd * lambda + curbits;177 cost += rd * lambda + curbits;
178 resbits += curbits;178 resbits += curbits;
179 if (cost >= uplim)179 if (cost >= uplim)
@@ -575,7 +575,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 395 unmodified lines
575 int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);575 int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
576 q1 = qnrg + 30;576 q1 = qnrg + 30;
577 q0 = qnrg - 30;577 q0 = qnrg - 30;
578 //av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);578 //av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);
579 if (q0 < q0low) {579 if (q0 < q0low) {
580 q1 += q0low - q0;580 q1 += q0low - q0;
581 q0 = q0low;581 q0 = q0low;
libavcodec/aacpsy.c+12−9
@@ -39,8 +39,8 @@ · 38 unmodified lines
39 * constants for 3GPP AAC psychoacoustic model39 * constants for 3GPP AAC psychoacoustic model
40 * @{40 * @{
41 */41 */
42#define PSY_3GPP_SPREAD_HI 1.5f // spreading factor for ascending threshold spreading (15 dB/Bark)42#define PSY_3GPP_THR_SPREAD_HI 1.5f // spreading factor for low-to-hi threshold spreading (15 dB/Bark)
43#define PSY_3GPP_SPREAD_LOW 3.0f // spreading factor for descending threshold spreading (30 dB/Bark)43#define PSY_3GPP_THR_SPREAD_LOW 3.0f // spreading factor for hi-to-low threshold spreading (30 dB/Bark)
44 44
45#define PSY_3GPP_RPEMIN 0.01f45#define PSY_3GPP_RPEMIN 0.01f
46#define PSY_3GPP_RPELEV 2.0f46#define PSY_3GPP_RPELEV 2.0f
@@ -256,8 +256,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { · 209 unmodified lines
256 for (g = 0; g < ctx->num_bands[j] - 1; g++) {256 for (g = 0; g < ctx->num_bands[j] - 1; g++) {
257 AacPsyCoeffs *coeff = &coeffs[g];257 AacPsyCoeffs *coeff = &coeffs[g];
258 float bark_width = coeffs[g+1].barks - coeffs->barks;258 float bark_width = coeffs[g+1].barks - coeffs->barks;
259 coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_LOW);259 coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_LOW);
260 coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_HI);260 coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_HI);
261 }261 }
262 start = 0;262 start = 0;
263 for (g = 0; g < ctx->num_bands[j]; g++) {263 for (g = 0; g < ctx->num_bands[j]; g++) {
@@ -395,9 +395,9 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, · 131 unmodified lines
395 AacPsyChannel *pch = &pctx->ch[channel];395 AacPsyChannel *pch = &pctx->ch[channel];
396 int start = 0;396 int start = 0;
397 int i, w, g;397 int i, w, g;
398 const int num_bands = ctx->num_bands[wi->num_windows == 8];398 const int num_bands = ctx->num_bands[wi->num_windows == 8];
399 const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8];399 const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8];
400 AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];400 AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
401 401
402 //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"402 //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
403 for (w = 0; w < wi->num_windows*16; w += 16) {403 for (w = 0; w < wi->num_windows*16; w += 16) {
@@ -410,17 +410,19 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, · 6 unmodified lines
410 start += band_sizes[g];410 start += band_sizes[g];
411 }411 }
412 }412 }
413 //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"413 //modify thresholds and energies - spread, threshold in quiet, pre-echo control
414 for (w = 0; w < wi->num_windows*16; w += 16) {414 for (w = 0; w < wi->num_windows*16; w += 16) {
415
416 AacPsyBand *bands = &pch->band[w];415 AacPsyBand *bands = &pch->band[w];
416 //5.4.2.3 "Spreading" & 5.4.3 "Spreaded Energy Calculation"
417 for (g = 1; g < num_bands; g++)417 for (g = 1; g < num_bands; g++)
418 bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]);418 bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]);
419 for (g = num_bands - 2; g >= 0; g--)419 for (g = num_bands - 2; g >= 0; g--)
420 bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]);420 bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]);
421 //5.4.2.4 "Threshold in quiet"
421 for (g = 0; g < num_bands; g++) {422 for (g = 0; g < num_bands; g++) {
422 AacPsyBand *band = &bands[g];423 AacPsyBand *band = &bands[g];
423 band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);424 band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);
425 //5.4.2.5 "Pre-echo control"
424 if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))426 if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))
425 band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,427 band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,
426 PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));428 PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
@@ -436,6 +438,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, · 9 unmodified lines
436 psy_band->energy = band->energy;438 psy_band->energy = band->energy;
437 }439 }
438 }440 }
441
439 memcpy(pch->prev_band, pch->band, sizeof(pch->band));442 memcpy(pch->prev_band, pch->band, sizeof(pch->band));
440}443}
441 444

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t