<?xml version="1.0" encoding="utf-8"?>
<!-- 
     draft-rfcxml-general-template-standard-00
  
     This template includes examples of the most commonly used features of RFCXML with comments 
     explaining how to customise them. This template can be quickly turned into an I-D by editing 
     the examples provided. Look for [REPLACE], [REPLACE/DELETE], [CHECK] and edit accordingly.
     Note - 'DELETE' means delete the element or attribute, not just the contents.
     
     Documentation is at https://authors.ietf.org/en/templates-and-schemas
-->
<?xml-model href="rfc7991bis.rnc"?>  <!-- Required for schema validation and schema-aware editing -->
<!-- <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?> -->
<!-- This third-party XSLT can be enabled for direct transformations in XML processors, including most browsers -->


<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<!-- If further character entities are required then they should be added to the DOCTYPE above.
     Use of an external entity file is not recommended. -->

<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="std"
  docName="draft-ietf-mlcodec-opus-dred-02"
  ipr="trust200902"
  obsoletes=""
  updates="6716"
  submissionType="IETF"
  xml:lang="en"
  version="3">
<!-- [REPLACE] 
       * docName with name of your draft
     [CHECK] 
       * category should be one of std, bcp, info, exp, historic
       * ipr should be one of trust200902, noModificationTrust200902, noDerivativesTrust200902, pre5378Trust200902
       * updates can be an RFC number as NNNN
       * obsoletes can be an RFC number as NNNN 
