FFmpeg
Loading...
Searching...
No Matches
speex.c
Go to the documentation of this file.
1/*
2 * Ogg Speex muxer mapping
3 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at free dot fr>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
24#include "libavutil/mem.h"
26
27#define SPEEX_HEADER_SIZE 80
28
30 OGGStreamContext *oggstream, int bitexact,
31 AVDictionary **m)
32{
33 uint8_t *p;
34
37
38 // first packet: Speex header
40 if (!p)
41 return AVERROR(ENOMEM);
42 oggstream->header[0] = p;
43 oggstream->header_len[0] = SPEEX_HEADER_SIZE;
45 AV_WL32(&oggstream->header[0][68], 0); // set extra_headers to 0
46
47 // second packet: VorbisComment
48 p = ff_ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0, NULL, 0);
49 if (!p)
50 return AVERROR(ENOMEM);
51 oggstream->header[1] = p;
52
53 return 0;
54}
55
57{
58 int err = speex_build_headers(st->codecpar, st->priv_data,
59 s->flags & AVFMT_FLAG_BITEXACT,
60 &st->metadata);
61 if (err)
62 av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
63 return err;
64}
65
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition avformat.h:1570
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition bytestream.h:372
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
@ AV_CODEC_ID_SPEEX
Definition codec_id.h:494
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
#define AV_WL32(p, v)
Memory handling functions.
#define SPEEX_HEADER_SIZE
Definition speex.c:27
static int speex_init(AVFormatContext *s, AVStream *st)
Definition speex.c:56
static int speex_build_headers(AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
Definition speex.c:29
uint8_t * ff_ogg_write_vorbiscomment(int64_t offset, int bitexact, int *header_len, AVDictionary **m, int framing_bit, AVChapter **chapters, unsigned int nb_chapters)
Allocate a comment header packet holding a VorbisComment.
Definition muxer.c:257
const OGGMuxerMapping ff_ogg_speex_muxer_mapping
Definition speex.c:66
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
Format I/O context.
Definition avformat.h:1401
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
AVDictionary * metadata
Definition avformat.h:848
void * priv_data
Definition avformat.h:793
Codec mapping of the muxer: the parts of the Ogg encapsulation that depend on the codec.
Definition muxer.h:71
uint8_t * header[3]
Definition muxer.h:47
int header_len[3]
Definition muxer.h:48
#define av_mallocz(s)
#define av_log(a,...)