changeset 10110:4186efb86933 libavcodec

Modify the Ogg/Speex demuxer and the libspeex decoder so that they always treat a packet of Speex frames as a single frame.
author jbr
date Fri, 28 Aug 2009 00:44:54 +0000
parents 68f824761c1b
children ebe5812b39a7
files libspeexdec.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libspeexdec.c	Thu Aug 27 17:46:13 2009 +0000
+++ b/libspeexdec.c	Fri Aug 28 00:44:54 2009 +0000
@@ -53,6 +53,8 @@
         avctx->sample_rate = s->header->rate;
         avctx->channels    = s->header->nb_channels;
         avctx->frame_size  = s->header->frame_size;
+        if (s->header->frames_per_packet)
+            avctx->frame_size *= s->header->frames_per_packet;
 
         mode = speex_lib_get_mode(s->header->mode);
         if (!mode) {
@@ -98,7 +100,7 @@
     int16_t *output = data, *end;
     int i, num_samples;
 
-    num_samples = avctx->frame_size * avctx->channels;
+    num_samples = s->header->frame_size * avctx->channels;
     end = output + *data_size/2;
 
     speex_bits_read_from(&s->bits, buf, buf_size);
@@ -113,12 +115,13 @@
             break;
 
         if (avctx->channels == 2)
-            speex_decode_stereo_int(output, avctx->frame_size, &s->stereo);
+            speex_decode_stereo_int(output, s->header->frame_size, &s->stereo);
 
         output += num_samples;
     }
 
-    *data_size = i * avctx->channels * avctx->frame_size * 2;
+    avctx->frame_size = s->header->frame_size * i;
+    *data_size = avctx->channels * avctx->frame_size * sizeof(*output);
     return buf_size;
 }