[FFmpeg-cvslog] 8svx: ensure that packet size is multiple of channels.

Nicolas George git at videolan.org
Wed Aug 1 10:39:26 CEST 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Tue Jul 31 23:45:16 2012 +0200| [6eee9f5596074f9c0ff2cb25050b56c2914ff411] | committer: Nicolas George

8svx: ensure that packet size is multiple of channels.

Fix an assert failure with packets of invalid size.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6eee9f5596074f9c0ff2cb25050b56c2914ff411
---

 libavcodec/8svx.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index e89b252..8d6a6d6 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -112,9 +112,16 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
     /* decode and interleave the first packet */
     if (!esc->samples && avpkt) {
         uint8_t *deinterleaved_samples, *p = NULL;
+        int packet_size = avpkt->size;
 
+        if (packet_size % avctx->channels) {
+            av_log(avctx, AV_LOG_WARNING, "Packet with odd size, ignoring last byte\n");
+            if (packet_size < avctx->channels)
+                return packet_size;
+            packet_size -= packet_size % avctx->channels;
+        }
         esc->samples_size = !esc->table ?
-            avpkt->size : avctx->channels + (avpkt->size-avctx->channels) * 2;
+            packet_size : avctx->channels + (packet_size-avctx->channels) * 2;
         if (!(esc->samples = av_malloc(esc->samples_size)))
             return AVERROR(ENOMEM);
 



More information about the ffmpeg-cvslog mailing list