-->

  <front>
    <title abbrev="Opus DRED">Deep Audio Redundancy (DRED) Extension for the Opus Codec</title>

    <seriesInfo name="Internet-Draft" value="draft-ietf-mlcodec-opus-dred-02"/>
   
    <author fullname="Jean-Marc Valin" initials="JM" surname="Valin">
      <!-- [CHECK]
             * initials should not include an initial for the surname
             * role="editor" is optional -->
    <!-- Can have more than one author -->
      
    <!-- all of the following elements are optional -->
      <organization>Google</organization>
      <address>
        <postal>
          <country>CA</country>
          <!-- Uses two letter country code -->
        </postal>
        <email>jeanmarcv@google.com</email>  
      </address>
    </author>

    <author fullname="Jan Buethe" initials="J" surname="Buethe">
      <organization>Xiph.Org Foundation</organization>
      <address>
        <postal>
          <country>DE</country>
          <!-- Uses two letter country code -->
        </postal>
        <email>jan.buethe@googlemail.com</email>
      </address>
    </author>

    <date year="2024"/>
    <!-- On draft subbmission:
         * If only the current year is specified, the current day and month will be used.
         * If the month and year are both specified and are the current ones, the current day will
           be used
         * If the year is not the current one, it is necessary to specify at least a month and day="1" will be used.
    -->

    <area>Applications and Real-Time</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <!-- "Internet Engineering Task Force" is fine for individual submissions.  If this element is
          not present, the default is "Network Working Group", which is used by the RFC Editor as
          a nod to the history of the RFC Series. -->

    <keyword>Opus, RFC6716</keyword>

    <abstract>
      <t>This document proposes a mechanism for embedding very low bitrate deep audio redundancy (DRED)
          within the Opus codec (RFC6716) bitstream. </t>
    </abstract>

  </front>

  <middle>

    <section>
      <name>Introduction</name>
      <t>This document proposes a mechanism for embedding very low bitrate deep audio redundancy (DRED)
          within the Opus codec <xref target="RFC6716"/> bitstream.</t>

      <section>
        <name>Requirements Language</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
          "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT
          RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
          interpreted as described in BCP 14 <xref target="RFC2119"/>
          <xref target="RFC8174"/> when, and only when, they appear in
          all capitals, as shown here.</t>
      </section>

    </section>
    
    <section>
        <name>DRED Description</name>
        <t>Opus already includes a low-bitrate redundancy (LBRR) mechanism to transmit redundancy in-band to
            improve robustness to packet loss. LBRR is however limited to a single frame of redundancy, and
            typically uses about 2/3 of the bitrate of the "regular" Opus packet. The DRED extension allows
            up to one second or more redundancy to be included in each packet, using
            a bitrate about 1/50 of the regular Opus bitrate.
            Although the amount of redundancy that can be encoded in a packet is unbounded,
            there appears to be little use to including more than a few seconds.
        </t>

        <t>DRED is transmitted within the Opus padding, as described in <xref target="opus-extension"/>.
          In the case of multi-frame packets, there SHOULD only be one DRED extension per packet and
          it SHOULD be associated with the first frame of the packet.
          In all cases, there MUST NOT be more than one DRED extension associated to the same frame.
        </t>

        <t>
          The DRED encoder SHOULD remove any leading or trailing silence from the redundant audio data.
          That being said, silence that occurs between speech segments cannot be left out.
          Any Selective Forwarding Unit (SFU) designed not to forward silent packets SHOULD
          still forward DRED-containing packets from the last known active source.
          Conference mixers SHOULD either forward DRED from the last known active source or
          re-encode DRED from the mixed audio.
        </t>
        
        <t>DRED works by having the encoder transmit acoustic features in the Opus bitstream. On the receiver side,
            if packets are lost, then the first packet to arrive will contain the acoustic features for a certain
            duration in the past. The decoder can then use the features to synthesize the missing speech -- either
            from the last received or from the last audio samples produced by packet loss concealment (PLC). Although
            the synthesized speech samples should be consistent with the last known samples at the point of the transition,
            the features do not contain waveform-specific or phase-specific information so the synthesized speech waveform
            will significantly deviate from the original waveform, despite sounding similar. </t>
        <section>
            <name>Acoustic Features</name>
            <t>DRED uses 20 acoustic features to synthesize speech. The first 18 are Bark-frequency cepstral coefficients (BFCC)
                and the last represent the pitch frequency and the voicing information. The BFCC features are based on bands
                that match the CELT bands, as shown in <xref target="bands"/>.
                </t>

            <table anchor="bands">
                <name>Band definitions for DRED</name>
                <thead>
                    <tr><th>Band</th><th>Start frequency (Hz)</th><th>Center frequency (Hz)</th><th>End frequency (Hz)</th></tr>
                </thead>
                <tbody>
            <!-- Generated with this Python code:
            band = [0, 0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 2000, 2400, 2800, 3200, 4000, 4800, 5600, 6800, 8000, 8000]
            for i in range(18):
                print(f"          <tr><td>{i}</td><td>{band[i]}</td><td>{band[i+1]}</td><td>{band[i+2]}</td></tr>")
            -->
          <tr><td>0</td><td>0</td><td>0</td><td>200</td></tr>
          <tr><td>1</td><td>0</td><td>200</td><td>400</td></tr>
          <tr><td>2</td><td>200</td><td>400</td><td>600</td></tr>
          <tr><td>3</td><td>400</td><td>600</td><td>800</td></tr>
          <tr><td>4</td><td>600</td><td>800</td><td>1000</td></tr>
          <tr><td>5</td><td>800</td><td>1000</td><td>1200</td></tr>
          <tr><td>6</td><td>1000</td><td>1200</td><td>1400</td></tr>
          <tr><td>7</td><td>1200</td><td>1400</td><td>1600</td></tr>
          <tr><td>8</td><td>1400</td><td>1600</td><td>2000</td></tr>
          <tr><td>9</td><td>1600</td><td>2000</td><td>2400</td></tr>
          <tr><td>10</td><td>2000</td><td>2400</td><td>2800</td></tr>
          <tr><td>11</td><td>2400</td><td>2800</td><td>3200</td></tr>
          <tr><td>12</td><td>2800</td><td>3200</td><td>4000</td></tr>
          <tr><td>13</td><td>3200</td><td>4000</td><td>4800</td></tr>
          <tr><td>14</td><td>4000</td><td>4800</td><td>5600</td></tr>
          <tr><td>15</td><td>4800</td><td>5600</td><td>6800</td></tr>
          <tr><td>16</td><td>5600</td><td>6800</td><td>8000</td></tr>
          <tr><td>17</td><td>6800</td><td>8000</td><td>8000</td></tr>
                </tbody>
            </table>
                <t>
                    TODO: Specify exact computation of the cepstral features and voicing. Open question: how do we specify the neural pitch estimator?
                </t>                
        </section>
        <section>
            <name>Rate-Distortion-Optimized Variational Autoencoder (RDO)</name>
            <t>The features described above need to be transmitted to the decoder with the fewest number of bits possible.
                Although it is not acceptable to make redundancy from one packet depend on the redundancy of another packet,
                we can use as much prediction as we like within one packet. In practical use, the same audio
                feature vector is included in many different packets (50 for 1 second redundancy). For that reason, we do not
                want to fully re-encode acoustic features for each packet. On the decoder side, since the most recent audio is
                the most likely to be used, we minimize the computation time by having the audio encoded from the most recent,
                going backward in time.
                </t>
                <t>
                    TODO: Specify the cepstral features and voicing. Open question: how do we specify the neural pitch estimator?
                </t>

            <figure>
                <name>DRED encoding/decoding</name>
                    <artset>
                        <artwork type="ascii-art" name="dred-decoding.txt">
            <![CDATA[
                              Audio
                                |
                                v
                        +---------------+
                        | RDOVAE encoder|
                        +---------------+
                                |
                                v
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | L | L | L | L | L | L | L | L | L | L | L | L | L | L |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | S | S | S | S | S | S | S | S | S | S | S | S | S | S |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+
                                      |   |   |
                                      v   |   |
            +---+---+---+---+---+---+---+ |   |
 decoder <--| L |   | L |   | L |   | L | |   |
            +---+---+---+---+---+---+---+ |   |
                                    | S | |   |
                                    +---+ |   |
                                          v   |
                +---+---+---+---+---+---+---+ |
     decoder <--| L |   | L |   | L |   | L | |
                +---+---+---+---+---+---+---+ |
                                        | S | |
                                        +---+ |
                                              v
                    +---+---+---+---+---+---+---+
         decoder <--| L |   | L |   | L |   | L |
                    +---+---+---+---+---+---+---+
                                            | S |
                                            +---+
            ]]>
                        </artwork>
                    </artset>
                </figure>
            <section>
                <name>Encoder architecture</name>
                <t>
                    Every 20 ms, the encoder takes in a pair of 20-dimensional acoustic feature vectors as input
                    and produces one initial state (IS) and one latent vector. Each latent vector encodes 40 ms
                    (their information overlaps), so only half the latent vectors need to be transmitted. 
                    Although an encoder is provided for reference, the encoder architecture is not normative.
                    Each redundancy packet contains the latest initial state, along with latent vectors ordered
                    from the latest (the one aligned with the initial state) to the earliest one the encoder includes.
                    Each conponent of the IS and latent vectors are quantized and then entropy-coded following a
                    Laplace distribution. The same procedure is used for both the latent vectors and the initial state
                    (we will describe the process for a latent variable).
                    The quantized index X is obtained by scaling the i'th latent variable z_i by a scaling factor s_{i,q} that depends
                    on both i and on the quantizer q. We then apply a "dead-zone" function zeta(z) = z - d*tanh(z / (d + epsilon)),
                    where d also depends on i and q, and epsilon=0.1. The result is then rounded to the nearest integer:
                    X = round(zeta(s_{i,q}*z_i)). The Laplace distribution used for entropy coding is
                    parameterized with a probability that the value is zero (p0), as well
                    as a decay factor r (0 &lt; r &lt; 1). Both p0 and r depend on i and q. The probability p(X) for a coefficient is given by: 
                </t>
                <artwork type="ascii-art" name="dred-decoding.txt">
            <![CDATA[
                          /
                          | p0               ,   if X = 0
                          |
                   P(X) = <             |X|    
                          | (1 - p0) * r     ,   if X != 0
                          | ---------------
                          \   2 * (1 - r)
            ]]>
                 </artwork>
            </section>
            <section>
                <name>Decoder architecture</name>
                <t>
                    Unlike the encoder, the decoder is normative. The decoder uses the same Laplace distribution above to decode
                    the symbols and then scales them back by 1/s_{i,q}. The initial state is used as input to initialize the decoder's gated recurrent units (GRUs). The latent vectors are used one at a time as input the DNN decoder,
                    which produces 4 vectors of 20 acoustic features for each input latent vector. 
                </t>
                <t>The decoder is mostly structured as a DenseNet network, with 5 sets of
                  alternating GRU and convolutional layers.
                  Let gru1..gru5 denote the 5 GRUs, conv1..conv5 denote the 5 convolutional layers,
                  hidden_init/gru_init/dense1/output denote fully-connected layers, glu1..glu5 denote gated linear units (GLUs),
                  and cat() denote tensor concatenation.
                  All GRU layers have 96 outputs (number of neurons) and all convolutional
                  layers have 32 outputs.
                  Despite using a functional notation, both the GRU and convolutional layers have an
                  internal state when used one latent vector at a time.
                  The fully-connected layers all have different sizes.
                  Unless otherwise noted, the GRUs, convolutional and fully-connected layers all
                  use tanh output activations and the GRUs use sigmoid as gate activation.
                  GLUs are defined as:
                  </t>
                <artwork type="ascii-art" name="dred-dec-glu.txt">
            <![CDATA[
                   L(y) = sigmoid(W*y)*y
            ]]>
                 </artwork>
                  <t>
                 where y is the input and W is a square matrix of the same dimensions as y.
                  The decoder starts with the 18-dimensional initial state vector IS.
                  The IS is used to compute the GRU initialization vector V using both hidden_init and gru_init:</t>
                <artwork type="ascii-art" name="dred-dec-init.txt">
            <![CDATA[
                   V = gru_init(hidden_init(IS))
            ]]>
                 </artwork>
                <t>where hidden_init has 18 inputs and 128 output, and D2 has 128 inputs and 480 (5*96)
                  outputs.
                  The components of V are split (sequentially) into the V1..V5 initialization
                  vectors (original state before the decoding process) for GRUs gru1..gru5.
                  Let Z be the decoded 20-dimensional latent vector for a particular 40-ms chunk.
                  From there, the DenseNet structure can be expressed as:
                </t>
                <artwork type="ascii-art" name="dred-dec-densenet.txt">
            <![CDATA[
                   t1 = dense1(Z)
                   t2 = cat(t1, conv1(t1))
                   t3 = cat(t2, glu1(gru1(t2)))
                   t4 = cat(t3, conv2(t3))
                   t5 = cat(t4, glu2(gru2(t4)))
                   t6 = cat(t5, conv3(t5))
                   t7 = cat(t6, glu3(gru3(t6)))
                   t8 = cat(t7, conv4(t7))
                   t9 = cat(t8, glu4(gru4(t8)))
                   t10 = cat(t9, conv5(t9))
                   t11 = cat(t10, glu5(gru5(t10)))
                   x = output(t11)
            ]]>
                 </artwork>
                <t>
                where t1..tN are temporary vectors and "output" is the only layer to have
                a linear output activation, with 80 output neurons (4*20).
                The dimensionality of t1..t11 (and corresponding GRU/convolutional input size)
                can be inferred from the concatenation operations.
                The output vector x is split (sequentially) into 4 feature vectors of
                20 dimensions each that can be sent to the vocoder is packets are lost.
                </t>
                <section>
                    <name>Decoder weights</name>
                    <t>The decoder weights are distributed outside of this document at
                      <eref target="https://media.xiph.org/opus/ietf/draft-ietf-mlcodec-opus-dred-01-weights.bin"/>.
                      [FIXME: Find permanent location for the weights]
                      They are distributed in a simple binary format that can also be used to
                      separate them from an implementation binary for easier downloads.
                      Each weight matrix is stored separately as a single array block.
                      Each block starts with a 64-byte header, followed by a multiple
                      of 64 bytes of array data.
                      Blocks are self-delimited and can be concatenated into a single file.
                    </t>
                    <t>The header starts with a 4-byte Header ID representing the string "DNNw",
                      followed by a 4-byte Version number (currently 0).
                      The Type of the weights follows, encoded as a 4-byte integer, where
                      value 0 represents floating point weights and value 3 represents
                      8-bit signed integers.
                      The 4-byte Size field that follows represents the size of the data in
                      bytes (not number of elements), and the Block Size is the number of
                      data bytes rounded up to 64 bytes. The block size indicates where
                      the next block is expected.
                      Note that the block size does not include the header size.
                      The remaining 44 bytes of the header contain the name of the array.
                    </t>
                    <t>For implementation efficiency, the binary format can be implemented
                      using any endianness, but for the purpose of distributing the reference
                      weights, we use a little-endian format.</t>

                    <figure>
                      <name>Binary Weights Format</name>
                      <artset>
                        <artwork type="ascii-art" name="binary-weights.txt">
                          <![CDATA[
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Header ID                           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                            Version                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                              Type                             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                              Size                             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Block size                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                         Name (44 bytes)                       |
   :                               ...                             :
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       Data (N x 64 bytes)                     |
   :                               ...                             :
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                          ]]>
                        </artwork>
                      </artset>
                    </figure>
                    <t>The decoder arrays are named dec_&lt;layer name&gt;_&lt;variable name&gt;, where the names
                      are gru1..gru5, con1..conv5, and so on.
                      There is an optional _float or _int8 suffix for type when relevant.
                      Variable names can be "bias", "subias", "scale" and "weights". 
                      TODO: more on how the matrices are used.</t>
                </section>
            </section>
            <section>
                <name>Statistical data</name>
                <t>
                    We define 16 different quantization settings, ranging from q=0 (higher bitrate) to q=15 (lower bitrate).
                    For each quantizer and for each latent variable or initial state coefficient, we have a normative scale (s),
                    decay (r), and p0 value. Note that the dead-zone parameters d are not normative.
                </t>


            <table anchor="scale_latent">
                <name>Scale values for latent</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>255</th><th>208</th><th>168</th><th>134</th><th>106</th><th>82</th><th>64</th><th>48</th><th>36</th><th>26</th><th>17</th><th>10</th><th>3</th><th>3</th><th>2</th><th>2</th></tr>
        <tr><th>1</th><th>255</th><th>219</th><th>187</th><th>160</th><th>137</th><th>117</th><th>101</th><th>81</th><th>70</th><th>50</th><th>23</th><th>6</th><th>6</th><th>5</th><th>3</th><th>2</th></tr>
        <tr><th>2</th><th>255</th><th>218</th><th>187</th><th>160</th><th>138</th><th>118</th><th>102</th><th>84</th><th>71</th><th>63</th><th>31</th><th>7</th><th>7</th><th>5</th><th>3</th><th>2</th></tr>
        <tr><th>3</th><th>255</th><th>217</th><th>186</th><th>159</th><th>137</th><th>118</th><th>102</th><th>87</th><th>76</th><th>66</th><th>53</th><th>25</th><th>11</th><th>5</th><th>2</th><th>1</th></tr>
        <tr><th>4</th><th>255</th><th>216</th><th>183</th><th>155</th><th>131</th><th>111</th><th>95</th><th>79</th><th>67</th><th>57</th><th>48</th><th>42</th><th>35</th><th>29</th><th>24</th><th>21</th></tr>
        <tr><th>5</th><th>255</th><th>219</th><th>189</th><th>163</th><th>141</th><th>122</th><th>107</th><th>90</th><th>87</th><th>31</th><th>11</th><th>3</th><th>3</th><th>2</th><th>1</th><th>1</th></tr>
        <tr><th>6</th><th>255</th><th>218</th><th>187</th><th>160</th><th>138</th><th>119</th><th>103</th><th>87</th><th>72</th><th>45</th><th>18</th><th>6</th><th>5</th><th>3</th><th>2</th><th>2</th></tr>
        <tr><th>7</th><th>255</th><th>217</th><th>184</th><th>157</th><th>133</th><th>113</th><th>96</th><th>78</th><th>67</th><th>53</th><th>34</th><th>17</th><th>6</th><th>5</th><th>4</th><th>3</th></tr>
        <tr><th>8</th><th>255</th><th>222</th><th>192</th><th>167</th><th>146</th><th>128</th><th>114</th><th>87</th><th>78</th><th>63</th><th>40</th><th>9</th><th>8</th><th>6</th><th>4</th><th>3</th></tr>
        <tr><th>9</th><th>255</th><th>217</th><th>184</th><th>157</th><th>135</th><th>115</th><th>99</th><th>84</th><th>73</th><th>65</th><th>56</th><th>48</th><th>18</th><th>11</th><th>6</th><th>2</th></tr>
        <tr><th>10</th><th>255</th><th>219</th><th>189</th><th>163</th><th>141</th><th>122</th><th>107</th><th>90</th><th>74</th><th>40</th><th>15</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th></tr>
        <tr><th>11</th><th>255</th><th>214</th><th>180</th><th>151</th><th>127</th><th>108</th><th>91</th><th>76</th><th>65</th><th>56</th><th>47</th><th>41</th><th>35</th><th>31</th><th>27</th><th>24</th></tr>
        <tr><th>12</th><th>255</th><th>215</th><th>181</th><th>152</th><th>129</th><th>109</th><th>93</th><th>78</th><th>67</th><th>57</th><th>49</th><th>43</th><th>38</th><th>33</th><th>29</th><th>27</th></tr>
        <tr><th>13</th><th>255</th><th>218</th><th>187</th><th>160</th><th>138</th><th>119</th><th>102</th><th>87</th><th>75</th><th>56</th><th>34</th><th>19</th><th>7</th><th>4</th><th>2</th><th>2</th></tr>
        <tr><th>14</th><th>255</th><th>219</th><th>188</th><th>162</th><th>139</th><th>120</th><th>103</th><th>80</th><th>69</th><th>34</th><th>12</th><th>3</th><th>3</th><th>2</th><th>1</th><th>1</th></tr>
        <tr><th>15</th><th>255</th><th>219</th><th>189</th><th>164</th><th>143</th><th>124</th><th>108</th><th>69</th><th>20</th><th>5</th><th>0</th><th>1</th><th>1</th><th>1</th><th>1</th><th>0</th></tr>
        <tr><th>16</th><th>255</th><th>217</th><th>185</th><th>158</th><th>136</th><th>117</th><th>101</th><th>86</th><th>76</th><th>67</th><th>58</th><th>47</th><th>15</th><th>11</th><th>7</th><th>6</th></tr>
        <tr><th>17</th><th>255</th><th>217</th><th>184</th><th>157</th><th>135</th><th>115</th><th>99</th><th>84</th><th>74</th><th>63</th><th>54</th><th>47</th><th>16</th><th>10</th><th>7</th><th>5</th></tr>
        <tr><th>18</th><th>255</th><th>213</th><th>178</th><th>149</th><th>124</th><th>104</th><th>87</th><th>72</th><th>60</th><th>50</th><th>42</th><th>35</th><th>29</th><th>25</th><th>21</th><th>18</th></tr>
        <tr><th>19</th><th>255</th><th>215</th><th>181</th><th>152</th><th>127</th><th>105</th><th>86</th><th>58</th><th>46</th><th>21</th><th>10</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>20</th><th>255</th><th>214</th><th>179</th><th>149</th><th>125</th><th>104</th><th>87</th><th>72</th><th>61</th><th>51</th><th>43</th><th>36</th><th>31</th><th>27</th><th>23</th><th>20</th></tr>

                </tbody>
            </table>

            <table anchor="deadzone_latent">
                <name>Dead zone values for latent</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>1</th><th>1</th><th>0</th><th>0</th><th>0</th><th>1</th><th>1</th><th>2</th><th>3</th><th>12</th><th>27</th><th>44</th><th>178</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>1</th><th>0</th><th>0</th><th>7</th><th>17</th><th>29</th><th>45</th><th>70</th><th>107</th><th>160</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>2</th><th>10</th><th>13</th><th>16</th><th>20</th><th>24</th><th>29</th><th>35</th><th>41</th><th>53</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>3</th><th>0</th><th>1</th><th>5</th><th>9</th><th>14</th><th>20</th><th>26</th><th>37</th><th>51</th><th>81</th><th>124</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>4</th><th>0</th><th>0</th><th>0</th><th>1</th><th>4</th><th>6</th><th>9</th><th>11</th><th>16</th><th>24</th><th>37</th><th>53</th><th>87</th><th>108</th><th>255</th><th>255</th></tr>
        <tr><th>5</th><th>6</th><th>12</th><th>17</th><th>24</th><th>31</th><th>41</th><th>56</th><th>85</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>6</th><th>11</th><th>15</th><th>18</th><th>22</th><th>27</th><th>33</th><th>41</th><th>48</th><th>53</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>7</th><th>0</th><th>0</th><th>0</th><th>5</th><th>11</th><th>17</th><th>27</th><th>46</th><th>75</th><th>124</th><th>220</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>8</th><th>0</th><th>8</th><th>25</th><th>43</th><th>66</th><th>94</th><th>133</th><th>168</th><th>231</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>9</th><th>0</th><th>0</th><th>2</th><th>6</th><th>11</th><th>16</th><th>23</th><th>31</th><th>44</th><th>71</th><th>104</th><th>158</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>10</th><th>7</th><th>12</th><th>17</th><th>22</th><th>28</th><th>36</th><th>47</th><th>59</th><th>81</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>11</th><th>0</th><th>0</th><th>0</th><th>1</th><th>2</th><th>4</th><th>5</th><th>7</th><th>9</th><th>12</th><th>15</th><th>19</th><th>23</th><th>27</th><th>30</th><th>38</th></tr>
        <tr><th>12</th><th>0</th><th>0</th><th>1</th><th>2</th><th>4</th><th>6</th><th>9</th><th>11</th><th>14</th><th>20</th><th>28</th><th>37</th><th>57</th><th>65</th><th>75</th><th>96</th></tr>
        <tr><th>13</th><th>0</th><th>3</th><th>7</th><th>11</th><th>16</th><th>21</th><th>28</th><th>39</th><th>54</th><th>67</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>14</th><th>13</th><th>18</th><th>22</th><th>28</th><th>34</th><th>43</th><th>56</th><th>72</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>15</th><th>0</th><th>0</th><th>4</th><th>13</th><th>23</th><th>37</th><th>56</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>16</th><th>4</th><th>7</th><th>11</th><th>14</th><th>19</th><th>24</th><th>30</th><th>39</th><th>49</th><th>70</th><th>96</th><th>123</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>17</th><th>0</th><th>0</th><th>3</th><th>7</th><th>11</th><th>16</th><th>21</th><th>28</th><th>38</th><th>54</th><th>73</th><th>108</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>18</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>2</th><th>3</th><th>5</th><th>7</th><th>9</th><th>11</th></tr>
        <tr><th>19</th><th>5</th><th>12</th><th>18</th><th>26</th><th>34</th><th>43</th><th>56</th><th>84</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>20</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>1</th><th>2</th><th>3</th><th>5</th><th>8</th><th>11</th><th>14</th><th>16</th><th>18</th><th>21</th></tr>

                </tbody>
            </table>

            <table anchor="decay_latent">
                <name>Decay (r) values for latent</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>233</th><th>228</th><th>222</th><th>214</th><th>204</th><th>191</th><th>176</th><th>155</th><th>135</th><th>106</th><th>66</th><th>32</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>1</th><th>94</th><th>85</th><th>72</th><th>59</th><th>45</th><th>32</th><th>21</th><th>10</th><th>4</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>2</th><th>91</th><th>75</th><th>58</th><th>43</th><th>29</th><th>17</th><th>9</th><th>4</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>3</th><th>112</th><th>96</th><th>81</th><th>65</th><th>51</th><th>38</th><th>26</th><th>16</th><th>10</th><th>4</th><th>1</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>4</th><th>149</th><th>138</th><th>125</th><th>109</th><th>93</th><th>77</th><th>61</th><th>45</th><th>32</th><th>21</th><th>12</th><th>7</th><th>3</th><th>1</th><th>0</th><th>0</th></tr>
        <tr><th>5</th><th>65</th><th>50</th><th>36</th><th>24</th><th>14</th><th>8</th><th>4</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>6</th><th>92</th><th>75</th><th>59</th><th>43</th><th>29</th><th>18</th><th>10</th><th>5</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>7</th><th>118</th><th>107</th><th>97</th><th>74</th><th>60</th><th>48</th><th>38</th><th>29</th><th>17</th><th>6</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>8</th><th>55</th><th>47</th><th>36</th><th>27</th><th>19</th><th>13</th><th>8</th><th>3</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>9</th><th>122</th><th>107</th><th>92</th><th>76</th><th>60</th><th>46</th><th>34</th><th>22</th><th>15</th><th>9</th><th>4</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>10</th><th>82</th><th>67</th><th>53</th><th>40</th><th>29</th><th>20</th><th>14</th><th>8</th><th>4</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>11</th><th>190</th><th>181</th><th>171</th><th>160</th><th>149</th><th>135</th><th>120</th><th>101</th><th>85</th><th>68</th><th>52</th><th>38</th><th>26</th><th>17</th><th>10</th><th>6</th></tr>
        <tr><th>12</th><th>175</th><th>165</th><th>154</th><th>143</th><th>128</th><th>113</th><th>98</th><th>81</th><th>67</th><th>53</th><th>41</th><th>31</th><th>23</th><th>15</th><th>9</th><th>5</th></tr>
        <tr><th>13</th><th>100</th><th>85</th><th>70</th><th>56</th><th>42</th><th>31</th><th>21</th><th>12</th><th>6</th><th>1</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>14</th><th>80</th><th>64</th><th>49</th><th>35</th><th>23</th><th>14</th><th>7</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>15</th><th>62</th><th>47</th><th>33</th><th>21</th><th>12</th><th>6</th><th>3</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>16</th><th>125</th><th>109</th><th>92</th><th>75</th><th>59</th><th>43</th><th>30</th><th>18</th><th>10</th><th>5</th><th>1</th><th>1</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>17</th><th>130</th><th>114</th><th>98</th><th>82</th><th>66</th><th>50</th><th>37</th><th>24</th><th>15</th><th>7</th><th>2</th><th>1</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>18</th><th>236</th><th>233</th><th>229</th><th>224</th><th>219</th><th>213</th><th>206</th><th>198</th><th>189</th><th>180</th><th>169</th><th>158</th><th>146</th><th>132</th><th>118</th><th>104</th></tr>
        <tr><th>19</th><th>90</th><th>72</th><th>54</th><th>37</th><th>24</th><th>15</th><th>9</th><th>3</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>20</th><th>219</th><th>213</th><th>207</th><th>199</th><th>190</th><th>181</th><th>172</th><th>160</th><th>148</th><th>133</th><th>118</th><th>103</th><th>88</th><th>74</th><th>62</th><th>51</th></tr>

                </tbody>
            </table>

            <table anchor="p0_latent">
                <name>P(0) values for latent</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>12</th><th>14</th><th>18</th><th>22</th><th>27</th><th>35</th><th>44</th><th>57</th><th>78</th><th>106</th><th>152</th><th>201</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>1</th><th>162</th><th>171</th><th>184</th><th>197</th><th>211</th><th>224</th><th>235</th><th>246</th><th>252</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>2</th><th>137</th><th>147</th><th>158</th><th>171</th><th>184</th><th>198</th><th>212</th><th>228</th><th>241</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>3</th><th>134</th><th>142</th><th>152</th><th>163</th><th>175</th><th>188</th><th>201</th><th>216</th><th>228</th><th>242</th><th>253</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>4</th><th>107</th><th>118</th><th>126</th><th>135</th><th>144</th><th>155</th><th>166</th><th>179</th><th>192</th><th>207</th><th>223</th><th>235</th><th>248</th><th>253</th><th>255</th><th>255</th></tr>
        <tr><th>5</th><th>138</th><th>152</th><th>167</th><th>183</th><th>199</th><th>215</th><th>231</th><th>246</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>6</th><th>118</th><th>130</th><th>144</th><th>158</th><th>174</th><th>190</th><th>206</th><th>223</th><th>237</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>7</th><th>138</th><th>149</th><th>159</th><th>167</th><th>180</th><th>194</th><th>208</th><th>227</th><th>239</th><th>250</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>8</th><th>201</th><th>209</th><th>220</th><th>229</th><th>237</th><th>243</th><th>248</th><th>253</th><th>254</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>9</th><th>114</th><th>123</th><th>133</th><th>145</th><th>158</th><th>172</th><th>186</th><th>204</th><th>218</th><th>234</th><th>246</th><th>253</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>10</th><th>145</th><th>157</th><th>169</th><th>182</th><th>196</th><th>209</th><th>223</th><th>237</th><th>248</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>11</th><th>66</th><th>75</th><th>85</th><th>96</th><th>107</th><th>115</th><th>122</th><th>132</th><th>140</th><th>151</th><th>163</th><th>175</th><th>189</th><th>201</th><th>213</th><th>224</th></tr>
        <tr><th>12</th><th>81</th><th>91</th><th>102</th><th>113</th><th>122</th><th>131</th><th>140</th><th>153</th><th>164</th><th>177</th><th>192</th><th>205</th><th>220</th><th>230</th><th>238</th><th>244</th></tr>
        <tr><th>13</th><th>143</th><th>153</th><th>163</th><th>175</th><th>187</th><th>199</th><th>211</th><th>226</th><th>237</th><th>249</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>14</th><th>146</th><th>157</th><th>170</th><th>183</th><th>198</th><th>213</th><th>228</th><th>245</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>15</th><th>159</th><th>168</th><th>179</th><th>193</th><th>208</th><th>222</th><th>237</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>16</th><th>122</th><th>130</th><th>140</th><th>150</th><th>161</th><th>174</th><th>187</th><th>203</th><th>216</th><th>232</th><th>245</th><th>253</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>17</th><th>121</th><th>128</th><th>137</th><th>147</th><th>159</th><th>170</th><th>183</th><th>198</th><th>212</th><th>228</th><th>241</th><th>250</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>18</th><th>20</th><th>23</th><th>27</th><th>32</th><th>37</th><th>43</th><th>50</th><th>58</th><th>67</th><th>76</th><th>87</th><th>98</th><th>108</th><th>116</th><th>125</th><th>134</th></tr>
        <tr><th>19</th><th>104</th><th>120</th><th>139</th><th>159</th><th>182</th><th>205</th><th>227</th><th>251</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th></tr>
        <tr><th>20</th><th>37</th><th>43</th><th>49</th><th>57</th><th>66</th><th>75</th><th>84</th><th>96</th><th>106</th><th>115</th><th>126</th><th>137</th><th>148</th><th>159</th><th>169</th><th>180</th></tr>

                </tbody>
            </table>

            <table anchor="scale_state">
                <name>Scale values for state</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>255</th><th>215</th><th>181</th><th>153</th><th>129</th><th>109</th><th>93</th><th>78</th><th>67</th><th>58</th><th>51</th><th>45</th><th>40</th><th>35</th><th>31</th><th>27</th></tr>
        <tr><th>1</th><th>255</th><th>215</th><th>181</th><th>153</th><th>128</th><th>108</th><th>91</th><th>77</th><th>65</th><th>55</th><th>47</th><th>41</th><th>36</th><th>31</th><th>27</th><th>24</th></tr>
        <tr><th>2</th><th>255</th><th>233</th><th>205</th><th>175</th><th>146</th><th>120</th><th>97</th><th>77</th><th>62</th><th>49</th><th>40</th><th>33</th><th>27</th><th>23</th><th>19</th><th>15</th></tr>
        <tr><th>3</th><th>255</th><th>215</th><th>181</th><th>152</th><th>127</th><th>107</th><th>89</th><th>74</th><th>62</th><th>53</th><th>44</th><th>37</th><th>32</th><th>28</th><th>24</th><th>21</th></tr>
        <tr><th>4</th><th>255</th><th>216</th><th>182</th><th>154</th><th>131</th><th>111</th><th>95</th><th>81</th><th>70</th><th>63</th><th>57</th><th>51</th><th>47</th><th>41</th><th>36</th><th>31</th></tr>
        <tr><th>5</th><th>255</th><th>215</th><th>181</th><th>152</th><th>128</th><th>108</th><th>91</th><th>76</th><th>64</th><th>55</th><th>46</th><th>39</th><th>34</th><th>29</th><th>25</th><th>21</th></tr>
        <tr><th>6</th><th>255</th><th>216</th><th>182</th><th>155</th><th>131</th><th>111</th><th>95</th><th>81</th><th>71</th><th>65</th><th>60</th><th>53</th><th>47</th><th>41</th><th>36</th><th>32</th></tr>
        <tr><th>7</th><th>255</th><th>216</th><th>183</th><th>155</th><th>132</th><th>113</th><th>98</th><th>87</th><th>79</th><th>79</th><th>78</th><th>69</th><th>62</th><th>53</th><th>46</th><th>40</th></tr>
        <tr><th>8</th><th>255</th><th>215</th><th>181</th><th>152</th><th>128</th><th>108</th><th>91</th><th>77</th><th>65</th><th>56</th><th>47</th><th>41</th><th>36</th><th>31</th><th>27</th><th>24</th></tr>
        <tr><th>9</th><th>255</th><th>216</th><th>183</th><th>155</th><th>131</th><th>112</th><th>96</th><th>82</th><th>71</th><th>62</th><th>54</th><th>47</th><th>41</th><th>37</th><th>34</th><th>42</th></tr>
        <tr><th>10</th><th>121</th><th>114</th><th>102</th><th>84</th><th>61</th><th>43</th><th>31</th><th>1</th><th>0</th><th>2</th><th>131</th><th>188</th><th>255</th><th>216</th><th>181</th><th>151</th></tr>
        <tr><th>11</th><th>255</th><th>215</th><th>182</th><th>153</th><th>129</th><th>108</th><th>91</th><th>77</th><th>65</th><th>55</th><th>47</th><th>40</th><th>34</th><th>28</th><th>24</th><th>20</th></tr>
        <tr><th>12</th><th>255</th><th>217</th><th>184</th><th>155</th><th>130</th><th>110</th><th>92</th><th>77</th><th>64</th><th>54</th><th>45</th><th>38</th><th>32</th><th>27</th><th>23</th><th>19</th></tr>
        <tr><th>13</th><th>255</th><th>227</th><th>196</th><th>166</th><th>140</th><th>118</th><th>98</th><th>82</th><th>69</th><th>57</th><th>48</th><th>40</th><th>34</th><th>29</th><th>24</th><th>20</th></tr>
        <tr><th>14</th><th>255</th><th>216</th><th>182</th><th>154</th><th>130</th><th>110</th><th>93</th><th>80</th><th>69</th><th>60</th><th>53</th><th>47</th><th>42</th><th>37</th><th>32</th><th>28</th></tr>
        <tr><th>15</th><th>255</th><th>216</th><th>184</th><th>156</th><th>133</th><th>114</th><th>98</th><th>87</th><th>77</th><th>72</th><th>66</th><th>59</th><th>52</th><th>46</th><th>40</th><th>36</th></tr>
        <tr><th>16</th><th>255</th><th>216</th><th>184</th><th>156</th><th>134</th><th>115</th><th>100</th><th>91</th><th>82</th><th>77</th><th>67</th><th>59</th><th>52</th><th>46</th><th>40</th><th>36</th></tr>
        <tr><th>17</th><th>255</th><th>216</th><th>183</th><th>155</th><th>131</th><th>110</th><th>93</th><th>78</th><th>66</th><th>57</th><th>49</th><th>42</th><th>37</th><th>32</th><th>28</th><th>25</th></tr>
        <tr><th>18</th><th>71</th><th>65</th><th>60</th><th>54</th><th>49</th><th>45</th><th>42</th><th>45</th><th>49</th><th>92</th><th>189</th><th>235</th><th>255</th><th>213</th><th>177</th><th>146</th></tr>

                </tbody>
            </table>

            <table anchor="deadzone_state">
                <name>Dead zone values for state</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>13</th><th>12</th><th>11</th><th>11</th><th>11</th><th>11</th><th>11</th><th>11</th><th>11</th><th>13</th><th>12</th><th>9</th><th>7</th><th>13</th><th>19</th><th>26</th></tr>
        <tr><th>1</th><th>16</th><th>14</th><th>12</th><th>11</th><th>9</th><th>8</th><th>7</th><th>4</th><th>4</th><th>4</th><th>4</th><th>5</th><th>7</th><th>5</th><th>3</th><th>7</th></tr>
        <tr><th>2</th><th>9</th><th>8</th><th>7</th><th>6</th><th>6</th><th>4</th><th>3</th><th>3</th><th>2</th><th>3</th><th>2</th><th>0</th><th>3</th><th>2</th><th>4</th><th>4</th></tr>
        <tr><th>3</th><th>6</th><th>8</th><th>8</th><th>9</th><th>9</th><th>9</th><th>10</th><th>8</th><th>8</th><th>11</th><th>11</th><th>10</th><th>15</th><th>22</th><th>28</th><th>37</th></tr>
        <tr><th>4</th><th>20</th><th>18</th><th>17</th><th>16</th><th>15</th><th>15</th><th>15</th><th>14</th><th>13</th><th>14</th><th>13</th><th>9</th><th>9</th><th>14</th><th>21</th><th>30</th></tr>
        <tr><th>5</th><th>10</th><th>8</th><th>7</th><th>5</th><th>4</th><th>4</th><th>3</th><th>3</th><th>2</th><th>3</th><th>4</th><th>6</th><th>8</th><th>9</th><th>10</th><th>10</th></tr>
        <tr><th>6</th><th>13</th><th>13</th><th>13</th><th>13</th><th>13</th><th>13</th><th>14</th><th>12</th><th>12</th><th>11</th><th>2</th><th>1</th><th>10</th><th>17</th><th>24</th><th>34</th></tr>
        <tr><th>7</th><th>35</th><th>30</th><th>25</th><th>22</th><th>19</th><th>17</th><th>16</th><th>18</th><th>15</th><th>22</th><th>0</th><th>1</th><th>0</th><th>4</th><th>7</th><th>12</th></tr>
        <tr><th>8</th><th>13</th><th>11</th><th>9</th><th>8</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>3</th><th>3</th><th>4</th><th>9</th><th>6</th><th>2</th><th>5</th></tr>
        <tr><th>9</th><th>15</th><th>15</th><th>15</th><th>15</th><th>15</th><th>16</th><th>17</th><th>17</th><th>18</th><th>16</th><th>20</th><th>26</th><th>34</th><th>46</th><th>75</th><th>255</th></tr>
        <tr><th>10</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>2</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>11</th><th>9</th><th>7</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>1</th><th>1</th><th>0</th><th>0</th><th>1</th><th>2</th><th>2</th><th>3</th><th>3</th></tr>
        <tr><th>12</th><th>11</th><th>9</th><th>6</th><th>5</th><th>3</th><th>2</th><th>2</th><th>2</th><th>2</th><th>3</th><th>4</th><th>4</th><th>3</th><th>3</th><th>3</th><th>2</th></tr>
        <tr><th>13</th><th>10</th><th>8</th><th>6</th><th>5</th><th>4</th><th>3</th><th>2</th><th>2</th><th>1</th><th>2</th><th>2</th><th>2</th><th>4</th><th>3</th><th>4</th><th>1</th></tr>
        <tr><th>14</th><th>23</th><th>19</th><th>17</th><th>14</th><th>12</th><th>11</th><th>9</th><th>8</th><th>8</th><th>11</th><th>9</th><th>4</th><th>4</th><th>7</th><th>9</th><th>13</th></tr>
        <tr><th>15</th><th>14</th><th>14</th><th>14</th><th>15</th><th>16</th><th>17</th><th>18</th><th>20</th><th>18</th><th>0</th><th>8</th><th>13</th><th>14</th><th>23</th><th>33</th><th>50</th></tr>
        <tr><th>16</th><th>26</th><th>24</th><th>21</th><th>19</th><th>17</th><th>16</th><th>12</th><th>7</th><th>0</th><th>11</th><th>14</th><th>14</th><th>17</th><th>24</th><th>32</th><th>46</th></tr>
        <tr><th>17</th><th>43</th><th>38</th><th>32</th><th>27</th><th>22</th><th>18</th><th>14</th><th>7</th><th>1</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th></tr>
        <tr><th>18</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>121</th><th>29</th><th>4</th><th>1</th><th>0</th><th>1</th><th>4</th></tr>

                </tbody>
            </table>

            <table anchor="decay_state">
                <name>Decay (r) values for state</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>207</th><th>199</th><th>190</th><th>181</th><th>169</th><th>158</th><th>145</th><th>130</th><th>116</th><th>103</th><th>90</th><th>77</th><th>66</th><th>52</th><th>39</th><th>27</th></tr>
        <tr><th>1</th><th>224</th><th>218</th><th>212</th><th>205</th><th>196</th><th>187</th><th>177</th><th>165</th><th>152</th><th>139</th><th>126</th><th>112</th><th>101</th><th>87</th><th>74</th><th>60</th></tr>
        <tr><th>2</th><th>253</th><th>253</th><th>252</th><th>252</th><th>251</th><th>250</th><th>249</th><th>247</th><th>245</th><th>242</th><th>239</th><th>235</th><th>231</th><th>226</th><th>220</th><th>213</th></tr>
        <tr><th>3</th><th>207</th><th>199</th><th>190</th><th>180</th><th>169</th><th>157</th><th>144</th><th>128</th><th>113</th><th>99</th><th>82</th><th>68</th><th>56</th><th>46</th><th>37</th><th>30</th></tr>
        <tr><th>4</th><th>197</th><th>187</th><th>177</th><th>165</th><th>152</th><th>139</th><th>124</th><th>109</th><th>95</th><th>84</th><th>74</th><th>64</th><th>56</th><th>42</th><th>30</th><th>19</th></tr>
        <tr><th>5</th><th>233</th><th>229</th><th>224</th><th>218</th><th>212</th><th>205</th><th>197</th><th>187</th><th>177</th><th>166</th><th>154</th><th>140</th><th>127</th><th>112</th><th>97</th><th>81</th></tr>
        <tr><th>6</th><th>190</th><th>181</th><th>170</th><th>158</th><th>144</th><th>130</th><th>115</th><th>100</th><th>86</th><th>78</th><th>70</th><th>60</th><th>48</th><th>36</th><th>25</th><th>16</th></tr>
        <tr><th>7</th><th>198</th><th>189</th><th>178</th><th>167</th><th>154</th><th>141</th><th>127</th><th>115</th><th>106</th><th>107</th><th>107</th><th>96</th><th>86</th><th>71</th><th>57</th><th>43</th></tr>
        <tr><th>8</th><th>232</th><th>227</th><th>223</th><th>217</th><th>210</th><th>203</th><th>194</th><th>183</th><th>173</th><th>161</th><th>149</th><th>136</th><th>124</th><th>111</th><th>99</th><th>84</th></tr>
        <tr><th>9</th><th>180</th><th>168</th><th>156</th><th>143</th><th>128</th><th>112</th><th>97</th><th>79</th><th>64</th><th>50</th><th>37</th><th>25</th><th>17</th><th>10</th><th>7</th><th>5</th></tr>
        <tr><th>10</th><th>4</th><th>3</th><th>1</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>0</th><th>19</th><th>104</th><th>132</th><th>117</th><th>100</th><th>83</th></tr>
        <tr><th>11</th><th>245</th><th>243</th><th>240</th><th>237</th><th>234</th><th>230</th><th>226</th><th>220</th><th>214</th><th>208</th><th>200</th><th>191</th><th>182</th><th>171</th><th>160</th><th>147</th></tr>
        <tr><th>12</th><th>251</th><th>251</th><th>250</th><th>249</th><th>247</th><th>246</th><th>244</th><th>241</th><th>239</th><th>235</th><th>232</th><th>227</th><th>222</th><th>216</th><th>210</th><th>202</th></tr>
        <tr><th>13</th><th>254</th><th>253</th><th>253</th><th>253</th><th>252</th><th>251</th><th>250</th><th>249</th><th>248</th><th>246</th><th>244</th><th>242</th><th>239</th><th>236</th><th>233</th><th>229</th></tr>
        <tr><th>14</th><th>210</th><th>203</th><th>194</th><th>185</th><th>174</th><th>162</th><th>149</th><th>136</th><th>122</th><th>109</th><th>98</th><th>88</th><th>78</th><th>64</th><th>51</th><th>38</th></tr>
        <tr><th>15</th><th>173</th><th>162</th><th>149</th><th>135</th><th>120</th><th>105</th><th>91</th><th>78</th><th>67</th><th>63</th><th>53</th><th>43</th><th>32</th><th>22</th><th>15</th><th>9</th></tr>
        <tr><th>16</th><th>169</th><th>156</th><th>142</th><th>128</th><th>112</th><th>98</th><th>85</th><th>77</th><th>71</th><th>61</th><th>48</th><th>37</th><th>28</th><th>18</th><th>10</th><th>5</th></tr>
        <tr><th>17</th><th>223</th><th>218</th><th>212</th><th>205</th><th>197</th><th>188</th><th>179</th><th>166</th><th>155</th><th>143</th><th>131</th><th>120</th><th>110</th><th>99</th><th>89</th><th>79</th></tr>
        <tr><th>18</th><th>22</th><th>17</th><th>12</th><th>7</th><th>4</th><th>2</th><th>1</th><th>2</th><th>11</th><th>90</th><th>166</th><th>183</th><th>188</th><th>178</th><th>164</th><th>150</th></tr>

                </tbody>
            </table>

            <table anchor="p0_state">
                <name>P(0) values for state</name>
                <thead>
                    <tr><th>k</th><th>Q0</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Q8</th><th>Q9</th><th>Q10</th><th>Q11</th><th>Q12</th><th>Q13</th><th>Q14</th><th>Q15</th></tr>
                </thead>
                <tbody>
        <tr><th>0</th><th>40</th><th>45</th><th>52</th><th>59</th><th>67</th><th>75</th><th>84</th><th>95</th><th>105</th><th>115</th><th>124</th><th>132</th><th>139</th><th>153</th><th>167</th><th>182</th></tr>
        <tr><th>1</th><th>24</th><th>28</th><th>32</th><th>37</th><th>43</th><th>49</th><th>56</th><th>63</th><th>72</th><th>80</th><th>90</th><th>100</th><th>110</th><th>119</th><th>128</th><th>142</th></tr>
        <tr><th>2</th><th>1</th><th>2</th><th>2</th><th>2</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>9</th><th>11</th><th>13</th><th>16</th><th>19</th><th>23</th></tr>
        <tr><th>3</th><th>35</th><th>41</th><th>48</th><th>56</th><th>65</th><th>75</th><th>85</th><th>97</th><th>109</th><th>124</th><th>139</th><th>153</th><th>168</th><th>183</th><th>197</th><th>210</th></tr>
        <tr><th>4</th><th>45</th><th>50</th><th>56</th><th>64</th><th>72</th><th>81</th><th>90</th><th>101</th><th>110</th><th>118</th><th>125</th><th>132</th><th>139</th><th>155</th><th>171</th><th>188</th></tr>
        <tr><th>5</th><th>15</th><th>18</th><th>21</th><th>24</th><th>29</th><th>33</th><th>39</th><th>45</th><th>52</th><th>60</th><th>69</th><th>78</th><th>88</th><th>98</th><th>108</th><th>119</th></tr>
        <tr><th>6</th><th>47</th><th>54</th><th>62</th><th>70</th><th>79</th><th>89</th><th>99</th><th>110</th><th>119</th><th>126</th><th>127</th><th>136</th><th>150</th><th>167</th><th>183</th><th>200</th></tr>
        <tr><th>7</th><th>44</th><th>49</th><th>54</th><th>60</th><th>67</th><th>74</th><th>82</th><th>90</th><th>95</th><th>97</th><th>91</th><th>99</th><th>107</th><th>121</th><th>135</th><th>151</th></tr>
        <tr><th>8</th><th>15</th><th>17</th><th>20</th><th>23</th><th>27</th><th>31</th><th>35</th><th>40</th><th>46</th><th>53</th><th>61</th><th>70</th><th>78</th><th>88</th><th>96</th><th>109</th></tr>
        <tr><th>9</th><th>58</th><th>65</th><th>73</th><th>82</th><th>92</th><th>102</th><th>112</th><th>125</th><th>136</th><th>146</th><th>160</th><th>176</th><th>193</th><th>209</th><th>226</th><th>251</th></tr>
        <tr><th>10</th><th>252</th><th>253</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>255</th><th>189</th><th>93</th><th>72</th><th>83</th><th>96</th><th>110</th></tr>
        <tr><th>11</th><th>7</th><th>8</th><th>9</th><th>11</th><th>13</th><th>15</th><th>18</th><th>21</th><th>24</th><th>29</th><th>33</th><th>39</th><th>46</th><th>53</th><th>60</th><th>69</th></tr>
        <tr><th>12</th><th>2</th><th>3</th><th>3</th><th>4</th><th>4</th><th>5</th><th>6</th><th>7</th><th>9</th><th>11</th><th>13</th><th>15</th><th>17</th><th>21</th><th>24</th><th>29</th></tr>
        <tr><th>13</th><th>1</th><th>1</th><th>1</th><th>2</th><th>2</th><th>2</th><th>3</th><th>4</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>10</th><th>12</th><th>14</th></tr>
        <tr><th>14</th><th>25</th><th>28</th><th>33</th><th>39</th><th>45</th><th>52</th><th>60</th><th>70</th><th>79</th><th>89</th><th>98</th><th>106</th><th>114</th><th>128</th><th>142</th><th>157</th></tr>
        <tr><th>15</th><th>56</th><th>64</th><th>73</th><th>83</th><th>93</th><th>105</th><th>116</th><th>128</th><th>135</th><th>131</th><th>142</th><th>155</th><th>168</th><th>185</th><th>201</th><th>218</th></tr>
        <tr><th>16</th><th>53</th><th>61</th><th>69</th><th>78</th><th>88</th><th>98</th><th>109</th><th>116</th><th>121</th><th>131</th><th>145</th><th>159</th><th>172</th><th>188</th><th>204</th><th>220</th></tr>
        <tr><th>17</th><th>17</th><th>21</th><th>25</th><th>31</th><th>39</th><th>45</th><th>52</th><th>58</th><th>65</th><th>74</th><th>84</th><th>94</th><th>105</th><th>116</th><th>128</th><th>139</th></tr>
        <tr><th>18</th><th>230</th><th>235</th><th>240</th><th>246</th><th>250</th><th>252</th><th>254</th><th>251</th><th>235</th><th>129</th><th>50</th><th>39</th><th>36</th><th>43</th><th>51</th><th>60</th></tr>

                </tbody>
            </table>
            </section>
            <section>
                <name>Vocoder</name>
                <t>
                    A vocoder is needed to turn the acoustic features into actual speech to fill in the audio
                    for any missing packets. Although the decoder is not normative, certain properties are needed for
                    DRED to function adequately. First, the vocoder SHOULD be able to start synthesizing speech by
                    continuing an existing waveform, reducing the artifacts caused at the beginning of a lost packet.
                    If such property cannot be achieved, then the implementation SHOULD at least make an attempt to
                    synchronize the phase of the synthesized speech with the last received speech, and attempt some
                    form of blending, e.g. by splicing the signals in the LPC residual domain.
                </t>
                <t>
                    A second important property of the vocoder is to not rely on more than one feature vector of look-ahead.
                    To synthesize speech between time t-10ms and t, the vocoder SHOULD NOT rely on acoustic features centered
                    beyond t+5ms (i.e. covering t-5ms to t+15ms). The vocoder MAY use more look-ahead when it is available,
                    but there are cases (e.g. last lost packet) where the amount of acoustic feature vectors will be limited.
                    For frames sizes less than 20 ms, the decoder SHOULD be prelated to deal with having less than one feature
                    vector of look-ahead.
                </t>
            </section>
          
        </section>
    </section>
    

    <section>
      <name>DRED Extension Format</name>
      <t>We use the Opus extension mechanism <xref target="opus-extension"/> to add deep redundancy within the padding
          of an Opus packet. We use the extension ID 32, which means that the L flag signals whether a length code is included.
          In this document, we define only the extension payload. [Note: until adoption by the IETF, experimental
          implementations of DRED MUST use experiment extension ID 126 to avoid causing interoperability problems]</t>

      <t>The principles behind the DRED mechanism defined in this extension are explained in <xref target="dred-paper"/>.
          All the data in the extension payload is encoded using the Opus entropy coder defined in Section&nbsp;4.1 of
          <xref target="RFC6716"/>. Since some of the fields at the beginning of the payload are encoded with flat
          binary probabilities, they can still be interpreted as bits.</t>

      <t>The extension starts with a 4-bit initial quantizer field (Q0) ranging from 0 to 15.
          That quantizer is used on the most recent
          frame encoded and is followed by the 3-bit quantizer slope dQ. The 3-bit dQ index selects from the following values:
          [0, 1/8, 3/16, 1/4, 3/8, 1/2, 3/4, 1] quantizer step per frame. The quantizer for frame k is thus given by:
          q=min(Qmax, round(Q0 + dQ_table[dQ] * k)), where Qmax is the maximum quantizer allowed.
          For example, using Q0=5 and dQ=2 (3/16), frame k=20 would
          use a quantizer of round(5 + 3/16 * k) = 9.</t>
      <t>We then have one bit (X) that flags whether an extended offset is used.
          If X=0, then a 5-bit offset indicator follows.
          The offset is a positive integer in units of 2.5&nbsp;ms.
          It indicates the time of the last sample analysed for the transmitted features in the packet, measured
          from 40ms after the first sample in the Opus frame that contains the extension data.
      </t>
      <t>If X=1, then we have an extended offset field, with an additional 8 bits to signal the offset.
         This makes it possible to signal a maximum offset of (2^13-1)*2.5ms, or approximately 20.5 seconds.
      </t>
      <t>If Q0&lt;14 and dQ!=0, then the offset is followed by the range-coded Qmax parameter.
        The probability of Qmax=15 is set to 1/2 (one bit is used), whereas other possible values
        (Q0 &lt; Qmax &lt; 15) are coded with a flat probability distribution.
        The pdf for Qmax is {nval, 1, 1, ...}/(2*nval), where there are nval=14-Q0 ones.
        The Qmax=15 symbol is first, followed by other values in ascending order, starting from Qmax=Q0+1.
        </t>

      <t>The compressed redundancy information consists of an initial state coded,
          followed by a sequence of 40-ms latent vectors.
          Both the initial state and the latent vectors are entropy-coded using
          a Laplace distribution.
          The number of 40-ms DRED latent vectors is not coded explicitly.
          Instead, the decoder keeps decoding them until it runs out of bits.
          More specifically, the decoder MUST NOT decode blocks when fewer than
          8 bits remain in the DRED payload.
          There is no arbitrary limit on the number of vectors that can be
          coded in a packet, but the authors do not believe that using more than
          a few seconds of redundancy is likely to be useful. Also, decoders
          MAY ignore any redundancy data beyond a certain amount.</t>

      <figure>
        <name>Extension framing</name>
        <artset>
        <!-- This <artset> includes two <artwork> elements, each of a different type -->
          <artwork type="ascii-art" name="dred-framing.txt">
            <![CDATA[
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Q0   |  dQ |X| (Ext. offset) | Offset  |Qmax | Initial state |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
   :                                                               :
   +            ...                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                               |  Latent vectors 0,            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
   |  latent vector 1, ...                                         |
   :                                                               :
   +                                                     +-+-+-+-+-|
   |                            Latent vector n-1        | unused  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            ]]>
          </artwork>
        </artset>
      </figure>

      <section>
        <name>Latent decoding</name>
        <t>Since the DRED decoder is normative, we describe DRED from the decoder perspective,
          but the encoder is expected to have the corresponding behavior.
          DRED uses the same range coder as the rest of Opus, as described in Section 4.1
          of <xref target="RFC6716"/>.
          Because the non-entropy-coded bits (Q0, dQ, ...) do not amount to an integer number of
          bytes, it is simpler to code them using the range coder.
          The result is the same for those bits, but it ensures that the complete DRED payload
          is an integer number of bytes (which is important to handle the end condition).
        </t>
        <t>The initial state and latent vectors are handled in the same way, both coded one
          dimension at a time.
          For each dimension, the decoder uses the quantization tables to determine the <em>r</em> and
          <em>p0</em> parameters.
          If r=0 or p0=255 for the current symbols and quantizer, then no symbol is decoded and the
          decoded quantized value is 0.
          Otherwise, decoding proceeds as follows.
        </t>
        <t>
          The first symbol decoded determines whether the quantized index is zero, positive, or negative
          (in that order).
          The decoder uses the pdf {2*p0_{i,q}, 256-p0_{i,q}, 256-p0_{i,q}}/512.
          If the value is non-zero, a second symbol is decoded.
          We start by generating an "inverse cdf" in Q15:
        </t>
          <artwork type="ascii-art" name="latent-icdf.txt">
