]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libspeexdec.c
Fixed-point support in fft-test
[ffmpeg] / libavcodec / libspeexdec.c
index 4241de2ab49a9181f9586d872879a96cdfb3f4ff..e6626dc88b28d4f6bff8352180940e3925ffc65b 100644 (file)
@@ -1,20 +1,20 @@
 /*
  * Copyright (C) 2008 David Conrad
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -29,6 +29,7 @@ typedef struct {
     SpeexStereoState stereo;
     void *dec_state;
     SpeexHeader *header;
+    int frame_size;
 } LibSpeexContext;
 
 
@@ -48,11 +49,11 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
     if (avctx->extradata_size >= 80)
         s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
 
-    avctx->sample_fmt = SAMPLE_FMT_S16;
+    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     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,9 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
         return -1;
     }
 
-    if (!s->header)
-        speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &avctx->frame_size);
+    if (!s->header) {
+        speex_decoder_ctl(s->dec_state, SPEEX_GET_FRAME_SIZE, &s->frame_size);
+    }
 
     if (avctx->channels == 2) {
         SpeexCallback callback;
@@ -100,7 +102,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 +117,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;
 }
@@ -136,9 +138,9 @@ static av_cold int libspeex_decode_close(AVCodecContext *avctx)
     return 0;
 }
 
-AVCodec libspeex_decoder = {
+AVCodec ff_libspeex_decoder = {
     "libspeex",
-    CODEC_TYPE_AUDIO,
+    AVMEDIA_TYPE_AUDIO,
     CODEC_ID_SPEEX,
     sizeof(LibSpeexContext),
     libspeex_decode_init,