[FFmpeg-devel] [PATCH] AAC: move scratch array to context to ensure 16-byte alignment
Måns Rullgård
mans
Wed Dec 10 02:07:38 CET 2008
"Robert Swain" <robert.swain at gmail.com> writes:
> 2008/12/9 Mans Rullgard <mans at mansr.com>:
>> diff --git a/libavcodec/aac.c b/libavcodec/aac.c
>> index 1803d4d..8fbf964 100644
>> --- a/libavcodec/aac.c
>> +++ b/libavcodec/aac.c
>> @@ -1336,7 +1336,7 @@ static void imdct_and_windowing(AACContext * ac, SingleChannelElement * sce) {
>> const float * lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
>> const float * swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
>> float * buf = ac->buf_mdct;
>> - DECLARE_ALIGNED(16, float, temp[128]);
>> + float * temp = ac->temp;
>> int i;
>>
>> // imdct
>> diff --git a/libavcodec/aac.h b/libavcodec/aac.h
>> index 6022ca6..dab85b9 100644
>> --- a/libavcodec/aac.h
>> +++ b/libavcodec/aac.h
>> @@ -288,6 +288,7 @@ typedef struct {
>> int sf_offset; ///< offset into pow2sf_tab as appropriate for dsp.float_to_int16
>> /** @} */
>>
>> + DECLARE_ALIGNED(16, float, temp[128]);
>> } AACContext;
>>
>> #endif /* AVCODEC_AAC_H */
>
> Is temp[] not aligned when the declaration is within the function? The
> GCC manual at least says it works for variables or structure fields so
> either should be OK, shouldn't they? Does this differ in other
> compilers?
The gcc aligned attribute can only align stack variables to whatever
alignment is guaranteed for the stack pointer, which is often less
than 16.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list