[FFmpeg-devel] [patch] 6 channel raw audio input results in invalid PCM packet error

Michael Niedermayer michaelni
Fri Nov 7 20:25:08 CET 2008


On Fri, Oct 31, 2008 at 11:21:22AM -0700, Phil Rutschman wrote:
> Raw audio input fails with SVN- r15760 when the number of channels times
> the number of bytes per sample isn't an integer divisor of 1024.
> 
>  
> 
> Example:
> 
[...]
> The problem seems to be that raw_read_audio_packet in libavformat/raw.c
> always uses a 1024-byte packet size (RAW_PACKET_SIZE), but
> pcm_decode_frame in libavcodec/pcm.c expects a whole number of audio
> frames in the packet. With 6 input channels of 16 bit samples this is 12
> bytes, which doesn't divide evenly into 1024.
> 
>  
> 
> I took a first stab at a patch to raw_read_audio_packet which peeks
> inside the AVFormatContext to get the number of channels and bytes per
> sample from the codec structure and adjusts the packet size to be an
> integer multiple of bytes*channels. It fixes the problem for me, but I'm
> not at all familiar with the code base so I don't know if this is a
> legitimate operation or the best way to fix this. Feedback on a better
> approach would be welcome.
> 
>  
> 
>  
> 
>  
> 

Content-Description: raw_audio_6_channels.diff
> Index: libavformat/raw.c
> ===================================================================
> --- libavformat/raw.c	(revision 15760)
> +++ libavformat/raw.c	(working copy)
> @@ -138,11 +138,17 @@
>  
>  static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
> -    int ret, size, bps;
> -    //    AVStream *st = s->streams[0];
> +    int ret, size, bps, sample_size;
> +    AVStream *st = s->streams[0];
>  
>      size= RAW_PACKET_SIZE;

if(channels>0 && channels<20)
    size *= channels;

seems like a simpler solution

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081107/5d7c8463/attachment.pgp>



More information about the ffmpeg-devel mailing list