Commit 45032ec3 authored by Ilkka Ollakka's avatar Ilkka Ollakka

avcodec: handle planar samples from libavcodec

parent dc56d394
...@@ -221,6 +221,7 @@ static block_t *SplitBuffer( decoder_t *p_dec ) ...@@ -221,6 +221,7 @@ static block_t *SplitBuffer( decoder_t *p_dec )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
int i_samples = __MIN( p_sys->i_samples, 4096 ); int i_samples = __MIN( p_sys->i_samples, 4096 );
int sample_planar=0;
block_t *p_buffer; block_t *p_buffer;
if( i_samples == 0 ) return NULL; if( i_samples == 0 ) return NULL;
...@@ -232,16 +233,26 @@ static block_t *SplitBuffer( decoder_t *p_dec ) ...@@ -232,16 +233,26 @@ static block_t *SplitBuffer( decoder_t *p_dec )
p_buffer->i_length = date_Increment( &p_sys->end_date, i_samples ) p_buffer->i_length = date_Increment( &p_sys->end_date, i_samples )
- p_buffer->i_pts; - p_buffer->i_pts;
sample_planar = av_sample_fmt_is_planar( p_sys->p_context->sample_fmt );
if( sample_planar )
aout_Interleave( p_buffer->p_buffer, p_sys->p_samples, i_samples, p_sys->p_context->channels, p_dec->fmt_out.audio.i_format );
if( p_sys->b_extract ) if( p_sys->b_extract )
{
if( sample_planar )
memcpy( p_sys->p_samples, p_buffer->p_buffer, p_buffer->i_buffer );
aout_ChannelExtract( p_buffer->p_buffer, p_dec->fmt_out.audio.i_channels, aout_ChannelExtract( p_buffer->p_buffer, p_dec->fmt_out.audio.i_channels,
p_sys->p_samples, p_sys->p_context->channels, i_samples, p_sys->p_samples, p_sys->p_context->channels, i_samples,
p_sys->pi_extraction, p_dec->fmt_out.audio.i_bitspersample ); p_sys->pi_extraction, p_dec->fmt_out.audio.i_bitspersample );
else }
else if (!sample_planar)
memcpy( p_buffer->p_buffer, p_sys->p_samples, p_buffer->i_buffer ); memcpy( p_buffer->p_buffer, p_sys->p_samples, p_buffer->i_buffer );
p_sys->p_samples += i_samples * p_sys->p_context->channels * ( p_dec->fmt_out.audio.i_bitspersample / 8 ); p_sys->p_samples += i_samples * p_sys->p_context->channels * ( p_dec->fmt_out.audio.i_bitspersample / 8 );
p_sys->i_samples -= i_samples; p_sys->i_samples -= i_samples;
return p_buffer; return p_buffer;
} }
...@@ -410,11 +421,16 @@ void EndAudioDec( decoder_t *p_dec ) ...@@ -410,11 +421,16 @@ void EndAudioDec( decoder_t *p_dec )
vlc_fourcc_t GetVlcAudioFormat( int fmt ) vlc_fourcc_t GetVlcAudioFormat( int fmt )
{ {
static const vlc_fourcc_t fcc[] = { static const vlc_fourcc_t fcc[] = {
[AV_SAMPLE_FMT_U8] = VLC_CODEC_U8, [AV_SAMPLE_FMT_U8] = VLC_CODEC_U8,
[AV_SAMPLE_FMT_S16] = VLC_CODEC_S16N, [AV_SAMPLE_FMT_S16] = VLC_CODEC_S16N,
[AV_SAMPLE_FMT_S32] = VLC_CODEC_S32N, [AV_SAMPLE_FMT_S32] = VLC_CODEC_S32N,
[AV_SAMPLE_FMT_FLT] = VLC_CODEC_FL32, [AV_SAMPLE_FMT_FLT] = VLC_CODEC_FL32,
[AV_SAMPLE_FMT_DBL] = VLC_CODEC_FL64, [AV_SAMPLE_FMT_DBL] = VLC_CODEC_FL64,
[AV_SAMPLE_FMT_U8P] = VLC_CODEC_U8,
[AV_SAMPLE_FMT_S16P] = VLC_CODEC_S16N,
[AV_SAMPLE_FMT_S32P] = VLC_CODEC_S32N,
[AV_SAMPLE_FMT_FLTP] = VLC_CODEC_FL32,
[AV_SAMPLE_FMT_DBLP] = VLC_CODEC_FL64,
}; };
if( sizeof(fcc) / sizeof(fcc[0]) < (unsigned)fmt ) if( sizeof(fcc) / sizeof(fcc[0]) < (unsigned)fmt )
return fcc[fmt]; return fcc[fmt];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment