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
330 }330 }
331 for (w = 0; w < group_len; w++) {331 for (w = 0; w < group_len; w++) {
332 FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb];332 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,333 rd += quantize_band_cost(s, &sce->coeffs[start + w*128],
334 s->scoefs + start + w*128, size,334 &s->scoefs[start + w*128], size,
335 sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb],335 sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb],
336 lambda / band->threshold, INFINITY, NULL, 0);336 lambda / band->threshold, INFINITY, NULL, 0);
337 }337 }
@@ -461,8 +461,8 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 123 unmodified lines
461 continue;461 continue;
462 }462 }
463 for (w = 0; w < group_len; w++) {463 for (w = 0; w < group_len; w++) {
464 bits += quantize_band_cost(s, sce->coeffs + start + w*128,464 bits += quantize_band_cost(s, &sce->coeffs[start + w*128],
465 s->scoefs + start + w*128, size,465 &s->scoefs[start + w*128], size,
466 sce->sf_idx[win*16+swb],466 sce->sf_idx[win*16+swb],
467 aac_cb_out_map[cb],467 aac_cb_out_map[cb],
468 0, INFINITY, NULL, 0);468 0, INFINITY, NULL, 0);
@@ -636,7 +636,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 167 unmodified lines
636 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {636 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
637 start = w*128;637 start = w*128;
638 for (g = 0; g < sce->ics.num_swb; g++) {638 for (g = 0; g < sce->ics.num_swb; g++) {
639 const float *coefs = sce->coeffs + start;639 const float *coefs = &sce->coeffs[start];
640 float qmin, qmax;640 float qmin, qmax;
641 int nz = 0;641 int nz = 0;
642 642
@@ -800,8 +800,8 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 157 unmodified lines
800 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {800 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
801 start = w*128;801 start = w*128;
802 for (g = 0; g < sce->ics.num_swb; g++) {802 for (g = 0; g < sce->ics.num_swb; g++) {
803 const float *coefs = sce->coeffs + start;803 const float *coefs = &sce->coeffs[start];
804 const float *scaled = s->scoefs + start;804 const float *scaled = &s->scoefs[start];
805 int bits = 0;805 int bits = 0;
806 int cb;806 int cb;
807 float dist = 0.0f;807 float dist = 0.0f;
@@ -896,7 +896,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 88 unmodified lines
896 }896 }
897 } else {897 } else {
898 for (w = 0; w < 8; w++) {898 for (w = 0; w < 8; w++) {
899 const float *coeffs = sce->coeffs + w*128;899 const float *coeffs = &sce->coeffs[w*128];
900 curband = start = 0;900 curband = start = 0;
901 for (i = 0; i < 128; i++) {901 for (i = 0; i < 128; i++) {
902 if (i - start >= sce->ics.swb_sizes[curband]) {902 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
921 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {921 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
922 start = w*128;922 start = w*128;
923 for (g = 0; g < sce->ics.num_swb; g++) {923 for (g = 0; g < sce->ics.num_swb; g++) {
924 float *coefs = sce->coeffs + start;924 float *coefs = &sce->coeffs[start];
925 const int size = sce->ics.swb_sizes[g];925 const int size = sce->ics.swb_sizes[g];
926 int start2 = start, end2 = start + size, peakpos = start;926 int start2 = start, end2 = start + size, peakpos = start;
927 float maxval = -1, thr = 0.0f, t;927 float maxval = -1, thr = 0.0f, t;
@@ -962,8 +962,8 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 34 unmodified lines
962 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {962 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
963 start = w*128;963 start = w*128;
964 for (g = 0; g < sce->ics.num_swb; g++) {964 for (g = 0; g < sce->ics.num_swb; g++) {
965 const float *coefs = sce->coeffs + start;965 const float *coefs = &sce->coeffs[start];
966 const float *scaled = s->scoefs + start;966 const float *scaled = &s->scoefs[start];
967 const int size = sce->ics.swb_sizes[g];967 const int size = sce->ics.swb_sizes[g];
968 int scf, prev_scf, step;968 int scf, prev_scf, step;
969 int min_scf = -1, max_scf = 256;969 int min_scf = -1, max_scf = 256;
@@ -1229,22 +1229,22 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 259 unmodified lines
1229 float minthr = FFMIN(band0->threshold, band1->threshold);1229 float minthr = FFMIN(band0->threshold, band1->threshold);
1230 float maxthr = FFMAX(band0->threshold, band1->threshold);1230 float maxthr = FFMAX(band0->threshold, band1->threshold);
1231 for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {1231 for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
1232 M[i] = (sce0->pcoeffs[start+(w+w2)*128+i]1232 M[i] = (sce0->coeffs[start+(w+w2)*128+i]
1233 + sce1->pcoeffs[start+(w+w2)*128+i]) * 0.5;1233 + sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
1234 S[i] = M[i]1234 S[i] = M[i]
1235 - sce1->pcoeffs[start+(w+w2)*128+i];1235 - sce1->coeffs[start+(w+w2)*128+i];
1236 }1236 }
1237 abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);1237 abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
1238 abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);1238 abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
1239 abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);1239 abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
1240 abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);1240 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],
1242 L34,1242 L34,
1243 sce0->ics.swb_sizes[g],1243 sce0->ics.swb_sizes[g],
1244 sce0->sf_idx[(w+w2)*16+g],1244 sce0->sf_idx[(w+w2)*16+g],
1245 sce0->band_type[(w+w2)*16+g],1245 sce0->band_type[(w+w2)*16+g],
1246 lambda / band0->threshold, INFINITY, NULL, 0);1246 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],
1248 R34,1248 R34,
1249 sce1->ics.swb_sizes[g],1249 sce1->ics.swb_sizes[g],
1250 sce1->sf_idx[(w+w2)*16+g],1250 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