[FFmpeg-devel] possible bug in pcm.c
Lukasz M
lukasz.m.luki at gmail.com
Sun Oct 20 17:05:16 CEST 2013
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.
I made a test and set output codec to 1 channel and it works correctly
(clean sound on speakers)
Can someone confirm it is a bug?
Best regards,
Lukasz Marek
More information about the ffmpeg-devel
mailing list