[FFmpeg-devel] [patch] 6 channel raw audio inputresultsin invalid PCM packet error

Phil Rutschman philr
Fri Nov 7 23:58:45 CET 2008


> [...]
> > +    sample_size = av_get_bits_per_sample(st->codec->codec_id)/8;
> 
> why is this needed?

As I explained in my original bug report, pcm_decode_frame in
libavcodec/pcm.c expects the size of the audio packet to be an integer
multiple of the number of channels and the number of bytes per sample.
If it isn't, it reports "invalid PCM packet" and returns with an error.
If the input is mono or stereo 16-bit, it will work because 2 and 4
divide into 1024. Anything with 24-bit audio (3 bytes * number of
channels) or a channel count that isn't a power of two will fail.

>From libavcodec/pcm.c in pcm_decode_frame:

   sample_size = av_get_bits_per_sample(avctx->codec_id)/8;

    /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */
    if (CODEC_ID_PCM_DVD == avctx->codec_id)
        /* 2 samples are interleaved per block in PCM_DVD */
        sample_size = avctx->bits_per_coded_sample * 2 / 8;

    n = avctx->channels * sample_size;

    if(n && buf_size % n){
        av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
        return -1;
    }

I omitted the CODEC_ID_PCM_DVD case from my patch because
CODEC_ID_PCM_DVD doesn't use the raw audio demuxer.




More information about the ffmpeg-devel mailing list