]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/oggparsespeex.c
oggenc: return error value from ogg_build_flac_headers()
[ffmpeg] / libavformat / oggparsespeex.c
index ad2f0b7db44fb37f4952efbae6a9c266612ae20c..140a58a9eb4b0c04eef32cd3886149d96d423b1f 100644 (file)
 #include <stdlib.h>
 #include "libavutil/bswap.h"
 #include "libavutil/avstring.h"
-#include "libavcodec/bitstream.h"
+#include "libavcodec/get_bits.h"
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
 #include "oggdec.h"
 
 static int speex_header(AVFormatContext *s, int idx) {
-    ogg_t *ogg = s->priv_data;
-    ogg_stream_t *os = ogg->streams + idx;
+    struct ogg *ogg = s->priv_data;
+    struct ogg_stream *os = ogg->streams + idx;
     AVStream *st = s->streams[idx];
     uint8_t *p = os->buf + os->pstart;
 
-    if (os->psize < 80)
-        return 1;
+    if (os->seq > 1)
+        return 0;
 
-    st->codec->codec_type = CODEC_TYPE_AUDIO;
-    st->codec->codec_id = CODEC_ID_SPEEX;
+    if (os->seq == 0) {
+        st->codec->codec_type = CODEC_TYPE_AUDIO;
+        st->codec->codec_id = CODEC_ID_SPEEX;
 
-    st->codec->sample_rate = AV_RL32(p + 36);
-    st->codec->channels = AV_RL32(p + 48);
-    st->codec->extradata_size = os->psize;
-    st->codec->extradata = av_malloc(st->codec->extradata_size);
-    memcpy(st->codec->extradata, p, st->codec->extradata_size);
+        st->codec->sample_rate = AV_RL32(p + 36);
+        st->codec->channels = AV_RL32(p + 48);
+        st->codec->frame_size = AV_RL32(p + 56);
+        st->codec->extradata_size = os->psize;
+        st->codec->extradata = av_malloc(st->codec->extradata_size
+                                         + FF_INPUT_BUFFER_PADDING_SIZE);
+        memcpy(st->codec->extradata, p, st->codec->extradata_size);
 
-    st->time_base.num = 1;
-    st->time_base.den = st->codec->sample_rate;
+        st->time_base.num = 1;
+        st->time_base.den = st->codec->sample_rate;
+    } else
+        vorbis_comment(s, p, os->psize);
 
-    return 0;
+    return 1;
 }
 
-ogg_codec_t speex_codec = {
+const struct ogg_codec ff_speex_codec = {
     .magic = "Speex   ",
     .magicsize = 8,
     .header = speex_header