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