[SCM] libav/experimental: Correctly update output sample format in wavpack decoder. Patch by Laurent Aimar (at 'fenrir (cons 'videolan 'org))

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:45:01 UTC 2013


The following commit has been merged in the experimental branch:
commit 60294c593e1abb8bd90a40ae5340775db3caa594
Author: Laurent Aimar <fenrir at via.ecp.fr>
Date:   Sun Apr 26 04:23:29 2009 +0000

    Correctly update output sample format in wavpack decoder.
    Patch by Laurent Aimar (at 'fenrir (cons 'videolan 'org))
    
    Originally committed as revision 18694 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 4e262a2..f31402d 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -524,7 +524,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
     int got_hybrid = 0;
     const uint8_t* buf_end = buf + buf_size;
     int i, j, id, size, ssize, weights, t;
-    int bpp = avctx->bits_per_coded_sample <= 16 ? 2 : 4;
+    int bpp;
 
     if (buf_size == 0){
         *data_size = 0;
@@ -540,18 +540,27 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
         *data_size = 0;
         return buf_size;
     }
-    /* should not happen but who knows */
-    if(s->samples * bpp * avctx->channels > *data_size){
-        av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
-        return -1;
-    }
     s->frame_flags = AV_RL32(buf); buf += 4;
+    if((s->frame_flags&0x03) <= 1){
+        bpp = 2;
+        avctx->sample_fmt = SAMPLE_FMT_S16;
+    } else {
+        bpp = 4;
+        avctx->sample_fmt = SAMPLE_FMT_S32;
+    }
     s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
     s->joint = s->frame_flags & WV_JOINT_STEREO;
     s->hybrid = s->frame_flags & WV_HYBRID_MODE;
     s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE;
     s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f);
     s->CRC = AV_RL32(buf); buf += 4;
+
+    /* should not happen but who knows */
+    if(s->samples * bpp * avctx->channels > *data_size){
+        av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
+        return -1;
+    }
+
     // parse metadata blocks
     while(buf < buf_end){
         id = *buf++;

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list