#include <vlc_plugin.h>
#include <vlc_codec.h>
-#include <stream_decoder.h>
-#include <stream_encoder.h>
+#include <FLAC/stream_decoder.h>
+#include <FLAC/stream_encoder.h>
#include <vlc_block_helper.h>
#include <vlc_bits.h>
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE,
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_MIDDLELEFT
- | AOUT_CHAN_MIDDLERIGHT,
+ | AOUT_CHAN_REARCENTER | AOUT_CHAN_MIDDLELEFT| AOUT_CHAN_MIDDLERIGHT
+ | AOUT_CHAN_LFE,
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT
| AOUT_CHAN_REARRIGHT | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT
| AOUT_CHAN_LFE
/*****************************************************************************
* Interleave: helper function to interleave channels
*****************************************************************************/
-static void Interleave32( int32_t *p_out, const int32_t * const *pp_in,
- const int pi_index[],
- int i_nb_channels, int i_samples )
+static void Interleave( int32_t *p_out, const int32_t * const *pp_in,
+ const unsigned char *restrict pi_index, unsigned i_nb_channels,
+ unsigned i_samples, unsigned bits )
{
- int i, j;
- for ( j = 0; j < i_samples; j++ )
- {
- for ( i = 0; i < i_nb_channels; i++ )
- {
- p_out[j * i_nb_channels + i] = pp_in[pi_index[i]][j];
- }
- }
-}
+ unsigned shift = 32 - bits;
-static void Interleave24( int8_t *p_out, const int32_t * const *pp_in,
- const int pi_index[],
- int i_nb_channels, int i_samples )
-{
- int i, j;
- for ( j = 0; j < i_samples; j++ )
- {
- for ( i = 0; i < i_nb_channels; i++ )
- {
- const int i_index = pi_index[i];
-#ifdef WORDS_BIGENDIAN
- p_out[3*(j * i_nb_channels + i)+0] = (pp_in[i_index][j] >> 16) & 0xff;
- p_out[3*(j * i_nb_channels + i)+1] = (pp_in[i_index][j] >> 8 ) & 0xff;
- p_out[3*(j * i_nb_channels + i)+2] = (pp_in[i_index][j] >> 0 ) & 0xff;
-#else
- p_out[3*(j * i_nb_channels + i)+2] = (pp_in[i_index][j] >> 16) & 0xff;
- p_out[3*(j * i_nb_channels + i)+1] = (pp_in[i_index][j] >> 8 ) & 0xff;
- p_out[3*(j * i_nb_channels + i)+0] = (pp_in[i_index][j] >> 0 ) & 0xff;
-#endif
- }
- }
-}
-
-static void Interleave16( int16_t *p_out, const int32_t * const *pp_in,
- const int pi_index[],
- int i_nb_channels, int i_samples )
-{
- int i, j;
- for ( j = 0; j < i_samples; j++ )
- {
- for ( i = 0; i < i_nb_channels; i++ )
- {
- p_out[j * i_nb_channels + i] = (int32_t)(pp_in[pi_index[i]][j]);
- }
- }
+ for( unsigned j = 0; j < i_samples; j++ )
+ for( unsigned i = 0; i < i_nb_channels; i++ )
+ p_out[j * i_nb_channels + i] = pp_in[pi_index[i]][j] << shift;
}
/*****************************************************************************
const FLAC__int32 *const buffer[], void *client_data )
{
/* XXX it supposes our internal format is WG4 */
- static const int ppi_reorder[1+8][8] = {
- {-1},
+ static const unsigned char ppi_reorder[1+8][8] = {
+ { },
{ 0, },
{ 0, 1 },
{ 0, 1, 2 },
{ 0, 1, 2, 3 },
{ 0, 1, 3, 4, 2 },
{ 0, 1, 4, 5, 2, 3 },
-
- { 0, 1, 6, 4, 5, 2, 3 }, /* 7.0 Unspecified by flac, but following SMPTE */
- { 0, 1, 6, 7, 4, 5, 2, 3 }, /* 7.1 Unspecified by flac, but following SMPTE */
+ { 0, 1, 5, 6, 4, 2, 3 },
+ { 0, 1, 6, 7, 4, 5, 2, 3 },
};
VLC_UNUSED(decoder);
if( date_Get( &p_sys->end_date ) <= VLC_TS_INVALID )
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
- const int * const pi_reorder = ppi_reorder[p_dec->fmt_out.audio.i_channels];
+ const unsigned char *pi_reorder = ppi_reorder[p_dec->fmt_out.audio.i_channels];
p_sys->p_aout_buffer =
decoder_NewAudioBuffer( p_dec, frame->header.blocksize );
if( p_sys->p_aout_buffer == NULL )
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
- switch( frame->header.bits_per_sample )
- {
- case 16:
- Interleave16( (int16_t *)p_sys->p_aout_buffer->p_buffer, buffer, pi_reorder,
- frame->header.channels, frame->header.blocksize );
- break;
- case 24:
- Interleave24( (int8_t *)p_sys->p_aout_buffer->p_buffer, buffer, pi_reorder,
- frame->header.channels, frame->header.blocksize );
- break;
- default:
- Interleave32( (int32_t *)p_sys->p_aout_buffer->p_buffer, buffer, pi_reorder,
- frame->header.channels, frame->header.blocksize );
- }
+ Interleave( (int32_t *)p_sys->p_aout_buffer->p_buffer, buffer, pi_reorder,
+ frame->header.channels, frame->header.blocksize,
+ frame->header.bits_per_sample );
/* Date management (already done by packetizer) */
p_sys->p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
decoder_t *p_dec = (decoder_t *)client_data;
decoder_sys_t *p_sys = p_dec->p_sys;
- if( p_dec->pf_decode_audio )
- {
- switch( metadata->data.stream_info.bits_per_sample )
- {
- case 8:
- p_dec->fmt_out.i_codec = VLC_CODEC_S8;
- break;
- case 16:
- p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
- break;
- case 24:
- p_dec->fmt_out.i_codec = VLC_CODEC_S24N;
- break;
- default:
- msg_Dbg( p_dec, "strange bit/sample value: %d",
- metadata->data.stream_info.bits_per_sample );
- p_dec->fmt_out.i_codec = VLC_CODEC_FI32;
- break;
- }
- }
-
/* Setup the format */
p_dec->fmt_out.audio.i_rate = metadata->data.stream_info.sample_rate;
p_dec->fmt_out.audio.i_channels = metadata->data.stream_info.channels;
/* Set output properties */
p_dec->fmt_out.i_cat = AUDIO_ES;
- p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
+ p_dec->fmt_out.i_codec = VLC_CODEC_S32N;
/* Set callbacks */
p_dec->pf_decode_audio = DecodeBlock;