• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavformat/oggparsespeex.c

Go to the documentation of this file.
00001 /*
00002       Copyright (C) 2008  Reimar Döffinger
00003 
00004       Permission is hereby granted, free of charge, to any person
00005       obtaining a copy of this software and associated documentation
00006       files (the "Software"), to deal in the Software without
00007       restriction, including without limitation the rights to use, copy,
00008       modify, merge, publish, distribute, sublicense, and/or sell copies
00009       of the Software, and to permit persons to whom the Software is
00010       furnished to do so, subject to the following conditions:
00011 
00012       The above copyright notice and this permission notice shall be
00013       included in all copies or substantial portions of the Software.
00014 
00015       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00016       EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00018       NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00019       HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00020       WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021       OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00022       DEALINGS IN THE SOFTWARE.
00023 **/
00024 
00025 #include <stdlib.h>
00026 #include "libavutil/bswap.h"
00027 #include "libavutil/avstring.h"
00028 #include "libavcodec/bitstream.h"
00029 #include "libavcodec/bytestream.h"
00030 #include "avformat.h"
00031 #include "oggdec.h"
00032 
00033 static int speex_header(AVFormatContext *s, int idx) {
00034     struct ogg *ogg = s->priv_data;
00035     struct ogg_stream *os = ogg->streams + idx;
00036     AVStream *st = s->streams[idx];
00037     uint8_t *p = os->buf + os->pstart;
00038 
00039     if (os->psize < 80)
00040         return 1;
00041 
00042     st->codec->codec_type = CODEC_TYPE_AUDIO;
00043     st->codec->codec_id = CODEC_ID_SPEEX;
00044 
00045     st->codec->sample_rate = AV_RL32(p + 36);
00046     st->codec->channels = AV_RL32(p + 48);
00047     st->codec->extradata_size = os->psize;
00048     st->codec->extradata = av_malloc(st->codec->extradata_size);
00049     memcpy(st->codec->extradata, p, st->codec->extradata_size);
00050 
00051     st->time_base.num = 1;
00052     st->time_base.den = st->codec->sample_rate;
00053 
00054     return 0;
00055 }
00056 
00057 const struct ogg_codec ff_speex_codec = {
00058     .magic = "Speex   ",
00059     .magicsize = 8,
00060     .header = speex_header
00061 };

Generated on Sat Feb 16 2013 09:23:15 for ffmpeg by  doxygen 1.7.1