aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/libspeexdec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2009-08-29 21:04:18 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2009-08-29 21:04:18 +0000
commit6833385d30167c966a4e1cbb4d22f0ba82ef4e37 (patch)
treef6288db601d7f58cbf983e9f437ba90b575e799a /libavcodec/libspeexdec.c
parente78516c6d8c0b5ca42d2eabc5c2e10e38523930c (diff)
downloadffmpeg-6833385d30167c966a4e1cbb4d22f0ba82ef4e37.tar.gz
Store the frame size in the LibSpeexContext in case the header does not exist.
Originally committed as revision 19741 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/libspeexdec.c')
-rw-r--r--libavcodec/libspeexdec.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c
index 4241de2ab4..88bf85f209 100644
--- a/libavcodec/libspeexdec.c
+++ b/libavcodec/libspeexdec.c
@@ -29,6 +29,7 @@ typedef struct {
SpeexStereoState stereo;
void *dec_state;
SpeexHeader *header;
+ int frame_size;
} LibSpeexContext;
@@ -52,7 +53,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
- avctx->frame_size = s->header->frame_size;
+ avctx->frame_size = s->frame_size = s->header->frame_size;
if (s->header->frames_per_packet)
avctx->frame_size *= s->header->frames_per_packet;
@@ -76,8 +77,10 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
return -1;
}
- if (!s->header)
+ if (!s->header) {
speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &avctx->frame_size);
+ s->frame_size = avctx->frame_size;
+ }
if (avctx->channels == 2) {
SpeexCallback callback;
@@ -100,7 +103,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx,
int16_t *output = data, *end;
int i, num_samples;
- num_samples = s->header->frame_size * avctx->channels;
+ num_samples = s->frame_size * avctx->channels;
end = output + *data_size / sizeof(*output);
speex_bits_read_from(&s->bits, buf, buf_size);
@@ -115,12 +118,12 @@ static int libspeex_decode_frame(AVCodecContext *avctx,
break;
if (avctx->channels == 2)
- speex_decode_stereo_int(output, s->header->frame_size, &s->stereo);
+ speex_decode_stereo_int(output, s->frame_size, &s->stereo);
output += num_samples;
}
- avctx->frame_size = s->header->frame_size * i;
+ avctx->frame_size = s->frame_size * i;
*data_size = avctx->channels * avctx->frame_size * sizeof(*output);
return buf_size;
}