The Speex Codec Manual
(version 1.1.11)
Jean-Marc Valin
20th November 2005
1
2
Copyright (c) 2002-2005 Jean-Marc Valin/Xiph.org Foundation
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.1 or any later version pub-
lished by the Free Software Foundation; with no Invariant Section, with no Front-Cover
Texts, and with no Back-Cover. A copy of the license is included in the section entitled
"GNU Free Documentation License".
CONTENTS
3
Contents
1 Introduction to Speex 6
2 Codec description 8
2.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Codec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Adaptive Jitter Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Acoustic Echo Canceller . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Compiling 11
4 Command-line encoder/decoder 12
4.1 speexenc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2 speexdec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5 Programming with Speex (the libspeex API) 15
5.1 Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.4 Echo Cancellation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.4.1 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . 19
5.5 Codec Options (speex_*_ctl) . . . . . . . . . . . . . . . . . . . . . . 20
5.6 Mode queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.7 Preprocessor options . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.8 Packing and in-band signalling . . . . . . . . . . . . . . . . . . . . . 23
6 Formats and standards 24
6.1 RTP Payload Format . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.2 MIME Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.3 Ogg file format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7 Introduction to CELP Coding 26
7.1 Linear Prediction (LPC) . . . . . . . . . . . . . . . . . . . . . . . . 26
7.2 Pitch Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7.3 Innovation Codebook . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.4 Analysis-by-Synthesis and Error Weighting . . . . . . . . . . . . . . 29
CONTENTS
4
8 Speex narrowband mode 31
8.1 LPC Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8.2 Pitch Prediction (adaptive codebook) . . . . . . . . . . . . . . . . . . 31
8.3 Innovation Codebook . . . . . . . . . . . . . . . . . . . . . . . . . . 32
8.4 Bit allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
8.5 Perceptual enhancement . . . . . . . . . . . . . . . . . . . . . . . . 33
9 Speex wideband mode (sub-band CELP) 35
9.1 Linear Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
9.2 Pitch Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
9.3 Excitation Quantization . . . . . . . . . . . . . . . . . . . . . . . . . 35
9.4 Bit allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
A FAQ 37
B Sample code 41
B.1 sampleenc.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
B.2 sampledec.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
C IETF RTP Profile 45
D Speex License 68
E GNU Free Documentation License 69
LIST OF TABLES
5
List of Tables
1 In-band signalling codes . . . . . . . . . . . . . . . . . . . . . . . . 24
2 Ogg/Speex header packet . . . . . . . . . . . . . . . . . . . . . . . . 26
3 Bit allocation for narrowband modes . . . . . . . . . . . . . . . . . . 32
4 Quality versus bit-rate . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5 Bit allocation for high-band in wideband mode . . . . . . . . . . . . 36
- 1
- 2
- 3
- 4
前往页