Skip to content

Instantly share code, notes, and snippets.

@lu-zero
Last active November 3, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lu-zero/b42b77f3aa0b460406b3 to your computer and use it in GitHub Desktop.
Save lu-zero/b42b77f3aa0b460406b3 to your computer and use it in GitHub Desktop.
Beautifying posts
<p>I decided to improve Libav DTS decoder - dcadec. Here I want to explain what are its problems now and what I would like to do about them.</p>
<p>DTS encoded audio stream consists of core audio and may contain extended audio. Lavc dcadec supports <code>XCH</code> and <code>XLL</code> extensions but <code>X96</code>, <code>XXCH</code> and <code>XBR</code> extensions are waiting to be implemented - I'd like to implement them later.</p>
<p>For the DTS lossless extension - <code>XLL</code>, the decoded output audio should be a bit for <strong>bit accurate</strong> reproduction of the encoded input. However there are some problems.</p>
<ul>
<li>The main problem is that the core decoder converts integer coefficients read from the bitstream to <strong>floats</strong> just after reading them (along with dequantization). All other steps of audio reconstruction are done with floats and the output can <strong>not</strong> be bitexact reproduction of the input so it is not lossless. When the coefficients are read from the bitstream the core decoder does following:</li>
</ul>
<pre>dequantization (with int -&gt; float conversion)
&darr;
inverse ADPCM (when needed)
&darr;
VQ decoding (when needed)
&darr;
filtering: QMF, LFE, downmixing (when needed)
&darr;
float output.
</pre>
<p>I'm working now on modifying the core to work with integer coefficients and then convert them to floats before QMF filtering for lossy output but use <strong>bitexact</strong> QMF (intermediate LFE coefficients should be always integers and I think it's not correct in the current version) for lossless output. Also I added an option called <code>-force_fixed</code> to force fixed point reconstruction for any kind of input.</p>
<ul>
<li>Another problem is XLL extension presence <strong>detection</strong>. During the testing I found out that <code>XLL</code> extension is not detected sometimes and the core audio only is decoded in this case. I want to fix this issue as well.</li>
</ul>

I decided to improve Libav DTS decoder - dcadec. Here I want to explain what are its problems now and what I would like to do about them.

DTS encoded audio stream consists of core audio and may contain extended audio. Lavc dcadec supports XCH and XLL extensions but X96, XXCH and XBR extensions are waiting to be implemented - I'd like to implement them later.

For the DTS lossless extension - XLL, the decoded output audio should be a bit for bit accurate reproduction of the encoded input. However there are some problems.

  • The main problem is that the core decoder converts integer coefficients read from the bitstream to floats just after reading them (along with dequantization). All other steps of audio reconstruction are done with floats and the output can not be bitexact reproduction of the input so it is not lossless. When the coefficients are read from the bitstream the core decoder does following:
dequantization (with int -> float conversion)
                    |
       inverse ADPCM (when needed)
                    |
         VQ decoding (when needed) 
                    |
filtering: QMF, LFE, downmixing (when needed) 
                    |
              float output.

I'm working now on modifying the core to work with integer coefficients and then convert them to floats before QMF filtering for lossy output but use bitexact QMF (intermediate LFE coefficients should be always integers and I think it's not correct in the current version) for lossless output. Also I added an option called -force_fixed to force fixed point reconstruction for any kind of input.

  • Another problem is XLL extension presence detection. During the testing I found out that XLL extension is not detected sometimes and the core audio only is decoded in this case. I want to fix this issue as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment