blob: ea68fe3092267b7adcecd2e31a7c5beca298ca5c [file] [log] [blame]
Gregory Maxwell635b5f22012-08-21 14:24:38 -04001== Opus audio codec ==
2
Gregory Maxwell42815772012-04-25 13:30:21 -04003Opus is a codec for interactive speech and audio transmission over the Internet.
4
5 Opus can handle a wide range of interactive audio applications, including
6Voice over IP, videoconferencing, in-game chat, and even remote live music
7performances. It can scale from low bit-rate narrowband speech to very high
8quality stereo music.
9
Gregory Maxwell635b5f22012-08-21 14:24:38 -040010 Opus, when coupled with an appropriate container format, is also suitable
11for non-realtime stored-file applications such as music distribution, game
12soundtracks, portable music players, jukeboxes, and other applications that
13have historically used high latency formats such as MP3, AAC, or Vorbis.
Gregory Maxwell42815772012-04-25 13:30:21 -040014
Gregory Maxwell635b5f22012-08-21 14:24:38 -040015 Opus is specified by IETF RFC 6716:
16 http://tools.ietf.org/html/rfc6716
17
18 The Opus format and this implementation of it are subject to the royalty-
19free patent and copyright licenses specified in the file COPYING.
Gregory Maxwell42815772012-04-25 13:30:21 -040020
21This package implements a shared library for encoding and decoding raw Opus
22bitstreams. Raw Opus bitstreams should be used over RTP according to
23 http://tools.ietf.org/html/draft-spittka-payload-rtp-opus
24
25The package also includes a number of test tools used for testing the
26correct operation of the library. The bitstreams read/written by these
27tools should not be used for Opus file distribution: They include
28additional debugging data and cannot support seeking.
29
30Opus stored in files should use the Ogg encapsulation for Opus which is
31described at:
32 http://wiki.xiph.org/OggOpus
33
34An opus-tools package is available which provides encoding and decoding of
35Ogg encapsulated Opus files and includes a number of useful features.
Gregory Maxwell635b5f22012-08-21 14:24:38 -040036
Gregory Maxwell42815772012-04-25 13:30:21 -040037Opus-tools can be found at:
Gregory Maxwell635b5f22012-08-21 14:24:38 -040038 https://git.xiph.org/?p=opus-tools.git
39or on the main Opus website:
40 http://opus-codec.org/
Gregory Maxwell42815772012-04-25 13:30:21 -040041
42== Compiling libopus ==
Gregory Maxwell635b5f22012-08-21 14:24:38 -040043
Jean-Marc Valin4468c752010-07-08 13:40:07 -040044To build from a distribution tarball, you only need to do the following:
Jean-Marc Valin8ba2a772010-07-05 14:55:02 -040045
Jean-Marc Valinfe741252011-04-30 14:21:35 -040046% ./configure
Jean-Marc Valin8ba2a772010-07-05 14:55:02 -040047% make
48
Kat Walsh3269dce2011-08-15 22:43:51 -040049To build from the git repository, the following steps are necessary:
Jean-Marc Valin4468c752010-07-08 13:40:07 -040050
Jean-Marc Valinfe741252011-04-30 14:21:35 -0400511) Clone the repository:
Jean-Marc Valin4468c752010-07-08 13:40:07 -040052
Jean-Marc Valinfe741252011-04-30 14:21:35 -040053% git clone git://git.opus-codec.org/opus.git
54% cd opus
Jean-Marc Valin4468c752010-07-08 13:40:07 -040055
Gregory Maxwell635b5f22012-08-21 14:24:38 -0400562) Compiling the source
Jean-Marc Valin4468c752010-07-08 13:40:07 -040057
58% ./autogen.sh
Jean-Marc Valinfe741252011-04-30 14:21:35 -040059% ./configure
Jean-Marc Valin4468c752010-07-08 13:40:07 -040060% make
61
Gregory Maxwell635b5f22012-08-21 14:24:38 -040062Once you have compiled the codec, there will be a opus_demo executable
63in the top directory.
Jean-Marc Valin4468c752010-07-08 13:40:07 -040064
Gregory Maxwella5ff49e2011-10-26 19:56:00 -040065Usage: opus_demo [-e] <application> <sampling rate (Hz)> <channels (1/2)>
Gregory Maxwell3bcf3672011-09-09 17:11:43 -040066 <bits per second> [options] <input> <output>
Gregory Maxwella5ff49e2011-10-26 19:56:00 -040067 opus_demo -d <sampling rate (Hz)> <channels (1/2)> [options]
Gregory Maxwell3bcf3672011-09-09 17:11:43 -040068 <input> <output>
Jean-Marc Valin4468c752010-07-08 13:40:07 -040069
Gregory Maxwell3bcf3672011-09-09 17:11:43 -040070mode: voip | audio | restricted-lowdelay
Jean-Marc Valin08062002011-03-09 13:24:24 -050071options:
Gregory Maxwell635b5f22012-08-21 14:24:38 -040072 -e : only runs the encoder (output the bit-stream)
73 -d : only runs the decoder (reads the bit-stream as input)
74 -cbr : enable constant bitrate; default: variable bitrate
75 -cvbr : enable constrained variable bitrate; default:
76 unconstrained
77 -bandwidth <NB|MB|WB|SWB|FB>
78 : audio bandwidth (from narrowband to fullband);
79 default: sampling rate
80 -framesize <2.5|5|10|20|40|60>
81 : frame size in ms; default: 20
82 -max_payload <bytes>
83 : maximum payload size in bytes, default: 1024
84 -complexity <comp>
85 : complexity, 0 (lowest) ... 10 (highest); default: 10
86 -inbandfec : enable SILK inband FEC
87 -forcemono : force mono encoding, even for stereo input
88 -dtx : enable SILK DTX
89 -loss <perc> : simulate packet loss, in percent (0-100); default: 0
Jean-Marc Valin78a4b582010-07-08 15:51:49 -040090
Gregory Maxwell635b5f22012-08-21 14:24:38 -040091input and output are little-endian signed 16-bit PCM files or opus
92bitstreams with simple opus_demo proprietary framing.
Gregory Maxwell42815772012-04-25 13:30:21 -040093
94== Testing ==
95
96This package includes a collection of automated unit and system tests
Gregory Maxwell635b5f22012-08-21 14:24:38 -040097which SHOULD be run after compiling the package especially the first
Gregory Maxwell42815772012-04-25 13:30:21 -040098time it is run on a new platform.
99
100To run the integrated tests:
101% make check
102
103There is also collection of standard test vectors which are not
104included in this package for size reasons but can be obtained from:
Gregory Maxwell8115a462012-08-21 17:56:51 -0400105http://opus-codec.org/testvectors/opus_testvectors.tar.gz
Gregory Maxwell42815772012-04-25 13:30:21 -0400106
107To run compare the code to these test vectors:
Gregory Maxwell635b5f22012-08-21 14:24:38 -0400108
Gregory Maxwell8115a462012-08-21 17:56:51 -0400109% curl -O http://opus-codec.org/testvectors/opus_testvectors.tar.gz
110% tar -zxf opus_testvectors.tar.gz
Gregory Maxwell42815772012-04-25 13:30:21 -0400111% ./tests/run_vectors.sh ./ opus_testvectors 48000
112
113== Portability notes ==
114
115This implementation uses floating-point by default but can be compiled to
116use only fixed-point arithmetic by setting --enable-fixed-point (if using
117autoconf) or by defining the FIXED_POINT macro (if building manually).
118The fixed point implementation has somewhat lower audio quality and is
119slower on platforms with fast FPUs, it is normally only used in embedded
120environments.
121
122The implementation can be compiled with either a C89 or a C99 compiler.
123While it does not rely on any _undefined behavior_ as defined by C89 or
124C99, it relies on common _implementation-defined behavior_ for two's
125complement architectures:
126
127o Right shifts of negative values are consistent with two's
128 complement arithmetic, so that a>>b is equivalent to
129 floor(a/(2^b)),
130
131o For conversion to a signed integer of N bits, the value is reduced
132 modulo 2^N to be within range of the type,
133
134o The result of integer division of a negative value is truncated
135 towards zero, and
136
137o The compiler provides a 64-bit integer type (a C99 requirement
138 which is supported by most C89 compilers).