Commit de398308 authored by Ilkka Ollakka's avatar Ilkka Ollakka Committed by Rafaël Carré

avcodec: handle planar samples from libavcodec

(cherry picked from commit 45032ec3b271641aaa3d9613e7c579fabc3d475a)

Conflicts:
	modules/codec/avcodec/audio.c
parent c32ab884
......@@ -268,6 +268,7 @@ static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
int i_samples = __MIN( p_sys->i_samples, 4096 );
int sample_planar=0;
aout_buffer_t *p_buffer;
if( i_samples == 0 ) return NULL;
......@@ -279,16 +280,26 @@ static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
p_buffer->i_length = date_Increment( &p_sys->end_date, i_samples )
- p_buffer->i_pts;
sample_planar = av_sample_fmt_is_planar( p_sys->p_context->sample_fmt );
if( sample_planar )
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( 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,
p_sys->p_samples, p_sys->p_context->channels, i_samples,
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 );
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;
return p_buffer;
}
......@@ -457,11 +468,18 @@ void EndAudioDec( decoder_t *p_dec )
vlc_fourcc_t GetVlcAudioFormat( int fmt )
{
static const vlc_fourcc_t fcc[] = {
[AV_SAMPLE_FMT_U8] = VLC_CODEC_U8,
[AV_SAMPLE_FMT_S16] = VLC_CODEC_S16N,
[AV_SAMPLE_FMT_S32] = VLC_CODEC_S32N,
[AV_SAMPLE_FMT_FLT] = VLC_CODEC_FL32,
[AV_SAMPLE_FMT_DBL] = VLC_CODEC_FL64,
[AV_SAMPLE_FMT_U8] = VLC_CODEC_U8,
[AV_SAMPLE_FMT_S16] = VLC_CODEC_S16N,
[AV_SAMPLE_FMT_S32] = VLC_CODEC_S32N,
[AV_SAMPLE_FMT_FLT] = VLC_CODEC_FL32,
[AV_SAMPLE_FMT_DBL] = VLC_CODEC_FL64,
#ifdef HAVE_AVUTIL_PLANAR
[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,
#endif
};
if( (sizeof(fcc) / sizeof(fcc[0])) > (unsigned)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