History

aacenc: coding style changes

This commit only changes the coding style to a saner way of accessing coefficients (makes more sense to get the memory address of a coefficients and start from there rather than adding arbitrary numbers to offset a pointer). Some compilers might detect an out of bounds access easier. Also the way M/S and IS coefficients are calculated has been changed, but should still have the same result (with the exception that IS now applies from the normal coefficients rather than the pristine ones, this is needed for upcoming commits).

Rostislav Pehlivanov committed 11 years ago

Commit 32be2641 parent 907373e2 files · +23 −21Browse files

Showing the changes to libavcodec/aaccoder.c (1 of 2 files). Show all

Unified · Split

libavcodec/aaccoder.c+16−16
@@ -330,8 +330,8 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 329 unmodified lines
330330 }
331331 for (w = 0; w < group_len; w++) {
332332 FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb];
333− rd += quantize_band_cost(s, sce->coeffs + start + w*128,
334− s->scoefs + start + w*128, size,
333+ rd += quantize_band_cost(s, &sce->coeffs[start + w*128],
334+ &s->scoefs[start + w*128], size,
335335 sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb],
336336 lambda / band->threshold, INFINITY, NULL, 0);
337337 }
@@ -461,8 +461,8 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 123 unmodified lines
461461 continue;
462462 }
463463 for (w = 0; w < group_len; w++) {
464− bits += quantize_band_cost(s, sce->coeffs + start + w*128,
465− s->scoefs + start + w*128, size,
464+ bits += quantize_band_cost(s, &sce->coeffs[start + w*128],
465+ &s->scoefs[start + w*128], size,
466466 sce->sf_idx[win*16+swb],
467467 aac_cb_out_map[cb],
468468 0, INFINITY, NULL, 0);
@@ -636,7 +636,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 167 unmodified lines
636636 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
637637 start = w*128;
638638 for (g = 0; g < sce->ics.num_swb; g++) {
639− const float *coefs = sce->coeffs + start;
639+ const float *coefs = &sce->coeffs[start];
640640 float qmin, qmax;
641641 int nz = 0;
642642
@@ -800,8 +800,8 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 157 unmodified lines
800800 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
801801 start = w*128;
802802 for (g = 0; g < sce->ics.num_swb; g++) {
803− const float *coefs = sce->coeffs + start;
804− const float *scaled = s->scoefs + start;
803+ const float *coefs = &sce->coeffs[start];
804+ const float *scaled = &s->scoefs[start];
805805 int bits = 0;
806806 int cb;
807807 float dist = 0.0f;
@@ -896,7 +896,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 88 unmodified lines
896896 }
897897 } else {
898898 for (w = 0; w < 8; w++) {
899− const float *coeffs = sce->coeffs + w*128;
899+ const float *coeffs = &sce->coeffs[w*128];
900900 curband = start = 0;
901901 for (i = 0; i < 128; i++) {
902902 if (i - start >= sce->ics.swb_sizes[curband]) {
@@ -921,7 +921,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 18 unmodified lines
921921 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
922922 start = w*128;
923923 for (g = 0; g < sce->ics.num_swb; g++) {
924− float *coefs = sce->coeffs + start;
924+ float *coefs = &sce->coeffs[start];
925925 const int size = sce->ics.swb_sizes[g];
926926 int start2 = start, end2 = start + size, peakpos = start;
927927 float maxval = -1, thr = 0.0f, t;
@@ -962,8 +962,8 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 34 unmodified lines
962962 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
963963 start = w*128;
964964 for (g = 0; g < sce->ics.num_swb; g++) {
965− const float *coefs = sce->coeffs + start;
966− const float *scaled = s->scoefs + start;
965+ const float *coefs = &sce->coeffs[start];
966+ const float *scaled = &s->scoefs[start];
967967 const int size = sce->ics.swb_sizes[g];
968968 int scf, prev_scf, step;
969969 int min_scf = -1, max_scf = 256;
@@ -1229,22 +1229,22 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 259 unmodified lines
12291229 float minthr = FFMIN(band0->threshold, band1->threshold);
12301230 float maxthr = FFMAX(band0->threshold, band1->threshold);
12311231 for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
1232− M[i] = (sce0->pcoeffs[start+(w+w2)*128+i]
1233− + sce1->pcoeffs[start+(w+w2)*128+i]) * 0.5;
1232+ M[i] = (sce0->coeffs[start+(w+w2)*128+i]
1233+ + sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
12341234 S[i] = M[i]
1235− - sce1->pcoeffs[start+(w+w2)*128+i];
1235+ - sce1->coeffs[start+(w+w2)*128+i];
12361236 }
12371237 abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
12381238 abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
12391239 abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
12401240 abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
1241− dist1 += quantize_band_cost(s, sce0->coeffs + start + (w+w2)*128,
1241+ dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
12421242 L34,
12431243 sce0->ics.swb_sizes[g],
12441244 sce0->sf_idx[(w+w2)*16+g],
12451245 sce0->band_type[(w+w2)*16+g],
12461246 lambda / band0->threshold, INFINITY, NULL, 0);
1247− dist1 += quantize_band_cost(s, sce1->coeffs + start + (w+w2)*128,
1247+ dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
12481248 R34,
12491249 sce1->ics.swb_sizes[g],
12501250 sce1->sf_idx[(w+w2)*16+g],

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