Timeline: Avoid unaligned access.

This commit is contained in:
Jonathan Moore Liles 2013-08-14 17:54:38 -07:00
parent 1cb9f68cf1
commit e578deb112
3 changed files with 10 additions and 1 deletions

View File

@ -45,6 +45,14 @@ buffer_apply_gain ( sample_t * __restrict__ buf, nframes_t nframes, float g )
*(buf_++) *= g; *(buf_++) *= g;
} }
void
buffer_apply_gain_unaligned ( sample_t * __restrict__ buf, nframes_t nframes, float g )
{
if ( g != 1.0f )
while ( nframes-- )
*(buf++) *= g;
}
void void
buffer_apply_gain_buffer ( sample_t * __restrict__ buf, const sample_t * __restrict__ gainbuf, nframes_t nframes ) buffer_apply_gain_buffer ( sample_t * __restrict__ buf, const sample_t * __restrict__ gainbuf, nframes_t nframes )
{ {

View File

@ -25,6 +25,7 @@
sample_t *buffer_alloc ( nframes_t size ); sample_t *buffer_alloc ( nframes_t size );
void buffer_apply_gain ( sample_t *buf, nframes_t nframes, float g ); void buffer_apply_gain ( sample_t *buf, nframes_t nframes, float g );
void buffer_apply_gain_unaligned ( sample_t *buf, nframes_t nframes, float g );
void buffer_apply_gain_buffer ( sample_t *buf, const sample_t *gainbuf, nframes_t nframes ); void buffer_apply_gain_buffer ( sample_t *buf, const sample_t *gainbuf, nframes_t nframes );
void buffer_copy_and_apply_gain_buffer ( sample_t *dst, const sample_t *src, const sample_t *gainbuf, nframes_t nframes ); void buffer_copy_and_apply_gain_buffer ( sample_t *dst, const sample_t *src, const sample_t *gainbuf, nframes_t nframes );
void buffer_mix ( sample_t *dst, const sample_t *src, nframes_t nframes ); void buffer_mix ( sample_t *dst, const sample_t *src, nframes_t nframes );

View File

@ -192,7 +192,7 @@ Audio_Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channe
/* apply gain */ /* apply gain */
buffer_apply_gain( buf + ofs, cnt, _scale ); buffer_apply_gain_unaligned( buf + ofs, cnt, _scale );
/* perform declicking if necessary */ /* perform declicking if necessary */