Internet Engineering Task Force (IETF) JM. Valin Request for Comments: 8251 Mozilla Corporation Updates: 6716 K. Vos Category: Standards Track vocTone ISSN: 2070-1721 October 2017
Internet Engineering Task Force (IETF) JM. Valin Request for Comments: 8251 Mozilla Corporation Updates: 6716 K. Vos Category: Standards Track vocTone ISSN: 2070-1721 October 2017
Updates to the Opus Audio Codec
Opus音频编解码器的更新
Abstract
摘要
This document addresses minor issues that were found in the specification of the Opus audio codec in RFC 6716. It updates the normative decoder implementation included in Appendix A of RFC 6716. The changes fix real and potential security-related issues, as well as minor quality-related issues.
本文档解决RFC6716中Opus音频编解码器规范中发现的小问题。它更新了RFC 6716附录A中包含的标准解码器实现。这些更改修复了实际和潜在的安全相关问题,以及次要的质量相关问题。
Status of This Memo
关于下段备忘
This is an Internet Standards Track document.
这是一份互联网标准跟踪文件。
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.
本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 7841第2节。
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at https://www.rfc-editor.org/info/rfc8251.
有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问https://www.rfc-editor.org/info/rfc8251.
Copyright Notice
版权公告
Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved.
版权所有(c)2017 IETF信托基金和确定为文件作者的人员。版权所有。
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(https://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括信托法律条款第4.e节中所述的简化BSD许可证文本,并提供简化BSD许可证中所述的无担保。
Table of Contents
目录
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Stereo State Reset in SILK . . . . . . . . . . . . . . . . . 3 4. Parsing of the Opus Packet Padding . . . . . . . . . . . . . 4 5. Resampler Buffer . . . . . . . . . . . . . . . . . . . . . . 4 6. Integer Wrap-Around in Inverse Gain Computation . . . . . . . 6 7. Integer Wrap-Around in LSF Decoding . . . . . . . . . . . . . 7 8. Cap on Band Energy . . . . . . . . . . . . . . . . . . . . . 7 9. Hybrid Folding . . . . . . . . . . . . . . . . . . . . . . . 8 10. Downmix to Mono . . . . . . . . . . . . . . . . . . . . . . . 9 11. New Test Vectors . . . . . . . . . . . . . . . . . . . . . . 9 12. Security Considerations . . . . . . . . . . . . . . . . . . . 11 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11 14. Normative References . . . . . . . . . . . . . . . . . . . . 11 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 11 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 12
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Stereo State Reset in SILK . . . . . . . . . . . . . . . . . 3 4. Parsing of the Opus Packet Padding . . . . . . . . . . . . . 4 5. Resampler Buffer . . . . . . . . . . . . . . . . . . . . . . 4 6. Integer Wrap-Around in Inverse Gain Computation . . . . . . . 6 7. Integer Wrap-Around in LSF Decoding . . . . . . . . . . . . . 7 8. Cap on Band Energy . . . . . . . . . . . . . . . . . . . . . 7 9. Hybrid Folding . . . . . . . . . . . . . . . . . . . . . . . 8 10. Downmix to Mono . . . . . . . . . . . . . . . . . . . . . . . 9 11. New Test Vectors . . . . . . . . . . . . . . . . . . . . . . 9 12. Security Considerations . . . . . . . . . . . . . . . . . . . 11 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11 14. Normative References . . . . . . . . . . . . . . . . . . . . 11 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 11 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 12
This document addresses minor issues that were discovered in the reference implementation of the Opus codec. Unlike most IETF specifications, RFC 6716 [RFC6716] defines Opus in terms of a normative reference decoder implementation rather than from the associated text description. Appendix A of that RFC includes the reference decoder implementation, which is why only issues affecting the decoder are listed here. An up-to-date implementation of the Opus encoder can be found at <https://opus-codec.org/>.
本文档介绍在Opus编解码器的参考实现中发现的一些小问题。与大多数IETF规范不同,RFC 6716[RFC6716]根据标准参考解码器实现而不是相关文本描述来定义OPU。RFC的附录A包括参考解码器实现,这就是为什么这里只列出影响解码器的问题。Opus编码器的最新实现可在<https://opus-codec.org/>.
Some of the changes in this document update normative behavior in a way that requires new test vectors. Only the C implementation is affected, not the English text of the specification. This specification remains fully compatible with RFC 6716 [RFC6716].
本文档中的一些更改以一种需要新测试向量的方式更新了规范行为。只影响C实现,而不影响规范的英文文本。本规范与RFC 6716[RFC6716]完全兼容。
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. Referenced line numbers are approximations. A properly formatted patch including all changes is available at <https://www.ietf.org/proceedings/98/slides/ materials-98-codec-opus-update-00.patch> and has a SHA-1 hash of 029e3aa88fc342c91e67a21e7bfbc9458661cd5f.
注意:由于RFC格式约定,将使用反斜杠字符拆分面片中超过列宽的行。一行末尾的反斜杠和下一行开头的空白不是面片的一部分。参考线号是近似值。包含所有更改的正确格式的修补程序可在<https://www.ietf.org/proceedings/98/slides/ materials-98-codec-opus-update-00.patch>并具有029E3AA88FC342C91E67A21E7FBC9458661CD5F的SHA-1哈希。
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 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
本文件中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“建议”、“不建议”、“可”和“可选”在所有大写字母出现时(如图所示)应按照BCP 14[RFC2119][RFC8174]所述进行解释。
The reference implementation does not reinitialize the stereo state during a mode switch. The old stereo memory can produce a brief impulse (i.e., single sample) in the decoded audio. This can be fixed by changing silk/dec_API.c around line 72:
在模式切换期间,参考实现不会重新初始化立体声状态。旧的立体声存储器可以在解码的音频中产生短暂的脉冲(即单个样本)。这可以通过改变第72行附近的silk/dec_API.c来解决:
<CODE BEGINS> for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { ret = silk_init_decoder( &channel_state[ n ] ); } + silk_memset(&((silk_decoder *)decState)->sStereo, 0, + sizeof(((silk_decoder *)decState)->sStereo)); + /* Not strictly needed, but it's cleaner that way */ + ((silk_decoder *)decState)->prev_decode_only_middle = 0;
<CODE BEGINS> for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { ret = silk_init_decoder( &channel_state[ n ] ); } + silk_memset(&((silk_decoder *)decState)->sStereo, 0, + sizeof(((silk_decoder *)decState)->sStereo)); + /* Not strictly needed, but it's cleaner that way */ + ((silk_decoder *)decState)->prev_decode_only_middle = 0;
return ret; } <CODE ENDS>
return ret; } <CODE ENDS>
This change affects the normative output of the decoder, but the amount of change is within the tolerance and is too small to make the test vector check fail.
此更改影响解码器的标准输出,但更改量在公差范围内,且太小,无法使测试向量检查失败。
It was discovered that some invalid packets of a very large size could trigger an out-of-bounds read in the Opus packet parsing code responsible for padding. This is due to an integer overflow if the signaled padding exceeds 2^31-1 bytes (the actual packet may be smaller). The code can be fixed by decrementing the (signed) len value, instead of incrementing a separate padding counter. This is done by applying the following changes around line 596 of src/opus_decoder.c:
发现一些非常大的无效数据包可能会触发Opus数据包解析代码中负责填充的越界读取。这是由于如果信号填充超过2^31-1字节(实际数据包可能更小),则会出现整数溢出。可以通过减少(有符号的)len值来修复代码,而不是增加单独的填充计数器。这是通过在src/opus_decoder.c的第596行周围应用以下更改来实现的:
<CODE BEGINS> /* Padding flag is bit 6 */ if (ch&0x40) { - int padding=0; int p; do { if (len<=0) return OPUS_INVALID_PACKET; p = *data++; len--; - padding += p==255 ? 254: p; + len -= p==255 ? 254: p; } while (p==255); - len -= padding; } <CODE ENDS>
<CODE BEGINS> /* Padding flag is bit 6 */ if (ch&0x40) { - int padding=0; int p; do { if (len<=0) return OPUS_INVALID_PACKET; p = *data++; len--; - padding += p==255 ? 254: p; + len -= p==255 ? 254: p; } while (p==255); - len -= padding; } <CODE ENDS>
This packet-parsing issue is limited to reading memory up to about 60 KB beyond the compressed buffer. This can only be triggered by a compressed packet more than about 16 MB long, so it's not a problem for RTP. In theory, it could crash a file decoder (e.g., Opus in Ogg) if the memory just after the incoming packet is out of range, but our attempts to trigger such a crash in a production application built using an affected version of the Opus decoder failed.
此数据包解析问题仅限于在压缩缓冲区之外读取高达约60KB的内存。这只能由长度超过16MB的压缩数据包触发,因此RTP不会有问题。理论上,如果传入数据包后的内存超出范围,则可能导致文件解码器崩溃(例如,Ogg中的Opus),但我们尝试在使用受影响版本的Opus解码器构建的生产应用程序中触发此类崩溃失败。
The SILK resampler had the following issues:
丝绸再采样器存在以下问题:
1. The calls to memcpy() were using sizeof(opus_int32), but the type of the local buffer was opus_int16.
1. 对memcpy()的调用使用的是sizeof(opus_int32),但本地缓冲区的类型是opus_int16。
2. Because the size was wrong, this potentially allowed the source and destination regions of the memcpy() to overlap on the copy from "buf" to "buf". We believe that nSamplesIn (number of input samples) is at least fs_in_khZ (sampling rate in kHz), which is at least 8. Since RESAMPLER_ORDER_FIR_12 is only 8, that should not be a problem once the type size is fixed.
2. 由于大小错误,这可能会允许memcpy()的源区域和目标区域在从“buf”到“buf”的副本上重叠。我们认为nSamplesIn(输入样本数)至少为fs_in_khZ(采样率以khZ为单位),至少为8。由于重采样器的顺序仅为8,所以一旦类型大小固定,这应该不是问题。
3. The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the data stored in it was actually twice the input batch size (nSamplesIn<<1).
3. 使用重采样器\u MAX\u BATCH\u size\u IN的缓冲区大小,但其中存储的数据实际上是输入批大小的两倍(nSamplesIn<<1)。
The code can be fixed by applying the following changes around line 78 of silk/resampler_private_IIR_FIR.c:
代码可以通过在silk/resampler_private_IIR_FIR.c第78行周围应用以下更改来修复:
<CODE BEGINS>
<代码开始>
) { silk_resampler_state_struct *S = \ (silk_resampler_state_struct *)SS; opus_int32 nSamplesIn; opus_int32 max_index_Q16, index_increment_Q16; - opus_int16 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + \ RESAMPLER_ORDER_FIR_12 ]; + opus_int16 buf[ 2*RESAMPLER_MAX_BATCH_SIZE_IN + \ RESAMPLER_ORDER_FIR_12 ];
) { silk_resampler_state_struct *S = \ (silk_resampler_state_struct *)SS; opus_int32 nSamplesIn; opus_int32 max_index_Q16, index_increment_Q16; - opus_int16 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + \ RESAMPLER_ORDER_FIR_12 ]; + opus_int16 buf[ 2*RESAMPLER_MAX_BATCH_SIZE_IN + \ RESAMPLER_ORDER_FIR_12 ];
/* Copy buffered samples to start of buffer */ - silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \ * sizeof( opus_int32 ) ); + silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \ * sizeof( opus_int16 ) );
/* Copy buffered samples to start of buffer */ - silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \ * sizeof( opus_int32 ) ); + silk_memcpy( buf, S->sFIR, RESAMPLER_ORDER_FIR_12 \ * sizeof( opus_int16 ) );
/* Iterate over blocks of frameSizeIn input samples */ index_increment_Q16 = S->invRatio_Q16; while( 1 ) { nSamplesIn = silk_min( inLen, S->batchSize );
/* Iterate over blocks of frameSizeIn input samples */ index_increment_Q16 = S->invRatio_Q16; while( 1 ) { nSamplesIn = silk_min( inLen, S->batchSize );
/* Upsample 2x */ silk_resampler_private_up2_HQ( S->sIIR, &buf[ \ RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn );
/* Upsample 2x */ silk_resampler_private_up2_HQ( S->sIIR, &buf[ \ RESAMPLER_ORDER_FIR_12 ], in, nSamplesIn );
max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 \ ); /* + 1 because 2x upsampling */ out = silk_resampler_private_IIR_FIR_INTERPOL( out, \ buf, max_index_Q16, index_increment_Q16 ); in += nSamplesIn; inLen -= nSamplesIn;
max_index_Q16 = silk_LSHIFT32( nSamplesIn, 16 + 1 \ ); /* + 1 because 2x upsampling */ out = silk_resampler_private_IIR_FIR_INTERPOL( out, \ buf, max_index_Q16, index_increment_Q16 ); in += nSamplesIn; inLen -= nSamplesIn;
if( inLen > 0 ) { /* More iterations to do; copy last part of \ filtered signal to beginning of buffer */ - silk_memcpy( buf, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); + silk_memmove( buf, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); } else { break; } }
if( inLen > 0 ) { /* More iterations to do; copy last part of \ filtered signal to beginning of buffer */ - silk_memcpy( buf, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); + silk_memmove( buf, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); } else { break; } }
/* Copy last part of filtered signal to the state for \ the next call */ - silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); + silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); } <CODE ENDS>
/* Copy last part of filtered signal to the state for \ the next call */ - silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) ); + silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) ); } <CODE ENDS>
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. The C standard considers this behavior as undefined. The following patch around 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:
通过解码器模糊化发现,在LPC_inverse_pred_gain_QA()中,某些位流可能产生超过32位的整数值,从而导致环绕。C标准认为这种行为是未定义的。silk/LPC_inv_pred_gain.c第87行周围的以下补丁检测到不适合32位整数的值,并认为相应的过滤器不稳定:
<CODE BEGINS> /* 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; } <CODE ENDS>
<CODE BEGINS> /* 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; } <CODE ENDS>
It was discovered -- also from decoder fuzzing -- that an integer wrap-around could occur when decoding bitstreams with extremely large values for the high Line Spectral Frequency (LSF) parameters. 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 around line 137 of silk/ NLSF_stabilize.c prevents the problem:
人们发现——同样是从解码器模糊化中发现——当解码具有非常大的高线谱频率(LSF)参数值的比特流时,可能会发生整数环绕。环绕的最终结果是堆栈上的非法读取访问,作者认为这是不可利用的,但应予以修复。silk/NLSF_.c第137行周围的以下补丁可防止该问题:
<CODE BEGINS> /* 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] ) );
<CODE BEGINS> /* 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] */ <CODE ENDS>
/* Last NLSF should be no higher than 1 - NDeltaMin[L] */ <CODE ENDS>
On extreme bitstreams, 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 (not a number), possibly causing problems in the software using the PCM values. This can be avoided with the following patch around line 552 of celt/quant_bands.c:
在极端比特流上,一旦转换为线性刻度,对数域频带能量级别可能超过最大单精度浮点值。这将导致解码值为NaN(不是数字),可能导致使用PCM值的软件出现问题。在celt/quant_bands.c的第552行周围使用以下贴片可以避免这种情况:
<CODE BEGINS> { 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++) <CODE ENDS>
<CODE BEGINS> { 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++) <CODE ENDS>
When encoding in hybrid mode at low bitrate, we sometimes only have enough bits to code a single Constrained-Energy Lapped Transform (CELT) band (8 - 9.6 kHz). When that happens, the second band (CELT band 18, from 9.6 - 12 kHz) cannot use folding because it is wider than the amount already coded and falls back to white noise. Because it can also happen on transients (e.g., stops), it can cause audible pre-echo.
当以低比特率以混合模式编码时,我们有时只有足够的比特来编码单个受限能量重叠变换(CELT)频带(8-9.6 kHz)。当这种情况发生时,第二个波段(CELT波段18,从9.6-12 kHz)不能使用折叠,因为它比已经编码的数量更宽,并且返回到白噪声。因为它也可能发生在瞬变(例如停止)时,所以它可能会导致可听见的预回声。
To address the issue, we change the folding behavior so that it is never forced to fall back to Linear Congruential Generator (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 of the second band. This changes the code in celt/bands.c around line 1237:
为了解决这个问题,我们改变了折叠行为,这样它就不会因为第一个频带没有足够的系数折叠到第二个频带而被迫退回到线性同余生成器(LCG)。这是通过简单地在折叠第二波段时重复第一波段的一部分来实现的。这将更改celt/bands.c中第1237行附近的代码:
<CODE BEGINS> b = 0; }
<CODE BEGINS> b = 0; }
- if (resynth && M*eBands[i]-N >= M*eBands[start] && \ (update_lowband || lowband_offset==0)) + if (resynth && (M*eBands[i]-N >= M*eBands[start] || \ i==start+1) && (update_lowband || lowband_offset==0)) lowband_offset = i;
- 如果(重新同步和M*eBands[i]-N>=M*eBands[start]&&(更新低带| |低带|低带|低带|偏移==0))+if(重新同步和(M*eBands[i]-N>=M*eBands[start].\i==start+1)和(更新低带| |低带|低带|偏移==0))低带|偏移=i;
+ if (i == start+1) + { + int n1, n2; + int offset; + n1 = M*(eBands[start+1]-eBands[start]); + n2 = M*(eBands[start+2]-eBands[start+1]); + offset = M*eBands[start]; + /* Duplicate enough of the first band folding data to \ be able to fold the second band. + Copies no data for CELT-only mode. */ + OPUS_COPY(&norm[offset+n1], &norm[offset+2*n1 - n2], n2-n1); + if (C==2) + OPUS_COPY(&norm2[offset+n1], &norm2[offset+2*n1 - n2], \ n2-n1); + } + tf_change = tf_res[i]; if (i>=m->effEBands) { <CODE ENDS>
+ 如果(i==start+1)+{+int n1,n2;+int offset;+n1=M*(eband[start+1]-eband[start]);+n2=M*(eband[start+2]-eband[start+1]);+offset=M*eband[start];+/*复制足够多的第一个波段折叠数据,以便\能够折叠第二个波段。+仅复制CELT模式的数据。*/+OPUS_COPY(&norm[offset+n1],&norm[offset+n1],&norm[offset+2*n1-n2],n2-n1);+if(C==2)+OPUS_COPY(&norm2[offset+n1],&norm2[offset+2*n1-n2],\n2-n1);+}+tf_change=tf_res[i];如果(i>=m->effEBands){<代码结束>
as well as around line 1260:
以及1260线附近:
<CODE BEGINS> fold_start = lowband_offset; while(M*eBands[--fold_start] > effective_lowband); fold_end = lowband_offset-1; - while(M*eBands[++fold_end] < effective_lowband+N); + while(++fold_end < i && M*eBands[fold_end] < \ effective_lowband+N); x_cm = y_cm = 0; fold_i = fold_start; do { x_cm |= collapse_masks[fold_i*C+0];
<CODE BEGINS> fold_start = lowband_offset; while(M*eBands[--fold_start] > effective_lowband); fold_end = lowband_offset-1; - while(M*eBands[++fold_end] < effective_lowband+N); + while(++fold_end < i && M*eBands[fold_end] < \ effective_lowband+N); x_cm = y_cm = 0; fold_i = fold_start; do { x_cm |= collapse_masks[fold_i*C+0];
<CODE ENDS>
<代码结束>
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 behavior to improve quality over the proposed change.
修复不会影响兼容性,因为改进并不依赖于编码器执行任何特殊操作。编码器也没有合理的方法使用原始行为来提高提议更改的质量。
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 canceled, sometimes resulting in audible artifacts.
最后一个问题并不是严格意义上的错误,但在将Opus解码流下混音到单声道时,这是一个已报告的问题,无论是在解码器内部还是作为立体声解码器输出的后处理步骤。Opus intensity stereo允许在每个频带的基础上对两个通道进行180度异相编码。这比强制两个通道同相提供更好的立体声质量,但当输出下混为单声道时,受影响频带中的能量会被抵消,有时会导致声音伪影。
As a work-around for this issue, the decoder MAY choose not to apply the 180-degree phase shift. This can be useful when downmixing to mono inside or outside of the decoder (e.g., requested explicitly from an API).
作为该问题的解决方法,解码器可以选择不应用180度相移。这在解码器内部或外部下混音到单声道时非常有用(例如,从API明确请求)。
Changes in Sections 9 and 10 have sufficient impact on the test vectors 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 Section 10, while the outputs without the suffix do. An implementation is compliant as long as it passes either set of vectors.
第9节和第10节中的变更对测试向量有足够的影响,使其失败。因此,本文件还更新了Opus测试向量。新的测试向量现在包括相同比特流的两个解码输出。后缀为“m”的输出不适用第10节中允许的CELT 180度相移,而不带后缀的输出则适用。只要一个实现通过了任意一组向量,它就是兼容的。
Any Opus implementation that passes either the original test vectors from RFC 6716 [RFC6716] or one of the new sets of test vectors is compliant with the Opus specification. However, newer implementations SHOULD be based on the new test vectors rather than the old ones.
任何通过RFC 6716[RFC6716]原始测试向量或新测试向量集之一的Opus实现都符合Opus规范。然而,新的实现应该基于新的测试向量,而不是旧的测试向量。
The new test vectors are located at <https://www.ietf.org/proceedings/98/slides/materials-98-codec-opus-newvectors-00.tar.gz>. The SHA-1 hashes of the test vectors are:
新的测试向量位于<https://www.ietf.org/proceedings/98/slides/materials-98-codec-opus-newvectors-00.tar.gz>. 测试向量的SHA-1散列为:
e49b2862ceec7324790ed8019eb9744596d5be01 testvector01.bit b809795ae1bcd606049d76de4ad24236257135e0 testvector02.bit e0c4ecaeab44d35a2f5b6575cd996848e5ee2acc testvector03.bit a0f870cbe14ebb71fa9066ef3ee96e59c9a75187 testvector04.bit 9b3d92b48b965dfe9edf7b8a85edd4309f8cf7c8 testvector05.bit 28e66769ab17e17f72875283c14b19690cbc4e57 testvector06.bit bacf467be3215fc7ec288f29e2477de1192947a6 testvector07.bit ddbe08b688bbf934071f3893cd0030ce48dba12f testvector08.bit 3932d9d61944dab1201645b8eeaad595d5705ecb testvector09.bit 521eb2a1e0cc9c31b8b740673307c2d3b10c1900 testvector10.bit 6bc8f3146fcb96450c901b16c3d464ccdf4d5d96 testvector11.bit 338c3f1b4b97226bc60bc41038becbc6de06b28f testvector12.bit f5ef93884da6a814d311027918e9afc6f2e5c2c8 testvector01.dec 48ac1ff1995250a756e1e17bd32acefa8cd2b820 testvector02.dec d15567e919db2d0e818727092c0af8dd9df23c95 testvector03.dec 1249dd28f5bd1e39a66fd6d99449dca7a8316342 testvector04.dec b85675d81deef84a112c466cdff3b7aaa1d2fc76 testvector05.dec 55f0b191e90bfa6f98b50d01a64b44255cb4813e testvector06.dec 61e8b357ab090b1801eeb578a28a6ae935e25b7b testvector07.dec a58539ee5321453b2ddf4c0f2500e856b3966862 testvector08.dec bb96aad2cde188555862b7bbb3af6133851ef8f4 testvector09.dec 1b6cdf0413ac9965b16184b1bea129b5c0b2a37a testvector10.dec b1fff72b74666e3027801b29dbc48b31f80dee0d testvector11.dec 98e09bbafed329e341c3b4052e9c4ba5fc83f9b1 testvector12.dec 1e7d984ea3fbb16ba998aea761f4893fbdb30157 testvector01m.dec 48ac1ff1995250a756e1e17bd32acefa8cd2b820 testvector02m.dec d15567e919db2d0e818727092c0af8dd9df23c95 testvector03m.dec 1249dd28f5bd1e39a66fd6d99449dca7a8316342 testvector04m.dec d70b0bad431e7d463bc3da49bd2d49f1c6d0a530 testvector05m.dec 6ac1648c3174c95fada565161a6c78bdbe59c77d testvector06m.dec fc5e2f709693738324fb4c8bdc0dad6dda04e713 testvector07m.dec aad2ba397bf1b6a18e8e09b50e4b19627d479f00 testvector08m.dec 6feb7a7b9d7cdc1383baf8d5739e2a514bd0ba08 testvector09m.dec 1b6cdf0413ac9965b16184b1bea129b5c0b2a37a testvector10m.dec fd3d3a7b0dfbdab98d37ed9aa04b659b9fefbd18 testvector11m.dec 98e09bbafed329e341c3b4052e9c4ba5fc83f9b1 testvector12m.dec
E49B2862CEEC7324790ED8019EB97445966D5BE01测试向量01.bit b809795ae1bcd606049d76de4ad24236257135e0测试向量02.bit e0c4ecaeab44d35a2f5b6575cd996848e5ee2acc测试向量03.bit A0F870CBE14EBB71FA9066EF3EE96E59E59C9C9A75187测试向量04.bit 9B3D92B48B48B465DFE9EDF7B8A854309CF7C8测试向量05.bit 28E6697677CBC1967测试向量06bacf467be3215fc7ec288f29e2477de1192947a6测试向量07.bit DDBE08B688BF934071F3893CD0030CE48DBA12F测试向量08.bit 3932D9D61944AB1201645B8EEAAD595D5705ECB测试向量09.bit 521EB2A1E0CC9C38B74067330C2D3B10C1900测试向量10.bit 6BC8F3146FCB96450C901B16C3D464CDF4D4D5D96测试向量11.bit 338C3B97226BC60BCB138F测试向量12.bit测试向量f5ef93884da6a814d311027918e9afc6f2e5c2c8测试向量01.dec 48AC1FF1995250A756E17BD32CEFA8CD2B820测试向量02.dec D15567E919DB2D0E818727092C08AF8DD9DF23C95测试向量03.dec 1249DD28F5BD1E39A66FD6D99449DCA8316342测试向量04.dec B85675D81F84A112C466CD3B7AAD2FC76测试向量05.dec B190BF8B40B40B50B4DEC测试向量61E8B357AB090B1801EBEB578A28A6AE935E25B7B测试向量07.dec A58539EE5321453B2DDF4C0F2500E856B39666862测试向量08.dec BB96AAD2CDE188555862B7BB3AF6133851EF8F4测试向量09.dec 1B6CDF0413AC9965B16184B1129B5C0B2A37A测试向量10.dec B1FFF72B74666E302780B1B229DBC48B310D测试向量11.98E09BBAF329E39CF8B19B19B19FC0812E测试向量1e7d984ea3fbb16ba998aea761f4893fbdb30157测试向量01M.dec 48AC1FF1995250A756E17BD32CEFA8CD2B820测试向量02M.dec d15567e919db2d0e818727092c0af8dd9df23c95测试向量03M.dec 1249DD28F5BD1E39A66FD6D99449DCA8316342测试向量04M.dec D70B0BAD431E7D463BCA492DF49C6C530测试向量056BDC1616.dec测试向量机06M.dec FC5E2F70969738324FB4C8BDC0DAD6DDA04E713测试向量机07M.dec AAD2BA397BF1B6A18E8E09B50E4B19727D479F00测试向量机08M.dec 6feb7a7b9d7cdc1383baf8d5739e2a514bd0ba08测试向量机09M.dec 1B6CDF0413AC9965B16184B1129B5C0B2A37A测试向量机10M.dec FD3D3A07DFBD98D37ED9A4测试向量机11M.dec98e09bbafed329e341c3b4052e9c4ba5fc83f9b1测试向量2012年12月
Note that the decoder input bitstream files (.bit) are unchanged.
请注意,解码器输入位流文件(.bit)没有改变。
This document fixes two security issues reported on Opus that affect the reference implementation in RFC 6716 [RFC6716]: CVE-2013-0899 <https://nvd.nist.gov/vuln/detail/CVE-2013-0899> and CVE-2017-0381 <https://nvd.nist.gov/vuln/detail/CVE-2017-0381>. CVE-2013-0899 theoretically could have caused an information leak. The leaked information would have gone through the decoder process before being accessible to the attacker. The update in Section 4 fixes this. CVE-2017-0381 could have resulted in a 16-bit out-of-bounds read from a fixed location. The update in Section 7 fixes this. Beyond the two fixed Common Vulnerabilities and Exposures (CVEs), this document adds no new security considerations beyond those in RFC 6716 [RFC6716].
本文档修复了Opus上报告的两个安全问题,它们影响RFC 6716[RFC6716]:CVE-2013-0899中的参考实现<https://nvd.nist.gov/vuln/detail/CVE-2013-0899>和CVE-2017-0381<https://nvd.nist.gov/vuln/detail/CVE-2017-0381>. CVE-2013-0899理论上可能导致信息泄漏。泄漏的信息在被攻击者访问之前会经过解码过程。第4节中的更新修复了这一问题。CVE-2017-0381可能导致从固定位置读取16位越界。第7节中的更新修复了这一问题。除了两个固定的常见漏洞和暴露(CVE)之外,本文档没有添加RFC 6716[RFC6716]中以外的新安全注意事项。
This document does not require any IANA actions.
本文件不要求IANA采取任何行动。
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>.
[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,DOI 10.17487/RFC2119,1997年3月<https://www.rfc-editor.org/info/rfc2119>.
[RFC6716] Valin, JM., Vos, K., and T. Terriberry, "Definition of the Opus Audio Codec", RFC 6716, DOI 10.17487/RFC6716, September 2012, <https://www.rfc-editor.org/info/rfc6716>.
[RFC6716]Valin,JM.,Vos,K.,和T.Terriberry,“作品音频编解码器的定义”,RFC 6716,DOI 10.17487/RFC6716,2012年9月<https://www.rfc-editor.org/info/rfc6716>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC8174]Leiba,B.,“RFC 2119关键词中大写与小写的歧义”,BCP 14,RFC 8174,DOI 10.17487/RFC8174,2017年5月<https://www.rfc-editor.org/info/rfc8174>.
Acknowledgements
致谢
We would like to thank Juri Aedla for reporting the issue with the parsing of the Opus padding. Thanks to Felicia Lim for reporting the LSF integer overflow issue. Also, thanks to Tina le Grand, Jonathan Lennox, and Mark Harris for their feedback on this document.
我们要感谢Juri Aedla报告了Opus padding解析的问题。感谢Felicia Lim报告LSF整数溢出问题。另外,感谢Tina le Grand、Jonathan Lennox和Mark Harris对本文档的反馈。
Authors' Addresses
作者地址
Jean-Marc Valin Mozilla Corporation 331 E. Evelyn Avenue Mountain View, CA 94041 United States of America
Jean-Marc Valin Mozilla Corporation美国加利福尼亚州伊夫林大道东331号山景城94041
Phone: +1 650 903-0800 Email: jmvalin@jmvalin.ca
Phone: +1 650 903-0800 Email: jmvalin@jmvalin.ca
Koen Vos vocTone
科恩沃斯酒店
Email: koenvos74@gmail.com
Email: koenvos74@gmail.com