[FFmpeg-devel] possible bug in pcm.c

Michael Niedermayer michaelni at gmx.at
Sun Oct 20 23:56:12 CEST 2013


On Sun, Oct 20, 2013 at 10:54:36PM +0200, Lukasz M wrote:
> 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.

sample format should be checked by avcodec_open2()

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131020/c1d83498/attachment.asc>


More information about the ffmpeg-devel mailing list