<![CDATA[
              / 32768                                , if i < 0
              |
              | MAX(7, 128*r_{i,q})                  , if i = 0
    icdf(i) = <
              | MAX(7-i, (icdf[i-1]*r_{i,q})//32768) , if 0 < i < 7
              |
              \ 0                                    , i>= 7
        ]]>
          </artwork>
          <t>
          where // denotes the truncating integer division.
          The pdf is then given by pdf[i] = icdf[i-1]-icdf[i].
          If the decoded symbol equals 7, then another symbol is decoded and added to the 7 already decoded.
          The process is repeated until the decoded symbol is different from 7.
          At that point, the sign is applied and the decoded value is equal to
          quantized_index*256/s_{i,q}.
        </t>
      </section>
    </section>

    <section anchor="IANA">
      <name>IANA Considerations</name>
      <t>[Note: Until the IANA performs the actions described below, implementers should use 126 instead of 32 as the extension number. Moreover, the DRED payload temporarily uses a two-byte prefix for compatibility: a 'D' character, followed by a version number (currently 10).]</t>
      <t>This document assigns ID 32 to the "Opus Extension IDs" registry created in <xref target="opus-extension"/> to implement the proposed DRED
          extension. </t>

      <section anchor="media">
        <name>Opus Media Type Update</name>
        <t>This document updates the audio/opus media type registration
            <xref target="RFC7587"/> to add the following two optional parameters:</t>
        <t>ext32-dred-duration: Specifies the maximum amount of DRED information (in milliseconds) that the receiver can use. The receiver MUST
            be able to handle any valid DRED duration even if it does not make use of it.
            The sender MUST NOT send more than the specified amount of redundancy to avoid
            leaking information beyond what the receiver expects.</t>
        <t>sprop-ext32-dred-duration: Maximum amount of DRED information (in milliseconds) that the sender is likely to use. The received MUST
            be able to handle any valid DRED duration even if it does not make use of it.
            The sender MUST NOT send more than the specified amount of redundancy to avoid
            leaking information beyond what the receiver expects.</t>
      </section>
      <section anchor="SDP">
        <name>Mapping to SDP Parameters</name>
        <t>The media type parameters described above map to declarative SDP and
            SDP offer-answer in the same way as other optional parameters in <xref target="RFC7587"/>.
            Regardless of any a=fmtp SDP attribute specified, the receiver MUST be
            capable of receiving any signal.</t>
      </section>

    </section>
    
    <section anchor="Security">
      <!-- All drafts are required to have a security considerations section. See RFC 3552 for a guide. -->
      <name>Security Considerations</name>
      <t>When using a Selective Forwarding Unit (SFU), it is possible for the DRED payload to include
        speech that would not otherwise have been transmitted. For example, a new user joining may receive
        audio that was transmitted before them joining. If such behavior is a security or confidentiality
        concern, then the SFU SHOULD use the ext32-dred-duration and sprop-ext32-dred-duration parameters to limit
        the amount of redundancy and/or temporarily drop DRED payloads when that could leak information.</t>

      <t>As is the case for any media codec, the decoder must be robust against malicious payloads.
         Similarly, the encoder must also be robust to malicious audio input since the encoder input
         can often be controlled by an attacker. That can happen through browser JS, echo, or when
         the encoder is on a gateway.</t>
     
      <t>DRED is designed to have a complexity that is independent of the signal characteristics. However,
         there exist implementation details that can cause signal-dependent complexity changes. One example
         is CPU treatement of denormals that can sometimes cause increased CPU load and could be triggered
         by malicious input. For that reason, it is important to minimize such impact to reduce the impact
         of DOS attacks. Similarly, since the encoding and decoding process can be computationally costly,
         devices must manage the complexity to avoid attacks that could trigger too much DRED encoding or decoding
         to be performed.</t>
     
      <t>The use of variable-bitrate (VBR) encoding in DRED poses a theoretical information leak threat
         <xref target="RFC6562"/>, but that threat is believed to be significantly lower than that posed by
         VBR encoding in the main Opus payload. Since this document provides a way to dymanically vary the amount
         of redundancy transmitted, it is also possible to reduce the overall VBR risk of Opus by using DRED as
         a way of making the total Opus payload constant (CBR) or nearly constant.</t>
    </section>

  </middle>

  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7587.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6716.xml"/>
        <!-- The recommended and simplest way to include a well known reference -->
        <reference anchor="opus-extension">
        <!-- Manually added reference -->
          <front>
            <title>Extension Formatting for the Opus Codec (draft-ietf-mlcodec-opus-extension)</title>
            <author initials="T.B." surname="Terriberry" fullname="Timothy B. Terriberry">
              <organization/>
            </author>
            <author initials="J.-M." surname="Valin" fullname="Jean-Marc Valin">
              <organization/>
            </author>
            <date year="2023" month="October"/>
            <abstract>
              <t>Opus extension format.
              </t>
            </abstract>
          </front>
        </reference>
      </references>
 
      <references>
        <name>Informative References</name>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6562.xml"/>       
        <reference anchor="dred-paper" target="https://arxiv.org/abs/2212.04453">
          <front>
            <title>Low-Bitrate Redundancy Coding of Speech Using a Rate-Distortion-Optimized Variational Autoencoder</title>
            <author initials="J.-M." surname="Valin"/>
            <author initials="J." surname="Buethe"/>
            <author initials="A." surname="Mustafa"/>
            <date year="2023"/>
          </front>
        </reference>

      </references>
    </references>
    
    <!--
    <section>
      <name>Appendix 1 [REPLACE/DELETE]</name>
      <t>This becomes an Appendix [REPLACE]</t>
    </section>

    <section anchor="Acknowledgements" numbered="false">
      <name>Acknowledgements</name>
      <t>We would like to thank...</t>
    </section>
    
    <section anchor="Contributors" numbered="false">
      <name>Contributors</name>
      <t>Thanks to all of the contributors. [REPLACE]</t>
      </section>
    -->
    
 </back>
</rfc>
