[FFmpeg-devel] [PATCH] lavf/au: check bits per coded sample.

Nicolas George nicolas.george at normalesup.org
Sat Aug 18 14:23:04 CEST 2012


Without that, it would repeatedly produce empty packets
if the codec if forced to something invalid.

Fix trac ticket #1652.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavformat/au.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)


Another solution would be to keep the packet size (BLOCK_SIZE * channels *
bpcs >> 3) in the codec context once and for all.


diff --git a/libavformat/au.c b/libavformat/au.c
index b7654a4..788e261 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -181,10 +181,13 @@ static int au_read_packet(AVFormatContext *s,
                           AVPacket *pkt)
 {
     int ret;
+    int bpcs = av_get_bits_per_sample(s->streams[0]->codec->codec_id);
 
+    if (!bpcs)
+        return AVERROR(EINVAL);
     ret= av_get_packet(s->pb, pkt, BLOCK_SIZE *
                        s->streams[0]->codec->channels *
-                       av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
+                       bpcs >> 3);
     if (ret < 0)
         return ret;
     pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list