aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/draft-ietf-codec-opus-update.xml153
-rw-r--r--doc/opus_in_isobmff.html208
2 files changed, 222 insertions, 139 deletions
diff --git a/doc/draft-ietf-codec-opus-update.xml b/doc/draft-ietf-codec-opus-update.xml
index a97124fc..3124e22c 100644
--- a/doc/draft-ietf-codec-opus-update.xml
+++ b/doc/draft-ietf-codec-opus-update.xml
@@ -10,8 +10,8 @@
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
-<rfc category="std" docName="draft-ietf-codec-opus-update-06"
- ipr="trust200902">
+<rfc category="std" docName="draft-ietf-codec-opus-update-10"
+ ipr="trust200902" updates="6716">
<front>
<title abbrev="Opus Update">Updates to the Opus Audio Codec</title>
@@ -47,21 +47,26 @@
- <date day="19" month="June" year="2017" />
+ <date day="24" month="August" year="2017" />
<abstract>
<t>This document addresses minor issues that were found in the specification
- of the Opus audio codec in <xref target="RFC6716">RFC 6716</xref>.</t>
+ of the Opus audio codec in RFC 6716. It updates the normative decoder implementation
+ included in the appendix of RFC 6716. The changes fixes real and potential security-related
+ issues, as well minor quality-related issues.</t>
</abstract>
</front>
<middle>
<section title="Introduction">
<t>This document addresses minor issues that were discovered in the reference
- implementation of the Opus codec that serves as the specification in
- <xref target="RFC6716">RFC 6716</xref>. Only issues affecting the decoder are
+ implementation of the Opus codec. Unlike most IETF specifications, Opus is defined
+ in <xref target="RFC6716">RFC 6716</xref> in terms of a normative reference
+ decoder implementation rather than from the associated text description.
+ That RFC includes the reference decoder implementation as Appendix A.
+ That's 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/.</t>
+ <eref target="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
@@ -75,8 +80,8 @@
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)
+ <eref target="https://www.ietf.org/proceedings/98/slides/materials-98-codec-opus-update-00.patch"/>
+ and has a SHA-1 hash of 029e3aa88fc342c91e67a21e7bfbc9458661cd5f.
</t>
</section>
@@ -96,6 +101,7 @@
</t>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
ret = silk_init_decoder( &channel_state[ n ] );
}
@@ -106,11 +112,12 @@
return ret;
}
+<CODE ENDS>
]]></artwork>
</figure>
<t>
- This change affects the normative part of the decoder, although the
- amount of change is too small to make a significant impact on testvectors.
+ This change affects the normative output of the decoder, but the
+ amount of change is within the tolerance and too small to make the testvector check fail.
</t>
</section>
@@ -118,11 +125,13 @@
<t>It was discovered that some invalid packets of 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 applying the following
- changes at line 596 of src/opus_decoder.c:
+ (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 at line 596 of src/opus_decoder.c:
</t>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
/* Padding flag is bit 6 */
if (ch&0x40)
{
@@ -138,12 +147,13 @@
} while (p==255);
- len -= padding;
}
+<CODE ENDS>
]]></artwork>
</figure>
<t>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 <spanx style="emph">could</spanx> crash a file
+ 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.</t>
@@ -155,25 +165,20 @@
<t>The calls to memcpy() were using sizeof(opus_int32), but the type of the
local buffer was opus_int16.</t>
<t>Because the size was wrong, this potentially allowed the source
- and destination regions of the memcpy() to overlap.
- We <spanx style="emph">believe</spanx> that nSamplesIn is at least fs_in_khZ,
+ 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.</t>
<t>The size of the buffer used RESAMPLER_MAX_BATCH_SIZE_IN, but the
- data stored in it was actually _twice_ the input batch size
+ data stored in it was actually twice the input batch size
(nSamplesIn&lt;&lt;1).</t>
</list></t>
- <t>
- The fact that the code never produced any error in testing (including when run under the
- Valgrind memory debugger), suggests that in practice
- 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 78 of silk/resampler_private_IIR_FIR.c:
</t>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
)
{
silk_resampler_state_struct *S = \
@@ -226,6 +231,7 @@ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int32 ) );
+ silk_memcpy( S->sFIR, &buf[ nSamplesIn << 1 ], \
RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
}
+<CODE ENDS>
]]></artwork>
</figure>
</section>
@@ -234,12 +240,13 @@ RESAMPLER_ORDER_FIR_12 * sizeof( opus_int16 ) );
<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
+ a wrap-around. The C standard considers
+ this behavior as undefined. 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>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
/* Update AR coefficient */
for( n = 0; n < k; n++ ) {
- tmp_QA = Aold_QA[ n ] - MUL32_FRAC_Q( \
@@ -255,20 +262,22 @@ rc_mult2 ), mult2Q);
+ }
+ Anew_QA[ n ] = ( opus_int32 )tmp64;
}
+<CODE ENDS>
]]></artwork>
</figure>
</section>
- <section title="Integer wrap-around in LSF decoding">
+ <section title="Integer wrap-around in LSF decoding" anchor="lsf_overflow">
<t>
It was discovered -- also from decoder fuzzing -- that an integer wrap-around could
- occur when decoding line spectral frequency coefficients from extreme bitstreams.
+ occur when decoding bitstreams with extremely large values for the high 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 to line 137 of silk/NLSF_stabilize.c prevents the problem:
</t>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
/* Keep delta_min distance between the NLSFs */
for( i = 1; i < L; i++ )
- NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], \
@@ -277,6 +286,7 @@ NLSF_Q15[i-1] + NDeltaMin_Q15[i] );
silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
/* Last NLSF should be no higher than 1 - NDeltaMin[L] */
+<CODE ENDS>
]]></artwork>
</figure>
@@ -285,12 +295,13 @@ silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
<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,
+ 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 to line 552 of celt/quant_bands.c:
</t>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
{
opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands],
SHL16((opus_val16)eMeans[i],6));
@@ -298,6 +309,7 @@ silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4);
}
for (;i<m->nbEBands;i++)
+<CODE ENDS>
]]></artwork>
</figure>
</section>
@@ -307,7 +319,7 @@ silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
enough bits to code a single CELT band (8 - 9.6 kHz). When that happens,
the second band (CELT band 18, from 9.6 to 12 kHz) cannot use folding
because it is wider than the amount already coded, and falls back to
- LCG noise. Because it can also happen on transients (e.g. stops), it
+ white noise. Because it can also happen on transients (e.g. stops), it
can cause audible pre-echo.
</t>
<t>
@@ -319,6 +331,7 @@ silk_ADD_SAT16( NLSF_Q15[i-1], NDeltaMin_Q15[i] ) );
</t>
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
b = 0;
}
@@ -347,6 +360,7 @@ n2-n1);
tf_change = tf_res[i];
if (i>=m->effEBands)
{
+<CODE ENDS>
]]></artwork>
</figure>
@@ -356,6 +370,7 @@ n2-n1);
<figure>
<artwork><![CDATA[
+<CODE BEGINS>
fold_start = lowband_offset;
while(M*eBands[--fold_start] > effective_lowband);
fold_end = lowband_offset-1;
@@ -366,6 +381,7 @@ effective_lowband+N);
fold_i = fold_start; do {
x_cm |= collapse_masks[fold_i*C+0];
+<CODE ENDS>
]]></artwork>
</figure>
<t>
@@ -383,11 +399,11 @@ effective_lowband+N);
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.
+ sometimes resulting in audible artifacts.
</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).
+ phase shift. This can be useful when downmixing to mono inside or
+ outside of the decoder (e.g. user-controllable).
</t>
</section>
@@ -402,14 +418,72 @@ effective_lowband+N);
implementation is compliant as long as it passes either set of vectors.
</t>
<t>
- In addition, any Opus implementation
- that passes the original test vectors from <xref target="RFC6716">RFC 6716</xref>
- is still compliant with the Opus specification. However, newer implementations
+ Any Opus implementation
+ that passes either the original test vectors from <xref target="RFC6716">RFC 6716</xref>
+ 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.
</t>
<t>The new test vectors are located at
- <eref target="https://jmvalin.ca/misc_stuff/opus_newvectors.tar.gz"/>. (EDITOR:
- change to an ietf.org link when ready)
+ <eref target="https://www.ietf.org/proceedings/98/slides/materials-98-codec-opus-newvectors-00.tar.gz"/>.
+ The SHA-1 hashes of the test vectors are:
+<figure>
+<artwork>
+<![CDATA[
+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
+]]>
+</artwork>
+</figure>
+ Note that the decoder input bitstream files (.bit) are unchanged.
+ </t>
+ </section>
+
+ <section anchor="security" title="Security Considerations">
+ <t>This document fixes two security issues reported on Opus and that affect the
+ reference implementation in <xref target="RFC6716">RFC 6716</xref>: CVE-2013-0899
+ <eref target="https://nvd.nist.gov/vuln/detail/CVE-2013-0899"/>
+ and CVE-2017-0381 <eref target="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. It is fixed by <xref target="padding"/>.
+ CVE-2017-0381 could have resulted in a 16-bit out-of-bounds read from a fixed
+ location. It is fixed in <xref target="lsf_overflow"/>.
+ Beyond the two fixed CVEs, this document adds no new security considerations on top of
+ <xref target="RFC6716">RFC 6716</xref>.
</t>
</section>
@@ -422,13 +496,14 @@ 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. Also, thanks to Jonathan Lennox and Mark Harris for their
+ 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.</t>
</section>
</middle>
<back>
- <references title="References">
+ <references title="Normative References">
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6716.xml"?>
diff --git a/doc/opus_in_isobmff.html b/doc/opus_in_isobmff.html
index a1175dbf..38aefbf2 100644
--- a/doc/opus_in_isobmff.html
+++ b/doc/opus_in_isobmff.html
@@ -7,12 +7,12 @@
</head>
<body bgcolor="0x333333" text="#60B0C0">
<b><u>Encapsulation of Opus in ISO Base Media File Format</u></b><br>
- <font size="2">last updated: April 28, 2016</font><br>
+ <font size="2">last updated: August 28, 2018</font><br>
<br>
<div class="normal_link pre frame_box">
Encapsulation of Opus in ISO Base Media File Format
- Version 0.6.8 (incomplete)
+ Version 0.8.1 (incomplete)
Table of Contents
@@ -20,7 +20,7 @@ Table of Contents
<a href="#2">2</a> Normative References
<a href="#3">3</a> Terms and Definitions
<a href="#4">4</a> Design Rules of Encapsulation
- <a href="#4.1">4.1</a> File Type Indentification
+ <a href="#4.1">4.1</a> File Type Identification
<a href="#4.2">4.2</a> Overview of Track Structure
<a href="#4.3">4.3</a> Definitions of Opus sample
<a href="#4.3.1">4.3.1</a> Sample entry format
@@ -32,7 +32,9 @@ Table of Contents
<a href="#4.3.6.1">4.3.6.1</a> Random Access Point
<a href="#4.3.6.2">4.3.6.2</a> Pre-roll
<a href="#4.4">4.4</a> Trimming of Actual Duration
- <a href="#4.5">4.5</a> Channel Layout (informative)
+ <a href="#4.5">4.5</a> Channel Mapping
+ <a href="#4.5.1">4.5.1</a> ISO Base Media native Channel Mapping
+ <a href="#4.5.2">4.5.2</a> Composition on all active tracks (informative)
<a href="#4.6">4.6</a> Basic Structure (informative)
<a href="#4.6.1">4.6.2</a> Initial Movie
<a href="#4.6.2">4.6.3</a> Movie Fragments
@@ -53,7 +55,7 @@ Table of Contents
[2] RFC 6716
Definition of the Opus Audio Codec
- [3] draft-ietf-codec-oggopus-06
+ [3] RFC 7845
Ogg Encapsulation for the Opus Audio Codec
<a name="3"></a>
@@ -83,8 +85,8 @@ Table of Contents
<a name="4"></a>
4 Design Rules of Encapsulation
- 4.1 File Type Indentification<a name="4.1"></a>
- This specification does not define any brand to declare files are conformant to this specification. However,
+ 4.1 File Type Identification<a name="4.1"></a>
+ This specification defines the brand 'Opus' to declare files are conformant to this specification. Additionally,
files conformant to this specification shall contain at least one brand, which supports the requirements and the
requirements described in this clause without contradiction, in the compatible brands list of the File Type Box.
As an example, the minimal support of the encapsulation of Opus bitstreams in ISO Base Media file format requires
@@ -117,15 +119,14 @@ Table of Contents
The syntax and semantics of the OpusSampleEntry is shown as follows.
- class OpusSampleEntry() extends AudioSampleEntry ('Opus'){
+ class OpusSampleEntry() extends AudioSampleEntry ('Opus') {
OpusSpecificBox();
}
+ channelcount:
- The channelcount field shall be set to the sum of the total number of Opus bitstreams and the number
- of Opus bitstreams producing two channels. This value is indentical with (M+N), where M is the value of
- the *Coupled Stream Count* field and N is the value of the *Stream Count* field in the *Channel Mapping
- Table* in the identification header defined in Ogg Opus [3].
+ The channelcount field indicates the number of output channels and shall be set to the same value of
+ the OutputChannelCount in the OpusDecoderConfigurationRecord. The value of this field may be used in
+ the ChannelLayout if any as described in 4.5.1.
+ samplesize:
The samplesize field shall be set to 16.
+ samplerate:
@@ -135,20 +136,21 @@ Table of Contents
4.3.2 Opus Specific Box<a name="4.3.2"></a>
Exactly one Opus Specific Box shall be present in each OpusSampleEntry.
- The Opus Specific Box contains the Version field and this specification defines version 0 of this box.
- If incompatible changes occured in the fields after the Version field within the OpusSpecificBox in the
- future versions of this specification, another version will be defined.
+ The Opus Specific Box contains an OpusDecoderConfigurationRecord which contains the Version field and
+ this specification defines version 0 of this record. If incompatible changes occured in the fields after
+ the Version field within the OpusDecoderConfigurationRecord in the future versions of this specification,
+ another version will be defined.
This box refers to Ogg Opus [3] at many parts but all the data are stored as big-endian format.
The syntax and semantics of the Opus Specific Box is shown as follows.
- class ChannelMappingTable (unsigned int(8) OutputChannelCount){
+ class ChannelMappingTable (unsigned int(8) OutputChannelCount) {
unsigned int(8) StreamCount;
unsigned int(8) CoupledCount;
unsigned int(8 * OutputChannelCount) ChannelMapping;
}
- aligned(8) class OpusSpecificBox extends Box('dOps'){
+ aligned(8) class OpusDecoderConfigurationRecord {
unsigned int(8) Version;
unsigned int(8) OutputChannelCount;
unsigned int(16) PreSkip;
@@ -160,6 +162,10 @@ Table of Contents
}
}
+ class OpusSpecificBox extends Box('dOps') {
+ OpusDecoderConfigurationRecord() OpusConfig;
+ }
+
+ Version:
The Version field shall be set to 0.
In the future versions of this specification, this field may be set to other values. And without support
@@ -181,7 +187,8 @@ Table of Contents
header define in Ogg Opus [3]. Note that the value is stored as 8.8 fixed-point.
+ ChannelMappingFamily:
The ChannelMappingFamily field shall be set to the same value as the *Channel Mapping Family* field in
- the identification header defined in Ogg Opus [3].
+ the identification header defined in Ogg Opus [3]. Note that the value 255 may be used for an alternative
+ to map channels by ISO Base Media native mapping. The details are described in 4.5.1.
+ StreamCount:
The StreamCount field shall be set to the same value as the *Stream Count* field in the identification
header defined in Ogg Opus [3].
@@ -270,42 +277,62 @@ Table of Contents
the duration of the last Opus sample may be helpful by setting zero to the segment_duration field since the
value 0 represents implicit duration equal to the sum of the duration of all samples.
<a name="4.5"></a>
- 4.5 Channel Layout (informative)
- By the application of alternate_group in the Track Header Box, whole audio channels in all active tracks from
- non-alternate group and/or different alternate group from each other are composited into the presentation. If
- an Opus sample consists of multiple Opus bitstreams, it can be splitted into individual Opus bitstreams and
- reconstructed into new Opus samples as long as every Opus bitstream has the same total duration in each Opus
- sample. This nature can be utilized to encapsulate a single Opus bitstream in each track without breaking the
- original channel layout.
-
- As an example, let's say there is a following track:
- OutputChannelCount = 6;
- StreamCount = 4;
- CoupledCount = 2;
- ChannelMapping = {0, 4, 1, 2, 3, 5}; // front left, front center, front right, rear left, rear right, LFE
- Here, to couple front left to front right channels into the first stream, and couple rear left to rear right
- channels into the second stream, reordering is needed since coupled streams must precede any non-coupled stream.
- You extract the four Opus bitstreams from this track and you encapsulate two of the four into a track and the
- others into another track. The former track is as follows.
- OutputChannelCount = 6;
- StreamCount = 2;
- CoupledCount = 2;
- ChannelMapping = {0, 255, 1, 2, 3, 255}; // front left, front center, front right, rear left, rear right, LFE
- And the latter track is as follows.
- OutputChannelCount = 6;
- StreamCount = 2;
- CoupledCount = 0;
- ChannelMapping = {255, 0, 255, 255, 255, 1}; // front left, front center, front right, rear left, rear right, LFE
- In addition, the value of the alternate_group field in the both tracks is set to 0. As the result, the player
- may play as if channels with 255 are not present, and play the presentation constructed from the both tracks
- in the same channel layout as the one of the original track. Keep in mind that the way of the composition, i.e.
- the mixing for playback, is not defined here, and maybe different results could occur except for the channel
- layout of the original, depending on an implementation or the definition of a derived file format.
-
- Note that some derived file formats may specify the restriction to ignore alternate grouping. In the context of
- such file formats, this application is not available. This unavailability does not mean incompatibilities among
- file formats unless the restriction to the value of the alternate_group field is specified and brings about
- any conflict among their definitions.
+ 4.5 Channel Mapping
+ 4.5.1 ISO Base Media native Channel Mapping<a name="4.5.1"></a>
+ ISO Base Media File Format, that is ISO/IEC 14496-12 [1], defines an extension ChannelLayout to the
+ AudioSampleEntry, which conveys information of mapping channels to loudspeaker positions. The ChannelLayout
+ enables to specify the channel layout more flexibly than the predefined layouts of the ChannelMappingFamily.
+
+ To utilize the ChannelLayout for OpusSampleEntry, the ChannelMappingFamily field should be set to 255.
+ Even when the ChannelMappingFamily field is set to another value, the assignment of each output channel to
+ loudspeaker position specified by the ChannelMappingFamily would be changed as specified by the ChannelLayout.
+ The procedure of the assignment is the following.
+
+ 1. Decoded channels are mapped to output channels according to the ChannelMappingTable.
+ 2. Output channels are mapped to loudspeaker positions according to the ChannelLayout.
+
+ In this way, the parameters of the Opus Specific Box are processed before the ChannelLayout, and the
+ ChannelLayout shall follow the Opus Specific Box.
+
+ 4.5.2 Composition on all active tracks (informative)<a name="4.5.2"></a>
+ By the application of alternate_group in the Track Header Box, whole audio channels in all active tracks from
+ non-alternate group and/or different alternate group from each other are composited into the presentation. If
+ an Opus sample consists of multiple Opus bitstreams, it can be splitted into individual Opus bitstreams and
+ reconstructed into new Opus samples as long as every Opus bitstream has the same total duration in each Opus
+ sample. This nature can be utilized to encapsulate a single Opus bitstream in each track without breaking the
+ original channel layout.
+
+ As an example, let's say there is a following track:
+ OutputChannelCount = 6;
+ StreamCount = 4;
+ CoupledCount = 2;
+ ChannelMapping = {0, 4, 1, 2, 3, 5}; // front left, front center, front right,
+ // rear left, rear right, LFE
+ Here, to couple front left to front right channels into the first stream, and couple rear left to rear right
+ channels into the second stream, reordering is needed since coupled streams must precede any non-coupled
+ stream. You extract the four Opus bitstreams from this track and you encapsulate two of the four into a track
+ and the others into another track. The former track is as follows.
+ OutputChannelCount = 6;
+ StreamCount = 2;
+ CoupledCount = 2;
+ ChannelMapping = {0, 255, 1, 2, 3, 255}; // front left, front center, front right,
+ // rear left, rear right, LFE
+ And the latter track is as follows.
+ OutputChannelCount = 6;
+ StreamCount = 2;
+ CoupledCount = 0;
+ ChannelMapping = {255, 0, 255, 255, 255, 1}; // front left, front center, front right,
+ // rear left, rear right, LFE
+ In addition, the value of the alternate_group field in the both tracks is set to 0. As the result, the player
+ may play as if channels with 255 are not present, and play the presentation constructed from the both tracks
+ in the same channel layout as the one of the original track. Keep in mind that the way of the composition, i.e.
+ the mixing for playback, is not defined here, and maybe different results could occur except for the channel
+ layout of the original, depending on an implementation or the definition of a derived file format.
+
+ Note that some derived file formats may specify the restriction to ignore alternate grouping. In the context
+ of such file formats, this application is not available. This unavailability does not mean incompatibilities
+ among file formats unless the restriction to the value of the alternate_group field is specified and brings
+ about any conflict among their definitions.
<a name="4.6"></a>
4.6 Basic Structure (informative)
4.6.1 Initial Movie<a name="4.6.1"></a>
@@ -395,7 +422,7 @@ Table of Contents
+----+----+----+----+----+----+----+----+------------------------------+
| | |sgpd|* | | | | | Sample Group Description Box |
+----+----+----+----+----+----+----+----+------------------------------+
- | | |sbgp|* | | | | | Sample to Group Box |
+ | | |sbgp| | | | | | Sample to Group Box |
+----+----+----+----+----+----+----+----+------------------------------+
Figure 3 - Basic structure of Movie Fragment Box
@@ -407,14 +434,14 @@ Table of Contents
<a name="4.7"></a>
4.7 Example of Encapsulation (informative)
[File]
- size = 17790
+ size = 17757
[ftyp: File Type Box]
position = 0
size = 24
- major_brand = mp42 : MP4 version 2
+ major_brand = Opus : Opus audio coding
minor_version = 0
compatible_brands
- brand[0] = mp42 : MP4 version 2
+ brand[0] = Opus : Opus audio coding
brand[1] = iso2 : ISO Base Media file format version 2
[moov: Movie Box]
position = 24
@@ -444,30 +471,11 @@ Table of Contents
pre_defined = 0x00000000
pre_defined = 0x00000000
next_track_ID = 2
- [iods: Object Descriptor Box]
- position = 140
- size = 33
- version = 0
- flags = 0x000000
- [tag = 0x10: MP4_IOD]
- expandableClassSize = 16
- ObjectDescriptorID = 1
- URL_Flag = 0
- includeInlineProfileLevelFlag = 0
- reserved = 0xf
- ODProfileLevelIndication = 0xff
- sceneProfileLevelIndication = 0xff
- audioProfileLevelIndication = 0xfe
- visualProfileLevelIndication = 0xff
- graphicsProfileLevelIndication = 0xff
- [tag = 0x0e: ES_ID_Inc]
- expandableClassSize = 4
- Track_ID = 1
[trak: Track Box]
- position = 173
+ position = 140
size = 608
[tkhd: Track Header Box]
- position = 181
+ position = 148
size = 92
version = 0
flags = 0x000007
@@ -492,7 +500,7 @@ Table of Contents
width = 0.000000
height = 0.000000
[edts: Edit Box]
- position = 273
+ position = 240
size = 36
[elst: Edit List Box]
position = 281
@@ -505,10 +513,10 @@ Table of Contents
media_time = 312
media_rate = 1.000000
[mdia: Media Box]
- position = 309
+ position = 276
size = 472
[mdhd: Media Header Box]
- position = 317
+ position = 284
size = 32
version = 0
flags = 0x000000
@@ -519,7 +527,7 @@ Table of Contents
language = und
pre_defined = 0x0000
[hdlr: Handler Reference Box]
- position = 349
+ position = 316
size = 51
version = 0
flags = 0x000000
@@ -530,41 +538,41 @@ Table of Contents
reserved = 0x00000000
name = Xiph Audio Handler
[minf: Media Information Box]
- position = 400
+ position = 367
size = 381
[smhd: Sound Media Header Box]
- position = 408
+ position = 375
size = 16
version = 0
flags = 0x000000
balance = 0.000000
reserved = 0x0000
[dinf: Data Information Box]
- position = 424
+ position = 391
size = 36
[dref: Data Reference Box]
- position = 432
+ position = 399
size = 28
version = 0
flags = 0x000000
entry_count = 1
[url : Data Entry Url Box]
- position = 448
+ position = 415
size = 12
version = 0
flags = 0x000001
location = in the same file
[stbl: Sample Table Box]
- position = 460
+ position = 427
size = 321
[stsd: Sample Description Box]
- position = 468
+ position = 435
size = 79
version = 0
flags = 0x000000
entry_count = 1
[Opus: Audio Description]
- position = 484
+ position = 451
size = 63
reserved = 0x000000000000
data_reference_index = 1
@@ -577,7 +585,7 @@ Table of Contents
reserved = 0
samplerate = 48000.000000
[dOps: Opus Specific Box]
- position = 520
+ position = 487
size = 27
Version = 0
OutputChannelCount = 6
@@ -595,7 +603,7 @@ Table of Contents
4 -> 3: side right
5 -> 5: rear center
[stts: Decoding Time to Sample Box]
- position = 547
+ position = 514
size = 24
version = 0
flags = 0x000000
@@ -604,7 +612,7 @@ Table of Contents
sample_count = 18
sample_delta = 1920
[stsc: Sample To Chunk Box]
- position = 571
+ position = 538
size = 40
version = 0
flags = 0x000000
@@ -618,7 +626,7 @@ Table of Contents
samples_per_chunk = 5
sample_description_index = 1
[stsz: Sample Size Box]
- position = 611
+ position = 578
size = 92
version = 0
flags = 0x000000
@@ -643,7 +651,7 @@ Table of Contents
entry_size[16] = 962
entry_size[17] = 848
[stco: Chunk Offset Box]
- position = 703
+ position = 670
size = 24
version = 0
flags = 0x000000
@@ -651,7 +659,7 @@ Table of Contents
chunk_offset[0] = 797
chunk_offset[1] = 13096
[sgpd: Sample Group Description Box]
- position = 727
+ position = 694
size = 26
version = 1
flags = 0x000000
@@ -660,7 +668,7 @@ Table of Contents
entry_count = 1
roll_distance[0] = -2
[sbgp: Sample to Group Box]
- position = 753
+ position = 720
size = 28
version = 0
flags = 0x000000
@@ -670,10 +678,10 @@ Table of Contents
sample_count = 18
group_description_index = 1
[free: Free Space Box]
- position = 781
+ position = 748
size = 8
[mdat: Media Data Box]
- position = 789
+ position = 756
size = 17001
<a name="5"></a>
5 Authors' Address