[FFmpeg-devel] possible bug in pcm.c
Lukasz M
lukasz.m.luki at gmail.com
Sun Oct 20 22:54:36 CEST 2013
On 20 October 2013 19:59, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Sun, Oct 20, 2013 at 05:05:16PM +0200, Lukasz M wrote:
> > Hi,
> >
> > I work on code that reads stream from input, decodes audio
> > with avcodec_decode_audio4 and then encode frame again.
> > Output muxer is pulse device. I use AV_CODEC_ID_PCM_S16LE codec (taken
> from
> > device) and AV_SAMPLE_FMT_S16 sample format
> >
> > Input has 2 channels. I got a noise on speakers. I was strugging a lot
> and
> > finally debugged it:
> >
> > after decoding with avcodec_decode_audio4, frame has sample
> > format AV_SAMPLE_FMT_S16P, 2 channels.
> > During encoding frame->data[0] is taken as a source for all samples, but
> it
> > has data only for one channel, second one is on frame->data[1]
> >
> > static int pcm_encode_frame(...)
> > [...]
> > sample_size = av_get_bits_per_sample(avctx->codec->id) / 8;
> > n = frame->nb_samples * avctx->channels;
> > samples = (const short *)frame->data[0];
> >
> > [...]
> >
> > switch (avctx->codec->id) {
> > [...]
> > case AV_CODEC_ID_PCM_S16LE:
> > #endif /* HAVE_BIGENDIAN */
> > case AV_CODEC_ID_PCM_U8:
> > memcpy(dst, samples, n * sample_size);
> > break;
> >
> > It seems pcm_encode_frame doesn't support AV_SAMPLE_FMT_S16P frames
> > correctly.
>
> make sure that the sample format you use is in the list of
> supported formats of the AVCodec used
>
I don't know what I was thinking about, but surprised it is not checked
anywere.
Thanks and sorry for spam.
More information about the ffmpeg-devel
mailing list