* \param fourcc sample format (must be a linear sample format)
* \note The samples must be naturally aligned in memory.
*/
-void aout_ChannelReorder( void *ptr, size_t bytes, unsigned channels,
+void aout_ChannelReorder( void *ptr, size_t bytes, uint8_t channels,
const uint8_t *restrict chans_table, vlc_fourcc_t fourcc )
{
+ if( unlikely(bytes == 0) )
+ return;
+
assert( channels != 0 );
- assert( channels <= AOUT_CHAN_MAX );
/* The audio formats supported in audio output are inlined. For other
* formats (used in demuxers and muxers), memcpy() is used to avoid
\
for( size_t i = 0; i < frames; i++ ) \
{ \
- float tmp[AOUT_CHAN_MAX]; \
+ type tmp[AOUT_CHAN_MAX]; \
\
for( size_t j = 0; j < channels; j++ ) \
tmp[chans_table[j]] = buf[j]; \
} \
} while(0)
- switch( fourcc )
+ if( likely(channels <= AOUT_CHAN_MAX) )
{
- case VLC_CODEC_U8: REORDER_TYPE(uint8_t); break;
- case VLC_CODEC_S16N: REORDER_TYPE(int16_t); break;
- case VLC_CODEC_FL32: REORDER_TYPE(float); break;
- case VLC_CODEC_S32N: REORDER_TYPE(int32_t); break;
- case VLC_CODEC_FL64: REORDER_TYPE(double); break;
-
- default:
+ switch( fourcc )
{
- unsigned size = aout_BitsPerSample( fourcc ) / 8;
- const size_t frames = bytes / (size * channels);
- unsigned char *buf = ptr;
+ case VLC_CODEC_U8: REORDER_TYPE(uint8_t); return;
+ case VLC_CODEC_S16N: REORDER_TYPE(int16_t); return;
+ case VLC_CODEC_FL32: REORDER_TYPE(float); return;
+ case VLC_CODEC_S32N: REORDER_TYPE(int32_t); return;
+ case VLC_CODEC_FL64: REORDER_TYPE(double); return;
+ }
+ }
- assert( bytes != 0 );
- for( size_t i = 0; i < frames; i++ )
- {
- unsigned char tmp[AOUT_CHAN_MAX * size];
+ unsigned size = aout_BitsPerSample( fourcc ) / 8;
+ assert( size != 0 && size <= 8 );
- for( size_t j = 0; j < channels; j++ )
- memcpy( tmp + size * chans_table[j], buf + size * j, size );
- memcpy( buf, tmp, size * channels );
- buf += size * channels;
- }
- break;
- }
+ const size_t frames = bytes / (size * channels);
+ unsigned char *buf = ptr;
+
+ for( size_t i = 0; i < frames; i++ )
+ {
+ unsigned char tmp[256 * 8];
+
+ for( size_t j = 0; j < channels; j++ )
+ memcpy( tmp + size * chans_table[j], buf + size * j, size );
+ memcpy( buf, tmp, size * channels );
+ buf += size * channels;
}
}
/**
* Interleaves audio samples within a block of samples.
* \param dst destination buffer for interleaved samples
- * \param src source buffer with consecutive planes of samples
+ * \param srcv source buffers (one per plane) of uninterleaved samples
* \param samples number of samples (per channel/per plane)
* \param chans channels/planes count
* \param fourcc sample format (must be a linear sample format)
* \note The samples must be naturally aligned in memory.
* \warning Destination and source buffers MUST NOT overlap.
*/
-void aout_Interleave( void *restrict dst, const void *restrict src,
+void aout_Interleave( void *restrict dst, const void *const *srcv,
unsigned samples, unsigned chans, vlc_fourcc_t fourcc )
{
#define INTERLEAVE_TYPE(type) \
do { \
type *d = dst; \
- const type *s = src; \
for( size_t i = 0; i < chans; i++ ) { \
+ const type *s = srcv[i]; \
for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
d[k] = *(s++); \
d++; \
case VLC_CODEC_FL32: INTERLEAVE_TYPE(float); break;
case VLC_CODEC_S32N: INTERLEAVE_TYPE(int32_t); break;
case VLC_CODEC_FL64: INTERLEAVE_TYPE(double); break;
- default: assert(0);
+ default: vlc_assert_unreachable();
}
#undef INTERLEAVE_TYPE
}
case VLC_CODEC_FL32: DEINTERLEAVE_TYPE(float); break;
case VLC_CODEC_S32N: DEINTERLEAVE_TYPE(int32_t); break;
case VLC_CODEC_FL64: DEINTERLEAVE_TYPE(double); break;
- default: assert(0);
+ default: vlc_assert_unreachable();
}
#undef DEINTERLEAVE_TYPE
}
return INT_MAX;
}
-/* This function will add or remove a a module from a string list (colon
+/* This function will add or remove a module from a string list (colon
* separated). It will return true if there is a modification
* In case p_aout is NULL, we will use configuration instead of variable */
bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,