efc67dc9f3513bcec2dc41622aea622bd5a76816
[speexdsp.git] / doc / manual.lyx
1 #LyX 1.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 220
3 \textclass article
4 \language english
5 \inputencoding auto
6 \fontscheme default
7 \graphics default
8 \float_placement h
9 \paperfontsize default
10 \spacing single 
11 \papersize Default
12 \paperpackage a4
13 \use_geometry 0
14 \use_amsmath 0
15 \use_natbib 0
16 \use_numerical_citations 0
17 \paperorientation portrait
18 \secnumdepth 3
19 \tocdepth 3
20 \paragraph_separation indent
21 \defskip medskip
22 \quotes_language english
23 \quotes_times 2
24 \papercolumns 1
25 \papersides 1
26 \paperpagestyle headings
27
28 \layout Title
29
30 The Speex Codec Manual
31 \newline 
32 (draft for Speex 1.0beta3)
33 \layout Author
34
35 Jean-Marc Valin
36 \layout Standard
37 \pagebreak_top 
38 Copyright (c) 2002 Jean-Marc Valin.
39 \layout Standard
40
41 Permission is granted to copy, distribute and/or modify this document under
42  the terms of the GNU Free Documentation License, Version 1.1 or any later
43  version published by the Free Software Foundation; with no Invariant Section,
44  with no Front-Cover Texts, and with no Back-Cover.
45  A copy of the license is included in the section entitled "GNU Free Documentati
46 on License".
47  
48 \layout Section*
49
50 Disclaimer
51 \layout Standard
52
53 This document is meant to provide useful information on the Speex codec
54  but there is absolutely no warranty regarding usefulness or correctness
55  of the information provided.
56  Also, some techniques used in Speex are said to be 
57 \begin_inset Quotes eld
58 \end_inset 
59
60 similar
61 \begin_inset Quotes erd
62 \end_inset 
63
64  to techniques used in known codecs.
65  This should not be understood as an acknowledgment that Speex is using
66  any patented algorithm used in these codecs, but merely that comprehension
67  of Speex can be facilitated by thinking that the principles of operation
68  are the same or similar.
69  Of course, there's also the obligatory 
70 \begin_inset Quotes eld
71 \end_inset 
72
73 all trademarks are property of their respective owner
74 \begin_inset Quotes erd
75 \end_inset 
76
77 .
78 \layout Standard
79 \pagebreak_top \pagebreak_bottom 
80
81 \begin_inset LatexCommand \tableofcontents{}
82
83 \end_inset 
84
85
86 \layout Standard
87 \pagebreak_bottom 
88
89 \begin_inset FloatList table
90
91 \end_inset 
92
93
94 \layout Section
95
96 Introduction to Speex
97 \layout Standard
98
99 The Speex project (
100 \family typewriter 
101 http://www.speex.org/
102 \family default 
103 ) has been started because there was a need for a speech codec that was
104  open-source and free from software patents.
105  These are essential conditions for being used by any open-source software.
106  There is already Vorbis that does general audio, but it is not really suitable
107  for speech.
108  Also, unlike many other speech codecs, Speex is not targeted at cell phones
109  (not many open-source cell phones anyway :-) ) but rather voice over IP
110  (VoIP) and file-based compression.
111  
112 \layout Standard
113
114 As design goals, we wanted to have a codec that would allowed both very
115  good quality speech and low bit-rate (unfortunately not at the same time!),
116  which led us to developing a codec with multiple bit-rates.
117  Of course very good quality also meant we had to do wideband (16 kHz sampling
118  rate) in addition to narrowband (telephone quality, 8 kHz sampling rate).
119 \layout Standard
120
121 Designing for VoIP instead of cell phone use means that Speex must be robust
122  to lost packets, but not to corrupted ones since packets either arrive
123  unaltered or don't arrive at all.
124  Also, the idea was to have a reasonnable complexity and memory requirement
125  without compromising too much on the efficiency of the codec.
126 \layout Standard
127
128 All this led us to the choice of CELP
129 \begin_inset LatexCommand \index{CELP}
130
131 \end_inset 
132
133  as the encoding technique to use for Speex.
134  One of the main reasons is that CELP has long proved that it could do the
135  job and scale well to both low bit-rates (think DoD CELP @ 4.8 kbps) and
136  high bit-rates (think G.728 @ 16 kbps).
137  
138 \layout Standard
139
140 The main characteristics can be summerized as follows:
141 \layout Itemize
142
143 Free software/open-source
144 \begin_inset LatexCommand \index{open-source}
145
146 \end_inset 
147
148 , patent
149 \begin_inset LatexCommand \index{patent}
150
151 \end_inset 
152
153  and royalty-free
154 \layout Itemize
155
156 Integration of wideband
157 \begin_inset LatexCommand \index{wideband}
158
159 \end_inset 
160
161  and narrowband
162 \begin_inset LatexCommand \index{narrowband}
163
164 \end_inset 
165
166  in the same bit-stream
167 \layout Itemize
168
169 Wide range of bit-rates available
170 \layout Itemize
171
172 Dynamic bit-rate switching and Variable Bit-Rate
173 \begin_inset LatexCommand \index{variable bit-rate}
174
175 \end_inset 
176
177  (VBR)
178 \layout Itemize
179
180 Voice Activity Detection
181 \begin_inset LatexCommand \index{voice activity detection}
182
183 \end_inset 
184
185  (VAD, integrated with VBR)
186 \layout Itemize
187
188 Variable complexity
189 \begin_inset LatexCommand \index{complexity}
190
191 \end_inset 
192
193
194 \layout Section
195 \pagebreak_top 
196 Introduction to CELP Coding
197 \begin_inset LatexCommand \index{CELP}
198
199 \end_inset 
200
201
202 \layout Standard
203
204 Speex is based on CELP, which stands for Code Excited Linear Prediction.
205  This section attempts to introduce the principles behind CELP, so if you
206  are already familiar with CELP, you can safely skip to section 
207 \begin_inset LatexCommand \ref{sec:Speex-narrowband-mode}
208
209 \end_inset 
210
211 .
212  The CELP technique is based on three ideas:
213 \layout Enumerate
214
215 The use of a linear prediction (LP) model to model the vocal tract
216 \layout Enumerate
217
218 The use of (adaptive and fixed) codebook entries as input (excitation) of
219  the LP model
220 \layout Enumerate
221
222 The search performed in closed-loop in a 
223 \begin_inset Quotes eld
224 \end_inset 
225
226 perceptually weighted domain
227 \begin_inset Quotes erd
228 \end_inset 
229
230
231 \layout Subsection
232
233 Linear Prediction (LPC)
234 \begin_inset LatexCommand \index{linear prediction}
235
236 \end_inset 
237
238
239 \layout Standard
240
241
242 \begin_inset Formula \[
243 y(n)=\sum _{i=1}^{N}a_{i}x(n-i)\]
244
245 \end_inset 
246
247
248 \begin_inset Formula \[
249 e(n)=x(n)-y(n)=x(n)-\sum _{i=1}^{N}a_{i}x(n-i)\]
250
251 \end_inset 
252
253
254 \begin_inset Formula \[
255 E=\sum _{n=0}^{L-1}\left[e(n)\right]^{2}=\sum _{n=0}^{L-1}\left[x(n)-\sum _{i=1}^{N}a_{i}x(n-i)\right]^{2}\]
256
257 \end_inset 
258
259
260 \begin_inset Formula \[
261 \frac{\partial E}{\partial a_{i}}=\frac{\partial }{\partial a_{i}}\sum _{n=0}^{L-1}\left[x(n)-\sum _{i=1}^{N}a_{i}x(n-i)\right]^{2}=0\]
262
263 \end_inset 
264
265
266 \layout Standard
267
268 The 
269 \begin_inset Formula $a_{i}$
270 \end_inset 
271
272  filter coefficients are computed using the Levinson-Durbin
273 \begin_inset LatexCommand \index{Levinson-Durbin}
274
275 \end_inset 
276
277  algorithm, which starts from the auto-correlation
278 \begin_inset LatexCommand \index{auto-correlation}
279
280 \end_inset 
281
282  
283 \begin_inset Formula $R(m)$
284 \end_inset 
285
286  of the signal 
287 \begin_inset Formula $x(n)$
288 \end_inset 
289
290 .
291 \layout Standard
292
293
294 \begin_inset Formula \[
295 R(m)=\sum _{i=0}^{N-1}x(i)x(i-m)\]
296
297 \end_inset 
298
299
300 \layout Standard
301
302 For an order 
303 \begin_inset Formula $N$
304 \end_inset 
305
306  filter, we have:
307 \begin_inset Formula \[
308 \mathbf{R}=\left[\begin{array}{cccc}
309  R(0) & R(1) & \cdots  & R(N-1)\\
310  R(1) & R(0) & \cdots  & R(N-2)\\
311  \vdots  & \vdots  & \ddots  & \vdots \\
312  R(N-1) & R(N-2) & \cdots  & R(0)\end{array}
313 \right]\]
314
315 \end_inset 
316
317
318 \begin_inset Formula \[
319 \mathbf{r}=\left[\begin{array}{c}
320  R(1)\\
321  R(2)\\
322  \vdots \\
323  R(N)\end{array}
324 \right]\]
325
326 \end_inset 
327
328
329 \layout Standard
330
331 The filter coefficients 
332 \begin_inset Formula $a_{i}$
333 \end_inset 
334
335  are found by solving the system 
336 \begin_inset Formula $\mathbf{Ra}=\mathbf{r}$
337 \end_inset 
338
339 .
340  What the Levinson-Durbin algorithm does here is making the solution to
341  the problem 
342 \begin_inset Formula $\mathcal{O}\left(N^{2}\right)$
343 \end_inset 
344
345  instead of 
346 \begin_inset Formula $\mathcal{O}\left(N^{3}\right)$
347 \end_inset 
348
349  by exploiting the fact that matrix 
350 \begin_inset Formula $\mathbf{R}$
351 \end_inset 
352
353  is toeplitz hermitian.
354  Also, it can be proved that all the roots of 
355 \begin_inset Formula $A(z)$
356 \end_inset 
357
358  are withing the unit circle, which means that 
359 \begin_inset Formula $1/A(z)$
360 \end_inset 
361
362  is always stable.
363  This is in theory; in practice because of finite precision, there are two
364  commonly used techniques to make sure we have a stable filter.
365  First, we multiply 
366 \begin_inset Formula $R(0)$
367 \end_inset 
368
369  by a number slightly above one (such as 1.0001), which is equivalent to
370  adding noise to the signal.
371  Also, we can apply a window the the auto-correlation, which is equivalent
372  to filtering in the frequency domain, reducing sharp resonances.
373 \layout Standard
374
375 The linear prediction model represents each speech sample as linear combination
376  of past samples, plus an error signal called the excitation (or residual).
377 \begin_inset Formula \[
378 x(n)=\sum _{i=1}^{N}a_{i}x(n-i)+e(n)\]
379
380 \end_inset 
381
382
383 \layout Standard
384
385 In the 
386 \emph on 
387 z
388 \emph default 
389 -domain, this can be expressed as
390 \layout Standard
391
392
393 \begin_inset Formula \[
394 x(z)=\frac{1}{A(z)}\: e(z)\]
395
396 \end_inset 
397
398
399 \layout Standard
400
401 where 
402 \begin_inset Formula $A(z)$
403 \end_inset 
404
405  is defined as
406 \layout Standard
407
408
409 \begin_inset Formula \[
410 A(z)=1-\sum _{i=1}^{N}a_{i}z^{-i}\]
411
412 \end_inset 
413
414
415 \layout Standard
416
417 We usually refer to 
418 \begin_inset Formula $A(z)$
419 \end_inset 
420
421  as the analysis filter and 
422 \begin_inset Formula $1/A(z)$
423 \end_inset 
424
425  as the synthesis filter.
426 \layout Standard
427
428 Because LPC coefficients have very little robustness to quantization, they
429  are converted to Line Spectral Pair
430 \begin_inset LatexCommand \index{line spectral pair}
431
432 \end_inset 
433
434  (LSP) coefficients which have a much better behaviour with quantization,
435  one of them being that it's easy to keep the filter stable.
436  
437 \layout Subsection
438
439 Pitch Prediction
440 \begin_inset LatexCommand \index{pitch}
441
442 \end_inset 
443
444
445 \layout Standard
446
447 During voiced segments, the speech signal is very periodic, so it is possible
448  to take advantage of that by expressing the excitation signal 
449 \begin_inset Formula $e(n)$
450 \end_inset 
451
452  as
453 \layout Standard
454
455
456 \begin_inset Formula \[
457 e(n)=\beta e(n-T)+c(n)\]
458
459 \end_inset 
460
461
462 \layout Standard
463
464 where 
465 \begin_inset Formula $T$
466 \end_inset 
467
468  is the pitch period, 
469 \begin_inset Formula $\beta $
470 \end_inset 
471
472  is the pitch gain and 
473 \begin_inset Formula $c(n)$
474 \end_inset 
475
476  is taken from the 
477 \emph on 
478 innovation codebook
479 \emph default 
480 .
481  In the 
482 \emph on 
483 z
484 \emph default 
485 -domain, the excitation can be expressed as:
486 \layout Standard
487
488
489 \begin_inset Formula \[
490 e(z)=\frac{1}{1-\beta z^{-T}}\: c(z)\]
491
492 \end_inset 
493
494
495 \layout Subsection
496
497 Innovation Codebook
498 \layout Standard
499
500 This is where most of the bits in a CELP codec are allocated.
501  It represents the information that couldn't be obtained either from linear
502  prediction or pitch prediction.
503 \layout Subsection
504
505 Analysis-by-Synthesis and Error Weighting
506 \begin_inset LatexCommand \index{error weighting}
507
508 \end_inset 
509
510
511 \begin_inset LatexCommand \index{analysis-by-synthesis}
512
513 \end_inset 
514
515
516 \layout Standard
517
518 Most (if not all) modern audio codecs attempt to 
519 \emph on 
520 shape
521 \emph default 
522  the noise so that it is the hardest to detect with the ear.
523  That means that more noise can be tolerated in parts of the spectrum that
524  are louder and 
525 \emph on 
526 vice versa
527 \emph default 
528 .
529  That's why the error is minimized for the perceptually weighted signal
530 \begin_inset Formula \[
531 X_{w}(z)=W(z)X(z)\]
532
533 \end_inset 
534
535 where 
536 \begin_inset Formula $W(z)$
537 \end_inset 
538
539  is the weighting filter, usually of the form
540 \layout Standard
541
542
543 \begin_inset Formula \begin{equation}
544 W(z)=\frac{A\left(\frac{z}{\gamma _{1}}\right)}{A\left(\frac{z}{\gamma _{2}}\right)}\label{eq:weighting_filter}\end{equation}
545
546 \end_inset 
547
548
549 \layout Standard
550
551 with control parameters 
552 \begin_inset Formula $\gamma _{1}>\gamma _{2}$
553 \end_inset 
554
555 .
556  If the noise is white in the perceptually weighted domain, then in the
557  signal domain its spectral shape will be of the form
558 \begin_inset Formula \[
559 A_{noise}(z)=\frac{1}{W(z)}=\frac{A\left(\frac{z}{\gamma _{2}}\right)}{A\left(\frac{z}{\gamma _{1}}\right)}\]
560
561 \end_inset 
562
563
564 \layout Standard
565
566 If a filter 
567 \begin_inset Formula $A(z)$
568 \end_inset 
569
570  has (complex) poles at 
571 \begin_inset Formula $p_{i}$
572 \end_inset 
573
574  in the 
575 \begin_inset Formula $z$
576 \end_inset 
577
578 -plane, the filter 
579 \begin_inset Formula $A(z/\gamma )$
580 \end_inset 
581
582  filter will have its poles at 
583 \begin_inset Formula $p_{i}^{'}=\gamma p_{i}$
584 \end_inset 
585
586 , making it a flatter version of 
587 \begin_inset Formula $A(z)$
588 \end_inset 
589
590 .
591 \layout Section
592 \pagebreak_top 
593 Speex narrowband mode
594 \begin_inset LatexCommand \label{sec:Speex-narrowband-mode}
595
596 \end_inset 
597
598
599 \begin_inset LatexCommand \index{narrowband}
600
601 \end_inset 
602
603
604 \layout Standard
605
606 This section looks at how Speex works for narrowband (
607 \begin_inset Formula $8\: \mathrm{kHz}$
608 \end_inset 
609
610  sampling rate) operation.
611  The frame size for this mode is 
612 \begin_inset Formula $20\: \mathrm{ms}$
613 \end_inset 
614
615 , corresponding to 160 samples.
616  Each frame is also subdivided into 4 sub-frames of 40 samples each.
617 \layout Standard
618
619 Also many design decisions were based on the original goals and assumptions:
620 \layout Itemize
621
622 Minimizing the amount of information extracted from past frames (for robustness
623  to packet loss)
624 \layout Itemize
625
626 Dynamically-selectable codebooks (LSP, pitch and innovation)
627 \layout Itemize
628
629 G.728-like fixed codebooks (without backward-adaptive grains because of patent
630  issues)
631 \layout Subsection
632
633 LPC Analysis
634 \begin_inset LatexCommand \index{linear prediction}
635
636 \end_inset 
637
638
639 \layout Standard
640
641 An LPC analysis is first performed on a (Hamming) window that spans all
642  the current frame and half a frame in advance.
643  The LPC coefficients are then converted to Line Spectral Pair
644 \begin_inset LatexCommand \index{line spectral pair}
645
646 \end_inset 
647
648  (LSP), a representation that is more robust to quantization.
649  The LSP's are considered to be associated to the 
650 \begin_inset Formula $4^{th}$
651 \end_inset 
652
653  sub-frames and the LSP's associated to the first 3 sub-frames are linearly
654  interpolated using the current and previous LSP's.
655 \layout Standard
656
657 The LSP's are encoded using 30 bits for higher quality modes and 18 bits
658  for lower quality, through the use of a multi-stage split-vector quantizer.
659  For the lower quality modes, the 10 coefficients are first quantized with
660  6 bits and the error is then divided in two 5-coefficient sub-vectors.
661  Each of them is quantized with 6 bits, for a total of 18 bits.
662  For the higher quality modes, the remaining error on both sub-vectors is
663  turther quantized with 6 bits each, for a total of 30 bits.
664 \layout Standard
665
666 The perceptual weighting filter 
667 \begin_inset Formula $W(z)$
668 \end_inset 
669
670  used by Speex is derived from the LPC analysis and corresponds to the one
671  described by eq.
672  
673 \begin_inset LatexCommand \ref{eq:weighting_filter}
674
675 \end_inset 
676
677  with 
678 \begin_inset Formula $\gamma _{1}=0.9$
679 \end_inset 
680
681  and 
682 \begin_inset Formula $\gamma _{2}=0.6$
683 \end_inset 
684
685 .
686  We can use the unquantized 
687 \begin_inset Formula $A(z)$
688 \end_inset 
689
690  filter since the weighting filter is only used in the encoder.
691 \layout Subsection
692
693 Pitch Prediction (adaptive codebook)
694 \begin_inset LatexCommand \index{pitch}
695
696 \end_inset 
697
698
699 \layout Standard
700
701 Speex uses a 3-tap prediction for pitch.
702  That is, 
703 \layout Standard
704
705
706 \begin_inset Formula \[
707 e(n)=\beta _{0}e(n-T-1)+\beta _{1}e(n-T)+\beta _{2}e(n-T+1)+c(n)\]
708
709 \end_inset 
710
711
712 \layout Standard
713
714 where 
715 \begin_inset Formula $T$
716 \end_inset 
717
718  is the pitch period and the 
719 \begin_inset Formula $\beta _{i}$
720 \end_inset 
721
722  are the prediction (filter) taps.
723  The period and quantized gains are determined in closed loop.
724 \layout Subsection
725
726 Innovation Codebook
727 \layout Standard
728
729 In Speex, the innovation signal is quantized using shape-only vector quantizatio
730 n (VQ).
731  That means that the codebooks that are used represent both the shape and
732  the gain at the same time.
733  This save many bits that would otherwise be allocated for a separate gain
734  at the price of a slight increase in complexity.
735  Except for the absence of (backward-adaptive) gain, the technique used
736  in Speex is similar to G.728 (LD-CELP).
737  However since we do not have a low-delay constraint, the search can be
738  made more 
739 \begin_inset Quotes eld
740 \end_inset 
741
742 global
743 \begin_inset Quotes erd
744 \end_inset 
745
746  and make use of the whole information available for a sub-frame.
747 \layout Subsection
748
749 Bit allocation
750 \layout Standard
751
752 There are 7 different narrowband bit-rates defined for Speex, ranging from
753  200 bps to 18.15 kbps, although the modes below 5.9 kbps should not be used
754  for speech.
755  The bit-allocation for each mode is detailed in table 
756 \begin_inset LatexCommand \ref{cap:bits-narrowband}
757
758 \end_inset 
759
760 .
761  Each frame starts with the mode ID encoded with 4 bits which allows a range
762  from 0 to 15, though only the first 7 values are used (the others are reserved).
763  The parameters are listed in the table in the order they are packed in
764  the bit-stream.
765  All frame-based parameters are packed before sub-frame parameters.
766  The parameters for a certain sub-frame are all packed before the following
767  sub-frame is packed.
768  Note that the 
769 \begin_inset Quotes eld
770 \end_inset 
771
772 OL
773 \begin_inset Quotes erd
774 \end_inset 
775
776  in the parameter description means the the parameter is an open loop estimation
777  based on the whole frame.
778 \layout Standard
779
780
781 \begin_inset Float table
782 placement htbp
783 wide true
784 collapsed false
785
786 \layout Standard
787
788
789 \begin_inset  Tabular
790 <lyxtabular version="3" rows="12" columns="10">
791 <features>
792 <column alignment="center" valignment="top" leftline="true" width="0pt">
793 <column alignment="center" valignment="top" leftline="true" width="0pt">
794 <column alignment="center" valignment="top" leftline="true" width="0pt">
795 <column alignment="center" valignment="top" leftline="true" width="0pt">
796 <column alignment="center" valignment="top" leftline="true" width="0pt">
797 <column alignment="center" valignment="top" leftline="true" width="0pt">
798 <column alignment="center" valignment="top" leftline="true" width="0pt">
799 <column alignment="center" valignment="top" leftline="true" width="0pt">
800 <column alignment="center" valignment="top" leftline="true" width="0pt">
801 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
802 <row topline="true" bottomline="true">
803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
804 \begin_inset Text
805
806 \layout Standard
807
808 Parameter
809 \end_inset 
810 </cell>
811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
812 \begin_inset Text
813
814 \layout Standard
815
816 Update rate
817 \end_inset 
818 </cell>
819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
820 \begin_inset Text
821
822 \layout Standard
823
824 0
825 \end_inset 
826 </cell>
827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
828 \begin_inset Text
829
830 \layout Standard
831
832 1
833 \end_inset 
834 </cell>
835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
836 \begin_inset Text
837
838 \layout Standard
839
840 2
841 \end_inset 
842 </cell>
843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
844 \begin_inset Text
845
846 \layout Standard
847
848 3
849 \end_inset 
850 </cell>
851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
852 \begin_inset Text
853
854 \layout Standard
855
856 4
857 \end_inset 
858 </cell>
859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
860 \begin_inset Text
861
862 \layout Standard
863
864 5
865 \end_inset 
866 </cell>
867 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
868 \begin_inset Text
869
870 \layout Standard
871
872 6
873 \end_inset 
874 </cell>
875 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
876 \begin_inset Text
877
878 \layout Standard
879
880 7
881 \end_inset 
882 </cell>
883 </row>
884 <row topline="true">
885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
886 \begin_inset Text
887
888 \layout Standard
889
890 Wideband bit
891 \end_inset 
892 </cell>
893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
894 \begin_inset Text
895
896 \layout Standard
897
898 frame
899 \end_inset 
900 </cell>
901 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
902 \begin_inset Text
903
904 \layout Standard
905
906 1
907 \end_inset 
908 </cell>
909 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
910 \begin_inset Text
911
912 \layout Standard
913
914 1
915 \end_inset 
916 </cell>
917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
918 \begin_inset Text
919
920 \layout Standard
921
922 1
923 \end_inset 
924 </cell>
925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
926 \begin_inset Text
927
928 \layout Standard
929
930 1
931 \end_inset 
932 </cell>
933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
934 \begin_inset Text
935
936 \layout Standard
937
938 1
939 \end_inset 
940 </cell>
941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
942 \begin_inset Text
943
944 \layout Standard
945
946 1
947 \end_inset 
948 </cell>
949 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
950 \begin_inset Text
951
952 \layout Standard
953
954 1
955 \end_inset 
956 </cell>
957 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
958 \begin_inset Text
959
960 \layout Standard
961
962 1
963 \end_inset 
964 </cell>
965 </row>
966 <row topline="true">
967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
968 \begin_inset Text
969
970 \layout Standard
971
972 Mode ID
973 \end_inset 
974 </cell>
975 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
976 \begin_inset Text
977
978 \layout Standard
979
980 frame
981 \end_inset 
982 </cell>
983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
984 \begin_inset Text
985
986 \layout Standard
987
988 4
989 \end_inset 
990 </cell>
991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
992 \begin_inset Text
993
994 \layout Standard
995
996 4
997 \end_inset 
998 </cell>
999 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1000 \begin_inset Text
1001
1002 \layout Standard
1003
1004 4
1005 \end_inset 
1006 </cell>
1007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1008 \begin_inset Text
1009
1010 \layout Standard
1011
1012 4
1013 \end_inset 
1014 </cell>
1015 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1016 \begin_inset Text
1017
1018 \layout Standard
1019
1020 4
1021 \end_inset 
1022 </cell>
1023 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1024 \begin_inset Text
1025
1026 \layout Standard
1027
1028 4
1029 \end_inset 
1030 </cell>
1031 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1032 \begin_inset Text
1033
1034 \layout Standard
1035
1036 4
1037 \end_inset 
1038 </cell>
1039 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1040 \begin_inset Text
1041
1042 \layout Standard
1043
1044 4
1045 \end_inset 
1046 </cell>
1047 </row>
1048 <row topline="true">
1049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1050 \begin_inset Text
1051
1052 \layout Standard
1053
1054 LSP
1055 \end_inset 
1056 </cell>
1057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1058 \begin_inset Text
1059
1060 \layout Standard
1061
1062 frame
1063 \end_inset 
1064 </cell>
1065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1066 \begin_inset Text
1067
1068 \layout Standard
1069
1070 0
1071 \end_inset 
1072 </cell>
1073 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1074 \begin_inset Text
1075
1076 \layout Standard
1077
1078 18
1079 \end_inset 
1080 </cell>
1081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1082 \begin_inset Text
1083
1084 \layout Standard
1085
1086 18
1087 \end_inset 
1088 </cell>
1089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1090 \begin_inset Text
1091
1092 \layout Standard
1093
1094 18
1095 \end_inset 
1096 </cell>
1097 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1098 \begin_inset Text
1099
1100 \layout Standard
1101
1102 18
1103 \end_inset 
1104 </cell>
1105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1106 \begin_inset Text
1107
1108 \layout Standard
1109
1110 30
1111 \end_inset 
1112 </cell>
1113 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1114 \begin_inset Text
1115
1116 \layout Standard
1117
1118 30
1119 \end_inset 
1120 </cell>
1121 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1122 \begin_inset Text
1123
1124 \layout Standard
1125
1126 30
1127 \end_inset 
1128 </cell>
1129 </row>
1130 <row topline="true">
1131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1132 \begin_inset Text
1133
1134 \layout Standard
1135
1136 OL pitch
1137 \end_inset 
1138 </cell>
1139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1140 \begin_inset Text
1141
1142 \layout Standard
1143
1144 frame
1145 \end_inset 
1146 </cell>
1147 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1148 \begin_inset Text
1149
1150 \layout Standard
1151
1152 0
1153 \end_inset 
1154 </cell>
1155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1156 \begin_inset Text
1157
1158 \layout Standard
1159
1160 7
1161 \end_inset 
1162 </cell>
1163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1164 \begin_inset Text
1165
1166 \layout Standard
1167
1168 7
1169 \end_inset 
1170 </cell>
1171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1172 \begin_inset Text
1173
1174 \layout Standard
1175
1176 0
1177 \end_inset 
1178 </cell>
1179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1180 \begin_inset Text
1181
1182 \layout Standard
1183
1184 0
1185 \end_inset 
1186 </cell>
1187 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1188 \begin_inset Text
1189
1190 \layout Standard
1191
1192 0
1193 \end_inset 
1194 </cell>
1195 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1196 \begin_inset Text
1197
1198 \layout Standard
1199
1200 0
1201 \end_inset 
1202 </cell>
1203 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1204 \begin_inset Text
1205
1206 \layout Standard
1207
1208 0
1209 \end_inset 
1210 </cell>
1211 </row>
1212 <row topline="true">
1213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1214 \begin_inset Text
1215
1216 \layout Standard
1217
1218 OL pitch gain
1219 \end_inset 
1220 </cell>
1221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1222 \begin_inset Text
1223
1224 \layout Standard
1225
1226 frame
1227 \end_inset 
1228 </cell>
1229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1230 \begin_inset Text
1231
1232 \layout Standard
1233
1234 0
1235 \end_inset 
1236 </cell>
1237 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1238 \begin_inset Text
1239
1240 \layout Standard
1241
1242 4
1243 \end_inset 
1244 </cell>
1245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1246 \begin_inset Text
1247
1248 \layout Standard
1249
1250 0
1251 \end_inset 
1252 </cell>
1253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1254 \begin_inset Text
1255
1256 \layout Standard
1257
1258 0
1259 \end_inset 
1260 </cell>
1261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1262 \begin_inset Text
1263
1264 \layout Standard
1265
1266 0
1267 \end_inset 
1268 </cell>
1269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1270 \begin_inset Text
1271
1272 \layout Standard
1273
1274 0
1275 \end_inset 
1276 </cell>
1277 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1278 \begin_inset Text
1279
1280 \layout Standard
1281
1282 0
1283 \end_inset 
1284 </cell>
1285 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1286 \begin_inset Text
1287
1288 \layout Standard
1289
1290 0
1291 \end_inset 
1292 </cell>
1293 </row>
1294 <row topline="true">
1295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1296 \begin_inset Text
1297
1298 \layout Standard
1299
1300 OL Exc gain
1301 \end_inset 
1302 </cell>
1303 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1304 \begin_inset Text
1305
1306 \layout Standard
1307
1308 frame
1309 \end_inset 
1310 </cell>
1311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1312 \begin_inset Text
1313
1314 \layout Standard
1315
1316 0
1317 \end_inset 
1318 </cell>
1319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1320 \begin_inset Text
1321
1322 \layout Standard
1323
1324 5
1325 \end_inset 
1326 </cell>
1327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1328 \begin_inset Text
1329
1330 \layout Standard
1331
1332 5
1333 \end_inset 
1334 </cell>
1335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1336 \begin_inset Text
1337
1338 \layout Standard
1339
1340 5
1341 \end_inset 
1342 </cell>
1343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1344 \begin_inset Text
1345
1346 \layout Standard
1347
1348 5
1349 \end_inset 
1350 </cell>
1351 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1352 \begin_inset Text
1353
1354 \layout Standard
1355
1356 5
1357 \end_inset 
1358 </cell>
1359 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1360 \begin_inset Text
1361
1362 \layout Standard
1363
1364 5
1365 \end_inset 
1366 </cell>
1367 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1368 \begin_inset Text
1369
1370 \layout Standard
1371
1372 5
1373 \end_inset 
1374 </cell>
1375 </row>
1376 <row topline="true">
1377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1378 \begin_inset Text
1379
1380 \layout Standard
1381
1382 Fine pitch
1383 \end_inset 
1384 </cell>
1385 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1386 \begin_inset Text
1387
1388 \layout Standard
1389
1390 sub-frame
1391 \end_inset 
1392 </cell>
1393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1394 \begin_inset Text
1395
1396 \layout Standard
1397
1398 0
1399 \end_inset 
1400 </cell>
1401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1402 \begin_inset Text
1403
1404 \layout Standard
1405
1406 0
1407 \end_inset 
1408 </cell>
1409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1410 \begin_inset Text
1411
1412 \layout Standard
1413
1414 0
1415 \end_inset 
1416 </cell>
1417 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1418 \begin_inset Text
1419
1420 \layout Standard
1421
1422 7
1423 \end_inset 
1424 </cell>
1425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1426 \begin_inset Text
1427
1428 \layout Standard
1429
1430 7
1431 \end_inset 
1432 </cell>
1433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1434 \begin_inset Text
1435
1436 \layout Standard
1437
1438 7
1439 \end_inset 
1440 </cell>
1441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1442 \begin_inset Text
1443
1444 \layout Standard
1445
1446 7
1447 \end_inset 
1448 </cell>
1449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1450 \begin_inset Text
1451
1452 \layout Standard
1453
1454 7
1455 \end_inset 
1456 </cell>
1457 </row>
1458 <row topline="true">
1459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1460 \begin_inset Text
1461
1462 \layout Standard
1463
1464 Pitch gain
1465 \end_inset 
1466 </cell>
1467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1468 \begin_inset Text
1469
1470 \layout Standard
1471
1472 sub-frame
1473 \end_inset 
1474 </cell>
1475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1476 \begin_inset Text
1477
1478 \layout Standard
1479
1480 0
1481 \end_inset 
1482 </cell>
1483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1484 \begin_inset Text
1485
1486 \layout Standard
1487
1488 0
1489 \end_inset 
1490 </cell>
1491 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1492 \begin_inset Text
1493
1494 \layout Standard
1495
1496 5
1497 \end_inset 
1498 </cell>
1499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1500 \begin_inset Text
1501
1502 \layout Standard
1503
1504 5
1505 \end_inset 
1506 </cell>
1507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1508 \begin_inset Text
1509
1510 \layout Standard
1511
1512 5
1513 \end_inset 
1514 </cell>
1515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1516 \begin_inset Text
1517
1518 \layout Standard
1519
1520 7
1521 \end_inset 
1522 </cell>
1523 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1524 \begin_inset Text
1525
1526 \layout Standard
1527
1528 7
1529 \end_inset 
1530 </cell>
1531 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1532 \begin_inset Text
1533
1534 \layout Standard
1535
1536 7
1537 \end_inset 
1538 </cell>
1539 </row>
1540 <row topline="true">
1541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1542 \begin_inset Text
1543
1544 \layout Standard
1545
1546 Innovation gain
1547 \end_inset 
1548 </cell>
1549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1550 \begin_inset Text
1551
1552 \layout Standard
1553
1554 sub-frame
1555 \end_inset 
1556 </cell>
1557 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1558 \begin_inset Text
1559
1560 \layout Standard
1561
1562 0
1563 \end_inset 
1564 </cell>
1565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1566 \begin_inset Text
1567
1568 \layout Standard
1569
1570 1
1571 \end_inset 
1572 </cell>
1573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1574 \begin_inset Text
1575
1576 \layout Standard
1577
1578 0
1579 \end_inset 
1580 </cell>
1581 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1582 \begin_inset Text
1583
1584 \layout Standard
1585
1586 1
1587 \end_inset 
1588 </cell>
1589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1590 \begin_inset Text
1591
1592 \layout Standard
1593
1594 1
1595 \end_inset 
1596 </cell>
1597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1598 \begin_inset Text
1599
1600 \layout Standard
1601
1602 3
1603 \end_inset 
1604 </cell>
1605 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1606 \begin_inset Text
1607
1608 \layout Standard
1609
1610 3
1611 \end_inset 
1612 </cell>
1613 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1614 \begin_inset Text
1615
1616 \layout Standard
1617
1618 3
1619 \end_inset 
1620 </cell>
1621 </row>
1622 <row topline="true" bottomline="true">
1623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1624 \begin_inset Text
1625
1626 \layout Standard
1627
1628 Innovation VQ
1629 \end_inset 
1630 </cell>
1631 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1632 \begin_inset Text
1633
1634 \layout Standard
1635
1636 sub-frame
1637 \end_inset 
1638 </cell>
1639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1640 \begin_inset Text
1641
1642 \layout Standard
1643
1644 0
1645 \end_inset 
1646 </cell>
1647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1648 \begin_inset Text
1649
1650 \layout Standard
1651
1652 0
1653 \end_inset 
1654 </cell>
1655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1656 \begin_inset Text
1657
1658 \layout Standard
1659
1660 16
1661 \end_inset 
1662 </cell>
1663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1664 \begin_inset Text
1665
1666 \layout Standard
1667
1668 20
1669 \end_inset 
1670 </cell>
1671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1672 \begin_inset Text
1673
1674 \layout Standard
1675
1676 35
1677 \end_inset 
1678 </cell>
1679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1680 \begin_inset Text
1681
1682 \layout Standard
1683
1684 48
1685 \end_inset 
1686 </cell>
1687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1688 \begin_inset Text
1689
1690 \layout Standard
1691
1692 64
1693 \end_inset 
1694 </cell>
1695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1696 \begin_inset Text
1697
1698 \layout Standard
1699
1700 96
1701 \end_inset 
1702 </cell>
1703 </row>
1704 <row topline="true" bottomline="true">
1705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1706 \begin_inset Text
1707
1708 \layout Standard
1709
1710 Total
1711 \end_inset 
1712 </cell>
1713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1714 \begin_inset Text
1715
1716 \layout Standard
1717
1718 frame
1719 \end_inset 
1720 </cell>
1721 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1722 \begin_inset Text
1723
1724 \layout Standard
1725
1726 5
1727 \end_inset 
1728 </cell>
1729 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1730 \begin_inset Text
1731
1732 \layout Standard
1733
1734 43
1735 \end_inset 
1736 </cell>
1737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1738 \begin_inset Text
1739
1740 \layout Standard
1741
1742 119
1743 \end_inset 
1744 </cell>
1745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1746 \begin_inset Text
1747
1748 \layout Standard
1749
1750 160
1751 \end_inset 
1752 </cell>
1753 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1754 \begin_inset Text
1755
1756 \layout Standard
1757
1758 220
1759 \end_inset 
1760 </cell>
1761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1762 \begin_inset Text
1763
1764 \layout Standard
1765
1766 300
1767 \end_inset 
1768 </cell>
1769 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1770 \begin_inset Text
1771
1772 \layout Standard
1773
1774 364
1775 \end_inset 
1776 </cell>
1777 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1778 \begin_inset Text
1779
1780 \layout Standard
1781
1782 492
1783 \end_inset 
1784 </cell>
1785 </row>
1786 </lyxtabular>
1787
1788 \end_inset 
1789
1790
1791 \layout Caption
1792
1793 Bit allocation for narrowband modes
1794 \begin_inset LatexCommand \label{cap:bits-narrowband}
1795
1796 \end_inset 
1797
1798
1799 \end_inset 
1800
1801
1802 \layout Standard
1803
1804 So far, no MOS (Mean Opinion Score
1805 \begin_inset LatexCommand \index{mean opinion score}
1806
1807 \end_inset 
1808
1809 ) subjective evaluation has been performed for Speex.
1810  In order to give an idea of the quality achivable with it, table 
1811 \begin_inset LatexCommand \ref{cap:quality_vs_bps}
1812
1813 \end_inset 
1814
1815  presents my own subjective opinion on it.
1816  It sould be noted that different people will perceive the quality differently
1817  and that the person that designed the codec often has a bias (one way or
1818  another) when it comes to subjective evaluation.
1819  Last thing, it should be noted that for most codecs (including Speex) encoding
1820  quality sometimes varies depending on the input.
1821  Note that the complexity is only approximate (withing 0.5 mflops and using
1822  the lowers complexity setting).
1823  Decoding requires approximately 0.5 mflops
1824 \begin_inset LatexCommand \index{complexity}
1825
1826 \end_inset 
1827
1828  in most modes (1 mflops with perceptual enhancement).
1829 \layout Standard
1830
1831
1832 \begin_inset Float table
1833 placement htbp
1834 wide true
1835 collapsed false
1836
1837 \layout Standard
1838
1839
1840 \begin_inset  Tabular
1841 <lyxtabular version="3" rows="17" columns="4">
1842 <features>
1843 <column alignment="center" valignment="top" leftline="true" width="0pt">
1844 <column alignment="center" valignment="top" leftline="true" width="0pt">
1845 <column alignment="center" valignment="top" leftline="true" width="0pt">
1846 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
1847 <row topline="true" bottomline="true">
1848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1849 \begin_inset Text
1850
1851 \layout Standard
1852
1853 Mode
1854 \end_inset 
1855 </cell>
1856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1857 \begin_inset Text
1858
1859 \layout Standard
1860
1861 Bit-rate
1862 \begin_inset LatexCommand \index{bit-rate}
1863
1864 \end_inset 
1865
1866  (bps)
1867 \end_inset 
1868 </cell>
1869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1870 \begin_inset Text
1871
1872 \layout Standard
1873
1874 mflops
1875 \begin_inset LatexCommand \index{complexity}
1876
1877 \end_inset 
1878
1879
1880 \end_inset 
1881 </cell>
1882 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1883 \begin_inset Text
1884
1885 \layout Standard
1886
1887 Quality/description
1888 \end_inset 
1889 </cell>
1890 </row>
1891 <row topline="true">
1892 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1893 \begin_inset Text
1894
1895 \layout Standard
1896
1897 0
1898 \end_inset 
1899 </cell>
1900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1901 \begin_inset Text
1902
1903 \layout Standard
1904
1905 250
1906 \end_inset 
1907 </cell>
1908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1909 \begin_inset Text
1910
1911 \layout Standard
1912
1913 N/A
1914 \end_inset 
1915 </cell>
1916 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1917 \begin_inset Text
1918
1919 \layout Standard
1920
1921 No sound (VBR only)
1922 \end_inset 
1923 </cell>
1924 </row>
1925 <row topline="true">
1926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1927 \begin_inset Text
1928
1929 \layout Standard
1930
1931 1
1932 \end_inset 
1933 </cell>
1934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1935 \begin_inset Text
1936
1937 \layout Standard
1938
1939 2,150
1940 \end_inset 
1941 </cell>
1942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1943 \begin_inset Text
1944
1945 \layout Standard
1946
1947 6
1948 \end_inset 
1949 </cell>
1950 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1951 \begin_inset Text
1952
1953 \layout Standard
1954
1955 Vocoder (mostly for comfort noise)
1956 \end_inset 
1957 </cell>
1958 </row>
1959 <row topline="true">
1960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1961 \begin_inset Text
1962
1963 \layout Standard
1964
1965 2
1966 \end_inset 
1967 </cell>
1968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1969 \begin_inset Text
1970
1971 \layout Standard
1972
1973 5,950
1974 \end_inset 
1975 </cell>
1976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1977 \begin_inset Text
1978
1979 \layout Standard
1980
1981 9
1982 \end_inset 
1983 </cell>
1984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1985 \begin_inset Text
1986
1987 \layout Standard
1988
1989 Very noticeable artifacts/noise, good intelligibility
1990 \end_inset 
1991 </cell>
1992 </row>
1993 <row topline="true">
1994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1995 \begin_inset Text
1996
1997 \layout Standard
1998
1999 3
2000 \end_inset 
2001 </cell>
2002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2003 \begin_inset Text
2004
2005 \layout Standard
2006
2007 8,000
2008 \end_inset 
2009 </cell>
2010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2011 \begin_inset Text
2012
2013 \layout Standard
2014
2015 10
2016 \end_inset 
2017 </cell>
2018 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2019 \begin_inset Text
2020
2021 \layout Standard
2022
2023 Artifacts/noise sometimes noticeable
2024 \end_inset 
2025 </cell>
2026 </row>
2027 <row topline="true">
2028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2029 \begin_inset Text
2030
2031 \layout Standard
2032
2033 4
2034 \end_inset 
2035 </cell>
2036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2037 \begin_inset Text
2038
2039 \layout Standard
2040
2041 11,000
2042 \end_inset 
2043 </cell>
2044 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2045 \begin_inset Text
2046
2047 \layout Standard
2048
2049 14
2050 \end_inset 
2051 </cell>
2052 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2053 \begin_inset Text
2054
2055 \layout Standard
2056
2057 Artifacts usually noticeable only with headphones
2058 \end_inset 
2059 </cell>
2060 </row>
2061 <row topline="true">
2062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2063 \begin_inset Text
2064
2065 \layout Standard
2066
2067 5
2068 \end_inset 
2069 </cell>
2070 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2071 \begin_inset Text
2072
2073 \layout Standard
2074
2075 15,000
2076 \end_inset 
2077 </cell>
2078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2079 \begin_inset Text
2080
2081 \layout Standard
2082
2083 11
2084 \end_inset 
2085 </cell>
2086 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2087 \begin_inset Text
2088
2089 \layout Standard
2090
2091 Need good headphones to tell the difference
2092 \end_inset 
2093 </cell>
2094 </row>
2095 <row topline="true">
2096 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2097 \begin_inset Text
2098
2099 \layout Standard
2100
2101 6
2102 \end_inset 
2103 </cell>
2104 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2105 \begin_inset Text
2106
2107 \layout Standard
2108
2109 18,200
2110 \end_inset 
2111 </cell>
2112 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2113 \begin_inset Text
2114
2115 \layout Standard
2116
2117 17.5
2118 \end_inset 
2119 </cell>
2120 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2121 \begin_inset Text
2122
2123 \layout Standard
2124
2125 Hard to tell the difference even with good headphones
2126 \end_inset 
2127 </cell>
2128 </row>
2129 <row topline="true">
2130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2131 \begin_inset Text
2132
2133 \layout Standard
2134
2135 7
2136 \end_inset 
2137 </cell>
2138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2139 \begin_inset Text
2140
2141 \layout Standard
2142
2143 24,600
2144 \end_inset 
2145 </cell>
2146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2147 \begin_inset Text
2148
2149 \layout Standard
2150
2151 14.5
2152 \end_inset 
2153 </cell>
2154 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2155 \begin_inset Text
2156
2157 \layout Standard
2158
2159 Completely transparent for voice, good quality music
2160 \end_inset 
2161 </cell>
2162 </row>
2163 <row topline="true">
2164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2165 \begin_inset Text
2166
2167 \layout Standard
2168
2169 8
2170 \end_inset 
2171 </cell>
2172 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2173 \begin_inset Text
2174
2175 \layout Standard
2176
2177 N/A
2178 \end_inset 
2179 </cell>
2180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2181 \begin_inset Text
2182
2183 \layout Standard
2184
2185 N/A
2186 \end_inset 
2187 </cell>
2188 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2189 \begin_inset Text
2190
2191 \layout Standard
2192
2193 (Tones/DTMF to be implemented)
2194 \end_inset 
2195 </cell>
2196 </row>
2197 <row topline="true">
2198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2199 \begin_inset Text
2200
2201 \layout Standard
2202
2203 9
2204 \end_inset 
2205 </cell>
2206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2207 \begin_inset Text
2208
2209 \layout Standard
2210
2211 N/A
2212 \end_inset 
2213 </cell>
2214 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2215 \begin_inset Text
2216
2217 \layout Standard
2218
2219 N/A
2220 \end_inset 
2221 </cell>
2222 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2223 \begin_inset Text
2224
2225 \layout Standard
2226
2227 reserved
2228 \end_inset 
2229 </cell>
2230 </row>
2231 <row topline="true">
2232 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2233 \begin_inset Text
2234
2235 \layout Standard
2236
2237 10
2238 \end_inset 
2239 </cell>
2240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2241 \begin_inset Text
2242
2243 \layout Standard
2244
2245 N/A
2246 \end_inset 
2247 </cell>
2248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2249 \begin_inset Text
2250
2251 \layout Standard
2252
2253 N/A
2254 \end_inset 
2255 </cell>
2256 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2257 \begin_inset Text
2258
2259 \layout Standard
2260
2261 reserved
2262 \end_inset 
2263 </cell>
2264 </row>
2265 <row topline="true">
2266 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2267 \begin_inset Text
2268
2269 \layout Standard
2270
2271 11
2272 \end_inset 
2273 </cell>
2274 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2275 \begin_inset Text
2276
2277 \layout Standard
2278
2279 N/A
2280 \end_inset 
2281 </cell>
2282 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2283 \begin_inset Text
2284
2285 \layout Standard
2286
2287 N/A
2288 \end_inset 
2289 </cell>
2290 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2291 \begin_inset Text
2292
2293 \layout Standard
2294
2295 reserved
2296 \end_inset 
2297 </cell>
2298 </row>
2299 <row topline="true">
2300 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2301 \begin_inset Text
2302
2303 \layout Standard
2304
2305 12
2306 \end_inset 
2307 </cell>
2308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2309 \begin_inset Text
2310
2311 \layout Standard
2312
2313 N/A
2314 \end_inset 
2315 </cell>
2316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2317 \begin_inset Text
2318
2319 \layout Standard
2320
2321 N/A
2322 \end_inset 
2323 </cell>
2324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2325 \begin_inset Text
2326
2327 \layout Standard
2328
2329 reserved
2330 \end_inset 
2331 </cell>
2332 </row>
2333 <row topline="true">
2334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2335 \begin_inset Text
2336
2337 \layout Standard
2338
2339 13
2340 \end_inset 
2341 </cell>
2342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2343 \begin_inset Text
2344
2345 \layout Standard
2346
2347 N/A
2348 \end_inset 
2349 </cell>
2350 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2351 \begin_inset Text
2352
2353 \layout Standard
2354
2355 N/A
2356 \end_inset 
2357 </cell>
2358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2359 \begin_inset Text
2360
2361 \layout Standard
2362
2363 Application-defined, interpreted by callback or skipped
2364 \end_inset 
2365 </cell>
2366 </row>
2367 <row topline="true">
2368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2369 \begin_inset Text
2370
2371 \layout Standard
2372
2373 14
2374 \end_inset 
2375 </cell>
2376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2377 \begin_inset Text
2378
2379 \layout Standard
2380
2381 N/A
2382 \end_inset 
2383 </cell>
2384 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2385 \begin_inset Text
2386
2387 \layout Standard
2388
2389 N/A
2390 \end_inset 
2391 </cell>
2392 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2393 \begin_inset Text
2394
2395 \layout Standard
2396
2397 Speex in-band signaling
2398 \end_inset 
2399 </cell>
2400 </row>
2401 <row topline="true" bottomline="true">
2402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2403 \begin_inset Text
2404
2405 \layout Standard
2406
2407 15
2408 \end_inset 
2409 </cell>
2410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2411 \begin_inset Text
2412
2413 \layout Standard
2414
2415 N/A
2416 \end_inset 
2417 </cell>
2418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2419 \begin_inset Text
2420
2421 \layout Standard
2422
2423 N/A
2424 \end_inset 
2425 </cell>
2426 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2427 \begin_inset Text
2428
2429 \layout Standard
2430
2431 Terminator code
2432 \end_inset 
2433 </cell>
2434 </row>
2435 </lyxtabular>
2436
2437 \end_inset 
2438
2439
2440 \layout Caption
2441
2442 Quality versus bit-rate
2443 \begin_inset LatexCommand \label{cap:quality_vs_bps}
2444
2445 \end_inset 
2446
2447
2448 \end_inset 
2449
2450
2451 \layout Subsection
2452
2453 Perceptual enhancement
2454 \begin_inset LatexCommand \index{perceptual enhancement}
2455
2456 \end_inset 
2457
2458
2459 \layout Standard
2460
2461 This part of the codec only applies to the decoder and can even be changed
2462  without affecting inter-operability.
2463  For that reason, the implementation provided and described here should
2464  only be considered as a reference implementation.
2465  The enhancement system is devided in two parts.
2466  First, the synthesis filter 
2467 \begin_inset Formula $S(z)=1/A(z)$
2468 \end_inset 
2469
2470  is replaced by an enhanced filter
2471 \begin_inset Formula \[
2472 S'(z)=\frac{A\left(z/a_{2}\right)A\left(z/a_{3}\right)}{A\left(z\right)A\left(z/a_{1}\right)}\]
2473
2474 \end_inset 
2475
2476 where 
2477 \begin_inset Formula $a_{1}$
2478 \end_inset 
2479
2480  and 
2481 \begin_inset Formula $a_{2}$
2482 \end_inset 
2483
2484  depend on the mode in use and 
2485 \begin_inset Formula $a_{3}=\frac{1}{r}\left(1-\frac{1-ra_{1}}{1-ra_{2}}\right)$
2486 \end_inset 
2487
2488  with 
2489 \begin_inset Formula $r=.9$
2490 \end_inset 
2491
2492 .
2493  The second part of the enhancement consists of using a comb filter to enhance
2494  the pitch in the excitation domain.
2495  
2496 \layout Section
2497 \pagebreak_top 
2498 Speex wideband mode (sub-band CELP)
2499 \begin_inset LatexCommand \index{wideband}
2500
2501 \end_inset 
2502
2503
2504 \layout Standard
2505
2506 For wideband, the Speex approach uses a 
2507 \emph on 
2508 q
2509 \emph default 
2510 uadrature 
2511 \emph on 
2512 m
2513 \emph default 
2514 irror 
2515 \emph on 
2516 f
2517 \emph default 
2518 ilter
2519 \begin_inset LatexCommand \index{quadrature mirror filter}
2520
2521 \end_inset 
2522
2523  (QMF) to split the band in two.
2524  The 16 kHz signal is thus divided into two 8 kHz signals, one representing
2525  the low band (0-4 kHz), the other the high band (4-8 kHz).
2526  The low band is encoded with the narrowband mode described in section 
2527 \begin_inset LatexCommand \ref{sec:Speex-narrowband-mode}
2528
2529 \end_inset 
2530
2531  in such a way that the resulting 
2532 \begin_inset Quotes eld
2533 \end_inset 
2534
2535 embedded narrowband bit-stream
2536 \begin_inset Quotes erd
2537 \end_inset 
2538
2539  can also be decoded with the narrowband decoder.
2540  Since the low band encoding has already been described only the high band
2541  encoding is described in this section.
2542 \layout Subsection
2543
2544 Linear Prediction
2545 \layout Standard
2546
2547 The linear prediction part used for the high-band is very similar to what
2548  is done for narrowband.
2549  The only difference is that we use only 12 bits to encode the high-band
2550  LSP's using a multi-stage vector quantizer (MSVQ).
2551  The first level quantizes the 10 coefficients with 6 bits and the error
2552  is then quantized using 6 bits too.
2553 \layout Subsection
2554
2555 Pitch Prediction
2556 \layout Standard
2557
2558 That part is easy: there's no pitch prediction for the high-band.
2559  There are two reasons for that.
2560  First, there is usually little harmonic structure in this band (above 4
2561  kHz).
2562  Second, it would be very hard to implement since the QMF folds the 4-8
2563  kHz band into 4-0 kHz (reversing the frequency axis), which means that
2564  the location of the harmonics are no longer at multiples of the fundamental
2565  (pitch).
2566 \layout Subsection
2567
2568 Excitation Quantization
2569 \layout Standard
2570
2571 The high-band excitation is coded in the same way as for narrowband.
2572  
2573 \layout Subsection
2574
2575 Bit allocation
2576 \layout Standard
2577
2578 For the wideband mode, all the narrowband frame is packed before the high-band
2579  is encoded.
2580  The narrowband part of the bit-stream is as defined in table 
2581 \begin_inset LatexCommand \ref{cap:bits-narrowband}
2582
2583 \end_inset 
2584
2585 .
2586  The high-band follows, as described in table 
2587 \begin_inset LatexCommand \ref{cap:bits-wideband}
2588
2589 \end_inset 
2590
2591 .
2592  This also means that a wideband frame may be correctly decoded by a narrowband
2593  decoder with the only caveat that if more than one frame is packed in the
2594  same packet, the decoder will need to skip the high-band parts in order
2595  to sync with the bit-stream.
2596 \layout Standard
2597
2598
2599 \begin_inset Float table
2600 placement htbp
2601 wide true
2602 collapsed false
2603
2604 \layout Standard
2605
2606
2607 \begin_inset  Tabular
2608 <lyxtabular version="3" rows="7" columns="7">
2609 <features>
2610 <column alignment="center" valignment="top" leftline="true" width="0pt">
2611 <column alignment="center" valignment="top" leftline="true" width="0pt">
2612 <column alignment="center" valignment="top" leftline="true" width="0pt">
2613 <column alignment="center" valignment="top" leftline="true" width="0pt">
2614 <column alignment="center" valignment="top" leftline="true" width="0pt">
2615 <column alignment="center" valignment="top" leftline="true" width="0pt">
2616 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
2617 <row topline="true" bottomline="true">
2618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2619 \begin_inset Text
2620
2621 \layout Standard
2622
2623 Parameter
2624 \end_inset 
2625 </cell>
2626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2627 \begin_inset Text
2628
2629 \layout Standard
2630
2631 Update rate
2632 \end_inset 
2633 </cell>
2634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2635 \begin_inset Text
2636
2637 \layout Standard
2638
2639 0
2640 \end_inset 
2641 </cell>
2642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2643 \begin_inset Text
2644
2645 \layout Standard
2646
2647 1
2648 \end_inset 
2649 </cell>
2650 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2651 \begin_inset Text
2652
2653 \layout Standard
2654
2655 2
2656 \end_inset 
2657 </cell>
2658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2659 \begin_inset Text
2660
2661 \layout Standard
2662
2663 3
2664 \end_inset 
2665 </cell>
2666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2667 \begin_inset Text
2668
2669 \layout Standard
2670
2671 4
2672 \end_inset 
2673 </cell>
2674 </row>
2675 <row topline="true">
2676 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2677 \begin_inset Text
2678
2679 \layout Standard
2680
2681 Wideband bit
2682 \end_inset 
2683 </cell>
2684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2685 \begin_inset Text
2686
2687 \layout Standard
2688
2689 frame
2690 \end_inset 
2691 </cell>
2692 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2693 \begin_inset Text
2694
2695 \layout Standard
2696
2697 1
2698 \end_inset 
2699 </cell>
2700 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2701 \begin_inset Text
2702
2703 \layout Standard
2704
2705 1
2706 \end_inset 
2707 </cell>
2708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2709 \begin_inset Text
2710
2711 \layout Standard
2712
2713 1
2714 \end_inset 
2715 </cell>
2716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2717 \begin_inset Text
2718
2719 \layout Standard
2720
2721 1
2722 \end_inset 
2723 </cell>
2724 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2725 \begin_inset Text
2726
2727 \layout Standard
2728
2729 1
2730 \end_inset 
2731 </cell>
2732 </row>
2733 <row topline="true">
2734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2735 \begin_inset Text
2736
2737 \layout Standard
2738
2739 Mode ID
2740 \end_inset 
2741 </cell>
2742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2743 \begin_inset Text
2744
2745 \layout Standard
2746
2747 frame
2748 \end_inset 
2749 </cell>
2750 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2751 \begin_inset Text
2752
2753 \layout Standard
2754
2755 3
2756 \end_inset 
2757 </cell>
2758 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2759 \begin_inset Text
2760
2761 \layout Standard
2762
2763 3
2764 \end_inset 
2765 </cell>
2766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2767 \begin_inset Text
2768
2769 \layout Standard
2770
2771 3
2772 \end_inset 
2773 </cell>
2774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2775 \begin_inset Text
2776
2777 \layout Standard
2778
2779 3
2780 \end_inset 
2781 </cell>
2782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2783 \begin_inset Text
2784
2785 \layout Standard
2786
2787 3
2788 \end_inset 
2789 </cell>
2790 </row>
2791 <row topline="true">
2792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2793 \begin_inset Text
2794
2795 \layout Standard
2796
2797 LSP
2798 \end_inset 
2799 </cell>
2800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2801 \begin_inset Text
2802
2803 \layout Standard
2804
2805 frame
2806 \end_inset 
2807 </cell>
2808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2809 \begin_inset Text
2810
2811 \layout Standard
2812
2813 0
2814 \end_inset 
2815 </cell>
2816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2817 \begin_inset Text
2818
2819 \layout Standard
2820
2821 12
2822 \end_inset 
2823 </cell>
2824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2825 \begin_inset Text
2826
2827 \layout Standard
2828
2829 12
2830 \end_inset 
2831 </cell>
2832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2833 \begin_inset Text
2834
2835 \layout Standard
2836
2837 12
2838 \end_inset 
2839 </cell>
2840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2841 \begin_inset Text
2842
2843 \layout Standard
2844
2845 12
2846 \end_inset 
2847 </cell>
2848 </row>
2849 <row topline="true">
2850 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2851 \begin_inset Text
2852
2853 \layout Standard
2854
2855 Excitation gain
2856 \end_inset 
2857 </cell>
2858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2859 \begin_inset Text
2860
2861 \layout Standard
2862
2863 sub-frame
2864 \end_inset 
2865 </cell>
2866 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2867 \begin_inset Text
2868
2869 \layout Standard
2870
2871 0
2872 \end_inset 
2873 </cell>
2874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2875 \begin_inset Text
2876
2877 \layout Standard
2878
2879 5
2880 \end_inset 
2881 </cell>
2882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2883 \begin_inset Text
2884
2885 \layout Standard
2886
2887 4
2888 \end_inset 
2889 </cell>
2890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2891 \begin_inset Text
2892
2893 \layout Standard
2894
2895 4
2896 \end_inset 
2897 </cell>
2898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2899 \begin_inset Text
2900
2901 \layout Standard
2902
2903 4
2904 \end_inset 
2905 </cell>
2906 </row>
2907 <row topline="true" bottomline="true">
2908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2909 \begin_inset Text
2910
2911 \layout Standard
2912
2913 Excitation VQ
2914 \end_inset 
2915 </cell>
2916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2917 \begin_inset Text
2918
2919 \layout Standard
2920
2921 sub-frame
2922 \end_inset 
2923 </cell>
2924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2925 \begin_inset Text
2926
2927 \layout Standard
2928
2929 0
2930 \end_inset 
2931 </cell>
2932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2933 \begin_inset Text
2934
2935 \layout Standard
2936
2937 0
2938 \end_inset 
2939 </cell>
2940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2941 \begin_inset Text
2942
2943 \layout Standard
2944
2945 20
2946 \end_inset 
2947 </cell>
2948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2949 \begin_inset Text
2950
2951 \layout Standard
2952
2953 40
2954 \end_inset 
2955 </cell>
2956 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2957 \begin_inset Text
2958
2959 \layout Standard
2960
2961 80
2962 \end_inset 
2963 </cell>
2964 </row>
2965 <row topline="true" bottomline="true">
2966 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2967 \begin_inset Text
2968
2969 \layout Standard
2970
2971 Total
2972 \end_inset 
2973 </cell>
2974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2975 \begin_inset Text
2976
2977 \layout Standard
2978
2979 frame
2980 \end_inset 
2981 </cell>
2982 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2983 \begin_inset Text
2984
2985 \layout Standard
2986
2987 4
2988 \end_inset 
2989 </cell>
2990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2991 \begin_inset Text
2992
2993 \layout Standard
2994
2995 36
2996 \end_inset 
2997 </cell>
2998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2999 \begin_inset Text
3000
3001 \layout Standard
3002
3003 112
3004 \end_inset 
3005 </cell>
3006 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3007 \begin_inset Text
3008
3009 \layout Standard
3010
3011 192
3012 \end_inset 
3013 </cell>
3014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3015 \begin_inset Text
3016
3017 \layout Standard
3018
3019 352
3020 \end_inset 
3021 </cell>
3022 </row>
3023 </lyxtabular>
3024
3025 \end_inset 
3026
3027
3028 \layout Caption
3029
3030 Bit allocation for high-band in wideband mode
3031 \begin_inset LatexCommand \label{cap:bits-wideband}
3032
3033 \end_inset 
3034
3035
3036 \end_inset 
3037
3038
3039 \layout Section
3040 \pagebreak_top 
3041 Command-line encoder/decoder
3042 \layout Standard
3043
3044 The base Speex distribution includes a command-line encoder (
3045 \emph on 
3046 speexenc
3047 \emph default 
3048 ) and decoder (
3049 \emph on 
3050 speexdec
3051 \emph default 
3052 ).
3053 \layout Subsection
3054
3055
3056 \emph on 
3057 speexenc
3058 \begin_inset LatexCommand \index{speexenc}
3059
3060 \end_inset 
3061
3062
3063 \layout Standard
3064
3065 The encoder takes the following options:
3066 \layout Description
3067
3068 --narrowband\SpecialChar ~
3069 (-n) Tell Speex to treat the input as narrowband (8 kHz).
3070  This is the default
3071 \layout Description
3072
3073 --wideband\SpecialChar ~
3074 (-w) Tell Speex to treat the input as wideband (16 kHz)
3075 \layout Description
3076
3077 --quality\SpecialChar ~
3078 n Set the encoding quality (0-10)
3079 \layout Description
3080
3081 --vbr Enable VBR (Variable Bit-Rate), disabled by default
3082 \layout Description
3083
3084 --nframes\SpecialChar ~
3085 n Pack n frames in each Ogg packet (this saves space at low bit-rates)
3086 \layout Description
3087
3088 --comp\SpecialChar ~
3089 n Set encoding speed/quality tradeoff.
3090  The higher the value of n, the slower the encoding (default is 3)
3091 \layout Description
3092
3093 -V Verbose operation, print bit-rate currently in use
3094 \layout Description
3095
3096 --help\SpecialChar ~
3097 (-h) Print the help
3098 \layout Description
3099
3100 --version\SpecialChar ~
3101 (-v) Print version information
3102 \layout Subsection
3103
3104
3105 \emph on 
3106 speexdec
3107 \begin_inset LatexCommand \index{speexdec}
3108
3109 \end_inset 
3110
3111
3112 \layout Standard
3113
3114 The decoder takes the following options:
3115 \layout Description
3116
3117 --enh enable post-filter
3118 \layout Description
3119
3120 --no-enh disable post-filter (default)
3121 \layout Description
3122
3123 --packet-loss\SpecialChar ~
3124 n Simulate n % random packet loss
3125 \layout Description
3126
3127 -V Verbose operation, print bit-rate currently in use
3128 \layout Description
3129
3130 --help\SpecialChar ~
3131 (-h) Print the help
3132 \layout Description
3133
3134 --version\SpecialChar ~
3135 (-v) Print version information
3136 \layout Section
3137 \pagebreak_top 
3138 Programming with Speex (the libspeex
3139 \begin_inset LatexCommand \index{libspeex}
3140
3141 \end_inset 
3142
3143  API
3144 \begin_inset LatexCommand \index{API}
3145
3146 \end_inset 
3147
3148 )
3149 \layout Subsection
3150
3151 Encoding
3152 \layout Standard
3153
3154 In order to encode speech using Speex, you first need to:
3155 \layout LyX-Code
3156
3157 #include <speex.h>
3158 \layout Standard
3159
3160 You then need to declare a Speex bit-packing struct
3161 \layout LyX-Code
3162
3163 SpeexBits bits;
3164 \layout Standard
3165
3166 and a Speex encoder state
3167 \layout LyX-Code
3168
3169 void *enc_state;
3170 \layout Standard
3171
3172 The two are initialized by:
3173 \layout LyX-Code
3174
3175 speex_bits_init(&bits);
3176 \layout LyX-Code
3177
3178 enc_state = speex_encoder_init(&speex_nb_mode);
3179 \layout Standard
3180
3181 For wideband coding, 
3182 \emph on 
3183 speex_nb_mode
3184 \emph default 
3185  will be replaced by 
3186 \emph on 
3187 speex_wb_mode
3188 \emph default 
3189 .
3190  In most cases, you will need to know the frame size used by the mode you
3191  are using.
3192  You can get that value in the 
3193 \emph on 
3194 frame_size
3195 \emph default 
3196  variable with:
3197 \layout LyX-Code
3198
3199 speex_encoder_ctl(enc_state,SPEEX_GET_FRAME_SIZE,&frame_size);
3200 \layout Standard
3201
3202 Once the initialization is done, for every input frame:
3203 \layout LyX-Code
3204
3205 speex_bits_reset(&bits);
3206 \layout LyX-Code
3207
3208 speex_encode(enc_state, input_frame, &bits);
3209 \layout LyX-Code
3210
3211 nbBytes = speex_bits_write(&bits, byte_ptr, MAX_NB_BYTES);
3212 \layout Standard
3213
3214 where 
3215 \emph on 
3216 input_frame
3217 \emph default 
3218  is a 
3219 \emph on 
3220 (float *)
3221 \emph default 
3222  pointing to the beginning of a speech frame, 
3223 \emph on 
3224 byte_ptr
3225 \emph default 
3226  is a 
3227 \emph on 
3228 (char *)
3229 \emph default 
3230  where the encoded frame will be written, 
3231 \emph on 
3232 MAX_NB_BYTES
3233 \emph default 
3234  is the maximum number of bytes that can be written to 
3235 \emph on 
3236 byte_ptr
3237 \emph default 
3238  without causing an overflow and 
3239 \emph on 
3240 nbBytes
3241 \emph default 
3242  is the number of bytes actually written to 
3243 \emph on 
3244 byte_ptr
3245 \emph default 
3246  (the encoded size in bytes).
3247  Before calling speex_bits_write, it is possible to find the number of bytes
3248  that need to be written by calling 
3249 \family typewriter 
3250 speex_bits_nbytes(&bits)
3251 \family default 
3252 , which returns a number of bytes.
3253  
3254 \layout Standard
3255
3256 After you're done with the encoding, free all resources with:
3257 \layout LyX-Code
3258
3259 speex_bits_destroy(&bits);
3260 \layout LyX-Code
3261
3262 speex_encoder_destroy(enc_state);
3263 \layout Standard
3264
3265 That's about it for the encoder.
3266  
3267 \layout Subsection
3268
3269 Decoding
3270 \layout Standard
3271
3272 In order to encode speech using Speex, you first need to:
3273 \layout LyX-Code
3274
3275 #include <speex.h>
3276 \layout Standard
3277
3278 You then need to declare a Speex bit-packing struct
3279 \layout LyX-Code
3280
3281 SpeexBits bits;
3282 \layout Standard
3283
3284 and a Speex encoder state
3285 \layout LyX-Code
3286
3287 void *dec_state;
3288 \layout Standard
3289
3290 The two are initialized by:
3291 \layout LyX-Code
3292
3293 speex_bits_init(&bits);
3294 \layout LyX-Code
3295
3296 dec_state = speex_decoder_init(&speex_nb_mode);
3297 \layout Standard
3298
3299 For wideband decoding, 
3300 \emph on 
3301 speex_nb_mode
3302 \emph default 
3303  will be replaced by 
3304 \emph on 
3305 speex_wb_mode
3306 \emph default 
3307 .
3308  You can get that value in the 
3309 \emph on 
3310 frame_size
3311 \emph default 
3312  variable with:
3313 \layout LyX-Code
3314
3315 speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &frame_size); 
3316 \layout Standard
3317
3318 There is also a parameter that can be set for the decoder: whether or not
3319  to use a perceptual post-filter.
3320  This can be set by: 
3321 \layout LyX-Code
3322
3323 speex_decoder_ctl(dec_state, SPEEX_SET_PF, &pf); 
3324 \layout Standard
3325
3326 where pf is an int that with value 0 to have the post-filter disabled and
3327  1 to have it enabled.
3328 \layout Standard
3329
3330 Again, once the decoder initialization is done, for every input frame:
3331 \layout LyX-Code
3332
3333 speex_bits_read_from(&bits, input_bytes, nbBytes);
3334 \layout LyX-Code
3335
3336 speex_decode(st, &bits, output_frame);
3337 \layout Standard
3338
3339 where input_bytes is a 
3340 \emph on 
3341 (char *)
3342 \emph default 
3343  containing the bit-stream data received for a frame, 
3344 \emph on 
3345 nbBytes
3346 \emph default 
3347  is the size (in bytes) of that bit-stream, and 
3348 \emph on 
3349 output_frame
3350 \emph default 
3351  is a 
3352 \emph on 
3353 (float *)
3354 \emph default 
3355  and points to the area where the decoded speech frame will be written.
3356  A NULL value as the first argument indicates that we don't have the bits
3357  for the current frame.
3358  When a frame is lost, the Speex decoder will do its best to "guess" the
3359  correct signal.
3360 \layout Standard
3361
3362 After you're done with the decoding, free all resources with:
3363 \layout LyX-Code
3364
3365 speex_bits_destroy(&bits);
3366 \layout LyX-Code
3367
3368 speex_decoder_destroy(dec_state);
3369 \layout Subsection
3370
3371 Codec Options (speex_*_ctl)
3372 \layout Standard
3373
3374 The Speex encoder and decoder support many options and requests that can
3375  be accessed through the 
3376 \emph on 
3377 speex_encoder_ctl
3378 \emph default 
3379  and 
3380 \emph on 
3381 speex_decoder_ctl
3382 \emph default 
3383  functions.
3384  These functions are similar the the 
3385 \emph on 
3386 ioctl
3387 \emph default 
3388  system call and their prototypes are:
3389 \layout LyX-Code
3390
3391 void speex_encoder_ctl(void *encoder, int request, void *ptr);
3392 \layout LyX-Code
3393
3394 void speex_decoder_ctl(void *encoder, int request, void *ptr);
3395 \layout Standard
3396
3397 The different values of request allowed are (note that some only apply to
3398  the encoder or the decoder):
3399 \layout Description
3400
3401 SPEEX_SET_ENH** Set perceptual enhancer to on (1) or off (0) (integer)
3402 \layout Description
3403
3404 SPEEX_GET_ENH** Get perceptual enhancer status (integer)
3405 \layout Description
3406
3407 SPEEX_GET_FRAME_SIZE Get the frame size used for the current mode (integer)
3408 \layout Description
3409
3410 SPEEX_SET_QUALITY* Set the encoder speech quality (integer 0 to 10)
3411 \layout Description
3412
3413 SPEEX_GET_QUALITY* Get the current encoder speech quality (integer 0 to
3414  10)
3415 \layout Description
3416
3417 SPEEX_SET_MODE*
3418 \begin_inset Formula $\dagger $
3419 \end_inset 
3420
3421
3422 \layout Description
3423
3424 SPEEX_GET_MODE*
3425 \begin_inset Formula $\dagger $
3426 \end_inset 
3427
3428
3429 \layout Description
3430
3431 SPEEX_SET_LOW_MODE*
3432 \begin_inset Formula $\dagger $
3433 \end_inset 
3434
3435
3436 \layout Description
3437
3438 SPEEX_GET_LOW_MODE*
3439 \begin_inset Formula $\dagger $
3440 \end_inset 
3441
3442
3443 \layout Description
3444
3445 SPEEX_SET_HIGH_MODE*
3446 \begin_inset Formula $\dagger $
3447 \end_inset 
3448
3449
3450 \layout Description
3451
3452 SPEEX_GET_HIGH_MODE*
3453 \begin_inset Formula $\dagger $
3454 \end_inset 
3455
3456
3457 \layout Description
3458
3459 SPEEX_SET_VBR* Set variable bit-rate (VBR) to on (1) or off (0) (integer)
3460 \layout Description
3461
3462 SPEEX_GET_VBR* Get variable bit-rate (VBR) status (integer)
3463 \layout Description
3464
3465 SPEEX_SET_VBR_QUALITY* Set the encoder VBR speech quality (integer 0 to
3466  10)
3467 \layout Description
3468
3469 SPEEX_GET_VBR_QUALITY* Get the current encoder VBR speech quality (integer
3470  0 to 10)
3471 \layout Description
3472
3473 SPEEX_SET_COMPLEXITY* Set the CPU resources allowed for the encoder
3474 \layout Description
3475
3476 SPEEX_GET_COMPLEXITY* Get the CPU resources allowed for the encoder
3477 \layout Description
3478
3479 SPEEX_GET_BITRATE Get the current bit-rate in use (integer in bps)
3480 \layout Description
3481
3482 * applies only to the encoder
3483 \layout Description
3484
3485 ** applies only to the decoder
3486 \layout Description
3487
3488
3489 \begin_inset Formula $\dagger $
3490 \end_inset 
3491
3492  normally only used internally
3493 \layout Subsection
3494
3495 Mode queries
3496 \layout Standard
3497
3498 Speex modes have a querry system similar to the speex_encoder_ctl and speex_deco
3499 der_ctl calls.
3500  Since modes are read-only, it is only possible to get information about
3501  a particular mode.
3502  The function used to do that is:
3503 \layout LyX-Code
3504
3505 void speex_mode_query(SpeexMode *mode, int request, void *ptr);
3506 \layout Standard
3507
3508 The admissible values for request are (unless otherwise note, the values
3509  are returned through 
3510 \emph on 
3511 ptr
3512 \emph default 
3513 ):
3514 \layout Description
3515
3516 SPEEX_MODE_FRAME_SIZE Get the frame size (in samples) for the mode
3517 \layout Description
3518
3519 SPEEX_SUBMODE_BITRATE Get the bit-rate for a submode number specified throught
3520  
3521 \emph on 
3522 ptr
3523 \emph default 
3524 .
3525 \layout Subsection
3526
3527 Packing and in-band signalling
3528 \begin_inset LatexCommand \index{in-band signalling}
3529
3530 \end_inset 
3531
3532
3533 \layout Standard
3534
3535 Sometimes it is desirable to pack more than one frame per packet (or other
3536  basic unit of storage).
3537  The proper way to do it is to call speex_encode 
3538 \begin_inset Formula $N$
3539 \end_inset 
3540
3541  times before writing the stream with speex_bits_write.
3542  In cases where the number of frames is not determined by an out-of-band
3543  mechanism, it is possible to include a terminator code.
3544  That terminator consists of the code 15 (decimal) encoded with 5 bits,
3545  as shown in figure 
3546 \begin_inset LatexCommand \ref{cap:quality_vs_bps}
3547
3548 \end_inset 
3549
3550 .
3551  
3552 \layout Standard
3553
3554 It is also possible to send in-band 
3555 \begin_inset Quotes eld
3556 \end_inset 
3557
3558 messages
3559 \begin_inset Quotes erd
3560 \end_inset 
3561
3562  to the other side.
3563  All these messages are encoded as a 
3564 \begin_inset Quotes eld
3565 \end_inset 
3566
3567 pseudo-frame
3568 \begin_inset Quotes erd
3569 \end_inset 
3570
3571  of mode 14 which contain a 4-bit message type code, followed by the message.
3572  Table 
3573 \begin_inset LatexCommand \ref{cap:In-band-signalling-codes}
3574
3575 \end_inset 
3576
3577  lists the available codes, their meaning and the size of the message that
3578  follow.
3579  Most of these messages are requests that are sent to the encoder or decoder
3580  on the other end, which is free to comply or ignore them.
3581  By default, all in-band messages are ignored.
3582 \layout Standard
3583
3584
3585 \begin_inset Float table
3586 placement htbp
3587 wide false
3588 collapsed false
3589
3590 \layout Standard
3591
3592
3593 \begin_inset  Tabular
3594 <lyxtabular version="3" rows="17" columns="3">
3595 <features>
3596 <column alignment="center" valignment="top" leftline="true" width="0pt">
3597 <column alignment="center" valignment="top" leftline="true" width="0pt">
3598 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
3599 <row topline="true" bottomline="true">
3600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3601 \begin_inset Text
3602
3603 \layout Standard
3604
3605 code
3606 \end_inset 
3607 </cell>
3608 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3609 \begin_inset Text
3610
3611 \layout Standard
3612
3613 Size (bits)
3614 \end_inset 
3615 </cell>
3616 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3617 \begin_inset Text
3618
3619 \layout Standard
3620
3621 Content
3622 \end_inset 
3623 </cell>
3624 </row>
3625 <row topline="true">
3626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3627 \begin_inset Text
3628
3629 \layout Standard
3630
3631 0
3632 \end_inset 
3633 </cell>
3634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3635 \begin_inset Text
3636
3637 \layout Standard
3638
3639 1
3640 \end_inset 
3641 </cell>
3642 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3643 \begin_inset Text
3644
3645 \layout Standard
3646
3647 Asks decoder to set perceptual enhancement on (1) or off(1)
3648 \end_inset 
3649 </cell>
3650 </row>
3651 <row topline="true">
3652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3653 \begin_inset Text
3654
3655 \layout Standard
3656
3657 1
3658 \end_inset 
3659 </cell>
3660 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3661 \begin_inset Text
3662
3663 \layout Standard
3664
3665 1
3666 \end_inset 
3667 </cell>
3668 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3669 \begin_inset Text
3670
3671 \layout Standard
3672
3673 Asks encoder to set VBR on (1) or off(1)
3674 \end_inset 
3675 </cell>
3676 </row>
3677 <row topline="true">
3678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3679 \begin_inset Text
3680
3681 \layout Standard
3682
3683 2
3684 \end_inset 
3685 </cell>
3686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3687 \begin_inset Text
3688
3689 \layout Standard
3690
3691 4
3692 \end_inset 
3693 </cell>
3694 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3695 \begin_inset Text
3696
3697 \layout Standard
3698
3699 Asks encoder to switch to mode N
3700 \end_inset 
3701 </cell>
3702 </row>
3703 <row topline="true">
3704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3705 \begin_inset Text
3706
3707 \layout Standard
3708
3709 3
3710 \end_inset 
3711 </cell>
3712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3713 \begin_inset Text
3714
3715 \layout Standard
3716
3717 4
3718 \end_inset 
3719 </cell>
3720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3721 \begin_inset Text
3722
3723 \layout Standard
3724
3725 Asks encoder to switch to mode N for low-band
3726 \end_inset 
3727 </cell>
3728 </row>
3729 <row topline="true">
3730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3731 \begin_inset Text
3732
3733 \layout Standard
3734
3735 4
3736 \end_inset 
3737 </cell>
3738 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3739 \begin_inset Text
3740
3741 \layout Standard
3742
3743 4
3744 \end_inset 
3745 </cell>
3746 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3747 \begin_inset Text
3748
3749 \layout Standard
3750
3751 Asks encoder to switch to mode N for high-band
3752 \end_inset 
3753 </cell>
3754 </row>
3755 <row topline="true">
3756 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3757 \begin_inset Text
3758
3759 \layout Standard
3760
3761 5
3762 \end_inset 
3763 </cell>
3764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3765 \begin_inset Text
3766
3767 \layout Standard
3768
3769 4
3770 \end_inset 
3771 </cell>
3772 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3773 \begin_inset Text
3774
3775 \layout Standard
3776
3777 Asks encoder to switch to quality N for VBR
3778 \end_inset 
3779 </cell>
3780 </row>
3781 <row topline="true">
3782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3783 \begin_inset Text
3784
3785 \layout Standard
3786
3787 6
3788 \end_inset 
3789 </cell>
3790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3791 \begin_inset Text
3792
3793 \layout Standard
3794
3795 4
3796 \end_inset 
3797 </cell>
3798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3799 \begin_inset Text
3800
3801 \layout Standard
3802
3803 Request acknowloedge (0=no, 1=all, 2=only for in-band data)
3804 \end_inset 
3805 </cell>
3806 </row>
3807 <row topline="true">
3808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3809 \begin_inset Text
3810
3811 \layout Standard
3812
3813 7
3814 \end_inset 
3815 </cell>
3816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3817 \begin_inset Text
3818
3819 \layout Standard
3820
3821 4
3822 \end_inset 
3823 </cell>
3824 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3825 \begin_inset Text
3826
3827 \layout Standard
3828
3829 reserved
3830 \end_inset 
3831 </cell>
3832 </row>
3833 <row topline="true">
3834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3835 \begin_inset Text
3836
3837 \layout Standard
3838
3839 8
3840 \end_inset 
3841 </cell>
3842 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3843 \begin_inset Text
3844
3845 \layout Standard
3846
3847 8
3848 \end_inset 
3849 </cell>
3850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3851 \begin_inset Text
3852
3853 \layout Standard
3854
3855 Transmit (8-bit) character to the other end
3856 \end_inset 
3857 </cell>
3858 </row>
3859 <row topline="true">
3860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3861 \begin_inset Text
3862
3863 \layout Standard
3864
3865 9
3866 \end_inset 
3867 </cell>
3868 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3869 \begin_inset Text
3870
3871 \layout Standard
3872
3873 8
3874 \end_inset 
3875 </cell>
3876 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3877 \begin_inset Text
3878
3879 \layout Standard
3880
3881 reserved
3882 \end_inset 
3883 </cell>
3884 </row>
3885 <row topline="true">
3886 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3887 \begin_inset Text
3888
3889 \layout Standard
3890
3891 10
3892 \end_inset 
3893 </cell>
3894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3895 \begin_inset Text
3896
3897 \layout Standard
3898
3899 16
3900 \end_inset 
3901 </cell>
3902 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3903 \begin_inset Text
3904
3905 \layout Standard
3906
3907 Announce maximum bit-rate acceptable (N in bytes/second)
3908 \end_inset 
3909 </cell>
3910 </row>
3911 <row topline="true">
3912 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3913 \begin_inset Text
3914
3915 \layout Standard
3916
3917 11
3918 \end_inset 
3919 </cell>
3920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3921 \begin_inset Text
3922
3923 \layout Standard
3924
3925 16
3926 \end_inset 
3927 </cell>
3928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3929 \begin_inset Text
3930
3931 \layout Standard
3932
3933 reserved
3934 \end_inset 
3935 </cell>
3936 </row>
3937 <row topline="true">
3938 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3939 \begin_inset Text
3940
3941 \layout Standard
3942
3943 12
3944 \end_inset 
3945 </cell>
3946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3947 \begin_inset Text
3948
3949 \layout Standard
3950
3951 32
3952 \end_inset 
3953 </cell>
3954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3955 \begin_inset Text
3956
3957 \layout Standard
3958
3959 Acknowledge receiving packet N
3960 \end_inset 
3961 </cell>
3962 </row>
3963 <row topline="true">
3964 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3965 \begin_inset Text
3966
3967 \layout Standard
3968
3969 13
3970 \end_inset 
3971 </cell>
3972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3973 \begin_inset Text
3974
3975 \layout Standard
3976
3977 32
3978 \end_inset 
3979 </cell>
3980 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3981 \begin_inset Text
3982
3983 \layout Standard
3984
3985 reserved
3986 \end_inset 
3987 </cell>
3988 </row>
3989 <row topline="true">
3990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3991 \begin_inset Text
3992
3993 \layout Standard
3994
3995 14
3996 \end_inset 
3997 </cell>
3998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3999 \begin_inset Text
4000
4001 \layout Standard
4002
4003 64
4004 \end_inset 
4005 </cell>
4006 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4007 \begin_inset Text
4008
4009 \layout Standard
4010
4011 reserved
4012 \end_inset 
4013 </cell>
4014 </row>
4015 <row topline="true" bottomline="true">
4016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4017 \begin_inset Text
4018
4019 \layout Standard
4020
4021 15
4022 \end_inset 
4023 </cell>
4024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4025 \begin_inset Text
4026
4027 \layout Standard
4028
4029 64
4030 \end_inset 
4031 </cell>
4032 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4033 \begin_inset Text
4034
4035 \layout Standard
4036
4037 reserved
4038 \end_inset 
4039 </cell>
4040 </row>
4041 </lyxtabular>
4042
4043 \end_inset 
4044
4045
4046 \layout Caption
4047
4048 In-band signalling codes
4049 \begin_inset LatexCommand \label{cap:In-band-signalling-codes}
4050
4051 \end_inset 
4052
4053
4054 \end_inset 
4055
4056
4057 \layout Standard
4058
4059 Finally, applications may define custom in-band messages using mode 13.
4060  The size of the message in bytes is encoded with 5 bits, so that the decoder
4061  can skip it if it doesn't know how to interpret it.
4062 \layout Section
4063 \pagebreak_top 
4064 Formats and standards
4065 \begin_inset LatexCommand \index{standards}
4066
4067 \end_inset 
4068
4069
4070 \layout Standard
4071
4072 Speex can encode speech in both narrowband and wideband and provides different
4073  bit-rates.
4074  However not all features must be supported by a certain implementation
4075  or device.
4076  In order to be said 
4077 \begin_inset Quotes eld
4078 \end_inset 
4079
4080 Speex compatible
4081 \begin_inset Quotes erd
4082 \end_inset 
4083
4084  (whatever that means), an implementation must implement at least a basic
4085  set of features.
4086 \layout Standard
4087
4088 At the minimum, all narrowband modes of operation MUST be supported at the
4089  decoder.
4090  This includes the decoding of a wideband bit-stream by the narrowband decoder
4091 \begin_inset Foot
4092 collapsed true
4093
4094 \layout Standard
4095
4096 The wideband bit-stream contains an embedded narrowband bit-stream which
4097  can be decoded alone
4098 \end_inset 
4099
4100 .
4101  If present, a wideband decoder MUST be able to decode a narrowband stream,
4102  and MAY either be able to decode all wideband modes or be able to decode
4103  the embedded narrowband part of all modes (which includes ignoring the
4104  high-band bits).
4105 \layout Standard
4106
4107 For encoders, at least one narrowband or wideband mode MUST be supported.
4108  The main reason why all encoding modes do not have to be supported is that
4109  some platforms may not be able to handle the complexity of encoding in
4110  some modes.
4111 \layout Subsection
4112
4113 RTP
4114 \begin_inset LatexCommand \index{RTP}
4115
4116 \end_inset 
4117
4118  Payload Format
4119 \layout Standard
4120
4121 This is a work in progress.
4122 \layout Comment
4123
4124 Since Speex encoded frames already contain mode information, they can be
4125  sent without any other information in an RTP packet.
4126  If more than one frame is transmitted, no byte padding is performed at
4127  the end of frames, except the last one.
4128  The number of frames contained in each packet MUST be transmitted out-of-band.
4129  
4130 \layout Subsection
4131
4132 Ogg
4133 \begin_inset LatexCommand \index{Ogg}
4134
4135 \end_inset 
4136
4137  file format
4138 \layout Standard
4139
4140 Speex bit-streams can be stored in Ogg files.
4141  In this case, the first packet of the Ogg file contains the Speex header
4142  described in table 
4143 \begin_inset LatexCommand \ref{cap:ogg_speex_header}
4144
4145 \end_inset 
4146
4147 .
4148  All integer fields in the headers are stored as little-endian.
4149  The 
4150 \family typewriter 
4151 speex_string
4152 \family default 
4153  field must contain the 
4154 \begin_inset Quotes eld
4155 \end_inset 
4156
4157
4158 \family typewriter 
4159 Speex
4160 \family default 
4161 \SpecialChar ~
4162 \SpecialChar ~
4163 \SpecialChar ~
4164
4165 \begin_inset Quotes eld
4166 \end_inset 
4167
4168  (with 3 training spaces), which identifies the bit-stream.
4169  The next field, 
4170 \family typewriter 
4171 speex_version
4172 \family default 
4173  contains the version of Speex that encoded the file.
4174  For now, refer to speex_header.[ch] for more info.
4175  The 
4176 \emph on 
4177 beginning of stream
4178 \emph default 
4179  (
4180 \family typewriter 
4181 b_o_s
4182 \family default 
4183 ) flag is set to 1 for the header.
4184  The header packet has 
4185 \family typewriter 
4186 packetno=0
4187 \family default 
4188  and 
4189 \family typewriter 
4190 granulepos=0
4191 \family default 
4192 .
4193 \layout Standard
4194
4195 The second packet contains the Speex comment header.
4196  The format used is the Vorbis comment format described here: http://www.xiph.org/
4197 ogg/vorbis/doc/v-comment.html .
4198  This packet has 
4199 \family typewriter 
4200 packetno=1
4201 \family default 
4202  and 
4203 \family typewriter 
4204 granulepos=0
4205 \family default 
4206 .
4207 \layout Standard
4208
4209 The third and subsequant packets each contain one or more (number found
4210  in header) Speex frames.
4211  These are identified with 
4212 \family typewriter 
4213 packetno
4214 \family default 
4215  starting from 2 and the 
4216 \family typewriter 
4217 granulepos
4218 \family default 
4219  is the number of the last sample encoded in that packet.
4220  Le last of these packets has the 
4221 \emph on 
4222 end of stream
4223 \emph default 
4224  (
4225 \family typewriter 
4226 e_o_s
4227 \family default 
4228 ) flag is set to 1.
4229 \layout Standard
4230
4231
4232 \begin_inset Float table
4233 placement htbp
4234 wide true
4235 collapsed false
4236
4237 \layout Standard
4238
4239
4240 \begin_inset  Tabular
4241 <lyxtabular version="3" rows="16" columns="3">
4242 <features>
4243 <column alignment="center" valignment="top" leftline="true" width="0pt">
4244 <column alignment="center" valignment="top" leftline="true" width="0pt">
4245 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
4246 <row topline="true" bottomline="true">
4247 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4248 \begin_inset Text
4249
4250 \layout Standard
4251
4252 Field
4253 \end_inset 
4254 </cell>
4255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4256 \begin_inset Text
4257
4258 \layout Standard
4259
4260 Type
4261 \end_inset 
4262 </cell>
4263 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4264 \begin_inset Text
4265
4266 \layout Standard
4267
4268 Size
4269 \end_inset 
4270 </cell>
4271 </row>
4272 <row topline="true">
4273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4274 \begin_inset Text
4275
4276 \layout Standard
4277
4278 speex_string
4279 \end_inset 
4280 </cell>
4281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4282 \begin_inset Text
4283
4284 \layout Standard
4285
4286 char[]
4287 \end_inset 
4288 </cell>
4289 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4290 \begin_inset Text
4291
4292 \layout Standard
4293
4294 8
4295 \end_inset 
4296 </cell>
4297 </row>
4298 <row topline="true">
4299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4300 \begin_inset Text
4301
4302 \layout Standard
4303
4304 speex_version
4305 \end_inset 
4306 </cell>
4307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4308 \begin_inset Text
4309
4310 \layout Standard
4311
4312 char[]
4313 \end_inset 
4314 </cell>
4315 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4316 \begin_inset Text
4317
4318 \layout Standard
4319
4320 20
4321 \end_inset 
4322 </cell>
4323 </row>
4324 <row topline="true">
4325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4326 \begin_inset Text
4327
4328 \layout Standard
4329
4330 speex_header_version
4331 \end_inset 
4332 </cell>
4333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4334 \begin_inset Text
4335
4336 \layout Standard
4337
4338 int
4339 \end_inset 
4340 </cell>
4341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4342 \begin_inset Text
4343
4344 \layout Standard
4345
4346 4
4347 \end_inset 
4348 </cell>
4349 </row>
4350 <row topline="true">
4351 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4352 \begin_inset Text
4353
4354 \layout Standard
4355
4356 header_size
4357 \end_inset 
4358 </cell>
4359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4360 \begin_inset Text
4361
4362 \layout Standard
4363
4364 int
4365 \end_inset 
4366 </cell>
4367 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4368 \begin_inset Text
4369
4370 \layout Standard
4371
4372 4
4373 \end_inset 
4374 </cell>
4375 </row>
4376 <row topline="true">
4377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4378 \begin_inset Text
4379
4380 \layout Standard
4381
4382 rate
4383 \end_inset 
4384 </cell>
4385 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4386 \begin_inset Text
4387
4388 \layout Standard
4389
4390 int
4391 \end_inset 
4392 </cell>
4393 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4394 \begin_inset Text
4395
4396 \layout Standard
4397
4398 4
4399 \end_inset 
4400 </cell>
4401 </row>
4402 <row topline="true">
4403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4404 \begin_inset Text
4405
4406 \layout Standard
4407
4408 mode
4409 \end_inset 
4410 </cell>
4411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4412 \begin_inset Text
4413
4414 \layout Standard
4415
4416 int
4417 \end_inset 
4418 </cell>
4419 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4420 \begin_inset Text
4421
4422 \layout Standard
4423
4424 4
4425 \end_inset 
4426 </cell>
4427 </row>
4428 <row topline="true">
4429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4430 \begin_inset Text
4431
4432 \layout Standard
4433
4434 mode_bitstream_version
4435 \end_inset 
4436 </cell>
4437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4438 \begin_inset Text
4439
4440 \layout Standard
4441
4442 int
4443 \end_inset 
4444 </cell>