[Matroska-devel] Opus audio codec
slhomme at matroska.org
Sat Dec 17 10:52:34 CET 2011
Le 14/12/2011 21:27, Ralph Giles a écrit :
> I'm interested in adding support for the IETF Opus audio codec in Matroska.
> Significant features, from the container point of view:
> - Opus codes everything at 48 kHz
> - The decoder can generate either mono or stereo from any stream
I suppose that's for using mono when stereo separation is lost in
compression (ie save bandwidth/quality). In that case it should be
marked as having 2 channels. If a stream is known to only be mono, then
it can have 1 channel.
> - Compressed frames are variable length, and the length of each frame
> must be signaled to the decoder
> - There's a 'multistream' extension for doing surround.
> Since there's little extra signalling necessary, a simple approach would be:
> CodecID is V_OPUS
> SamplingFrequency is always 48000
> Channels is 1 or 2, based on what the muxer thinks is most
> appropriate. When in doubt, use 2?
> CodecPrivate is void
Very good, a major improvement over Vorbis.
> That works great if you don't want more than two channels. The
> 'multistream' mode packs multiple mono/stereo streams into each frame,
> but requires the container signal the number of streams and how
> they're coupled. I can see two ways to make that work:
> 1) Define a new channel mapping element. The spec mentions a
> ChannelPositions element, but doesn't define the format for it.
> However we need more than just speaker positions. To decode
> multistream Opus we need to know, for each stream packed into the
> frames, whether to decode it as a coupled stereo pair (e.g.
> REAR_LEFT+REAR_RIGHT) or as an isolated mono channel (e.g. LFE) and
> how those map to the actual output channels.
> The multistream packing is designed so a single mono or coupled-stereo
> multistream frame is the same as a non-multistream frame, so for
> non-surround uses, this element can just be omitted.
> Pros: straightforward?
> Cons: probably not useful for other codecs
> 2) Copy the headers used in the Ogg encapsulation into CodecPrivate,
> similar to what is done for A_VORBIS and V_THEORA. This already
> defines a binary format for the channel mapping, along with a bunch of
> other things.
> Pros: Lossless transmux between Ogg and Matroska, possible code sharing
> Cons: more complex, codec specific code
Matroska has a channel mapping but it's mostly for codec that don't have
an internal representation like raw PCM data. In the case of Opus I
suppose the mapping is mostly fixed and the channel coupling is done
accordingly. Also playback would not be correct if the playback didn't
match what Opus uses internally. So I would put that channel mapping in
the CodecPrivate at least (or in frames, depending how it works
internally), not at the Matroska level. The decoder should be able to
understand how Opus uses it.
More information about the Matroska-devel