|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Internet Engineering Task Force (IETF) JM. Valin
|
|
|
ec241f |
Request for Comments: 8251 Mozilla Corporation
|
|
|
ec241f |
Updates: 6716 K. Vos
|
|
|
ec241f |
Category: Standards Track vocTone
|
|
|
ec241f |
ISSN: 2070-1721 October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Updates to the Opus Audio Codec
|
|
|
ec241f |
|
|
|
ec241f |
Abstract
|
|
|
ec241f |
|
|
|
ec241f |
This document addresses minor issues that were found in the
|
|
|
ec241f |
specification of the Opus audio codec in RFC 6716. It updates the
|
|
|
ec241f |
normative decoder implementation included in Appendix A of RFC 6716.
|
|
|
ec241f |
The changes fix real and potential security-related issues, as well
|
|
|
ec241f |
as minor quality-related issues.
|
|
|
ec241f |
|
|
|
ec241f |
Status of This Memo
|
|
|
ec241f |
|
|
|
ec241f |
This is an Internet Standards Track document.
|
|
|
ec241f |
|
|
|
ec241f |
This document is a product of the Internet Engineering Task Force
|
|
|
ec241f |
(IETF). It represents the consensus of the IETF community. It has
|
|
|
ec241f |
received public review and has been approved for publication by the
|
|
|
ec241f |
Internet Engineering Steering Group (IESG). Further information on
|
|
|
ec241f |
Internet Standards is available in Section 2 of RFC 7841.
|
|
|
ec241f |
|
|
|
ec241f |
Information about the current status of this document, any errata,
|
|
|
ec241f |
and how to provide feedback on it may be obtained at
|
|
|
ec241f |
https://www.rfc-editor.org/info/rfc8251.
|
|
|
ec241f |
|
|
|
ec241f |
Copyright Notice
|
|
|
ec241f |
|
|
|
ec241f |
Copyright (c) 2017 IETF Trust and the persons identified as the
|
|
|
ec241f |
document authors. All rights reserved.
|
|
|
ec241f |
|
|
|
ec241f |
This document is subject to BCP 78 and the IETF Trust's Legal
|
|
|
ec241f |
Provisions Relating to IETF Documents
|
|
|
ec241f |
(https://trustee.ietf.org/license-info) in effect on the date of
|
|
|
ec241f |
publication of this document. Please review these documents
|
|
|
ec241f |
carefully, as they describe your rights and restrictions with respect
|
|
|
ec241f |
to this document. Code Components extracted from this document must
|
|
|
ec241f |
include Simplified BSD License text as described in Section 4.e of
|
|
|
ec241f |
the Trust Legal Provisions and are provided without warranty as
|
|
|
ec241f |
described in the Simplified BSD License.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 1]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Table of Contents
|
|
|
ec241f |
|
|
|
ec241f |
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
|
|
|
ec241f |
2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3
|
|
|
ec241f |
3. Stereo State Reset in SILK . . . . . . . . . . . . . . . . . 3
|
|
|
ec241f |
4. Parsing of the Opus Packet Padding . . . . . . . . . . . . . 4
|
|
|
ec241f |
5. Resampler Buffer . . . . . . . . . . . . . . . . . . . . . . 4
|
|
|
ec241f |
6. Integer Wrap-Around in Inverse Gain Computation . . . . . . . 6
|
|
|
ec241f |
7. Integer Wrap-Around in LSF Decoding . . . . . . . . . . . . . 7
|
|
|
ec241f |
8. Cap on Band Energy . . . . . . . . . . . . . . . . . . . . . 7
|
|
|
ec241f |
9. Hybrid Folding . . . . . . . . . . . . . . . . . . . . . . . 8
|
|
|
ec241f |
10. Downmix to Mono . . . . . . . . . . . . . . . . . . . . . . . 9
|
|
|
ec241f |
11. New Test Vectors . . . . . . . . . . . . . . . . . . . . . . 9
|
|
|
ec241f |
12. Security Considerations . . . . . . . . . . . . . . . . . . . 11
|
|
|
ec241f |
13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11
|
|
|
ec241f |
14. Normative References . . . . . . . . . . . . . . . . . . . . 11
|
|
|
ec241f |
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 11
|
|
|
ec241f |
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 12
|
|
|
ec241f |
|
|
|
ec241f |
1. Introduction
|
|
|
ec241f |
|
|
|
ec241f |
This document addresses minor issues that were discovered in the
|
|
|
ec241f |
reference implementation of the Opus codec. Unlike most IETF
|
|
|
ec241f |
specifications, RFC 6716 [RFC6716] defines Opus in terms of a
|
|
|
ec241f |
normative reference decoder implementation rather than from the
|
|
|
ec241f |
associated text description. Appendix A of that RFC includes the
|
|
|
ec241f |
reference decoder implementation, which is why only issues affecting
|
|
|
ec241f |
the decoder are listed here. An up-to-date implementation of the
|
|
|
ec241f |
Opus encoder can be found at <https://opus-codec.org/>.
|
|
|
ec241f |
|
|
|
ec241f |
Some of the changes in this document update normative behavior in a
|
|
|
ec241f |
way that requires new test vectors. Only the C implementation is
|
|
|
ec241f |
affected, not the English text of the specification. This
|
|
|
ec241f |
specification remains fully compatible with RFC 6716 [RFC6716].
|
|
|
ec241f |
|
|
|
ec241f |
Note: Due to RFC formatting conventions, lines exceeding the column
|
|
|
ec241f |
width in the patch are split using a backslash character. The
|
|
|
ec241f |
backslashes at the end of a line and the white space at the beginning
|
|
|
ec241f |
of the following line are not part of the patch. Referenced line
|
|
|
ec241f |
numbers are approximations. A properly formatted patch including all
|
|
|
ec241f |
changes is available at
|
|
|
ec241f |
materials-98-codec-opus-update-00.patch> and has a SHA-1 hash of
|
|
|
ec241f |
029e3aa88fc342c91e67a21e7bfbc9458661cd5f.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 2]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
2. Terminology
|
|
|
ec241f |
|
|
|
ec241f |
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
|
|
ec241f |
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
|
|
|
ec241f |
"OPTIONAL" in this document are to be interpreted as described in
|
|
|
ec241f |
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
|
|
|
ec241f |
capitals, as shown here.
|
|
|
ec241f |
|
|
|
ec241f |
3. Stereo State Reset in SILK
|
|
|
ec241f |
|
|
|
ec241f |
The reference implementation does not reinitialize the stereo state
|
|
|
ec241f |
during a mode switch. The old stereo memory can produce a brief
|
|
|
ec241f |
impulse (i.e., single sample) in the decoded audio. This can be
|
|
|
ec241f |
fixed by changing silk/dec_API.c around line 72:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
|
|
|
ec241f |
ret = silk_init_decoder( &channel_state[ n ] );
|
|
|
ec241f |
}
|
|
|
ec241f |
+ silk_memset(&((silk_decoder *)decState)->sStereo, 0,
|
|
|
ec241f |
+ sizeof(((silk_decoder *)decState)->sStereo));
|
|
|
ec241f |
+ /* Not strictly needed, but it's cleaner that way */
|
|
|
ec241f |
+ ((silk_decoder *)decState)->prev_decode_only_middle = 0;
|
|
|
ec241f |
|
|
|
ec241f |
return ret;
|
|
|
ec241f |
}
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
This change affects the normative output of the decoder, but the
|
|
|
ec241f |
amount of change is within the tolerance and is too small to make the
|
|
|
ec241f |
test vector check fail.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 3]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
4. Parsing of the Opus Packet Padding
|
|
|
ec241f |
|
|
|
ec241f |
It was discovered that some invalid packets of a very large size
|
|
|
ec241f |
could trigger an out-of-bounds read in the Opus packet parsing code
|
|
|
ec241f |
responsible for padding. This is due to an integer overflow if the
|
|
|
ec241f |
signaled padding exceeds 2^31-1 bytes (the actual packet may be
|
|
|
ec241f |
smaller). The code can be fixed by decrementing the (signed) len
|
|
|
ec241f |
value, instead of incrementing a separate padding counter. This is
|
|
|
ec241f |
done by applying the following changes around line 596 of
|
|
|
ec241f |
src/opus_decoder.c:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
/* Padding flag is bit 6 */
|
|
|
ec241f |
if (ch&0x40)
|
|
|
ec241f |
{
|
|
|
ec241f |
- int padding=0;
|
|
|
ec241f |
int p;
|
|
|
ec241f |
do {
|
|
|
ec241f |
if (len<=0)
|
|
|
ec241f |
return OPUS_INVALID_PACKET;
|
|
|
ec241f |
p = *data++;
|
|
|
ec241f |
len--;
|
|
|
ec241f |
- padding += p==255 ? 254: p;
|
|
|
ec241f |
+ len -= p==255 ? 254: p;
|
|
|
ec241f |
} while (p==255);
|
|
|
ec241f |
- len -= padding;
|
|
|
ec241f |
}
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
This packet-parsing issue is limited to reading memory up to about 60
|
|
|
ec241f |
KB beyond the compressed buffer. This can only be triggered by a
|
|
|
ec241f |
compressed packet more than about 16 MB long, so it's not a problem
|
|
|
ec241f |
for RTP. In theory, it could crash a file decoder (e.g., Opus in
|
|
|
ec241f |
Ogg) if the memory just after the incoming packet is out of range,
|
|
|
ec241f |
but our attempts to trigger such a crash in a production application
|
|
|
ec241f |
built using an affected version of the Opus decoder failed.
|
|
|
ec241f |
|
|
|
ec241f |
5. Resampler Buffer
|
|
|
ec241f |
|
|
|
ec241f |
The SILK resampler had the following issues:
|
|
|
ec241f |
|
|
|
ec241f |
1. The calls to memcpy() were using sizeof(opus_int32), but the type
|
|
|
ec241f |
of the local buffer was opus_int16.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 4]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
2. Because the size was wrong, this potentially allowed the source
|
|
|
ec241f |
and destination regions of the memcpy() to overlap on the copy
|
|
|
ec241f |
from "buf" to "buf". We believe that nSamplesIn (number of input
|
|
|
ec241f |
samples) is at least fs_in_khZ (sampling rate in kHz), which is
|
|
|
ec241f |
at least 8. Since RESAMPLER_ORDER_FIR_12 is only 8, that should
|
|
|
ec241f |
not be a problem once the type size is fixed.
|
|
|
ec241f |
|
|
|
ec241f |
3. The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the
|
|
|
ec241f |
data stored in it was actually twice the input batch size
|
|
|
ec241f |
(nSamplesIn<<1).
|
|
|
ec241f |
|
|
|
ec241f |
The code can be fixed by applying the following changes around line
|
|
|
ec241f |
78 of silk/resampler_private_IIR_FIR.c:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
)
|
|
|
ec241f |
{
|
|
|
ec241f |
silk_resampler_state_struct *S = \
|
|
|
ec241f |
(silk_resampler_state_struct *)SS;
|
|
|
ec241f |
opus_int32 nSamplesIn;
|
|
|
ec241f |
opus_int32 max_index_Q16, index_increment_Q16;
|
|
|
ec241f |
- opus_int16 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 ];
|
|
|
ec241f |
+ opus_int16 buf[ 2*RESAMPLER_MAX_BATCH_SIZE_IN + \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 ];
|
|
|
ec241f |
|
|
|
ec241f |
/* Copy buffered samples to start of buffer */
|
|
|
ec241f |
- silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \
|
|
|
ec241f |
* sizeof( opus_int32 ) );
|
|
|
ec241f |
+ silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \
|
|
|
ec241f |
* sizeof( opus_int16 ) );
|
|
|
ec241f |
|
|
|
ec241f |
/* Iterate over blocks of frameSizeIn input samples */
|
|
|
ec241f |
index_increment_Q16 = S->invRatio_Q16;
|
|
|
ec241f |
while( 1 ) {
|
|
|
ec241f |
nSamplesIn = silk_min( inLen, S->batchSize );
|
|
|
ec241f |
|
|
|
ec241f |
/* Upsample 2x */
|
|
|
ec241f |
silk_resampler_private_up2_HQ( S->sIIR, &buf[ \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn );
|
|
|
ec241f |
|
|
|
ec241f |
max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 \
|
|
|
ec241f |
); /* + 1 because 2x upsampling */
|
|
|
ec241f |
out = silk_resampler_private_IIR_FIR_INTERPOL( out, \
|
|
|
ec241f |
buf, max_index_Q16, index_increment_Q16 );
|
|
|
ec241f |
in += nSamplesIn;
|
|
|
ec241f |
inLen -= nSamplesIn;
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 5]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
if( inLen > 0 ) {
|
|
|
ec241f |
/* More iterations to do; copy last part of \
|
|
|
ec241f |
filtered signal to beginning of buffer */
|
|
|
ec241f |
- silk_memcpy( buf, &buf[ nSamplesIn << 1 ], \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) );
|
|
|
ec241f |
+ silk_memmove( buf, &buf[ nSamplesIn << 1 ], \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
|
|
|
ec241f |
} else {
|
|
|
ec241f |
break;
|
|
|
ec241f |
}
|
|
|
ec241f |
}
|
|
|
ec241f |
|
|
|
ec241f |
/* Copy last part of filtered signal to the state for \
|
|
|
ec241f |
the next call */
|
|
|
ec241f |
- silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) );
|
|
|
ec241f |
+ silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \
|
|
|
ec241f |
RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
|
|
|
ec241f |
}
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
6. Integer Wrap-Around in Inverse Gain Computation
|
|
|
ec241f |
|
|
|
ec241f |
It was discovered through decoder fuzzing that some bitstreams could
|
|
|
ec241f |
produce integer values exceeding 32 bits in
|
|
|
ec241f |
LPC_inverse_pred_gain_QA(), causing a wrap-around. The C standard
|
|
|
ec241f |
considers this behavior as undefined. The following patch around
|
|
|
ec241f |
line 87 of silk/LPC_inv_pred_gain.c detects values that do not fit in
|
|
|
ec241f |
a 32-bit integer and considers the corresponding filters unstable:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
/* Update AR coefficient */
|
|
|
ec241f |
for( n = 0; n < k; n++ ) {
|
|
|
ec241f |
- tmp_QA = Aold_QA[ n ] - MUL32_FRAC_Q( \
|
|
|
ec241f |
Aold_QA[ k - n - 1 ], rc_Q31, 31 );
|
|
|
ec241f |
- Anew_QA[ n ] = MUL32_FRAC_Q( tmp_QA, rc_mult2 , mult2Q );
|
|
|
ec241f |
+ opus_int64 tmp64;
|
|
|
ec241f |
+ tmp_QA = silk_SUB_SAT32( Aold_QA[ n ], MUL32_FRAC_Q( \
|
|
|
ec241f |
Aold_QA[ k - n - 1 ], rc_Q31, 31 ) );
|
|
|
ec241f |
+ tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( tmp_QA, \
|
|
|
ec241f |
rc_mult2 ), mult2Q);
|
|
|
ec241f |
+ if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) {
|
|
|
ec241f |
+ return 0;
|
|
|
ec241f |
+ }
|
|
|
ec241f |
+ Anew_QA[ n ] = ( opus_int32 )tmp64;
|
|
|
ec241f |
}
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 6]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
7. Integer Wrap-Around in LSF Decoding
|
|
|
ec241f |
|
|
|
ec241f |
It was discovered -- also from decoder fuzzing -- that an integer
|
|
|
ec241f |
wrap-around could occur when decoding bitstreams with extremely large
|
|
|
ec241f |
values for the high Line Spectral Frequency (LSF) parameters. The
|
|
|
ec241f |
end result of the wrap-around is an illegal read access on the stack,
|
|
|
ec241f |
which the authors do not believe is exploitable but should
|
|
|
ec241f |
nonetheless be fixed. The following patch around line 137 of silk/
|
|
|
ec241f |
NLSF_stabilize.c prevents the problem:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
/* Keep delta_min distance between the NLSFs */
|
|
|
ec241f |
for( i = 1; i < L; i++ )
|
|
|
ec241f |
- NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
|
|
|
ec241f |
NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
|
|
|
ec241f |
+ NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
|
|
|
ec241f |
silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
|
|
|
ec241f |
|
|
|
ec241f |
/* Last NLSF should be no higher than 1 - NDeltaMin[L] */
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
8. Cap on Band Energy
|
|
|
ec241f |
|
|
|
ec241f |
On extreme bitstreams, it is possible for log-domain band energy
|
|
|
ec241f |
levels to exceed the maximum single-precision floating point value
|
|
|
ec241f |
once converted to a linear scale. This would later cause the decoded
|
|
|
ec241f |
values to be NaN (not a number), possibly causing problems in the
|
|
|
ec241f |
software using the PCM values. This can be avoided with the
|
|
|
ec241f |
following patch around line 552 of celt/quant_bands.c:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
{
|
|
|
ec241f |
opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands],
|
|
|
ec241f |
SHL16((opus_val16)eMeans[i],6));
|
|
|
ec241f |
+ lg = MIN32(QCONST32(32.f, 16), lg);
|
|
|
ec241f |
eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4);
|
|
|
ec241f |
}
|
|
|
ec241f |
for (;i<m->nbEBands;i++)
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 7]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
9. Hybrid Folding
|
|
|
ec241f |
|
|
|
ec241f |
When encoding in hybrid mode at low bitrate, we sometimes only have
|
|
|
ec241f |
enough bits to code a single Constrained-Energy Lapped Transform
|
|
|
ec241f |
(CELT) band (8 - 9.6 kHz). When that happens, the second band (CELT
|
|
|
ec241f |
band 18, from 9.6 - 12 kHz) cannot use folding because it is wider
|
|
|
ec241f |
than the amount already coded and falls back to white noise. Because
|
|
|
ec241f |
it can also happen on transients (e.g., stops), it can cause audible
|
|
|
ec241f |
pre-echo.
|
|
|
ec241f |
|
|
|
ec241f |
To address the issue, we change the folding behavior so that it is
|
|
|
ec241f |
never forced to fall back to Linear Congruential Generator (LCG) due
|
|
|
ec241f |
to the first band not containing enough coefficients to fold onto the
|
|
|
ec241f |
second band. This is achieved by simply repeating part of the first
|
|
|
ec241f |
band in the folding of the second band. This changes the code in
|
|
|
ec241f |
celt/bands.c around line 1237:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
b = 0;
|
|
|
ec241f |
}
|
|
|
ec241f |
|
|
|
ec241f |
- if (resynth && M*eBands[i]-N >= M*eBands[start] && \
|
|
|
ec241f |
(update_lowband || lowband_offset==0))
|
|
|
ec241f |
+ if (resynth && (M*eBands[i]-N >= M*eBands[start] || \
|
|
|
ec241f |
i==start+1) && (update_lowband || lowband_offset==0))
|
|
|
ec241f |
lowband_offset = i;
|
|
|
ec241f |
|
|
|
ec241f |
+ if (i == start+1)
|
|
|
ec241f |
+ {
|
|
|
ec241f |
+ int n1, n2;
|
|
|
ec241f |
+ int offset;
|
|
|
ec241f |
+ n1 = M*(eBands[start+1]-eBands[start]);
|
|
|
ec241f |
+ n2 = M*(eBands[start+2]-eBands[start+1]);
|
|
|
ec241f |
+ offset = M*eBands[start];
|
|
|
ec241f |
+ /* Duplicate enough of the first band folding data to \
|
|
|
ec241f |
be able to fold the second band.
|
|
|
ec241f |
+ Copies no data for CELT-only mode. */
|
|
|
ec241f |
+ OPUS_COPY(&norm[offset+n1], &norm[offset+2*n1 - n2], n2-n1);
|
|
|
ec241f |
+ if (C==2)
|
|
|
ec241f |
+ OPUS_COPY(&norm2[offset+n1], &norm2[offset+2*n1 - n2], \
|
|
|
ec241f |
n2-n1);
|
|
|
ec241f |
+ }
|
|
|
ec241f |
+
|
|
|
ec241f |
tf_change = tf_res[i];
|
|
|
ec241f |
if (i>=m->effEBands)
|
|
|
ec241f |
{
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 8]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
as well as around line 1260:
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
fold_start = lowband_offset;
|
|
|
ec241f |
while(M*eBands[--fold_start] > effective_lowband);
|
|
|
ec241f |
fold_end = lowband_offset-1;
|
|
|
ec241f |
- while(M*eBands[++fold_end] < effective_lowband+N);
|
|
|
ec241f |
+ while(++fold_end < i && M*eBands[fold_end] < \
|
|
|
ec241f |
effective_lowband+N);
|
|
|
ec241f |
x_cm = y_cm = 0;
|
|
|
ec241f |
fold_i = fold_start; do {
|
|
|
ec241f |
x_cm |= collapse_masks[fold_i*C+0];
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
The fix does not impact compatibility, because the improvement does
|
|
|
ec241f |
not depend on the encoder doing anything special. There is also no
|
|
|
ec241f |
reasonable way for an encoder to use the original behavior to improve
|
|
|
ec241f |
quality over the proposed change.
|
|
|
ec241f |
|
|
|
ec241f |
10. Downmix to Mono
|
|
|
ec241f |
|
|
|
ec241f |
The last issue is not strictly a bug, but it is an issue that has
|
|
|
ec241f |
been reported when downmixing an Opus decoded stream to mono, whether
|
|
|
ec241f |
this is done inside the decoder or as a post-processing step on the
|
|
|
ec241f |
stereo decoder output. Opus intensity stereo allows optionally
|
|
|
ec241f |
coding the two channels 180 degrees out of phase on a per-band basis.
|
|
|
ec241f |
This provides better stereo quality than forcing the two channels to
|
|
|
ec241f |
be in phase, but when the output is downmixed to mono, the energy in
|
|
|
ec241f |
the affected bands is canceled, sometimes resulting in audible
|
|
|
ec241f |
artifacts.
|
|
|
ec241f |
|
|
|
ec241f |
As a work-around for this issue, the decoder MAY choose not to apply
|
|
|
ec241f |
the 180-degree phase shift. This can be useful when downmixing to
|
|
|
ec241f |
mono inside or outside of the decoder (e.g., requested explicitly
|
|
|
ec241f |
from an API).
|
|
|
ec241f |
|
|
|
ec241f |
11. New Test Vectors
|
|
|
ec241f |
|
|
|
ec241f |
Changes in Sections 9 and 10 have sufficient impact on the test
|
|
|
ec241f |
vectors to make them fail. For this reason, this document also
|
|
|
ec241f |
updates the Opus test vectors. The new test vectors now include two
|
|
|
ec241f |
decoded outputs for the same bitstream. The outputs with suffix 'm'
|
|
|
ec241f |
do not apply the CELT 180-degree phase shift as allowed in
|
|
|
ec241f |
Section 10, while the outputs without the suffix do. An
|
|
|
ec241f |
implementation is compliant as long as it passes either set of
|
|
|
ec241f |
vectors.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 9]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Any Opus implementation that passes either the original test vectors
|
|
|
ec241f |
from RFC 6716 [RFC6716] or one of the new sets of test vectors is
|
|
|
ec241f |
compliant with the Opus specification. However, newer
|
|
|
ec241f |
implementations SHOULD be based on the new test vectors rather than
|
|
|
ec241f |
the old ones.
|
|
|
ec241f |
|
|
|
ec241f |
The new test vectors are located at
|
|
|
ec241f |
|
|
|
ec241f |
newvectors-00.tar.gz>. The SHA-1 hashes of the test vectors are:
|
|
|
ec241f |
|
|
|
ec241f |
e49b2862ceec7324790ed8019eb9744596d5be01 testvector01.bit
|
|
|
ec241f |
b809795ae1bcd606049d76de4ad24236257135e0 testvector02.bit
|
|
|
ec241f |
e0c4ecaeab44d35a2f5b6575cd996848e5ee2acc testvector03.bit
|
|
|
ec241f |
a0f870cbe14ebb71fa9066ef3ee96e59c9a75187 testvector04.bit
|
|
|
ec241f |
9b3d92b48b965dfe9edf7b8a85edd4309f8cf7c8 testvector05.bit
|
|
|
ec241f |
28e66769ab17e17f72875283c14b19690cbc4e57 testvector06.bit
|
|
|
ec241f |
bacf467be3215fc7ec288f29e2477de1192947a6 testvector07.bit
|
|
|
ec241f |
ddbe08b688bbf934071f3893cd0030ce48dba12f testvector08.bit
|
|
|
ec241f |
3932d9d61944dab1201645b8eeaad595d5705ecb testvector09.bit
|
|
|
ec241f |
521eb2a1e0cc9c31b8b740673307c2d3b10c1900 testvector10.bit
|
|
|
ec241f |
6bc8f3146fcb96450c901b16c3d464ccdf4d5d96 testvector11.bit
|
|
|
ec241f |
338c3f1b4b97226bc60bc41038becbc6de06b28f testvector12.bit
|
|
|
ec241f |
f5ef93884da6a814d311027918e9afc6f2e5c2c8 testvector01.dec
|
|
|
ec241f |
48ac1ff1995250a756e1e17bd32acefa8cd2b820 testvector02.dec
|
|
|
ec241f |
d15567e919db2d0e818727092c0af8dd9df23c95 testvector03.dec
|
|
|
ec241f |
1249dd28f5bd1e39a66fd6d99449dca7a8316342 testvector04.dec
|
|
|
ec241f |
b85675d81deef84a112c466cdff3b7aaa1d2fc76 testvector05.dec
|
|
|
ec241f |
55f0b191e90bfa6f98b50d01a64b44255cb4813e testvector06.dec
|
|
|
ec241f |
61e8b357ab090b1801eeb578a28a6ae935e25b7b testvector07.dec
|
|
|
ec241f |
a58539ee5321453b2ddf4c0f2500e856b3966862 testvector08.dec
|
|
|
ec241f |
bb96aad2cde188555862b7bbb3af6133851ef8f4 testvector09.dec
|
|
|
ec241f |
1b6cdf0413ac9965b16184b1bea129b5c0b2a37a testvector10.dec
|
|
|
ec241f |
b1fff72b74666e3027801b29dbc48b31f80dee0d testvector11.dec
|
|
|
ec241f |
98e09bbafed329e341c3b4052e9c4ba5fc83f9b1 testvector12.dec
|
|
|
ec241f |
1e7d984ea3fbb16ba998aea761f4893fbdb30157 testvector01m.dec
|
|
|
ec241f |
48ac1ff1995250a756e1e17bd32acefa8cd2b820 testvector02m.dec
|
|
|
ec241f |
d15567e919db2d0e818727092c0af8dd9df23c95 testvector03m.dec
|
|
|
ec241f |
1249dd28f5bd1e39a66fd6d99449dca7a8316342 testvector04m.dec
|
|
|
ec241f |
d70b0bad431e7d463bc3da49bd2d49f1c6d0a530 testvector05m.dec
|
|
|
ec241f |
6ac1648c3174c95fada565161a6c78bdbe59c77d testvector06m.dec
|
|
|
ec241f |
fc5e2f709693738324fb4c8bdc0dad6dda04e713 testvector07m.dec
|
|
|
ec241f |
aad2ba397bf1b6a18e8e09b50e4b19627d479f00 testvector08m.dec
|
|
|
ec241f |
6feb7a7b9d7cdc1383baf8d5739e2a514bd0ba08 testvector09m.dec
|
|
|
ec241f |
1b6cdf0413ac9965b16184b1bea129b5c0b2a37a testvector10m.dec
|
|
|
ec241f |
fd3d3a7b0dfbdab98d37ed9aa04b659b9fefbd18 testvector11m.dec
|
|
|
ec241f |
98e09bbafed329e341c3b4052e9c4ba5fc83f9b1 testvector12m.dec
|
|
|
ec241f |
|
|
|
ec241f |
Note that the decoder input bitstream files (.bit) are unchanged.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 10]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
12. Security Considerations
|
|
|
ec241f |
|
|
|
ec241f |
This document fixes two security issues reported on Opus that affect
|
|
|
ec241f |
the reference implementation in RFC 6716 [RFC6716]: CVE-2013-0899
|
|
|
ec241f |
<https://nvd.nist.gov/vuln/detail/CVE-2013-0899> and CVE-2017-0381
|
|
|
ec241f |
<https://nvd.nist.gov/vuln/detail/CVE-2017-0381>. CVE-2013-0899
|
|
|
ec241f |
theoretically could have caused an information leak. The leaked
|
|
|
ec241f |
information would have gone through the decoder process before being
|
|
|
ec241f |
accessible to the attacker. The update in Section 4 fixes this.
|
|
|
ec241f |
CVE-2017-0381 could have resulted in a 16-bit out-of-bounds read from
|
|
|
ec241f |
a fixed location. The update in Section 7 fixes this. Beyond the
|
|
|
ec241f |
two fixed Common Vulnerabilities and Exposures (CVEs), this document
|
|
|
ec241f |
adds no new security considerations beyond those in RFC 6716
|
|
|
ec241f |
[RFC6716].
|
|
|
ec241f |
|
|
|
ec241f |
13. IANA Considerations
|
|
|
ec241f |
|
|
|
ec241f |
This document does not require any IANA actions.
|
|
|
ec241f |
|
|
|
ec241f |
14. Normative References
|
|
|
ec241f |
|
|
|
ec241f |
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
|
|
|
ec241f |
Requirement Levels", BCP 14, RFC 2119,
|
|
|
ec241f |
DOI 10.17487/RFC2119, March 1997,
|
|
|
ec241f |
<https://www.rfc-editor.org/info/rfc2119>.
|
|
|
ec241f |
|
|
|
ec241f |
[RFC6716] Valin, JM., Vos, K., and T. Terriberry, "Definition of the
|
|
|
ec241f |
Opus Audio Codec", RFC 6716, DOI 10.17487/RFC6716,
|
|
|
ec241f |
September 2012, <https://www.rfc-editor.org/info/rfc6716>.
|
|
|
ec241f |
|
|
|
ec241f |
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
|
|
|
ec241f |
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
|
|
|
ec241f |
May 2017, <https://www.rfc-editor.org/info/rfc8174>.
|
|
|
ec241f |
|
|
|
ec241f |
Acknowledgements
|
|
|
ec241f |
|
|
|
ec241f |
We would like to thank Juri Aedla for reporting the issue with the
|
|
|
ec241f |
parsing of the Opus padding. Thanks to Felicia Lim for reporting the
|
|
|
ec241f |
LSF integer overflow issue. Also, thanks to Tina le Grand, Jonathan
|
|
|
ec241f |
Lennox, and Mark Harris for their feedback on this document.
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 11]
|
|
|
ec241f |
|
|
|
ec241f |
RFC 8251 Opus Update October 2017
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Authors' Addresses
|
|
|
ec241f |
|
|
|
ec241f |
Jean-Marc Valin
|
|
|
ec241f |
Mozilla Corporation
|
|
|
ec241f |
331 E. Evelyn Avenue
|
|
|
ec241f |
Mountain View, CA 94041
|
|
|
ec241f |
United States of America
|
|
|
ec241f |
|
|
|
ec241f |
Phone: +1 650 903-0800
|
|
|
ec241f |
Email: jmvalin@jmvalin.ca
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Koen Vos
|
|
|
ec241f |
vocTone
|
|
|
ec241f |
|
|
|
ec241f |
Email: koenvos74@gmail.com
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
|
|
|
ec241f |
Valin & Vos Standards Track [Page 12]
|
|
|
ec241f |
|