aboutsummaryrefslogtreecommitdiff
path: root/doc/draft-ietf-codec-opus-update.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/draft-ietf-codec-opus-update.xml')
-rw-r--r--doc/draft-ietf-codec-opus-update.xml146
1 files changed, 112 insertions, 34 deletions
diff --git a/doc/draft-ietf-codec-opus-update.xml b/doc/draft-ietf-codec-opus-update.xml
index 85228573..a97124fc 100644
--- a/doc/draft-ietf-codec-opus-update.xml
+++ b/doc/draft-ietf-codec-opus-update.xml
@@ -10,7 +10,7 @@
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
-<rfc category="std" docName="draft-ietf-codec-opus-update-02"
+<rfc category="std" docName="draft-ietf-codec-opus-update-06"
ipr="trust200902">
<front>
<title abbrev="Opus Update">Updates to the Opus Audio Codec</title>
@@ -47,7 +47,7 @@
- <date day="1" month="July" year="2016" />
+ <date day="19" month="June" year="2017" />
<abstract>
<t>This document addresses minor issues that were found in the specification
@@ -61,10 +61,24 @@
implementation of the Opus codec that serves as the specification in
<xref target="RFC6716">RFC 6716</xref>. Only issues affecting the decoder are
listed here. An up-to-date implementation of the Opus encoder can be found at
- http://opus-codec.org/. The updated specification remains fully compatible with
- the original specification and only one of the changes results in any difference
- in the audio output.
- </t>
+ https://opus-codec.org/.</t>
+ <t>
+ Some of the changes in this document update normative behaviour in a way that requires
+ new test vectors. The English text of the specification is unaffected, only
+ the C implementation is. The updated specification remains fully compatible with
+ the original specification.
+ </t>
+
+ <t>
+ Note: due to RFC formatting conventions, lines exceeding the column width
+ in the patch are split using a backslash character. The backslashes
+ at the end of a line and the white space at the beginning
+ of the following line are not part of the patch. A properly formatted patch
+ including all changes is available at
+ <eref target="https://jmvalin.ca/misc_stuff/opus_update.patch"/>. (EDITOR:
+ change to an ietf.org link when ready)
+ </t>
+
</section>
<section title="Terminology">
@@ -156,7 +170,7 @@
the batch sizes are reasonable enough that none of the issues above
was ever a problem. However, proving that is non-obvious.
</t>
- <t>The code can be fixed by applying the following changes to line 70 of silk/resampler_private_IIR_FIR.c:
+ <t>The code can be fixed by applying the following changes to line 78 of silk/resampler_private_IIR_FIR.c:
</t>
<figure>
<artwork><![CDATA[
@@ -214,30 +228,78 @@ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
}
]]></artwork>
</figure>
- <t>
- Note: due to RFC formatting conventions, lines exceeding the column width
- in the patch above are split using a backslash character. The backslashes
- at the end of a line and the white space at the beginning
- of the following line are not part of the patch. A properly formatted patch
- including the three changes above is available at
- <eref target="https://jmvalin.ca/misc_stuff/opus_update.patch"/>. (EDITOR:
- change to an ietf.org link when ready)
- </t>
</section>
- <section title="Downmix to Mono" anchor="stereo">
- <t>The last issue is not strictly a bug, but it is an issue that has been reported
- when downmixing an Opus decoded stream to mono, whether this is done inside the decoder
- or as a post-processing step on the stereo decoder output. Opus intensity stereo allows
- optionally coding the two channels 180-degrees out of phase on a per-band basis.
- This provides better stereo quality than forcing the two channels to be in phase,
- but when the output is downmixed to mono, the energy in the affected bands is cancelled
- sometimes resulting in audible artefacts.
+ <section title="Integer wrap-around in inverse gain computation">
+ <t>
+ It was discovered through decoder fuzzing that some bitstreams could produce
+ integer values exceeding 32-bits in LPC_inverse_pred_gain_QA(), causing
+ a wrap-around. Although the error is harmless in practice, the C standard considers
+ the behavior as undefined, so the following patch to line 87 of silk/LPC_inv_pred_gain.c
+ detects values that do not fit in a 32-bit integer and considers the corresponding filters unstable:
</t>
- <t>As a work-around for this issue, the decoder MAY choose not to apply the 180-degree
- phase shift when the output is meant to be downmixed (inside or
- outside of the decoder).
+<figure>
+<artwork><![CDATA[
+ /* Update AR coefficient */
+ for( n = 0; n < k; n++ ) {
+- tmp_QA = Aold_QA[ n ] - MUL32_FRAC_Q( \
+Aold_QA[ k - n - 1 ], rc_Q31, 31 );
+- Anew_QA[ n ] = MUL32_FRAC_Q( tmp_QA, rc_mult2 , mult2Q );
++ opus_int64 tmp64;
++ tmp_QA = silk_SUB_SAT32( Aold_QA[ n ], MUL32_FRAC_Q( \
+Aold_QA[ k - n - 1 ], rc_Q31, 31 ) );
++ tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( tmp_QA, \
+rc_mult2 ), mult2Q);
++ if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) {
++ return 0;
++ }
++ Anew_QA[ n ] = ( opus_int32 )tmp64;
+ }
+]]></artwork>
+</figure>
+ </section>
+
+ <section title="Integer wrap-around in LSF decoding">
+ <t>
+ It was discovered -- also from decoder fuzzing -- that an integer wrap-around could
+ occur when decoding line spectral frequency coefficients from extreme bitstreams.
+ The end result of the wrap-around is an illegal read access on the stack, which
+ the authors do not believe is exploitable but should nonetheless be fixed. The following
+ patch to line 137 of silk/NLSF_stabilize.c prevents the problem:
</t>
+<figure>
+<artwork><![CDATA[
+ /* Keep delta_min distance between the NLSFs */
+ for( i = 1; i < L; i++ )
+- NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
+NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
++ NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
+silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
+
+ /* Last NLSF should be no higher than 1 - NDeltaMin[L] */
+]]></artwork>
+</figure>
+
+ </section>
+
+ <section title="Cap on Band Energy">
+ <t>On extreme bit-streams, it is possible for log-domain band energy levels
+ to exceed the maximum single-precision floating point value once converted
+ to a linear scale. This would later cause the decoded values to be NaN,
+ possibly causing problems in the software using the PCM values. This can be
+ avoided with the following patch to line 552 of celt/quant_bands.c:
+ </t>
+<figure>
+<artwork><![CDATA[
+ {
+ opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands],
+ SHL16((opus_val16)eMeans[i],6));
++ lg = MIN32(QCONST32(32.f, 16), lg);
+ eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4);
+ }
+ for (;i<m->nbEBands;i++)
+]]></artwork>
+</figure>
</section>
<section title="Hybrid Folding" anchor="folding">
@@ -249,7 +311,7 @@ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
can cause audible pre-echo.
</t>
<t>
- To address the issue, we change the folding behaviour so that it is
+ To address the issue, we change the folding behavior so that it is
never forced to fall back to LCG due to the first band not containing
enough coefficients to fold onto the second band. This
is achieved by simply repeating part of the first band in the folding
@@ -309,20 +371,35 @@ effective_lowband+N);
<t>
The fix does not impact compatibility, because the improvement does
not depend on the encoder doing anything special. There is also no
- reasonable way for an encoder to use the original behaviour to
+ reasonable way for an encoder to use the original behavior to
improve quality over the proposed change.
</t>
</section>
+ <section title="Downmix to Mono" anchor="stereo">
+ <t>The last issue is not strictly a bug, but it is an issue that has been reported
+ when downmixing an Opus decoded stream to mono, whether this is done inside the decoder
+ or as a post-processing step on the stereo decoder output. Opus intensity stereo allows
+ optionally coding the two channels 180-degrees out of phase on a per-band basis.
+ This provides better stereo quality than forcing the two channels to be in phase,
+ but when the output is downmixed to mono, the energy in the affected bands is cancelled
+ sometimes resulting in audible artefacts.
+ </t>
+ <t>As a work-around for this issue, the decoder MAY choose not to apply the 180-degree
+ phase shift when the output is meant to be downmixed (inside or
+ outside of the decoder).
+ </t>
+ </section>
+
+
<section title="New Test Vectors">
- <t>Changes in <xref target="stereo"/> and <xref target="folding"/> have
+ <t>Changes in <xref target="folding"/> and <xref target="stereo"/> have
sufficient impact on the testvectors to make them fail. For this reason,
this document also updates the Opus test vectors. The new test vectors now
include two decoded outputs for the same bitstream. The outputs with
suffix 'm' do not apply the CELT 180-degree phase shift as allowed in
- <xref target="stereo"/>, while the outputs with suffix 's' do. An
- implementation is compliant as long as it passes either the 'm' or the
- 's' set of vectors.
+ <xref target="stereo"/>, while the outputs without the suffix do. An
+ implementation is compliant as long as it passes either set of vectors.
</t>
<t>
In addition, any Opus implementation
@@ -345,7 +422,8 @@ effective_lowband+N);
<section anchor="Acknowledgements" title="Acknowledgements">
<t>We would like to thank Juri Aedla for reporting the issue with the parsing of
- the Opus padding.</t>
+ the Opus padding. Also, thanks to Jonathan Lennox and Mark Harris for their
+ feedback on this document.</t>
</section>
</middle>