diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-08-21 18:30:51 +0100 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2015-08-21 18:30:51 +0100 |
commit | 32be264cea542b4dc721b10092bf1dfe511a28ee (patch) | |
tree | 0b45e999b69f460e9e10728eecc8557174c145ac /libavcodec/aacenc.c | |
parent | 907373ea9d23f782d438dd18babfd75cb5ab305a (diff) | |
download | ffmpeg-32be264cea542b4dc721b10092bf1dfe511a28ee.tar.gz |
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).
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/aacenc.c')
-rw-r--r-- | libavcodec/aacenc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index d87a90c7a0..8d48790745 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -149,7 +149,7 @@ static void apply_window_and_mdct(AACEncContext *s, SingleChannelElement *sce, s->mdct1024.mdct_calc(&s->mdct1024, sce->coeffs, output); else for (i = 0; i < 1024; i += 128) - s->mdct128.mdct_calc(&s->mdct128, sce->coeffs + i, output + i*2); + s->mdct128.mdct_calc(&s->mdct128, &sce->coeffs[i], output + i*2); memcpy(audio, audio + 1024, sizeof(audio[0]) * 1024); memcpy(sce->pcoeffs, sce->coeffs, sizeof(sce->pcoeffs)); } @@ -210,15 +210,17 @@ static void adjust_frame_information(ChannelElement *cpe, int chans) int p = -1 + 2 * (cpe->ch[1].band_type[w*16+g] - 14); float scale = cpe->ch[0].is_ener[w*16+g]; for (i = 0; i < ics->swb_sizes[g]; i++) { - cpe->ch[0].coeffs[start+i] = (cpe->ch[0].pcoeffs[start+i] + p*cpe->ch[1].pcoeffs[start+i]) * scale; + cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + p*cpe->ch[1].coeffs[start+i]) * scale; cpe->ch[1].coeffs[start+i] = 0.0f; } } else if (cpe->ms_mask[w*16 + g] && cpe->ch[0].band_type[w*16 + g] < NOISE_BT && cpe->ch[1].band_type[w*16 + g] < NOISE_BT) { for (i = 0; i < ics->swb_sizes[g]; i++) { - cpe->ch[0].coeffs[start+i] = (cpe->ch[0].pcoeffs[start+i] + cpe->ch[1].pcoeffs[start+i]) * 0.5f; - cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].pcoeffs[start+i]; + float L = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) * 0.5f; + float R = L - cpe->ch[1].coeffs[start+i]; + cpe->ch[0].coeffs[start+i] = L; + cpe->ch[1].coeffs[start+i] = R; } } start += ics->swb_sizes[g]; @@ -374,7 +376,7 @@ static void avoid_clipping(AACEncContext *s, SingleChannelElement *sce) for (w = 0; w < sce->ics.num_windows; w++) { start = 0; for (i = 0; i < sce->ics.max_sfb; i++) { - float *swb_coeffs = sce->coeffs + start + w*128; + float *swb_coeffs = &sce->coeffs[start + w*128]; for (j = 0; j < sce->ics.swb_sizes[i]; j++) swb_coeffs[j] *= sce->ics.clip_avoidance_factor; start += sce->ics.swb_sizes[i]; |