shithub: opus

Download patch

ref: 86a7b7871d73b4563fbe9bc6ae8d2f70fb3cd636
parent: f727386100e8021bf2bf27a746220419b2124c85
author: Jean-Marc Valin <[email protected]>
date: Thu Jul 2 12:09:03 EDT 2009

ietf doc: energy decoding, build script, misc stuff

--- /dev/null
+++ b/doc/ietf/build_drafts.sh
@@ -1,0 +1,15 @@
+#!/bin/sh
+
+./convert_source.sh
+
+./ietf_source.sh
+
+#codec draft
+xml2rfc.tcl draft-valin-celt-codec.xml draft-valin-celt-codec.html
+
+xml2rfc.tcl draft-valin-celt-codec.xml draft-valin-celt-codec.txt
+
+#RTP draft
+xml2rfc.tcl draft-valin-celt-rtp-profile.xml draft-valin-celt-rtp-profile.html
+
+xml2rfc.tcl draft-valin-celt-rtp-profile.xml draft-valin-celt-rtp-profile.txt
--- a/doc/ietf/draft-valin-celt-codec.xml
+++ b/doc/ietf/draft-valin-celt-codec.xml
@@ -443,7 +443,7 @@
 It is important to quantize the energy with sufficient resolution because
 any quantization error in the energy cannot be compensated for at a later
 stage. Regardless of the resolution used for encoding the shape of a band,
-it is perceptually important to preserve the energy in each band. We use a
+it is perceptually important to preserve the energy in each band. CELT uses a
 coarse-fine strategy for encoding the energy in the base-2 log domain, 
 as implemented in <xref target="quant_bands.c">quant_bands.c</xref></t>
 
@@ -459,7 +459,7 @@
 The prediction is applied on the quantized log-energy. We approximate the ideal 
 probability distribution of the prediction error using a Laplace distribution. The
 coarse energy quantisation is performed by quant_coarse_energy() and 
-quant_coarse_energy_mono() (<xref target="quant_bands.c">quant_bands.c</xref>).
+quant_coarse_energy() (<xref target="quant_bands.c">quant_bands.c</xref>).
 </t>
 
 <t>
@@ -477,9 +477,12 @@
 <section anchor="fine-energy" title="Fine energy quantization">
 <t>
 After the coarse energy quantization and encoding, the bit allocation is computed 
-(<xref target="allocation"></xref>) and the number of bits to use for refining the energy quantization is determined for each band. Let B_i be the number of fine energy bits 
+(<xref target="allocation"></xref>) and the number of bits to use for refining the
+energy quantization is determined for each band. Let B_i be the number of fine energy bits 
 for band i, the refement is an integer f in the range [0,2^B_i-1]. The mapping between f
-and the correction applied to the corse energy is equal to (f+1/2)/2^B_i - 1/2. 
+and the correction applied to the corse energy is equal to (f+1/2)/2^B_i - 1/2. Fine
+energy quantization is implemented in quant_fine_energy() 
+(<xref target="quant_bands.c">quant_bands.c</xref>).
 </t>
 
 <t>
@@ -487,8 +490,10 @@
 increase the resolution of the fine energy encoding in some bands. Priority is given
 to the bands for which the allocation (<xref target="allocation"></xref>) was rounded
 down. At the same level of priority, lower bands are encoded first. Refinement bits
-are added until there is no unused bit.
+are added until there is no unused bit. This is implemented in quant_energy_finalise() 
+(<xref target="quant_bands.c">quant_bands.c</xref>).
 </t>
+
 </section> <!-- fine energy -->
 
 
@@ -529,8 +534,10 @@
 </t>
 
 <t>
-For frequencies above the highest pitch band (~6374 Hz), the prediction is replaced by
-spectral folding if and only if the folding bit is set (otherwise, the prediction is simply zero).
+For frequencies above the highest pitch band (~6374 Hz), the pitch prediction is replaced by
+spectral folding if and only if the folding bit is set. Spectral folding is implemented in 
+intra_fold() (<xref target="vq.c">vq.c</xref>). If the folding bit is not set, then 
+the prediction is simply set to zero.
 The folding prediction uses the quantised spectrum at lower frequencies with a gain that depends
 both on the width of the band N and the number of pulses allocated K:
 </t>
@@ -543,6 +550,12 @@
 where kf = 6. 
 </t>
 
+<t>
+When the short blocks bit is not set, the spectral copy is performed starting with bin 0 (DC) and going up. When the short blocks is set, then the starting point is chosen between 0 and B-1 in such a way that the source and destination bins belong to the same MDCT (i.e. to prevent the folding from causing pre-echo). Before the folding operation, each band of the source spectrum is multiplied by sqrt(N) so that the expectation of the squared value for each bin is equal to one. The copied spectrum is then renormalised to have unit norm (||P|| = 1).
+</t>
+
+<t>For stereo streams, the folding is performed independently for each channel.</t>
+
 </section>
 
 <section anchor="pvq" title="Spherical Vector Quantization">
@@ -717,10 +730,32 @@
 
 <section anchor="energy-decoding" title="Energy Envelope Decoding">
 <t>
+The energy of each band is extracted from the bit-stream in two steps according
+to the same coarse-fine strategy used in the encoder. First, the coarse energy is
+decoded in unquant_coarse_energy() (<xref target="quant_bands.c">quant_bands.c</xref>)
+based on the probability of the Laplace model used by the encoder.
+</t>
 
+<t>
+After the coarse energy is decoded, the same allocation function as used in the
+encoder is called (<xref target="allocation"></xref>). This determines the number of
+bits to decode for the finer energy quantisation. The decoding of the fine energy bits
+is performed by unquant_fine_energy() (<xref target="quant_bands.c">quant_bands.c</xref>).
+Finally, like in the encoder the remaining bits in the stream (that would otherwise go unused)
+are decoded using unquant_energy_finalise() (<xref target="quant_bands.c">quant_bands.c</xref>).
 </t>
 </section>
 
+<section anchor="pitch-decoding" title="Pitch prediction decoding">
+<t>
+If the pitch bit is set, then the pitch period is extracted from the bit-stream. The pitch
+gain bits are extracted within the PVQ decoding as encoded by the encoder. When the folding
+bit is set, the folding prediction is computed in exactly the same way and with the same 
+gain as in the encoder, with function intra_fold() (<xref target="vq.c">vq.c</xref>).
+</t>
+
+</section>
+
 <section anchor="PVQ-decoder" title="Spherical VQ Decoder">
 <t>
 The spherical codebook is decoded by alg_unquant() (<xref target="vq.c">vq.c</xref>).
@@ -754,7 +789,7 @@
 <spanx style="emph">low-overlap</spanx> window 
 as the encoder. The IMDCT and windowing are performed by mdct_backward
 (<xref target="mdct.c">mdct.c</xref>). After the overlap-add process, 
-the signal is de-emphasised using the inverse of the pre-emphasis filter 
+the signal is de-emphasized using the inverse of the pre-emphasis filter 
 used in the encoder: 1/A(z)=1/(1-alpha_p*z^-1).
 </t>
 </section>