1*a58d3d2aSXin Li== Opus audio codec == 2*a58d3d2aSXin Li 3*a58d3d2aSXin LiOpus is a codec for interactive speech and audio transmission over the Internet. 4*a58d3d2aSXin Li 5*a58d3d2aSXin Li Opus can handle a wide range of interactive audio applications, including 6*a58d3d2aSXin LiVoice over IP, videoconferencing, in-game chat, and even remote live music 7*a58d3d2aSXin Liperformances. It can scale from low bit-rate narrowband speech to very high 8*a58d3d2aSXin Liquality stereo music. 9*a58d3d2aSXin Li 10*a58d3d2aSXin Li Opus, when coupled with an appropriate container format, is also suitable 11*a58d3d2aSXin Lifor non-realtime stored-file applications such as music distribution, game 12*a58d3d2aSXin Lisoundtracks, portable music players, jukeboxes, and other applications that 13*a58d3d2aSXin Lihave historically used high latency formats such as MP3, AAC, or Vorbis. 14*a58d3d2aSXin Li 15*a58d3d2aSXin Li Opus is specified by IETF RFC 6716: 16*a58d3d2aSXin Li https://tools.ietf.org/html/rfc6716 17*a58d3d2aSXin Li 18*a58d3d2aSXin Li The Opus format and this implementation of it are subject to the royalty- 19*a58d3d2aSXin Lifree patent and copyright licenses specified in the file COPYING. 20*a58d3d2aSXin Li 21*a58d3d2aSXin LiThis package implements a shared library for encoding and decoding raw Opus 22*a58d3d2aSXin Libitstreams. Raw Opus bitstreams should be used over RTP according to 23*a58d3d2aSXin Li https://tools.ietf.org/html/rfc7587 24*a58d3d2aSXin Li 25*a58d3d2aSXin LiThe package also includes a number of test tools used for testing the 26*a58d3d2aSXin Licorrect operation of the library. The bitstreams read/written by these 27*a58d3d2aSXin Litools should not be used for Opus file distribution: They include 28*a58d3d2aSXin Liadditional debugging data and cannot support seeking. 29*a58d3d2aSXin Li 30*a58d3d2aSXin LiOpus stored in files should use the Ogg encapsulation for Opus which is 31*a58d3d2aSXin Lidescribed at: 32*a58d3d2aSXin Li https://tools.ietf.org/html/rfc7845 33*a58d3d2aSXin Li 34*a58d3d2aSXin LiAn opus-tools package is available which provides encoding and decoding of 35*a58d3d2aSXin LiOgg encapsulated Opus files and includes a number of useful features. 36*a58d3d2aSXin Li 37*a58d3d2aSXin LiOpus-tools can be found at: 38*a58d3d2aSXin Li https://gitlab.xiph.org/xiph/opus-tools.git 39*a58d3d2aSXin Lior on the main Opus website: 40*a58d3d2aSXin Li https://opus-codec.org/ 41*a58d3d2aSXin Li 42*a58d3d2aSXin Li== Deep Learning and Opus == 43*a58d3d2aSXin Li 44*a58d3d2aSXin LiLossy networks continue to be a challenge for real-time communications. 45*a58d3d2aSXin LiWhile the original implementation of Opus provides an excellent packet loss 46*a58d3d2aSXin Liconcealment mechanism, the team has continued to advance the methodology used 47*a58d3d2aSXin Lito improve audio quality in challenge network environments. 48*a58d3d2aSXin Li 49*a58d3d2aSXin LiIn Opus 1.5, we added a deep learning based redundancy encoder that enhances 50*a58d3d2aSXin Liaudio in lossy networks by embedding one second of recovery data in the padding 51*a58d3d2aSXin Lidata of each packet. The underlying algorithm behind encoding and decoding the 52*a58d3d2aSXin Lirecovery data is called the deep redundancy (DRED) algorithm. By leveraging 53*a58d3d2aSXin Lithe padding data within the packet, Opus 1.5 is fully backward compatible with 54*a58d3d2aSXin Liprior revisions of Opus. Please see the README under the "dnn" subdirectory to 55*a58d3d2aSXin Liunderstand DRED. 56*a58d3d2aSXin Li 57*a58d3d2aSXin LiDRED was developed by a team that Amazon Web Services initially sponsored, 58*a58d3d2aSXin Liwho open-sourced the implementation as well as began the 59*a58d3d2aSXin Listandardization process at the IETF: 60*a58d3d2aSXin Li https://datatracker.ietf.org/doc/draft-ietf-mlcodec-opus-extension/ 61*a58d3d2aSXin LiThe license behind Opus or the intellectual property position of Opus does 62*a58d3d2aSXin Linot change with Opus 1.5. 63*a58d3d2aSXin Li 64*a58d3d2aSXin Li== Compiling libopus == 65*a58d3d2aSXin Li 66*a58d3d2aSXin LiTo build from a distribution tarball, you only need to do the following: 67*a58d3d2aSXin Li 68*a58d3d2aSXin Li % ./configure 69*a58d3d2aSXin Li % make 70*a58d3d2aSXin Li 71*a58d3d2aSXin LiTo build from the git repository, the following steps are necessary: 72*a58d3d2aSXin Li 73*a58d3d2aSXin Li0) Set up a development environment: 74*a58d3d2aSXin Li 75*a58d3d2aSXin LiOn an Ubuntu or Debian family Linux distribution: 76*a58d3d2aSXin Li 77*a58d3d2aSXin Li % sudo apt-get install git autoconf automake libtool gcc make 78*a58d3d2aSXin Li 79*a58d3d2aSXin LiOn a Fedora/Redhat based Linux: 80*a58d3d2aSXin Li 81*a58d3d2aSXin Li % sudo dnf install git autoconf automake libtool gcc make 82*a58d3d2aSXin Li 83*a58d3d2aSXin LiOr for older Redhat/Centos Linux releases: 84*a58d3d2aSXin Li 85*a58d3d2aSXin Li % sudo yum install git autoconf automake libtool gcc make 86*a58d3d2aSXin Li 87*a58d3d2aSXin LiOn Apple macOS, install Xcode and brew.sh, then in the Terminal enter: 88*a58d3d2aSXin Li 89*a58d3d2aSXin Li % brew install autoconf automake libtool 90*a58d3d2aSXin Li 91*a58d3d2aSXin Li1) Clone the repository: 92*a58d3d2aSXin Li 93*a58d3d2aSXin Li % git clone https://gitlab.xiph.org/xiph/opus.git 94*a58d3d2aSXin Li % cd opus 95*a58d3d2aSXin Li 96*a58d3d2aSXin Li2) Compiling the source 97*a58d3d2aSXin Li 98*a58d3d2aSXin Li % ./autogen.sh 99*a58d3d2aSXin Li % ./configure 100*a58d3d2aSXin Li % make 101*a58d3d2aSXin Li 102*a58d3d2aSXin LiOn x86, it's a good idea to use a -march= option that allows the use of AVX2. 103*a58d3d2aSXin Li 104*a58d3d2aSXin Li3) Install the codec libraries (optional) 105*a58d3d2aSXin Li 106*a58d3d2aSXin Li % sudo make install 107*a58d3d2aSXin Li 108*a58d3d2aSXin LiOnce you have compiled the codec, there will be a opus_demo executable 109*a58d3d2aSXin Liin the top directory. 110*a58d3d2aSXin Li 111*a58d3d2aSXin LiUsage: opus_demo [-e] <application> <sampling rate (Hz)> <channels (1/2)> 112*a58d3d2aSXin Li <bits per second> [options] <input> <output> 113*a58d3d2aSXin Li opus_demo -d <sampling rate (Hz)> <channels (1/2)> [options] 114*a58d3d2aSXin Li <input> <output> 115*a58d3d2aSXin Li 116*a58d3d2aSXin Limode: voip | audio | restricted-lowdelay 117*a58d3d2aSXin Lioptions: 118*a58d3d2aSXin Li -e : only runs the encoder (output the bit-stream) 119*a58d3d2aSXin Li -d : only runs the decoder (reads the bit-stream as input) 120*a58d3d2aSXin Li -cbr : enable constant bitrate; default: variable bitrate 121*a58d3d2aSXin Li -cvbr : enable constrained variable bitrate; default: 122*a58d3d2aSXin Li unconstrained 123*a58d3d2aSXin Li -bandwidth <NB|MB|WB|SWB|FB> 124*a58d3d2aSXin Li : audio bandwidth (from narrowband to fullband); 125*a58d3d2aSXin Li default: sampling rate 126*a58d3d2aSXin Li -framesize <2.5|5|10|20|40|60> 127*a58d3d2aSXin Li : frame size in ms; default: 20 128*a58d3d2aSXin Li -max_payload <bytes> 129*a58d3d2aSXin Li : maximum payload size in bytes, default: 1024 130*a58d3d2aSXin Li -complexity <comp> 131*a58d3d2aSXin Li : complexity, 0 (lowest) ... 10 (highest); default: 10 132*a58d3d2aSXin Li -inbandfec : enable SILK inband FEC 133*a58d3d2aSXin Li -forcemono : force mono encoding, even for stereo input 134*a58d3d2aSXin Li -dtx : enable SILK DTX 135*a58d3d2aSXin Li -loss <perc> : simulate packet loss, in percent (0-100); default: 0 136*a58d3d2aSXin Li 137*a58d3d2aSXin Liinput and output are little-endian signed 16-bit PCM files or opus 138*a58d3d2aSXin Libitstreams with simple opus_demo proprietary framing. 139*a58d3d2aSXin Li 140*a58d3d2aSXin Li== Testing == 141*a58d3d2aSXin Li 142*a58d3d2aSXin LiThis package includes a collection of automated unit and system tests 143*a58d3d2aSXin Liwhich SHOULD be run after compiling the package especially the first 144*a58d3d2aSXin Litime it is run on a new platform. 145*a58d3d2aSXin Li 146*a58d3d2aSXin LiTo run the integrated tests: 147*a58d3d2aSXin Li 148*a58d3d2aSXin Li % make check 149*a58d3d2aSXin Li 150*a58d3d2aSXin LiThere is also collection of standard test vectors which are not 151*a58d3d2aSXin Liincluded in this package for size reasons but can be obtained from: 152*a58d3d2aSXin Lihttps://opus-codec.org/docs/opus_testvectors-rfc8251.tar.gz 153*a58d3d2aSXin Li 154*a58d3d2aSXin LiTo run compare the code to these test vectors: 155*a58d3d2aSXin Li 156*a58d3d2aSXin Li % curl -OL https://opus-codec.org/docs/opus_testvectors-rfc8251.tar.gz 157*a58d3d2aSXin Li % tar -zxf opus_testvectors-rfc8251.tar.gz 158*a58d3d2aSXin Li % ./tests/run_vectors.sh ./ opus_newvectors 48000 159*a58d3d2aSXin Li 160*a58d3d2aSXin Li== Compiling libopus for Windows and alternative build systems == 161*a58d3d2aSXin Li 162*a58d3d2aSXin LiSee cmake/README.md or meson/README.md. 163*a58d3d2aSXin Li 164*a58d3d2aSXin Li== Portability notes == 165*a58d3d2aSXin Li 166*a58d3d2aSXin LiThis implementation uses floating-point by default but can be compiled to 167*a58d3d2aSXin Liuse only fixed-point arithmetic by setting --enable-fixed-point (if using 168*a58d3d2aSXin Liautoconf) or by defining the FIXED_POINT macro (if building manually). 169*a58d3d2aSXin LiThe fixed point implementation has somewhat lower audio quality and is 170*a58d3d2aSXin Lislower on platforms with fast FPUs, it is normally only used in embedded 171*a58d3d2aSXin Lienvironments. 172*a58d3d2aSXin Li 173*a58d3d2aSXin LiThe implementation can be compiled with either a C89 or a C99 compiler. 174*a58d3d2aSXin LiWhile it does not rely on any _undefined behavior_ as defined by C89 or 175*a58d3d2aSXin LiC99, it relies on common _implementation-defined behavior_ for two's 176*a58d3d2aSXin Licomplement architectures: 177*a58d3d2aSXin Li 178*a58d3d2aSXin Lio Right shifts of negative values are consistent with two's 179*a58d3d2aSXin Li complement arithmetic, so that a>>b is equivalent to 180*a58d3d2aSXin Li floor(a/(2^b)), 181*a58d3d2aSXin Li 182*a58d3d2aSXin Lio For conversion to a signed integer of N bits, the value is reduced 183*a58d3d2aSXin Li modulo 2^N to be within range of the type, 184*a58d3d2aSXin Li 185*a58d3d2aSXin Lio The result of integer division of a negative value is truncated 186*a58d3d2aSXin Li towards zero, and 187*a58d3d2aSXin Li 188*a58d3d2aSXin Lio The compiler provides a 64-bit integer type (a C99 requirement 189*a58d3d2aSXin Li which is supported by most C89 compilers). 190