├── .idea
├── .name
├── scopes
│ ├── scope_settings.xml
│ └── sources.xml
├── vcs.xml
├── encodings.xml
├── inspectionProfiles
│ └── profiles_settings.xml
├── modules.xml
├── copyright
│ ├── profiles_settings.xml
│ └── echocat.xml
└── compiler.xml
├── README.md
├── .gitignore
├── src
├── test
│ ├── resources
│ │ └── org
│ │ │ └── echocat
│ │ │ └── jopus
│ │ │ ├── bach_48k_mono.wav
│ │ │ ├── bach_48k_mono.opus
│ │ │ ├── bach_48k_stereo.opus
│ │ │ └── bach_48k_stereo.wav
│ └── java
│ │ └── org
│ │ └── echocat
│ │ └── jopus
│ │ ├── OpusDecoderTest.java
│ │ └── OpusEncoderTest.java
└── main
│ ├── java
│ └── org
│ │ └── echocat
│ │ └── jopus
│ │ ├── OpusJNI.java
│ │ ├── OpusJNISupport.java
│ │ ├── OpusHandleBasedSupport.java
│ │ ├── OpusException.java
│ │ ├── OpusHeaderException.java
│ │ ├── OpusUtilsJNI.java
│ │ ├── VbrConstraint.java
│ │ ├── Vbr.java
│ │ ├── Signal.java
│ │ ├── SamplingRate.java
│ │ ├── OpusDecoderJNI.java
│ │ ├── Bandwidth.java
│ │ ├── OpusRepacketizerJNI.java
│ │ ├── FrameSize.java
│ │ ├── OpusHeaderJNI.java
│ │ ├── Application.java
│ │ └── OpusConstants.java
│ ├── c
│ ├── org_echocat_jopus_OpusJNI.c
│ ├── org_echocat_jopus_OpusJNISupport.c
│ ├── opus
│ │ ├── mlp.h
│ │ ├── celt
│ │ │ ├── arm
│ │ │ │ ├── armopts.s.in
│ │ │ │ ├── arm_celt_map.c
│ │ │ │ ├── pitch_arm.h
│ │ │ │ ├── armcpu.h
│ │ │ │ └── fixed_armv4.h
│ │ │ ├── cpu_support.h
│ │ │ ├── cwrs.h
│ │ │ ├── celt_lpc.h
│ │ │ ├── laplace.h
│ │ │ ├── mfrngcod.h
│ │ │ ├── modes.h
│ │ │ ├── vq.h
│ │ │ ├── mdct.h
│ │ │ ├── quant_bands.h
│ │ │ ├── os_support.h
│ │ │ └── entcode.c
│ │ ├── silk
│ │ │ ├── arm
│ │ │ │ ├── SigProc_FIX_armv4.h
│ │ │ │ └── SigProc_FIX_armv5e.h
│ │ │ ├── lin2log.c
│ │ │ ├── float
│ │ │ │ ├── scale_vector_FLP.c
│ │ │ │ ├── bwexpander_FLP.c
│ │ │ │ ├── regularize_correlations_FLP.c
│ │ │ │ ├── scale_copy_vector_FLP.c
│ │ │ │ ├── k2a_FLP.c
│ │ │ │ ├── energy_FLP.c
│ │ │ │ ├── inner_product_FLP.c
│ │ │ │ ├── autocorrelation_FLP.c
│ │ │ │ ├── LTP_scale_ctrl_FLP.c
│ │ │ │ ├── schur_FLP.c
│ │ │ │ ├── levinsondurbin_FLP.c
│ │ │ │ └── LPC_inv_pred_gain_FLP.c
│ │ │ ├── init_decoder.c
│ │ │ ├── inner_prod_aligned.c
│ │ │ ├── bwexpander_32.c
│ │ │ ├── tables_gain.c
│ │ │ ├── fixed
│ │ │ │ ├── k2a_Q16_FIX.c
│ │ │ │ ├── k2a_FIX.c
│ │ │ │ ├── regularize_correlations_FIX.c
│ │ │ │ ├── autocorr_FIX.c
│ │ │ │ └── LTP_scale_ctrl_FIX.c
│ │ │ ├── interpolate.c
│ │ │ ├── log2lin.c
│ │ │ ├── resampler_structs.h
│ │ │ ├── resampler_private_AR2.c
│ │ │ ├── bwexpander.c
│ │ │ ├── init_encoder.c
│ │ │ ├── stereo_encode_pred.c
│ │ │ ├── NLSF_unpack.c
│ │ │ ├── tables_pitch_lag.c
│ │ │ ├── PLC.h
│ │ │ ├── sigm_Q15.c
│ │ │ ├── resampler_rom.h
│ │ │ ├── stereo_quant_pred.c
│ │ │ ├── stereo_decode_pred.c
│ │ │ ├── typedef.h
│ │ │ └── NLSF_VQ.c
│ │ ├── tansig_table.h
│ │ └── opus_multistream.c
│ ├── opus-tools
│ │ └── opus_header.h
│ └── org_echocat_jogg_OggJNISupport.c
│ └── include
│ ├── org_echocat_jopus_OpusJNISupport.h
│ └── org_echocat_jogg_OggJNISupport.h
├── LICENSE
└── jopus.iml
/.idea/.name:
--------------------------------------------------------------------------------
1 | echocat JOpus
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | jopus
2 | =====
3 |
4 | Java binding to native opus encoder/decoder.
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/libraries
2 | .idea/misc.xml
3 | .idea/workspace.xml
4 | target/
5 |
--------------------------------------------------------------------------------
/src/test/resources/org/echocat/jopus/bach_48k_mono.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echocat/jopus/HEAD/src/test/resources/org/echocat/jopus/bach_48k_mono.wav
--------------------------------------------------------------------------------
/src/test/resources/org/echocat/jopus/bach_48k_mono.opus:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echocat/jopus/HEAD/src/test/resources/org/echocat/jopus/bach_48k_mono.opus
--------------------------------------------------------------------------------
/src/test/resources/org/echocat/jopus/bach_48k_stereo.opus:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echocat/jopus/HEAD/src/test/resources/org/echocat/jopus/bach_48k_stereo.opus
--------------------------------------------------------------------------------
/src/test/resources/org/echocat/jopus/bach_48k_stereo.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/echocat/jopus/HEAD/src/test/resources/org/echocat/jopus/bach_48k_stereo.wav
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/scopes/sources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/copyright/echocat.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusJNI.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | final class OpusJNI extends OpusJNISupport {
18 |
19 | private OpusJNI() {
20 | }
21 |
22 | static native String getVersionString();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusJNISupport.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import org.echocat.jogg.OggJNISupport;
18 |
19 | class OpusJNISupport extends OggJNISupport {
20 |
21 | static {
22 | System.loadLibrary("jopus");
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/c/org_echocat_jopus_OpusJNI.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | #include "org_echocat_jopus_OpusJNISupport.h"
16 |
17 | JNIEXPORT jstring JNICALL Java_org_echocat_jopus_OpusJNI_getVersionString
18 | (JNIEnv *env, jclass thisClass) {
19 |
20 | const char* versionString = opus_get_version_string();
21 | return (*env)->NewStringUTF(env, versionString);
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/c/org_echocat_jopus_OpusJNISupport.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | #include "org_echocat_jopus_OpusJNISupport.h"
16 |
17 | void Java_org_echocat_jogg_OggJNISupport_checkResponse
18 | (JNIEnv *env, int result) {
19 | if (result < 0) {
20 | jclass type = (*env)->FindClass(env, "org/echocat/jopus/OpusException");
21 | const char* errorString = opus_strerror(result);
22 | (*env)->ThrowNew(env, type, errorString);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/include/org_echocat_jopus_OpusJNISupport.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | #ifndef org_echocat_jopus_OpusJNISupport_H
16 | #define org_echocat_jopus_OpusJNISupport_H
17 |
18 | #include "org_echocat_jogg_OggJNISupport.h"
19 | #include
20 |
21 | #ifdef __cplusplus
22 | extern "C" {
23 | #endif
24 |
25 | void Java_org_echocat_jogg_OggJNISupport_checkResponse
26 | (JNIEnv *env, int result);
27 |
28 | #ifdef __cplusplus
29 | }
30 | #endif
31 |
32 | #endif /* org_echocat_jopus_OpusJNISupport_H */
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusHandleBasedSupport.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import org.echocat.jogg.OggHandleBasedSupport;
18 |
19 | public abstract class OpusHandleBasedSupport extends OggHandleBasedSupport {
20 |
21 | protected OpusHandleBasedSupport(long handle) {
22 | super(handle);
23 | }
24 |
25 | protected OpusHandleBasedSupport(long handle, boolean autoDestroy) {
26 | super(handle, autoDestroy);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public class OpusException extends RuntimeException {
18 |
19 | public OpusException() {
20 | }
21 |
22 | public OpusException(String message) {
23 | super(message);
24 | }
25 |
26 | public OpusException(String message, Throwable cause) {
27 | super(message, cause);
28 | }
29 |
30 | public OpusException(Throwable cause) {
31 | super(cause);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusHeaderException.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public class OpusHeaderException extends OpusException {
18 |
19 | public OpusHeaderException() {
20 | }
21 |
22 | public OpusHeaderException(String message) {
23 | super(message);
24 | }
25 |
26 | public OpusHeaderException(String message, Throwable cause) {
27 | super(message, cause);
28 | }
29 |
30 | public OpusHeaderException(Throwable cause) {
31 | super(cause);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | jopus
2 | The MIT License (MIT)
3 |
4 | Copyright (c) echocat
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusUtilsJNI.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public final class OpusUtilsJNI extends OpusJNISupport {
18 |
19 | private OpusUtilsJNI() {
20 | }
21 |
22 | static native String getErrorStringForErrorCode(int errorCode);
23 |
24 | static native int getBandwidthOfPacket(byte[] packet);
25 |
26 | static native int getSamplesPerFrameOfPacket(byte[] packet, int samplingRateInHz);
27 |
28 | static native int getNumberOfChannelsOfPacket(byte[] packet);
29 |
30 | static native int getNumberOfFramesOfPacket(byte[] packet);
31 |
32 | static native int getNumberOfSamplesOfPacket(byte[] packet, int samplingRateInHz);
33 |
34 | static native void applyPcmSoftClipping(float[] pcm, int frameSize, int numberOfChannels, float[] softClipping);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/VbrConstraint.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public enum VbrConstraint {
18 | unconstrained(0),
19 | constrained(1),
20 |
21 | ;
22 |
23 | private final int _handle;
24 |
25 | VbrConstraint(int handle) {
26 | _handle = handle;
27 | }
28 |
29 | public static VbrConstraint vbrConstraintFor(int code) {
30 | VbrConstraint result = null;
31 | for (final VbrConstraint candidate : values()) {
32 | if (candidate.handle() == code) {
33 | result = candidate;
34 | break;
35 | }
36 | }
37 | if (result == null) {
38 | throw new IllegalArgumentException("Could not handle vbr constrained with code: " + code);
39 | }
40 | return result;
41 | }
42 |
43 | public int handle() {
44 | return _handle;
45 | }
46 |
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/src/main/include/org_echocat_jogg_OggJNISupport.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | #ifndef org_echocat_jogg_OggJNISupport_H
16 | #define org_echocat_jogg_OggJNISupport_H
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #define _CRTDBG_MAP_ALLOC
23 | #include
24 | #include
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | void Java_org_echocat_jogg_OggJNISupport_throwOutOfMemoryError
31 | (JNIEnv *env);
32 |
33 | void Java_org_echocat_jogg_OggJNISupport_throwNullPointerException
34 | (JNIEnv *env);
35 |
36 | int Java_org_echocat_jogg_OggJNISupport_checkNotNull(JNIEnv *env, void *value);
37 |
38 | jbyteArray Java_org_echocat_jogg_OggJNISupport_bufferToJavaByteArray
39 | (JNIEnv *env, long length, void *buffer);
40 |
41 | void Java_org_echocat_jogg_OggJNISupport_javaByteArrayToBuffer
42 | (JNIEnv *env, jbyteArray source, long *lengthDrain, void **bufferDrain);
43 |
44 | #ifdef __cplusplus
45 | }
46 | #endif
47 |
48 | #endif /* org_echocat_jogg_OggJNISupport_H */
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/Vbr.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public enum Vbr {
18 | /**
19 | * For LPC/hybrid modes at very low bit-rate, this can cause noticeable quality degradation.
20 | */
21 | hardCbr(0),
22 | /**
23 | * The exact type of VBR is controlled by vbrConstraint.
24 | */
25 | vbr(1),
26 |
27 | ;
28 |
29 | private final int _handle;
30 |
31 | Vbr(int handle) {
32 | _handle = handle;
33 | }
34 |
35 | public static Vbr vbrFor(int code) {
36 | Vbr result = null;
37 | for (final Vbr candidate : values()) {
38 | if (candidate.handle() == code) {
39 | result = candidate;
40 | break;
41 | }
42 | }
43 | if (result == null) {
44 | throw new IllegalArgumentException("Could not handle vbr with code: " + code);
45 | }
46 | return result;
47 | }
48 |
49 | public int handle() {
50 | return _handle;
51 | }
52 |
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/Signal.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import static org.echocat.jopus.OpusConstants.*;
18 |
19 | public enum Signal {
20 | /**
21 | * Signal being encoded is voice
22 | */
23 | voice(SIGNAL_VOICE),
24 | /**
25 | * Signal being encoded is music
26 | */
27 | music(SIGNAL_MUSIC),
28 |
29 | ;
30 |
31 | private final int _handle;
32 |
33 | Signal(int handle) {
34 | _handle = handle;
35 | }
36 |
37 | public static Signal signalFor(int code) {
38 | Signal result = null;
39 | for (final Signal candidate : values()) {
40 | if (candidate.handle() == code) {
41 | result = candidate;
42 | break;
43 | }
44 | }
45 | if (result == null) {
46 | throw new IllegalArgumentException("Could not handle signal with code: " + code);
47 | }
48 | return result;
49 | }
50 |
51 | public int handle() {
52 | return _handle;
53 | }
54 |
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/src/main/c/opus/mlp.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2008-2011 Octasic Inc.
2 | Written by Jean-Marc Valin */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifndef _MLP_H_
29 | #define _MLP_H_
30 |
31 | #include "arch.h"
32 |
33 | typedef struct {
34 | int layers;
35 | const int *topo;
36 | const float *weights;
37 | } MLP;
38 |
39 | void mlp_process(const MLP *m, const float *in, float *out);
40 |
41 | #endif /* _MLP_H_ */
42 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/SamplingRate.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public enum SamplingRate {
18 | kHz8(8000, "8kHz"),
19 | kHz12(12000, "12kHz"),
20 | kHz16(16000, "16kHz"),
21 | kHz24(24000, "24kHz"),
22 | kHz48(48000, "48kHz"),
23 | ;
24 |
25 | private final int _handle;
26 | private final String _display;
27 |
28 | SamplingRate(int handle, String display) {
29 | _handle = handle;
30 | _display = display;
31 | }
32 |
33 | public static SamplingRate samplingRateFor(int samplingRateInHz) {
34 | SamplingRate result = null;
35 | for (final SamplingRate candidate : values()) {
36 | if (candidate.handle() == samplingRateInHz) {
37 | result = candidate;
38 | break;
39 | }
40 | }
41 | if (result == null) {
42 | throw new IllegalArgumentException("Could not handle sampling rate in hz of " + samplingRateInHz + ".");
43 | }
44 | return result;
45 | }
46 |
47 | public int handle() {
48 | return _handle;
49 | }
50 |
51 |
52 | @Override
53 | public String toString() {
54 | return _display;
55 | }
56 |
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/arm/armopts.s.in:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2013 Mozilla Corporation */
2 | /*
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 |
7 | - Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 |
10 | - Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | ; Set the following to 1 if we have EDSP instructions
28 | ; (LDRD/STRD, etc., ARMv5E and later).
29 | OPUS_ARM_MAY_HAVE_EDSP * @OPUS_ARM_MAY_HAVE_EDSP@
30 |
31 | ; Set the following to 1 if we have ARMv6 media instructions.
32 | OPUS_ARM_MAY_HAVE_MEDIA * @OPUS_ARM_MAY_HAVE_MEDIA@
33 |
34 | ; Set the following to 1 if we have NEON (some ARMv7)
35 | OPUS_ARM_MAY_HAVE_NEON * @OPUS_ARM_MAY_HAVE_NEON@
36 |
37 | END
38 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusDecoderJNI.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | final class OpusDecoderJNI extends OpusJNISupport {
18 |
19 | private OpusDecoderJNI() {
20 | }
21 |
22 | static native long create(int samplingRateInHz, int numberOfChannels);
23 |
24 | static native void init(long decoderHandle, int samplingRateInHz, int numberOfChannels);
25 |
26 | static native int decode(long decoderHandle, byte[] packet, int packetLength, short[] pcm, int frameSize, int decodeFec);
27 |
28 | static native int decodeFloat(long decoderHandle, byte[] packet, int packetLength, float[] pcm, int frameSize, int decodeFec);
29 |
30 | static native void destroy(long decoderHandle);
31 |
32 | static native int getNumberOfSamplesOfPacket(long decoderHandle, byte[] packet);
33 |
34 | static native int getSampleRate(long decoderHandle);
35 |
36 | static native int getLookAhead(long decoderHandle);
37 |
38 | static native int getLastPacketDuration(long decoderHandle);
39 |
40 | static native int getFinalRange(long decoderHandle);
41 |
42 | static native int getPitch(long decoderHandle);
43 |
44 | static native int getBandwidth(long decoderHandle);
45 |
46 | static native void setGain(long decoderHandle, int value);
47 |
48 | static native int getGain(long decoderHandle);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/Bandwidth.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import static org.echocat.jopus.OpusConstants.*;
18 |
19 | public enum Bandwidth {
20 | /**
21 | * 4 kHz bandpass
22 | */
23 | narrowBand(BANDWIDTH_NARROWBAND),
24 | /**
25 | * 6 kHz bandpass
26 | */
27 | mediumBand(BANDWIDTH_MEDIUMBAND),
28 | /**
29 | * 8 kHz bandpass
30 | */
31 | wideBand(BANDWIDTH_WIDEBAND),
32 | /**
33 | * <12 kHz bandpass
34 | */
35 | superWideBand(BANDWIDTH_SUPERWIDEBAND),
36 | /**
37 | * <20 kHz bandpass
38 | */
39 | fullBand(BANDWIDTH_FULLBAND),
40 | ;
41 |
42 | private final int _handle;
43 |
44 | Bandwidth(int handle) {
45 | _handle = handle;
46 | }
47 |
48 | public static Bandwidth bandwidthFor(int code) {
49 | Bandwidth result = null;
50 | for (final Bandwidth candidate : values()) {
51 | if (candidate.handle() == code) {
52 | result = candidate;
53 | break;
54 | }
55 | }
56 | if (result == null) {
57 | throw new IllegalArgumentException("Could not handle bandwidth with code: " + code);
58 | }
59 | return result;
60 | }
61 |
62 | public int handle() {
63 | return _handle;
64 | }
65 |
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusRepacketizerJNI.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | public final class OpusRepacketizerJNI extends OpusJNISupport {
18 |
19 | private OpusRepacketizerJNI() {
20 | }
21 |
22 | static native long create(int samplingRateInHz, int numberOfChannels);
23 |
24 | static native void init(long decoderHandle, int samplingRateInHz, int numberOfChannels);
25 |
26 | static native int decode(long decoderHandle, byte[] opus, int opusLength, short[] pcm, int frameSize);
27 |
28 | static native int decodeFloat(long decoderHandle, byte[] opus, int opusLength, float[] pcm, int frameSize);
29 |
30 | static native void destroy(long decoderHandle);
31 |
32 | static native int getNumberOfSamplesOfPacket(long decoderHandle, byte[] opus, int opusLength, int samplingRateInHz);
33 |
34 | static native int getSampleRate(long decoderHandle);
35 |
36 | static native int getLookAhead(long decoderHandle);
37 |
38 | static native int getLastPacketDuration(long decoderHandle);
39 |
40 | static native int getFinalRange(long decoderHandle);
41 |
42 | static native int getPitch(long decoderHandle);
43 |
44 | static native int getBandwidth(long decoderHandle);
45 |
46 | static native void setGain(long decoderHandle, int value);
47 |
48 | static native int getGain(long decoderHandle);
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/FrameSize.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import static org.echocat.jopus.OpusConstants.*;
18 |
19 | public enum FrameSize {
20 | argument(FRAMESIZE_ARG, "argument"),
21 | ms2_5(FRAMESIZE_2_5_MS, "2.5ms"),
22 | ms5(FRAMESIZE_5_MS, "5ms"),
23 | ms10(FRAMESIZE_10_MS, "10ms"),
24 | ms20(FRAMESIZE_20_MS, "20ms"),
25 | ms40(FRAMESIZE_40_MS, "40ms"),
26 | ms60(FRAMESIZE_60_MS, "50ms"),
27 | variable(FRAMESIZE_VARIABLE, "variable"),
28 | ;
29 |
30 | private final int _handle;
31 | private final String _title;
32 |
33 | FrameSize(int handle, String title) {
34 | _handle = handle;
35 | _title = title;
36 | }
37 |
38 | public static FrameSize frameSizeFor(int code) {
39 | FrameSize result = null;
40 | for (final FrameSize candidate : values()) {
41 | if (candidate.handle() == code) {
42 | result = candidate;
43 | break;
44 | }
45 | }
46 | if (result == null) {
47 | throw new IllegalArgumentException("Could not handle frameSize with code: " + code);
48 | }
49 | return result;
50 | }
51 |
52 | public int handle() {
53 | return _handle;
54 | }
55 |
56 |
57 | @Override
58 | public String toString() {
59 | return _title;
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/cpu_support.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010 Xiph.Org Foundation
2 | * Copyright (c) 2013 Parrot */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifndef CPU_SUPPORT_H
29 | #define CPU_SUPPORT_H
30 |
31 | #include "opus_types.h"
32 | #include "opus_defines.h"
33 |
34 | #if defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_ASM)
35 | #include "arm/armcpu.h"
36 |
37 | /* We currently support 4 ARM variants:
38 | * arch[0] -> ARMv4
39 | * arch[1] -> ARMv5E
40 | * arch[2] -> ARMv6
41 | * arch[3] -> NEON
42 | */
43 | #define OPUS_ARCHMASK 3
44 |
45 | #else
46 | #define OPUS_ARCHMASK 0
47 |
48 | static OPUS_INLINE int opus_select_arch(void)
49 | {
50 | return 0;
51 | }
52 | #endif
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/cwrs.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007-2008 CSIRO
2 | Copyright (c) 2007-2009 Xiph.Org Foundation
3 | Copyright (c) 2007-2009 Timothy B. Terriberry
4 | Written by Timothy B. Terriberry and Jean-Marc Valin */
5 | /*
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions
8 | are met:
9 |
10 | - Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 |
13 | - Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #ifndef CWRS_H
31 | #define CWRS_H
32 |
33 | #include "arch.h"
34 | #include "stack_alloc.h"
35 | #include "entenc.h"
36 | #include "entdec.h"
37 |
38 | #ifdef CUSTOM_MODES
39 | int log2_frac(opus_uint32 val, int frac);
40 | #endif
41 |
42 | void get_required_bits(opus_int16 *bits, int N, int K, int frac);
43 |
44 | void encode_pulses(const int *_y, int N, int K, ec_enc *enc);
45 |
46 | void decode_pulses(int *_y, int N, int K, ec_dec *dec);
47 |
48 | #endif /* CWRS_H */
49 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusHeaderJNI.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | final class OpusHeaderJNI extends OpusJNISupport {
18 |
19 | private OpusHeaderJNI() {
20 | }
21 |
22 | static native long create();
23 |
24 | static native void destroy(long handle);
25 |
26 | static native int writePacket(long handle, byte[] buffer);
27 |
28 | static native void readPacket(long handle, byte[] buffer);
29 |
30 | static native void setVersion(long handle, int value);
31 |
32 | static native int getVersion(long handle);
33 |
34 | static native void setChannels(long handle, int value);
35 |
36 | static native int getChannels(long handle);
37 |
38 | static native void setPreskip(long handle, int value);
39 |
40 | static native int getPreskip(long handle);
41 |
42 | static native void setInputSampleRate(long handle, int value);
43 |
44 | static native int getInputSampleRate(long handle);
45 |
46 | static native void setGain(long handle, int value);
47 |
48 | static native int getGain(long handle);
49 |
50 | static native void setChannelMapping(long handle, int value);
51 |
52 | static native int getChannelMapping(long handle);
53 |
54 | static native void setNbStreams(long handle, int value);
55 |
56 | static native int getNbStreams(long handle);
57 |
58 | static native void setNbCoupled(long handle, int value);
59 |
60 | static native int getNbCoupled(long handle);
61 |
62 | static native void setStreamMap(long handle, byte[] value);
63 |
64 | static native byte[] getStreamMap(long handle);
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/arm/arm_celt_map.c:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010 Xiph.Org Foundation
2 | * Copyright (c) 2013 Parrot */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "pitch.h"
33 |
34 | #if defined(OPUS_HAVE_RTCD)
35 |
36 | # if defined(FIXED_POINT)
37 | opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
38 | const opus_val16 *, opus_val32 *, int , int) = {
39 | celt_pitch_xcorr_c, /* ARMv4 */
40 | MAY_HAVE_EDSP(celt_pitch_xcorr), /* EDSP */
41 | MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
42 | MAY_HAVE_NEON(celt_pitch_xcorr) /* NEON */
43 | };
44 | # else
45 | # error "Floating-point implementation is not supported by ARM asm yet." \
46 | "Reconfigure with --disable-rtcd or send patches."
47 | # endif
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/celt_lpc.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2009-2010 Xiph.Org Foundation
2 | Written by Jean-Marc Valin */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifndef PLC_H
29 | #define PLC_H
30 |
31 | #include "arch.h"
32 |
33 | #define LPC_ORDER 24
34 |
35 | void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p);
36 |
37 | void celt_fir(const opus_val16 *x,
38 | const opus_val16 *num,
39 | opus_val16 *y,
40 | int N,
41 | int ord,
42 | opus_val16 *mem);
43 |
44 | void celt_iir(const opus_val32 *x,
45 | const opus_val16 *den,
46 | opus_val32 *y,
47 | int N,
48 | int ord,
49 | opus_val16 *mem);
50 |
51 | int _celt_autocorr(const opus_val16 *x, opus_val32 *ac,
52 | const opus_val16 *window, int overlap, int lag, int n, int arch);
53 |
54 | #endif /* PLC_H */
55 |
--------------------------------------------------------------------------------
/src/main/c/opus-tools/opus_header.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)2012 Xiph.Org Foundation
2 | File: opus_header.h
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifndef OPUS_HEADER_H
29 | #define OPUS_HEADER_H
30 |
31 | #include
32 |
33 | typedef struct {
34 | int version;
35 | int channels; /* Number of channels: 1..255 */
36 | int preskip;
37 | ogg_uint32_t input_sample_rate;
38 | int gain; /* in dB S7.8 should be zero whenever possible */
39 | int channel_mapping;
40 | /* The rest is only used if channel_mapping != 0 */
41 | int nb_streams;
42 | int nb_coupled;
43 | unsigned char stream_map[255];
44 | } OpusHeader;
45 |
46 | int opus_header_parse(const unsigned char *header, int len, OpusHeader *h);
47 | int opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len);
48 |
49 | extern const int wav_permute_matrix[8][8];
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/arm/SigProc_FIX_armv4.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (C) 2013 Xiph.Org Foundation and contributors
3 | Copyright (c) 2013 Parrot
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 | - Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 | - Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
13 | names of specific contributors, may be used to endorse or promote
14 | products derived from this software without specific prior written
15 | permission.
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 | POSSIBILITY OF SUCH DAMAGE.
27 | ***********************************************************************/
28 |
29 | #ifndef SILK_SIGPROC_FIX_ARMv4_H
30 | #define SILK_SIGPROC_FIX_ARMv4_H
31 |
32 | #undef silk_MLA
33 | static OPUS_INLINE opus_int32 silk_MLA_armv4(opus_int32 a, opus_int32 b,
34 | opus_int32 c)
35 | {
36 | opus_int32 res;
37 | __asm__(
38 | "#silk_MLA\n\t"
39 | "mla %0, %1, %2, %3\n\t"
40 | : "=&r"(res)
41 | : "r"(b), "r"(c), "r"(a)
42 | );
43 | return res;
44 | }
45 | #define silk_MLA(a, b, c) (silk_MLA_armv4(a, b, c))
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/laplace.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007 CSIRO
2 | Copyright (c) 2007-2009 Xiph.Org Foundation
3 | Written by Jean-Marc Valin */
4 | /*
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #include "entenc.h"
30 | #include "entdec.h"
31 |
32 | /** Encode a value that is assumed to be the realisation of a
33 | Laplace-distributed random process
34 | @param enc Entropy encoder state
35 | @param value Value to encode
36 | @param fs Probability of 0, multiplied by 32768
37 | @param decay Probability of the value +/- 1, multiplied by 16384
38 | */
39 | void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay);
40 |
41 | /** Decode a value that is assumed to be the realisation of a
42 | Laplace-distributed random process
43 | @param dec Entropy decoder state
44 | @param fs Probability of 0, multiplied by 32768
45 | @param decay Probability of the value +/- 1, multiplied by 16384
46 | @return Value decoded
47 | */
48 | int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay);
49 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/lin2log.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 | /* Approximation of 128 * log2() (very close inverse of silk_log2lin()) */
34 | /* Convert input to a log scale */
35 | opus_int32 silk_lin2log(
36 | const opus_int32 inLin /* I input in linear scale */
37 | )
38 | {
39 | opus_int32 lz, frac_Q7;
40 |
41 | silk_CLZ_FRAC( inLin, &lz, &frac_Q7 );
42 |
43 | /* Piece-wise parabolic approximation */
44 | return silk_LSHIFT( 31 - lz, 7 ) + silk_SMLAWB( frac_Q7, silk_MUL( frac_Q7, 128 - frac_Q7 ), 179 );
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/arm/pitch_arm.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010 Xiph.Org Foundation
2 | * Copyright (c) 2013 Parrot */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !defined(PITCH_ARM_H)
29 | # define PITCH_ARM_H
30 |
31 | # include "armcpu.h"
32 |
33 | # if defined(FIXED_POINT)
34 |
35 | # if defined(OPUS_ARM_MAY_HAVE_NEON)
36 | opus_val32 celt_pitch_xcorr_neon(const opus_val16 *_x, const opus_val16 *_y,
37 | opus_val32 *xcorr, int len, int max_pitch);
38 | # endif
39 |
40 | # if defined(OPUS_ARM_MAY_HAVE_MEDIA)
41 | # define celt_pitch_xcorr_media MAY_HAVE_EDSP(celt_pitch_xcorr)
42 | # endif
43 |
44 | # if defined(OPUS_ARM_MAY_HAVE_EDSP)
45 | opus_val32 celt_pitch_xcorr_edsp(const opus_val16 *_x, const opus_val16 *_y,
46 | opus_val32 *xcorr, int len, int max_pitch);
47 | # endif
48 |
49 | # if !defined(OPUS_HAVE_RTCD)
50 | # define OVERRIDE_PITCH_XCORR (1)
51 | # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
52 | ((void)(arch),PRESUME_NEON(celt_pitch_xcorr)(_x, _y, xcorr, len, max_pitch))
53 | # endif
54 |
55 | # endif
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/mfrngcod.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2001-2008 Timothy B. Terriberry
2 | Copyright (c) 2008-2009 Xiph.Org Foundation */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !defined(_mfrngcode_H)
29 | # define _mfrngcode_H (1)
30 | # include "entcode.h"
31 |
32 | /*Constants used by the entropy encoder/decoder.*/
33 |
34 | /*The number of bits to output at a time.*/
35 | # define EC_SYM_BITS (8)
36 | /*The total number of bits in each of the state registers.*/
37 | # define EC_CODE_BITS (32)
38 | /*The maximum symbol value.*/
39 | # define EC_SYM_MAX ((1U<>EC_SYM_BITS)
46 | /*The number of bits available for the last, partial symbol in the code field.*/
47 | # define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1)
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/main/c/opus/tansig_table.h:
--------------------------------------------------------------------------------
1 | /* This file is auto-generated by gen_tables */
2 |
3 | static const float tansig_table[201] = {
4 | 0.000000f, 0.039979f, 0.079830f, 0.119427f, 0.158649f,
5 | 0.197375f, 0.235496f, 0.272905f, 0.309507f, 0.345214f,
6 | 0.379949f, 0.413644f, 0.446244f, 0.477700f, 0.507977f,
7 | 0.537050f, 0.564900f, 0.591519f, 0.616909f, 0.641077f,
8 | 0.664037f, 0.685809f, 0.706419f, 0.725897f, 0.744277f,
9 | 0.761594f, 0.777888f, 0.793199f, 0.807569f, 0.821040f,
10 | 0.833655f, 0.845456f, 0.856485f, 0.866784f, 0.876393f,
11 | 0.885352f, 0.893698f, 0.901468f, 0.908698f, 0.915420f,
12 | 0.921669f, 0.927473f, 0.932862f, 0.937863f, 0.942503f,
13 | 0.946806f, 0.950795f, 0.954492f, 0.957917f, 0.961090f,
14 | 0.964028f, 0.966747f, 0.969265f, 0.971594f, 0.973749f,
15 | 0.975743f, 0.977587f, 0.979293f, 0.980869f, 0.982327f,
16 | 0.983675f, 0.984921f, 0.986072f, 0.987136f, 0.988119f,
17 | 0.989027f, 0.989867f, 0.990642f, 0.991359f, 0.992020f,
18 | 0.992631f, 0.993196f, 0.993718f, 0.994199f, 0.994644f,
19 | 0.995055f, 0.995434f, 0.995784f, 0.996108f, 0.996407f,
20 | 0.996682f, 0.996937f, 0.997172f, 0.997389f, 0.997590f,
21 | 0.997775f, 0.997946f, 0.998104f, 0.998249f, 0.998384f,
22 | 0.998508f, 0.998623f, 0.998728f, 0.998826f, 0.998916f,
23 | 0.999000f, 0.999076f, 0.999147f, 0.999213f, 0.999273f,
24 | 0.999329f, 0.999381f, 0.999428f, 0.999472f, 0.999513f,
25 | 0.999550f, 0.999585f, 0.999617f, 0.999646f, 0.999673f,
26 | 0.999699f, 0.999722f, 0.999743f, 0.999763f, 0.999781f,
27 | 0.999798f, 0.999813f, 0.999828f, 0.999841f, 0.999853f,
28 | 0.999865f, 0.999875f, 0.999885f, 0.999893f, 0.999902f,
29 | 0.999909f, 0.999916f, 0.999923f, 0.999929f, 0.999934f,
30 | 0.999939f, 0.999944f, 0.999948f, 0.999952f, 0.999956f,
31 | 0.999959f, 0.999962f, 0.999965f, 0.999968f, 0.999970f,
32 | 0.999973f, 0.999975f, 0.999977f, 0.999978f, 0.999980f,
33 | 0.999982f, 0.999983f, 0.999984f, 0.999986f, 0.999987f,
34 | 0.999988f, 0.999989f, 0.999990f, 0.999990f, 0.999991f,
35 | 0.999992f, 0.999992f, 0.999993f, 0.999994f, 0.999994f,
36 | 0.999994f, 0.999995f, 0.999995f, 0.999996f, 0.999996f,
37 | 0.999996f, 0.999997f, 0.999997f, 0.999997f, 0.999997f,
38 | 0.999997f, 0.999998f, 0.999998f, 0.999998f, 0.999998f,
39 | 0.999998f, 0.999998f, 0.999999f, 0.999999f, 0.999999f,
40 | 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f,
41 | 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f,
42 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
43 | 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f,
44 | 1.000000f,
45 | };
46 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/scale_vector_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* multiply a vector by a constant */
35 | void silk_scale_vector_FLP(
36 | silk_float *data1,
37 | silk_float gain,
38 | opus_int dataSize
39 | )
40 | {
41 | opus_int i, dataSize4;
42 |
43 | /* 4x unrolled loop */
44 | dataSize4 = dataSize & 0xFFFC;
45 | for( i = 0; i < dataSize4; i += 4 ) {
46 | data1[ i + 0 ] *= gain;
47 | data1[ i + 1 ] *= gain;
48 | data1[ i + 2 ] *= gain;
49 | data1[ i + 3 ] *= gain;
50 | }
51 |
52 | /* any remaining elements */
53 | for( ; i < dataSize; i++ ) {
54 | data1[ i ] *= gain;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/bwexpander_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* Chirp (bw expand) LP AR filter */
35 | void silk_bwexpander_FLP(
36 | silk_float *ar, /* I/O AR filter to be expanded (without leading 1) */
37 | const opus_int d, /* I length of ar */
38 | const silk_float chirp /* I chirp factor (typically in range (0..1) ) */
39 | )
40 | {
41 | opus_int i;
42 | silk_float cfac = chirp;
43 |
44 | for( i = 0; i < d - 1; i++ ) {
45 | ar[ i ] *= cfac;
46 | cfac *= chirp;
47 | }
48 | ar[ d - 1 ] *= cfac;
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/init_decoder.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /************************/
35 | /* Init Decoder State */
36 | /************************/
37 | opus_int silk_init_decoder(
38 | silk_decoder_state *psDec /* I/O Decoder state pointer */
39 | )
40 | {
41 | /* Clear the entire encoder state, except anything copied */
42 | silk_memset( psDec, 0, sizeof( silk_decoder_state ) );
43 |
44 | /* Used to deactivate LSF interpolation */
45 | psDec->first_frame_after_reset = 1;
46 | psDec->prev_gain_Q16 = 65536;
47 |
48 | /* Reset CNG state */
49 | silk_CNG_Reset( psDec );
50 |
51 | /* Reset PLC state */
52 | silk_PLC_Reset( psDec );
53 |
54 | return(0);
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/inner_prod_aligned.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 |
34 | opus_int32 silk_inner_prod_aligned_scale(
35 | const opus_int16 *const inVec1, /* I input vector 1 */
36 | const opus_int16 *const inVec2, /* I input vector 2 */
37 | const opus_int scale, /* I number of bits to shift */
38 | const opus_int len /* I vector lengths */
39 | )
40 | {
41 | opus_int i;
42 | opus_int32 sum = 0;
43 | for( i = 0; i < len; i++ ) {
44 | sum = silk_ADD_RSHIFT32( sum, silk_SMULBB( inVec1[ i ], inVec2[ i ] ), scale );
45 | }
46 | return sum;
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/regularize_correlations_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main_FLP.h"
33 |
34 | /* Add noise to matrix diagonal */
35 | void silk_regularize_correlations_FLP(
36 | silk_float *XX, /* I/O Correlation matrices */
37 | silk_float *xx, /* I/O Correlation values */
38 | const silk_float noise, /* I Noise energy to add */
39 | const opus_int D /* I Dimension of XX */
40 | )
41 | {
42 | opus_int i;
43 |
44 | for( i = 0; i < D; i++ ) {
45 | matrix_ptr( &XX[ 0 ], i, i, D ) += noise;
46 | }
47 | xx[ 0 ] += noise;
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/arm/armcpu.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010 Xiph.Org Foundation
2 | * Copyright (c) 2013 Parrot */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !defined(ARMCPU_H)
29 | # define ARMCPU_H
30 |
31 | # if defined(OPUS_ARM_MAY_HAVE_EDSP)
32 | # define MAY_HAVE_EDSP(name) name ## _edsp
33 | # else
34 | # define MAY_HAVE_EDSP(name) name ## _c
35 | # endif
36 |
37 | # if defined(OPUS_ARM_MAY_HAVE_MEDIA)
38 | # define MAY_HAVE_MEDIA(name) name ## _media
39 | # else
40 | # define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name)
41 | # endif
42 |
43 | # if defined(OPUS_ARM_MAY_HAVE_NEON)
44 | # define MAY_HAVE_NEON(name) name ## _neon
45 | # else
46 | # define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name)
47 | # endif
48 |
49 | # if defined(OPUS_ARM_PRESUME_EDSP)
50 | # define PRESUME_EDSP(name) name ## _edsp
51 | # else
52 | # define PRESUME_EDSP(name) name ## _c
53 | # endif
54 |
55 | # if defined(OPUS_ARM_PRESUME_MEDIA)
56 | # define PRESUME_MEDIA(name) name ## _media
57 | # else
58 | # define PRESUME_MEDIA(name) PRESUME_EDSP(name)
59 | # endif
60 |
61 | # if defined(OPUS_ARM_PRESUME_NEON)
62 | # define PRESUME_NEON(name) name ## _neon
63 | # else
64 | # define PRESUME_NEON(name) PRESUME_MEDIA(name)
65 | # endif
66 |
67 | # if defined(OPUS_HAVE_RTCD)
68 | int opus_select_arch(void);
69 | # endif
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/arm/SigProc_FIX_armv5e.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Copyright (c) 2013 Parrot
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 | - Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 | - Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
13 | names of specific contributors, may be used to endorse or promote
14 | products derived from this software without specific prior written
15 | permission.
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 | POSSIBILITY OF SUCH DAMAGE.
27 | ***********************************************************************/
28 |
29 | #ifndef SILK_SIGPROC_FIX_ARMv5E_H
30 | #define SILK_SIGPROC_FIX_ARMv5E_H
31 |
32 | #undef silk_SMULTT
33 | static OPUS_INLINE opus_int32 silk_SMULTT_armv5e(opus_int32 a, opus_int32 b)
34 | {
35 | opus_int32 res;
36 | __asm__(
37 | "#silk_SMULTT\n\t"
38 | "smultt %0, %1, %2\n\t"
39 | : "=r"(res)
40 | : "%r"(a), "r"(b)
41 | );
42 | return res;
43 | }
44 | #define silk_SMULTT(a, b) (silk_SMULTT_armv5e(a, b))
45 |
46 | #undef silk_SMLATT
47 | static OPUS_INLINE opus_int32 silk_SMLATT_armv5e(opus_int32 a, opus_int32 b,
48 | opus_int32 c)
49 | {
50 | opus_int32 res;
51 | __asm__(
52 | "#silk_SMLATT\n\t"
53 | "smlatt %0, %1, %2, %3\n\t"
54 | : "=r"(res)
55 | : "%r"(b), "r"(c), "r"(a)
56 | );
57 | return res;
58 | }
59 | #define silk_SMLATT(a, b, c) (silk_SMLATT_armv5e(a, b, c))
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/scale_copy_vector_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* copy and multiply a vector by a constant */
35 | void silk_scale_copy_vector_FLP(
36 | silk_float *data_out,
37 | const silk_float *data_in,
38 | silk_float gain,
39 | opus_int dataSize
40 | )
41 | {
42 | opus_int i, dataSize4;
43 |
44 | /* 4x unrolled loop */
45 | dataSize4 = dataSize & 0xFFFC;
46 | for( i = 0; i < dataSize4; i += 4 ) {
47 | data_out[ i + 0 ] = gain * data_in[ i + 0 ];
48 | data_out[ i + 1 ] = gain * data_in[ i + 1 ];
49 | data_out[ i + 2 ] = gain * data_in[ i + 2 ];
50 | data_out[ i + 3 ] = gain * data_in[ i + 3 ];
51 | }
52 |
53 | /* any remaining elements */
54 | for( ; i < dataSize; i++ ) {
55 | data_out[ i ] = gain * data_in[ i ];
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/bwexpander_32.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 |
34 | /* Chirp (bandwidth expand) LP AR filter */
35 | void silk_bwexpander_32(
36 | opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
37 | const opus_int d, /* I Length of ar */
38 | opus_int32 chirp_Q16 /* I Chirp factor in Q16 */
39 | )
40 | {
41 | opus_int i;
42 | opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536;
43 |
44 | for( i = 0; i < d - 1; i++ ) {
45 | ar[ i ] = silk_SMULWW( chirp_Q16, ar[ i ] );
46 | chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 );
47 | }
48 | ar[ d - 1 ] = silk_SMULWW( chirp_Q16, ar[ d - 1 ] );
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/k2a_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* step up function, converts reflection coefficients to prediction coefficients */
35 | void silk_k2a_FLP(
36 | silk_float *A, /* O prediction coefficients [order] */
37 | const silk_float *rc, /* I reflection coefficients [order] */
38 | opus_int32 order /* I prediction order */
39 | )
40 | {
41 | opus_int k, n;
42 | silk_float Atmp[ SILK_MAX_ORDER_LPC ];
43 |
44 | for( k = 0; k < order; k++ ) {
45 | for( n = 0; n < k; n++ ) {
46 | Atmp[ n ] = A[ n ];
47 | }
48 | for( n = 0; n < k; n++ ) {
49 | A[ n ] += Atmp[ k - n - 1 ] * rc[ k ];
50 | }
51 | A[ k ] = -rc[ k ];
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/Application.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import static org.echocat.jopus.OpusConstants.APPLICATION_AUDIO;
18 | import static org.echocat.jopus.OpusConstants.APPLICATION_RESTRICTED_LOW_DELAY;
19 | import static org.echocat.jopus.OpusConstants.APPLICATION_VOIP;
20 |
21 | public enum Application {
22 | /**
23 | * Gives best quality at a given bitrate for voice signals. It enhances the input signal by high-pass filtering and
24 | * emphasizing formants and harmonics. Optionally it includes in-band forward error correction to protect against
25 | * packet loss. Use this mode for typical VoIP applications. Because of the enhancement, even at high bitrates the
26 | * output may sound different from the input.
27 | */
28 | voip(APPLICATION_VOIP),
29 | /**
30 | * Gives best quality at a given bitrate for most non-voice signals like music. Use this mode for music and mixed
31 | * (music/voice) content, broadcast, and applications requiring less than 15 ms of coding delay.
32 | */
33 | audio(APPLICATION_AUDIO),
34 | /**
35 | * Configures low-delay mode that disables the speech-optimized mode in exchange for slightly reduced delay.
36 | * This mode can only be set on an newly initialized or freshly reset encoder because it changes the codec delay.
37 | */
38 | restrictedLowDelay(APPLICATION_RESTRICTED_LOW_DELAY);
39 |
40 | private final int _handle;
41 |
42 | Application(int handle) {
43 | _handle = handle;
44 | }
45 |
46 | public static Application applicationFor(int code) {
47 | Application result = null;
48 | for (final Application candidate : values()) {
49 | if (candidate.handle() == code) {
50 | result = candidate;
51 | break;
52 | }
53 | }
54 | if (result == null) {
55 | throw new IllegalArgumentException("Could not handle application with code: " + code);
56 | }
57 | return result;
58 | }
59 |
60 | public int handle() {
61 | return _handle;
62 | }
63 |
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/energy_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* sum of squares of a silk_float array, with result as double */
35 | double silk_energy_FLP(
36 | const silk_float *data,
37 | opus_int dataSize
38 | )
39 | {
40 | opus_int i, dataSize4;
41 | double result;
42 |
43 | /* 4x unrolled loop */
44 | result = 0.0;
45 | dataSize4 = dataSize & 0xFFFC;
46 | for( i = 0; i < dataSize4; i += 4 ) {
47 | result += data[ i + 0 ] * (double)data[ i + 0 ] +
48 | data[ i + 1 ] * (double)data[ i + 1 ] +
49 | data[ i + 2 ] * (double)data[ i + 2 ] +
50 | data[ i + 3 ] * (double)data[ i + 3 ];
51 | }
52 |
53 | /* add any remaining products */
54 | for( ; i < dataSize; i++ ) {
55 | result += data[ i ] * (double)data[ i ];
56 | }
57 |
58 | silk_assert( result >= 0.0 );
59 | return result;
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/org/echocat/jopus/OpusDecoderTest.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import org.echocat.jogg.OggSyncStateInput;
18 | import org.junit.Rule;
19 | import org.junit.Test;
20 | import org.junit.rules.TemporaryFolder;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | import java.io.*;
25 |
26 | import static org.hamcrest.CoreMatchers.is;
27 | import static org.junit.Assert.assertThat;
28 |
29 |
30 | /**
31 | * Created by christian.rijke on 14.08.2014.
32 | */
33 | public class OpusDecoderTest {
34 |
35 | Logger LOG = LoggerFactory.getLogger(OpusDecoderTest.class);
36 |
37 | @Rule
38 | public TemporaryFolder tempFolder = new TemporaryFolder();
39 |
40 |
41 | @Test
42 | public void decodeMono() throws IOException {
43 | File result = decode("bach_48k_mono.opus", 1, SamplingRate.kHz48);
44 | assertThat(result.length(), is(1023360L));
45 | }
46 |
47 | @Test
48 | public void decodeStereo() throws IOException {
49 | File result = decode("bach_48k_stereo.opus", 2, SamplingRate.kHz48);
50 | assertThat(result.length(), is(1044480L));
51 | }
52 |
53 | public File decode(String source, int channels, SamplingRate samplingRate) throws IOException {
54 | LOG.info("decoding {}...", source);
55 |
56 | File tempFile = tempFolder.newFile(source.substring(0, source.length() - 5) + ".raw");
57 |
58 | try (final InputStream is = getClass().getResourceAsStream(source);
59 | final OggSyncStateInput ssi = new OggSyncStateInput(is);
60 | final OpusDecoder od = new OpusDecoder(ssi);
61 | final FileOutputStream fos = new FileOutputStream(tempFile);
62 | final DataOutputStream dos = new DataOutputStream(fos)) {
63 |
64 | od.setSamplingRate(samplingRate);
65 | od.setNumberOfChannels(channels);
66 |
67 | while (!od.isEofReached()) {
68 | for (short i : od.read()) {
69 | dos.writeShort(i);
70 | }
71 | }
72 | }
73 | LOG.info("decoding finished");
74 | return tempFile;
75 | }
76 | }
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/inner_product_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* inner product of two silk_float arrays, with result as double */
35 | double silk_inner_product_FLP(
36 | const silk_float *data1,
37 | const silk_float *data2,
38 | opus_int dataSize
39 | )
40 | {
41 | opus_int i, dataSize4;
42 | double result;
43 |
44 | /* 4x unrolled loop */
45 | result = 0.0;
46 | dataSize4 = dataSize & 0xFFFC;
47 | for( i = 0; i < dataSize4; i += 4 ) {
48 | result += data1[ i + 0 ] * (double)data2[ i + 0 ] +
49 | data1[ i + 1 ] * (double)data2[ i + 1 ] +
50 | data1[ i + 2 ] * (double)data2[ i + 2 ] +
51 | data1[ i + 3 ] * (double)data2[ i + 3 ];
52 | }
53 |
54 | /* add any remaining products */
55 | for( ; i < dataSize; i++ ) {
56 | result += data1[ i ] * (double)data2[ i ];
57 | }
58 |
59 | return result;
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/autocorrelation_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "typedef.h"
33 | #include "SigProc_FLP.h"
34 |
35 | /* compute autocorrelation */
36 | void silk_autocorrelation_FLP(
37 | silk_float *results, /* O result (length correlationCount) */
38 | const silk_float *inputData, /* I input data to correlate */
39 | opus_int inputDataSize, /* I length of input */
40 | opus_int correlationCount /* I number of correlation taps to compute */
41 | )
42 | {
43 | opus_int i;
44 |
45 | if( correlationCount > inputDataSize ) {
46 | correlationCount = inputDataSize;
47 | }
48 |
49 | for( i = 0; i < correlationCount; i++ ) {
50 | results[ i ] = (silk_float)silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i );
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/tables_gain.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "tables.h"
33 |
34 | #ifdef __cplusplus
35 | extern "C"
36 | {
37 | #endif
38 |
39 | const opus_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ] =
40 | {
41 | {
42 | 224, 112, 44, 15, 3, 2, 1, 0
43 | },
44 | {
45 | 254, 237, 192, 132, 70, 23, 4, 0
46 | },
47 | {
48 | 255, 252, 226, 155, 61, 11, 2, 0
49 | }
50 | };
51 |
52 | const opus_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ] = {
53 | 250, 245, 234, 203, 71, 50, 42, 38,
54 | 35, 33, 31, 29, 28, 27, 26, 25,
55 | 24, 23, 22, 21, 20, 19, 18, 17,
56 | 16, 15, 14, 13, 12, 11, 10, 9,
57 | 8, 7, 6, 5, 4, 3, 2, 1,
58 | 0
59 | };
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/fixed/k2a_Q16_FIX.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 |
34 | /* Step up function, converts reflection coefficients to prediction coefficients */
35 | void silk_k2a_Q16(
36 | opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */
37 | const opus_int32 *rc_Q16, /* I Reflection coefficients [order] Q16 */
38 | const opus_int32 order /* I Prediction order */
39 | )
40 | {
41 | opus_int k, n;
42 | opus_int32 Atmp[ SILK_MAX_ORDER_LPC ];
43 |
44 | for( k = 0; k < order; k++ ) {
45 | for( n = 0; n < k; n++ ) {
46 | Atmp[ n ] = A_Q24[ n ];
47 | }
48 | for( n = 0; n < k; n++ ) {
49 | A_Q24[ n ] = silk_SMLAWW( A_Q24[ n ], Atmp[ k - n - 1 ], rc_Q16[ k ] );
50 | }
51 | A_Q24[ k ] = -silk_LSHIFT( rc_Q16[ k ], 8 );
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/interpolate.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /* Interpolate two vectors */
35 | void silk_interpolate(
36 | opus_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */
37 | const opus_int16 x0[ MAX_LPC_ORDER ], /* I first vector */
38 | const opus_int16 x1[ MAX_LPC_ORDER ], /* I second vector */
39 | const opus_int ifact_Q2, /* I interp. factor, weight on 2nd vector */
40 | const opus_int d /* I number of parameters */
41 | )
42 | {
43 | opus_int i;
44 |
45 | silk_assert( ifact_Q2 >= 0 );
46 | silk_assert( ifact_Q2 <= 4 );
47 |
48 | for( i = 0; i < d; i++ ) {
49 | xi[ i ] = (opus_int16)silk_ADD_RSHIFT( x0[ i ], silk_SMULBB( x1[ i ] - x0[ i ], ifact_Q2 ), 2 );
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/fixed/k2a_FIX.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 |
34 | /* Step up function, converts reflection coefficients to prediction coefficients */
35 | void silk_k2a(
36 | opus_int32 *A_Q24, /* O Prediction coefficients [order] Q24 */
37 | const opus_int16 *rc_Q15, /* I Reflection coefficients [order] Q15 */
38 | const opus_int32 order /* I Prediction order */
39 | )
40 | {
41 | opus_int k, n;
42 | opus_int32 Atmp[ SILK_MAX_ORDER_LPC ];
43 |
44 | for( k = 0; k < order; k++ ) {
45 | for( n = 0; n < k; n++ ) {
46 | Atmp[ n ] = A_Q24[ n ];
47 | }
48 | for( n = 0; n < k; n++ ) {
49 | A_Q24[ n ] = silk_SMLAWB( A_Q24[ n ], silk_LSHIFT( Atmp[ k - n - 1 ], 1 ), rc_Q15[ k ] );
50 | }
51 | A_Q24[ k ] = -silk_LSHIFT( (opus_int32)rc_Q15[ k ], 9 );
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/fixed/regularize_correlations_FIX.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main_FIX.h"
33 |
34 | /* Add noise to matrix diagonal */
35 | void silk_regularize_correlations_FIX(
36 | opus_int32 *XX, /* I/O Correlation matrices */
37 | opus_int32 *xx, /* I/O Correlation values */
38 | opus_int32 noise, /* I Noise to add */
39 | opus_int D /* I Dimension of XX */
40 | )
41 | {
42 | opus_int i;
43 | for( i = 0; i < D; i++ ) {
44 | matrix_ptr( &XX[ 0 ], i, i, D ) = silk_ADD32( matrix_ptr( &XX[ 0 ], i, i, D ), noise );
45 | }
46 | xx[ 0 ] += noise;
47 | }
48 |
--------------------------------------------------------------------------------
/jopus.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/log2lin.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 |
34 | /* Approximation of 2^() (very close inverse of silk_lin2log()) */
35 | /* Convert input to a linear scale */
36 | opus_int32 silk_log2lin(
37 | const opus_int32 inLog_Q7 /* I input on log scale */
38 | )
39 | {
40 | opus_int32 out, frac_Q7;
41 |
42 | if( inLog_Q7 < 0 ) {
43 | return 0;
44 | } else if ( inLog_Q7 >= 3967 ) {
45 | return silk_int32_MAX;
46 | }
47 |
48 | out = silk_LSHIFT( 1, silk_RSHIFT( inLog_Q7, 7 ) );
49 | frac_Q7 = inLog_Q7 & 0x7F;
50 | if( inLog_Q7 < 2048 ) {
51 | /* Piece-wise parabolic approximation */
52 | out = silk_ADD_RSHIFT32( out, silk_MUL( out, silk_SMLAWB( frac_Q7, silk_SMULBB( frac_Q7, 128 - frac_Q7 ), -174 ) ), 7 );
53 | } else {
54 | /* Piece-wise parabolic approximation */
55 | out = silk_MLA( out, silk_RSHIFT( out, 7 ), silk_SMLAWB( frac_Q7, silk_SMULBB( frac_Q7, 128 - frac_Q7 ), -174 ) );
56 | }
57 | return out;
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/resampler_structs.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifndef SILK_RESAMPLER_STRUCTS_H
29 | #define SILK_RESAMPLER_STRUCTS_H
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | #define SILK_RESAMPLER_MAX_FIR_ORDER 36
36 | #define SILK_RESAMPLER_MAX_IIR_ORDER 6
37 |
38 | typedef struct _silk_resampler_state_struct{
39 | opus_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */
40 | union{
41 | opus_int32 i32[ SILK_RESAMPLER_MAX_FIR_ORDER ];
42 | opus_int16 i16[ SILK_RESAMPLER_MAX_FIR_ORDER ];
43 | } sFIR;
44 | opus_int16 delayBuf[ 48 ];
45 | opus_int resampler_function;
46 | opus_int batchSize;
47 | opus_int32 invRatio_Q16;
48 | opus_int FIR_Order;
49 | opus_int FIR_Fracs;
50 | opus_int Fs_in_kHz;
51 | opus_int Fs_out_kHz;
52 | opus_int inputDelay;
53 | const opus_int16 *Coefs;
54 | } silk_resampler_state_struct;
55 |
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 | #endif /* SILK_RESAMPLER_STRUCTS_H */
60 |
61 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/resampler_private_AR2.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 | #include "resampler_private.h"
34 |
35 | /* Second order AR filter with single delay elements */
36 | void silk_resampler_private_AR2(
37 | opus_int32 S[], /* I/O State vector [ 2 ] */
38 | opus_int32 out_Q8[], /* O Output signal */
39 | const opus_int16 in[], /* I Input signal */
40 | const opus_int16 A_Q14[], /* I AR coefficients, Q14 */
41 | opus_int32 len /* I Signal length */
42 | )
43 | {
44 | opus_int32 k;
45 | opus_int32 out32;
46 |
47 | for( k = 0; k < len; k++ ) {
48 | out32 = silk_ADD_LSHIFT32( S[ 0 ], (opus_int32)in[ k ], 8 );
49 | out_Q8[ k ] = out32;
50 | out32 = silk_LSHIFT( out32, 2 );
51 | S[ 0 ] = silk_SMLAWB( S[ 1 ], out32, A_Q14[ 0 ] );
52 | S[ 1 ] = silk_SMULWB( out32, A_Q14[ 1 ] );
53 | }
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/LTP_scale_ctrl_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main_FLP.h"
33 |
34 | void silk_LTP_scale_ctrl_FLP(
35 | silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
36 | silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
37 | opus_int condCoding /* I The type of conditional coding to use */
38 | )
39 | {
40 | opus_int round_loss;
41 |
42 | if( condCoding == CODE_INDEPENDENTLY ) {
43 | /* Only scale if first frame in packet */
44 | round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
45 | psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)silk_LIMIT( round_loss * psEncCtrl->LTPredCodGain * 0.1f, 0.0f, 2.0f );
46 | } else {
47 | /* Default is minimum scaling */
48 | psEnc->sCmn.indices.LTP_scaleIndex = 0;
49 | }
50 |
51 | psEncCtrl->LTP_scale = (silk_float)silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f;
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/fixed/autocorr_FIX.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 | #include "celt_lpc.h"
34 |
35 | /* Compute autocorrelation */
36 | void silk_autocorr(
37 | opus_int32 *results, /* O Result (length correlationCount) */
38 | opus_int *scale, /* O Scaling of the correlation vector */
39 | const opus_int16 *inputData, /* I Input data to correlate */
40 | const opus_int inputDataSize, /* I Length of input */
41 | const opus_int correlationCount, /* I Number of correlation taps to compute */
42 | int arch /* I Run-time architecture */
43 | )
44 | {
45 | opus_int corrCount;
46 | corrCount = silk_min_int( inputDataSize, correlationCount );
47 | *scale = _celt_autocorr(inputData, results, NULL, 0, corrCount-1, inputDataSize, arch);
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/modes.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007-2008 CSIRO
2 | Copyright (c) 2007-2009 Xiph.Org Foundation
3 | Copyright (c) 2008 Gregory Maxwell
4 | Written by Jean-Marc Valin and Gregory Maxwell */
5 | /*
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions
8 | are met:
9 |
10 | - Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 |
13 | - Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #ifndef MODES_H
31 | #define MODES_H
32 |
33 | #include "opus_types.h"
34 | #include "celt.h"
35 | #include "arch.h"
36 | #include "mdct.h"
37 | #include "entenc.h"
38 | #include "entdec.h"
39 |
40 | #define MAX_PERIOD 1024
41 |
42 | #ifndef OVERLAP
43 | #define OVERLAP(mode) ((mode)->overlap)
44 | #endif
45 |
46 | #ifndef FRAMESIZE
47 | #define FRAMESIZE(mode) ((mode)->mdctSize)
48 | #endif
49 |
50 | typedef struct {
51 | int size;
52 | const opus_int16 *index;
53 | const unsigned char *bits;
54 | const unsigned char *caps;
55 | } PulseCache;
56 |
57 | /** Mode definition (opaque)
58 | @brief Mode definition
59 | */
60 | struct OpusCustomMode {
61 | opus_int32 Fs;
62 | int overlap;
63 |
64 | int nbEBands;
65 | int effEBands;
66 | opus_val16 preemph[4];
67 | const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */
68 |
69 | int maxLM;
70 | int nbShortMdcts;
71 | int shortMdctSize;
72 |
73 | int nbAllocVectors; /**< Number of lines in the matrix below */
74 | const unsigned char *allocVectors; /**< Number of bits in each band for several rates */
75 | const opus_int16 *logN;
76 |
77 | const opus_val16 *window;
78 | mdct_lookup mdct;
79 | PulseCache cache;
80 | };
81 |
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/bwexpander.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 |
34 | /* Chirp (bandwidth expand) LP AR filter */
35 | void silk_bwexpander(
36 | opus_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */
37 | const opus_int d, /* I Length of ar */
38 | opus_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */
39 | )
40 | {
41 | opus_int i;
42 | opus_int32 chirp_minus_one_Q16 = chirp_Q16 - 65536;
43 |
44 | /* NB: Dont use silk_SMULWB, instead of silk_RSHIFT_ROUND( silk_MUL(), 16 ), below. */
45 | /* Bias in silk_SMULWB can lead to unstable filters */
46 | for( i = 0; i < d - 1; i++ ) {
47 | ar[ i ] = (opus_int16)silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, ar[ i ] ), 16 );
48 | chirp_Q16 += silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, chirp_minus_one_Q16 ), 16 );
49 | }
50 | ar[ d - 1 ] = (opus_int16)silk_RSHIFT_ROUND( silk_MUL( chirp_Q16, ar[ d - 1 ] ), 16 );
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/vq.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007-2008 CSIRO
2 | Copyright (c) 2007-2009 Xiph.Org Foundation
3 | Written by Jean-Marc Valin */
4 | /**
5 | @file vq.h
6 | @brief Vector quantisation of the residual
7 | */
8 | /*
9 | Redistribution and use in source and binary forms, with or without
10 | modification, are permitted provided that the following conditions
11 | are met:
12 |
13 | - Redistributions of source code must retain the above copyright
14 | notice, this list of conditions and the following disclaimer.
15 |
16 | - Redistributions in binary form must reproduce the above copyright
17 | notice, this list of conditions and the following disclaimer in the
18 | documentation and/or other materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
24 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 | #ifndef VQ_H
34 | #define VQ_H
35 |
36 | #include "entenc.h"
37 | #include "entdec.h"
38 | #include "modes.h"
39 |
40 | /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of
41 | * the pitch and a combination of pulses such that its norm is still equal
42 | * to 1. This is the function that will typically require the most CPU.
43 | * @param X Residual signal to quantise/encode (returns quantised version)
44 | * @param N Number of samples to encode
45 | * @param K Number of pulses to use
46 | * @param enc Entropy encoder state
47 | * @ret A mask indicating which blocks in the band received pulses
48 | */
49 | unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B,
50 | ec_enc *enc
51 | #ifdef RESYNTH
52 | , opus_val16 gain
53 | #endif
54 | );
55 |
56 | /** Algebraic pulse decoder
57 | * @param X Decoded normalised spectrum (returned)
58 | * @param N Number of samples to decode
59 | * @param K Number of pulses to use
60 | * @param dec Entropy decoder state
61 | * @ret A mask indicating which blocks in the band received pulses
62 | */
63 | unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B,
64 | ec_dec *dec, opus_val16 gain);
65 |
66 | void renormalise_vector(celt_norm *X, int N, opus_val16 gain);
67 |
68 | int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N);
69 |
70 | #endif /* VQ_H */
71 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/arm/fixed_armv4.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2013 Xiph.Org Foundation and contributors */
2 | /*
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 |
7 | - Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 |
10 | - Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
18 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | #ifndef FIXED_ARMv4_H
28 | #define FIXED_ARMv4_H
29 |
30 | /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
31 | #undef MULT16_32_Q16
32 | static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b)
33 | {
34 | unsigned rd_lo;
35 | int rd_hi;
36 | __asm__(
37 | "#MULT16_32_Q16\n\t"
38 | "smull %0, %1, %2, %3\n\t"
39 | : "=&r"(rd_lo), "=&r"(rd_hi)
40 | : "%r"(b),"r"(a<<16)
41 | );
42 | return rd_hi;
43 | }
44 | #define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv4(a, b))
45 |
46 |
47 | /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */
48 | #undef MULT16_32_Q15
49 | static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b)
50 | {
51 | unsigned rd_lo;
52 | int rd_hi;
53 | __asm__(
54 | "#MULT16_32_Q15\n\t"
55 | "smull %0, %1, %2, %3\n\t"
56 | : "=&r"(rd_lo), "=&r"(rd_hi)
57 | : "%r"(b), "r"(a<<16)
58 | );
59 | /*We intentionally don't OR in the high bit of rd_lo for speed.*/
60 | return rd_hi<<1;
61 | }
62 | #define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv4(a, b))
63 |
64 |
65 | /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add.
66 | b must fit in 31 bits.
67 | Result fits in 32 bits. */
68 | #undef MAC16_32_Q15
69 | #define MAC16_32_Q15(c, a, b) ADD32(c, MULT16_32_Q15(a, b))
70 |
71 |
72 | /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */
73 | #undef MULT32_32_Q31
74 | #define MULT32_32_Q31(a,b) (opus_val32)((((opus_int64)(a)) * ((opus_int64)(b)))>>31)
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/src/main/c/opus/opus_multistream.c:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2011 Xiph.Org Foundation
2 | Written by Jean-Marc Valin */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "opus_multistream.h"
33 | #include "opus.h"
34 | #include "opus_private.h"
35 | #include "stack_alloc.h"
36 | #include
37 | #include "float_cast.h"
38 | #include "os_support.h"
39 |
40 |
41 | int validate_layout(const ChannelLayout *layout)
42 | {
43 | int i, max_channel;
44 |
45 | max_channel = layout->nb_streams+layout->nb_coupled_streams;
46 | if (max_channel>255)
47 | return 0;
48 | for (i=0;inb_channels;i++)
49 | {
50 | if (layout->mapping[i] >= max_channel && layout->mapping[i] != 255)
51 | return 0;
52 | }
53 | return 1;
54 | }
55 |
56 |
57 | int get_left_channel(const ChannelLayout *layout, int stream_id, int prev)
58 | {
59 | int i;
60 | i = (prev<0) ? 0 : prev+1;
61 | for (;inb_channels;i++)
62 | {
63 | if (layout->mapping[i]==stream_id*2)
64 | return i;
65 | }
66 | return -1;
67 | }
68 |
69 | int get_right_channel(const ChannelLayout *layout, int stream_id, int prev)
70 | {
71 | int i;
72 | i = (prev<0) ? 0 : prev+1;
73 | for (;inb_channels;i++)
74 | {
75 | if (layout->mapping[i]==stream_id*2+1)
76 | return i;
77 | }
78 | return -1;
79 | }
80 |
81 | int get_mono_channel(const ChannelLayout *layout, int stream_id, int prev)
82 | {
83 | int i;
84 | i = (prev<0) ? 0 : prev+1;
85 | for (;inb_channels;i++)
86 | {
87 | if (layout->mapping[i]==stream_id+layout->nb_coupled_streams)
88 | return i;
89 | }
90 | return -1;
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/fixed/LTP_scale_ctrl_FIX.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main_FIX.h"
33 |
34 | /* Calculation of LTP state scaling */
35 | void silk_LTP_scale_ctrl_FIX(
36 | silk_encoder_state_FIX *psEnc, /* I/O encoder state */
37 | silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
38 | opus_int condCoding /* I The type of conditional coding to use */
39 | )
40 | {
41 | opus_int round_loss;
42 |
43 | if( condCoding == CODE_INDEPENDENTLY ) {
44 | /* Only scale if first frame in packet */
45 | round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
46 | psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)silk_LIMIT(
47 | silk_SMULWB( silk_SMULBB( round_loss, psEncCtrl->LTPredCodGain_Q7 ), SILK_FIX_CONST( 0.1, 9 ) ), 0, 2 );
48 | } else {
49 | /* Default is minimum scaling */
50 | psEnc->sCmn.indices.LTP_scaleIndex = 0;
51 | }
52 | psEncCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ];
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/mdct.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007-2008 CSIRO
2 | Copyright (c) 2007-2008 Xiph.Org Foundation
3 | Written by Jean-Marc Valin */
4 | /*
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | /* This is a simple MDCT implementation that uses a N/4 complex FFT
30 | to do most of the work. It should be relatively straightforward to
31 | plug in pretty much and FFT here.
32 |
33 | This replaces the Vorbis FFT (and uses the exact same API), which
34 | was a bit too messy and that was ending up duplicating code
35 | (might as well use the same FFT everywhere).
36 |
37 | The algorithm is similar to (and inspired from) Fabrice Bellard's
38 | MDCT implementation in FFMPEG, but has differences in signs, ordering
39 | and scaling in many places.
40 | */
41 |
42 | #ifndef MDCT_H
43 | #define MDCT_H
44 |
45 | #include "opus_defines.h"
46 | #include "kiss_fft.h"
47 | #include "arch.h"
48 |
49 | typedef struct {
50 | int n;
51 | int maxshift;
52 | const kiss_fft_state *kfft[4];
53 | const kiss_twiddle_scalar * OPUS_RESTRICT trig;
54 | } mdct_lookup;
55 |
56 | int clt_mdct_init(mdct_lookup *l,int N, int maxshift);
57 | void clt_mdct_clear(mdct_lookup *l);
58 |
59 | /** Compute a forward MDCT and scale by 4/N, trashes the input array */
60 | void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in,
61 | kiss_fft_scalar * OPUS_RESTRICT out,
62 | const opus_val16 *window, int overlap, int shift, int stride);
63 |
64 | /** Compute a backward MDCT (no scaling) and performs weighted overlap-add
65 | (scales implicitly by 1/2) */
66 | void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in,
67 | kiss_fft_scalar * OPUS_RESTRICT out,
68 | const opus_val16 * OPUS_RESTRICT window, int overlap, int shift, int stride);
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/init_encoder.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 | #ifdef FIXED_POINT
32 | #include "main_FIX.h"
33 | #else
34 | #include "main_FLP.h"
35 | #endif
36 | #include "tuning_parameters.h"
37 | #include "cpu_support.h"
38 |
39 | /*********************************/
40 | /* Initialize Silk Encoder state */
41 | /*********************************/
42 | opus_int silk_init_encoder(
43 | silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk FIX encoder state */
44 | int arch /* I Run-time architecture */
45 | )
46 | {
47 | opus_int ret = 0;
48 |
49 | /* Clear the entire encoder state */
50 | silk_memset( psEnc, 0, sizeof( silk_encoder_state_Fxx ) );
51 |
52 | psEnc->sCmn.arch = arch;
53 |
54 | psEnc->sCmn.variable_HP_smth1_Q15 = silk_LSHIFT( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ), 8 );
55 | psEnc->sCmn.variable_HP_smth2_Q15 = psEnc->sCmn.variable_HP_smth1_Q15;
56 |
57 | /* Used to deactivate LSF interpolation, pitch prediction */
58 | psEnc->sCmn.first_frame_after_reset = 1;
59 |
60 | /* Initialize Silk VAD */
61 | ret += silk_VAD_Init( &psEnc->sCmn.sVAD );
62 |
63 | return ret;
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/stereo_encode_pred.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /* Entropy code the mid/side quantization indices */
35 | void silk_stereo_encode_pred(
36 | ec_enc *psRangeEnc, /* I/O Compressor data structure */
37 | opus_int8 ix[ 2 ][ 3 ] /* I Quantization indices */
38 | )
39 | {
40 | opus_int n;
41 |
42 | /* Entropy coding */
43 | n = 5 * ix[ 0 ][ 2 ] + ix[ 1 ][ 2 ];
44 | silk_assert( n < 25 );
45 | ec_enc_icdf( psRangeEnc, n, silk_stereo_pred_joint_iCDF, 8 );
46 | for( n = 0; n < 2; n++ ) {
47 | silk_assert( ix[ n ][ 0 ] < 3 );
48 | silk_assert( ix[ n ][ 1 ] < STEREO_QUANT_SUB_STEPS );
49 | ec_enc_icdf( psRangeEnc, ix[ n ][ 0 ], silk_uniform3_iCDF, 8 );
50 | ec_enc_icdf( psRangeEnc, ix[ n ][ 1 ], silk_uniform5_iCDF, 8 );
51 | }
52 | }
53 |
54 | /* Entropy code the mid-only flag */
55 | void silk_stereo_encode_mid_only(
56 | ec_enc *psRangeEnc, /* I/O Compressor data structure */
57 | opus_int8 mid_only_flag
58 | )
59 | {
60 | /* Encode flag that only mid channel is coded */
61 | ec_enc_icdf( psRangeEnc, mid_only_flag, silk_stereo_only_code_mid_iCDF, 8 );
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/NLSF_unpack.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /* Unpack predictor values and indices for entropy coding tables */
35 | void silk_NLSF_unpack(
36 | opus_int16 ec_ix[], /* O Indices to entropy tables [ LPC_ORDER ] */
37 | opus_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */
38 | const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */
39 | const opus_int CB1_index /* I Index of vector in first LSF codebook */
40 | )
41 | {
42 | opus_int i;
43 | opus_uint8 entry;
44 | const opus_uint8 *ec_sel_ptr;
45 |
46 | ec_sel_ptr = &psNLSF_CB->ec_sel[ CB1_index * psNLSF_CB->order / 2 ];
47 | for( i = 0; i < psNLSF_CB->order; i += 2 ) {
48 | entry = *ec_sel_ptr++;
49 | ec_ix [ i ] = silk_SMULBB( silk_RSHIFT( entry, 1 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 );
50 | pred_Q8[ i ] = psNLSF_CB->pred_Q8[ i + ( entry & 1 ) * ( psNLSF_CB->order - 1 ) ];
51 | ec_ix [ i + 1 ] = silk_SMULBB( silk_RSHIFT( entry, 5 ) & 7, 2 * NLSF_QUANT_MAX_AMPLITUDE + 1 );
52 | pred_Q8[ i + 1 ] = psNLSF_CB->pred_Q8[ i + ( silk_RSHIFT( entry, 4 ) & 1 ) * ( psNLSF_CB->order - 1 ) + 1 ];
53 | }
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/quant_bands.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2007-2008 CSIRO
2 | Copyright (c) 2007-2009 Xiph.Org Foundation
3 | Written by Jean-Marc Valin */
4 | /*
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | - Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 |
12 | - Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #ifndef QUANT_BANDS
30 | #define QUANT_BANDS
31 |
32 | #include "arch.h"
33 | #include "modes.h"
34 | #include "entenc.h"
35 | #include "entdec.h"
36 | #include "mathops.h"
37 |
38 | #ifdef FIXED_POINT
39 | extern const signed char eMeans[25];
40 | #else
41 | extern const opus_val16 eMeans[25];
42 | #endif
43 |
44 | void amp2Log2(const CELTMode *m, int effEnd, int end,
45 | celt_ener *bandE, opus_val16 *bandLogE, int C);
46 |
47 | void log2Amp(const CELTMode *m, int start, int end,
48 | celt_ener *eBands, const opus_val16 *oldEBands, int C);
49 |
50 | void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
51 | const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget,
52 | opus_val16 *error, ec_enc *enc, int C, int LM,
53 | int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra,
54 | int two_pass, int loss_rate, int lfe);
55 |
56 | void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C);
57 |
58 | void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C);
59 |
60 | void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM);
61 |
62 | void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C);
63 |
64 | void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C);
65 |
66 | #endif /* QUANT_BANDS */
67 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/tables_pitch_lag.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "tables.h"
33 |
34 | const opus_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ] = {
35 | 253, 250, 244, 233, 212, 182, 150, 131,
36 | 120, 110, 98, 85, 72, 60, 49, 40,
37 | 32, 25, 19, 15, 13, 11, 9, 8,
38 | 7, 6, 5, 4, 3, 2, 1, 0
39 | };
40 |
41 | const opus_uint8 silk_pitch_delta_iCDF[21] = {
42 | 210, 208, 206, 203, 199, 193, 183, 168,
43 | 142, 104, 74, 52, 37, 27, 20, 14,
44 | 10, 6, 4, 2, 0
45 | };
46 |
47 | const opus_uint8 silk_pitch_contour_iCDF[34] = {
48 | 223, 201, 183, 167, 152, 138, 124, 111,
49 | 98, 88, 79, 70, 62, 56, 50, 44,
50 | 39, 35, 31, 27, 24, 21, 18, 16,
51 | 14, 12, 10, 8, 6, 4, 3, 2,
52 | 1, 0
53 | };
54 |
55 | const opus_uint8 silk_pitch_contour_NB_iCDF[11] = {
56 | 188, 176, 155, 138, 119, 97, 67, 43,
57 | 26, 10, 0
58 | };
59 |
60 | const opus_uint8 silk_pitch_contour_10_ms_iCDF[12] = {
61 | 165, 119, 80, 61, 47, 35, 27, 20,
62 | 14, 9, 4, 0
63 | };
64 |
65 | const opus_uint8 silk_pitch_contour_10_ms_NB_iCDF[3] = {
66 | 113, 63, 0
67 | };
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/schur_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | silk_float silk_schur_FLP( /* O returns residual energy */
35 | silk_float refl_coef[], /* O reflection coefficients (length order) */
36 | const silk_float auto_corr[], /* I autocorrelation sequence (length order+1) */
37 | opus_int order /* I order */
38 | )
39 | {
40 | opus_int k, n;
41 | silk_float C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ];
42 | silk_float Ctmp1, Ctmp2, rc_tmp;
43 |
44 | silk_assert( order==6||order==8||order==10||order==12||order==14||order==16 );
45 |
46 | /* Copy correlations */
47 | for( k = 0; k < order+1; k++ ) {
48 | C[ k ][ 0 ] = C[ k ][ 1 ] = auto_corr[ k ];
49 | }
50 |
51 | for( k = 0; k < order; k++ ) {
52 | /* Get reflection coefficient */
53 | rc_tmp = -C[ k + 1 ][ 0 ] / silk_max_float( C[ 0 ][ 1 ], 1e-9f );
54 |
55 | /* Save the output */
56 | refl_coef[ k ] = rc_tmp;
57 |
58 | /* Update correlations */
59 | for( n = 0; n < order - k; n++ ) {
60 | Ctmp1 = C[ n + k + 1 ][ 0 ];
61 | Ctmp2 = C[ n ][ 1 ];
62 | C[ n + k + 1 ][ 0 ] = Ctmp1 + Ctmp2 * rc_tmp;
63 | C[ n ][ 1 ] = Ctmp2 + Ctmp1 * rc_tmp;
64 | }
65 | }
66 |
67 | /* Return residual energy */
68 | return C[ 0 ][ 1 ];
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/src/main/java/org/echocat/jopus/OpusConstants.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import static org.echocat.jopus.OpusJNI.getVersionString;
18 |
19 | public interface OpusConstants {
20 |
21 | public static final String VERSION = getVersionString();
22 |
23 | public static final int AUTO = -1000;
24 | public static final int BIT_RATE_MAX = -1;
25 |
26 | /**
27 | * Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
28 | */
29 | public static final int APPLICATION_VOIP = 2048;
30 |
31 | /**
32 | * Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
33 | */
34 | public static final int APPLICATION_AUDIO = 2049;
35 | /**
36 | * Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
37 | */
38 | public static final int APPLICATION_RESTRICTED_LOW_DELAY = 2051;
39 |
40 | /**
41 | * Signal being encoded is voice
42 | */
43 | public static final int SIGNAL_VOICE = 3001;
44 | /**
45 | * Signal being encoded is music
46 | */
47 | public static final int SIGNAL_MUSIC = 3002;
48 | /**
49 | * 4 kHz bandpass
50 | */
51 | public static final int BANDWIDTH_NARROWBAND = 1101;
52 | /**
53 | * 6 kHz bandpass
54 | */
55 | public static final int BANDWIDTH_MEDIUMBAND = 1102;
56 | /**
57 | * 8 kHz bandpass
58 | */
59 | public static final int BANDWIDTH_WIDEBAND = 1103;
60 | /**
61 | * <12 kHz bandpass
62 | */
63 | public static final int BANDWIDTH_SUPERWIDEBAND = 1104;
64 | /**
65 | * <20 kHz bandpass
66 | */
67 | public static final int BANDWIDTH_FULLBAND = 1105;
68 |
69 | /**
70 | * Select frame size from the argument (default)
71 | */
72 | public static final int FRAMESIZE_ARG = 5000;
73 | /**
74 | * Use 2.5 ms frames
75 | */
76 | public static final int FRAMESIZE_2_5_MS = 5001;
77 | /**
78 | * Use 5 ms frames
79 | */
80 | public static final int FRAMESIZE_5_MS = 5002;
81 | /**
82 | * Use 10 ms frames
83 | */
84 | public static final int FRAMESIZE_10_MS = 5003;
85 | /**
86 | * Use 20 ms frames
87 | */
88 | public static final int FRAMESIZE_20_MS = 5004;
89 | /**
90 | * Use 40 ms frames
91 | */
92 | public static final int FRAMESIZE_40_MS = 5005;
93 | /**
94 | * Use 60 ms frames
95 | */
96 | public static final int FRAMESIZE_60_MS = 5006;
97 | /**
98 | * Optimize the frame size dynamically
99 | */
100 | public static final int FRAMESIZE_VARIABLE = 5010;
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/PLC.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifndef SILK_PLC_H
29 | #define SILK_PLC_H
30 |
31 | #include "main.h"
32 |
33 | #define BWE_COEF 0.99
34 | #define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */
35 | #define V_PITCH_GAIN_START_MAX_Q14 15565 /* 0.95 in Q14 */
36 | #define MAX_PITCH_LAG_MS 18
37 | #define RAND_BUF_SIZE 128
38 | #define RAND_BUF_MASK ( RAND_BUF_SIZE - 1 )
39 | #define LOG2_INV_LPC_GAIN_HIGH_THRES 3 /* 2^3 = 8 dB LPC gain */
40 | #define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */
41 | #define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */
42 |
43 | void silk_PLC_Reset(
44 | silk_decoder_state *psDec /* I/O Decoder state */
45 | );
46 |
47 | void silk_PLC(
48 | silk_decoder_state *psDec, /* I/O Decoder state */
49 | silk_decoder_control *psDecCtrl, /* I/O Decoder control */
50 | opus_int16 frame[], /* I/O signal */
51 | opus_int lost /* I Loss flag */
52 | );
53 |
54 | void silk_PLC_glue_frames(
55 | silk_decoder_state *psDec, /* I/O decoder state */
56 | opus_int16 frame[], /* I/O signal */
57 | opus_int length /* I length of signal */
58 | );
59 |
60 | #endif
61 |
62 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/sigm_Q15.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | /* Approximate sigmoid function */
33 |
34 | #include "SigProc_FIX.h"
35 |
36 | /* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */
37 | static const opus_int32 sigm_LUT_slope_Q10[ 6 ] = {
38 | 237, 153, 73, 30, 12, 7
39 | };
40 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp(-(0:5))))); */
41 | static const opus_int32 sigm_LUT_pos_Q15[ 6 ] = {
42 | 16384, 23955, 28861, 31213, 32178, 32548
43 | };
44 | /* fprintf(1, '%d, ', round(32767 * 1 ./ (1 + exp((0:5))))); */
45 | static const opus_int32 sigm_LUT_neg_Q15[ 6 ] = {
46 | 16384, 8812, 3906, 1554, 589, 219
47 | };
48 |
49 | opus_int silk_sigm_Q15(
50 | opus_int in_Q5 /* I */
51 | )
52 | {
53 | opus_int ind;
54 |
55 | if( in_Q5 < 0 ) {
56 | /* Negative input */
57 | in_Q5 = -in_Q5;
58 | if( in_Q5 >= 6 * 32 ) {
59 | return 0; /* Clip */
60 | } else {
61 | /* Linear interpolation of look up table */
62 | ind = silk_RSHIFT( in_Q5, 5 );
63 | return( sigm_LUT_neg_Q15[ ind ] - silk_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) );
64 | }
65 | } else {
66 | /* Positive input */
67 | if( in_Q5 >= 6 * 32 ) {
68 | return 32767; /* clip */
69 | } else {
70 | /* Linear interpolation of look up table */
71 | ind = silk_RSHIFT( in_Q5, 5 );
72 | return( sigm_LUT_pos_Q15[ ind ] + silk_SMULBB( sigm_LUT_slope_Q10[ ind ], in_Q5 & 0x1F ) );
73 | }
74 | }
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/resampler_rom.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifndef SILK_FIX_RESAMPLER_ROM_H
29 | #define SILK_FIX_RESAMPLER_ROM_H
30 |
31 | #ifdef __cplusplus
32 | extern "C"
33 | {
34 | #endif
35 |
36 | #include "typedef.h"
37 | #include "resampler_structs.h"
38 |
39 | #define RESAMPLER_DOWN_ORDER_FIR0 18
40 | #define RESAMPLER_DOWN_ORDER_FIR1 24
41 | #define RESAMPLER_DOWN_ORDER_FIR2 36
42 | #define RESAMPLER_ORDER_FIR_12 8
43 |
44 | /* Tables for 2x downsampler */
45 | static const opus_int16 silk_resampler_down2_0 = 9872;
46 | static const opus_int16 silk_resampler_down2_1 = 39809 - 65536;
47 |
48 | /* Tables for 2x upsampler, high quality */
49 | static const opus_int16 silk_resampler_up2_hq_0[ 3 ] = { 1746, 14986, 39083 - 65536 };
50 | static const opus_int16 silk_resampler_up2_hq_1[ 3 ] = { 6854, 25769, 55542 - 65536 };
51 |
52 | /* Tables with IIR and FIR coefficients for fractional downsamplers */
53 | extern const opus_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ];
54 | extern const opus_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ];
55 | extern const opus_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR1 / 2 ];
56 | extern const opus_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ];
57 | extern const opus_int16 silk_Resampler_1_4_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ];
58 | extern const opus_int16 silk_Resampler_1_6_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ];
59 | extern const opus_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ];
60 |
61 | /* Table with interplation fractions of 1/24, 3/24, ..., 23/24 */
62 | extern const opus_int16 silk_resampler_frac_FIR_12[ 12 ][ RESAMPLER_ORDER_FIR_12 / 2 ];
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 |
68 | #endif /* SILK_FIX_RESAMPLER_ROM_H */
69 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/levinsondurbin_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FLP.h"
33 |
34 | /* Solve the normal equations using the Levinson-Durbin recursion */
35 | silk_float silk_levinsondurbin_FLP( /* O prediction error energy */
36 | silk_float A[], /* O prediction coefficients [order] */
37 | const silk_float corr[], /* I input auto-correlations [order + 1] */
38 | const opus_int order /* I prediction order */
39 | )
40 | {
41 | opus_int i, mHalf, m;
42 | silk_float min_nrg, nrg, t, km, Atmp1, Atmp2;
43 |
44 | min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;
45 | nrg = corr[ 0 ];
46 | nrg = silk_max_float(min_nrg, nrg);
47 | A[ 0 ] = corr[ 1 ] / nrg;
48 | nrg -= A[ 0 ] * corr[ 1 ];
49 | nrg = silk_max_float(min_nrg, nrg);
50 |
51 | for( m = 1; m < order; m++ )
52 | {
53 | t = corr[ m + 1 ];
54 | for( i = 0; i < m; i++ ) {
55 | t -= A[ i ] * corr[ m - i ];
56 | }
57 |
58 | /* reflection coefficient */
59 | km = t / nrg;
60 |
61 | /* residual energy */
62 | nrg -= km * t;
63 | nrg = silk_max_float(min_nrg, nrg);
64 |
65 | mHalf = m >> 1;
66 | for( i = 0; i < mHalf; i++ ) {
67 | Atmp1 = A[ i ];
68 | Atmp2 = A[ m - i - 1 ];
69 | A[ m - i - 1 ] -= km * Atmp1;
70 | A[ i ] -= km * Atmp2;
71 | }
72 | if( m & 1 ) {
73 | A[ mHalf ] -= km * A[ mHalf ];
74 | }
75 | A[ m ] = km;
76 | }
77 |
78 | /* return the residual energy */
79 | return nrg;
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/os_support.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2007 Jean-Marc Valin
2 |
3 | File: os_support.h
4 | This is the (tiny) OS abstraction layer. Aside from math.h, this is the
5 | only place where system headers are allowed.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions are
9 | met:
10 |
11 | 1. Redistributions of source code must retain the above copyright notice,
12 | this list of conditions and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 | POSSIBILITY OF SUCH DAMAGE.
29 | */
30 |
31 | #ifndef OS_SUPPORT_H
32 | #define OS_SUPPORT_H
33 |
34 | #ifdef CUSTOM_SUPPORT
35 | # include "custom_support.h"
36 | #endif
37 |
38 | #include "opus_types.h"
39 | #include "opus_defines.h"
40 |
41 | #include
42 | #include
43 | #include
44 |
45 | /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */
46 | #ifndef OVERRIDE_OPUS_ALLOC
47 | static OPUS_INLINE void *opus_alloc (size_t size)
48 | {
49 | return malloc(size);
50 | }
51 | #endif
52 |
53 | /** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */
54 | #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH
55 | static OPUS_INLINE void *opus_alloc_scratch (size_t size)
56 | {
57 | /* Scratch space doesn't need to be cleared */
58 | return opus_alloc(size);
59 | }
60 | #endif
61 |
62 | /** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */
63 | #ifndef OVERRIDE_OPUS_FREE
64 | static OPUS_INLINE void opus_free (void *ptr)
65 | {
66 | free(ptr);
67 | }
68 | #endif
69 |
70 | /** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */
71 | #ifndef OVERRIDE_OPUS_COPY
72 | #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
73 | #endif
74 |
75 | /** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term
76 | provides compile-time type checking */
77 | #ifndef OVERRIDE_OPUS_MOVE
78 | #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
79 | #endif
80 |
81 | /** Set n elements of dst to zero, starting at address s */
82 | #ifndef OVERRIDE_OPUS_CLEAR
83 | #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
84 | #endif
85 |
86 | /*#ifdef __GNUC__
87 | #pragma GCC poison printf sprintf
88 | #pragma GCC poison malloc free realloc calloc
89 | #endif*/
90 |
91 | #endif /* OS_SUPPORT_H */
92 |
93 |
--------------------------------------------------------------------------------
/src/main/c/org_echocat_jogg_OggJNISupport.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | #include "org_echocat_jogg_OggJNISupport.h"
16 |
17 | JNIEXPORT void JNICALL Java_org_echocat_jogg_OggJNISupport_init
18 | (JNIEnv *env, jclass thisClass) {
19 |
20 | _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
21 | }
22 |
23 | void Java_org_echocat_jogg_OggJNISupport_throwOutOfMemoryError
24 | (JNIEnv *env) {
25 | jclass type = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
26 | (*env)->ThrowNew(env, type, NULL);
27 | }
28 |
29 | void Java_org_echocat_jogg_OggJNISupport_throwNullPointerException
30 | (JNIEnv *env) {
31 | jclass type = (*env)->FindClass(env, "java/lang/NullPointerException");
32 | (*env)->ThrowNew(env, type, NULL);
33 | }
34 |
35 | int Java_org_echocat_jogg_OggJNISupport_checkNotNull
36 | (JNIEnv *env, void *value) {
37 |
38 | int result = value != NULL;
39 | if (!result) {
40 | Java_org_echocat_jogg_OggJNISupport_throwNullPointerException(env);
41 | }
42 | return result;
43 | }
44 |
45 | jbyteArray Java_org_echocat_jogg_OggJNISupport_bufferToJavaByteArray
46 | (JNIEnv *env, long length, void *buffer) {
47 | jbyteArray result;
48 | if (length >= 0 && buffer != NULL) {
49 | result = (*env)->NewByteArray(env, length);
50 | if (result != NULL) {
51 | jbyte *nresult = (*env)->GetByteArrayElements(env, result, 0);
52 | if (nresult != NULL) {
53 | memcpy(nresult, buffer, length);
54 | (*env)->ReleaseByteArrayElements(env, result, nresult, 0);
55 | } else {
56 | Java_org_echocat_jogg_OggJNISupport_throwOutOfMemoryError(env);
57 | }
58 | } else {
59 | Java_org_echocat_jogg_OggJNISupport_throwOutOfMemoryError(env);
60 | }
61 | } else {
62 | result = NULL;
63 | }
64 | return result;
65 | }
66 |
67 | void Java_org_echocat_jogg_OggJNISupport_javaByteArrayToBuffer
68 | (JNIEnv *env, jbyteArray source, long *lengthDrain, void **bufferDrain) {
69 | if (source != NULL) {
70 | jsize length = (*env)->GetArrayLength(env, source);
71 | jbyte* nsource = (*env)->GetByteArrayElements(env, source, 0);
72 | if (nsource != NULL) {
73 | void* buffer = (void*) malloc((int) length);
74 | if (buffer != NULL) {
75 | memcpy(buffer, nsource, length);
76 | (*env)->ReleaseByteArrayElements(env, source, nsource, JNI_ABORT);
77 | if (*bufferDrain != NULL) {
78 | free(*bufferDrain);
79 | }
80 | *bufferDrain = buffer;
81 | *lengthDrain = length;
82 | } else {
83 | Java_org_echocat_jogg_OggJNISupport_throwOutOfMemoryError(env);
84 | }
85 | } else {
86 | Java_org_echocat_jogg_OggJNISupport_throwOutOfMemoryError(env);
87 | }
88 | } else {
89 | *bufferDrain = NULL;
90 | *lengthDrain = 0;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/float/LPC_inv_pred_gain_FLP.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "SigProc_FIX.h"
33 | #include "SigProc_FLP.h"
34 |
35 | #define RC_THRESHOLD 0.9999f
36 |
37 | /* compute inverse of LPC prediction gain, and */
38 | /* test if LPC coefficients are stable (all poles within unit circle) */
39 | /* this code is based on silk_a2k_FLP() */
40 | silk_float silk_LPC_inverse_pred_gain_FLP( /* O return inverse prediction gain, energy domain */
41 | const silk_float *A, /* I prediction coefficients [order] */
42 | opus_int32 order /* I prediction order */
43 | )
44 | {
45 | opus_int k, n;
46 | double invGain, rc, rc_mult1, rc_mult2;
47 | silk_float Atmp[ 2 ][ SILK_MAX_ORDER_LPC ];
48 | silk_float *Aold, *Anew;
49 |
50 | Anew = Atmp[ order & 1 ];
51 | silk_memcpy( Anew, A, order * sizeof(silk_float) );
52 |
53 | invGain = 1.0;
54 | for( k = order - 1; k > 0; k-- ) {
55 | rc = -Anew[ k ];
56 | if( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) {
57 | return 0.0f;
58 | }
59 | rc_mult1 = 1.0f - rc * rc;
60 | rc_mult2 = 1.0f / rc_mult1;
61 | invGain *= rc_mult1;
62 | /* swap pointers */
63 | Aold = Anew;
64 | Anew = Atmp[ k & 1 ];
65 | for( n = 0; n < k; n++ ) {
66 | Anew[ n ] = (silk_float)( ( Aold[ n ] - Aold[ k - n - 1 ] * rc ) * rc_mult2 );
67 | }
68 | }
69 | rc = -Anew[ 0 ];
70 | if( rc > RC_THRESHOLD || rc < -RC_THRESHOLD ) {
71 | return 0.0f;
72 | }
73 | rc_mult1 = 1.0f - rc * rc;
74 | invGain *= rc_mult1;
75 | return (silk_float)invGain;
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/java/org/echocat/jopus/OpusEncoderTest.java:
--------------------------------------------------------------------------------
1 | /*****************************************************************************************
2 | * *** BEGIN LICENSE BLOCK *****
3 | *
4 | * Version: MPL 2.0
5 | *
6 | * echocat JOpus, Copyright (c) 2014 echocat
7 | *
8 | * This Source Code Form is subject to the terms of the Mozilla Public
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | *
12 | * *** END LICENSE BLOCK *****
13 | ****************************************************************************************/
14 |
15 | package org.echocat.jopus;
16 |
17 | import org.echocat.jogg.OggSyncStateOutput;
18 | import org.junit.Rule;
19 | import org.junit.Test;
20 | import org.junit.rules.TemporaryFolder;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | import java.io.*;
25 | import java.util.Arrays;
26 |
27 | import static org.hamcrest.CoreMatchers.is;
28 | import static org.junit.Assert.assertThat;
29 |
30 | /**
31 | * Created by christian.rijke on 14.08.2014.
32 | */
33 | public class OpusEncoderTest {
34 |
35 | Logger LOG = LoggerFactory.getLogger(OpusEncoderTest.class);
36 |
37 | @Rule
38 | public TemporaryFolder tempFolder = new TemporaryFolder();
39 |
40 | @Test
41 | public void encodeMono() throws IOException {
42 | final OpusComments commments = new OpusComments(
43 | "ARTIST", "J.S. Bach",
44 | "GENRE", "Classical",
45 | "TRACKNUMBER", "1"
46 | );
47 | File result = encode("bach_48k_mono.wav", commments, 1, SamplingRate.kHz48);
48 | assertThat(result.length(), is(69524L));
49 | }
50 |
51 | @Test
52 | public void encodeStereo() throws IOException {
53 | final OpusComments commments = new OpusComments(
54 | "ARTIST", "J.S. Bach",
55 | "GENRE", "Classical",
56 | "TRACKNUMBER", "1"
57 | );
58 | File result = encode("bach_48k_stereo.wav", commments, 2, SamplingRate.kHz48);
59 | assertThat(result.length(), is(136707L));
60 | }
61 |
62 | public File encode(String source, OpusComments opusComments, int channels, SamplingRate samplingRate) throws IOException {
63 | LOG.info("encoding {}...", source);
64 |
65 | final int numberOfFrames = 2880;
66 |
67 | File tempFile = tempFolder.newFile(source.substring(0, source.length() - 4) + ".opus");
68 |
69 | try (final InputStream is = getClass().getResourceAsStream(source);
70 | final DataInputStream in = new DataInputStream(is);
71 | final OutputStream out = new FileOutputStream(tempFile);
72 | final OggSyncStateOutput sso = new OggSyncStateOutput(out);
73 | final OpusEncoder oe = new OpusEncoder(sso)) {
74 |
75 | oe.setComments(opusComments);
76 | oe.setNumberOfChannels(channels);
77 | oe.setSamplingRate(samplingRate);
78 |
79 | final short[] pcm = new short[numberOfFrames * oe.getNumberOfChannels()];
80 | final byte[] buffer = new byte[pcm.length * 2];
81 | int numberOfBytes;
82 | while ((numberOfBytes = in.read(buffer)) != -1) {
83 | int numberOfShorts = numberOfBytes / 2;
84 | for (int i = 0; i < numberOfShorts; i++) {
85 | pcm[i] = (short) ((buffer[i * 2] & 0xff) | (buffer[i * 2 + 1] << 8));
86 | }
87 | oe.write(numberOfFrames, Arrays.copyOfRange(pcm, 0, numberOfShorts));
88 | }
89 |
90 | }
91 | LOG.info("encoding finished");
92 | return tempFile;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/stereo_quant_pred.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /* Quantize mid/side predictors */
35 | void silk_stereo_quant_pred(
36 | opus_int32 pred_Q13[], /* I/O Predictors (out: quantized) */
37 | opus_int8 ix[ 2 ][ 3 ] /* O Quantization indices */
38 | )
39 | {
40 | opus_int i, j, n;
41 | opus_int32 low_Q13, step_Q13, lvl_Q13, err_min_Q13, err_Q13, quant_pred_Q13 = 0;
42 |
43 | /* Quantize */
44 | for( n = 0; n < 2; n++ ) {
45 | /* Brute-force search over quantization levels */
46 | err_min_Q13 = silk_int32_MAX;
47 | for( i = 0; i < STEREO_QUANT_TAB_SIZE - 1; i++ ) {
48 | low_Q13 = silk_stereo_pred_quant_Q13[ i ];
49 | step_Q13 = silk_SMULWB( silk_stereo_pred_quant_Q13[ i + 1 ] - low_Q13,
50 | SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) );
51 | for( j = 0; j < STEREO_QUANT_SUB_STEPS; j++ ) {
52 | lvl_Q13 = silk_SMLABB( low_Q13, step_Q13, 2 * j + 1 );
53 | err_Q13 = silk_abs( pred_Q13[ n ] - lvl_Q13 );
54 | if( err_Q13 < err_min_Q13 ) {
55 | err_min_Q13 = err_Q13;
56 | quant_pred_Q13 = lvl_Q13;
57 | ix[ n ][ 0 ] = i;
58 | ix[ n ][ 1 ] = j;
59 | } else {
60 | /* Error increasing, so we're past the optimum */
61 | goto done;
62 | }
63 | }
64 | }
65 | done:
66 | ix[ n ][ 2 ] = silk_DIV32_16( ix[ n ][ 0 ], 3 );
67 | ix[ n ][ 0 ] -= ix[ n ][ 2 ] * 3;
68 | pred_Q13[ n ] = quant_pred_Q13;
69 | }
70 |
71 | /* Subtract second from first predictor (helps when actually applying these) */
72 | pred_Q13[ 0 ] -= pred_Q13[ 1 ];
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/stereo_decode_pred.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /* Decode mid/side predictors */
35 | void silk_stereo_decode_pred(
36 | ec_dec *psRangeDec, /* I/O Compressor data structure */
37 | opus_int32 pred_Q13[] /* O Predictors */
38 | )
39 | {
40 | opus_int n, ix[ 2 ][ 3 ];
41 | opus_int32 low_Q13, step_Q13;
42 |
43 | /* Entropy decoding */
44 | n = ec_dec_icdf( psRangeDec, silk_stereo_pred_joint_iCDF, 8 );
45 | ix[ 0 ][ 2 ] = silk_DIV32_16( n, 5 );
46 | ix[ 1 ][ 2 ] = n - 5 * ix[ 0 ][ 2 ];
47 | for( n = 0; n < 2; n++ ) {
48 | ix[ n ][ 0 ] = ec_dec_icdf( psRangeDec, silk_uniform3_iCDF, 8 );
49 | ix[ n ][ 1 ] = ec_dec_icdf( psRangeDec, silk_uniform5_iCDF, 8 );
50 | }
51 |
52 | /* Dequantize */
53 | for( n = 0; n < 2; n++ ) {
54 | ix[ n ][ 0 ] += 3 * ix[ n ][ 2 ];
55 | low_Q13 = silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] ];
56 | step_Q13 = silk_SMULWB( silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] + 1 ] - low_Q13,
57 | SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) );
58 | pred_Q13[ n ] = silk_SMLABB( low_Q13, step_Q13, 2 * ix[ n ][ 1 ] + 1 );
59 | }
60 |
61 | /* Subtract second from first predictor (helps when actually applying these) */
62 | pred_Q13[ 0 ] -= pred_Q13[ 1 ];
63 | }
64 |
65 | /* Decode mid-only flag */
66 | void silk_stereo_decode_mid_only(
67 | ec_dec *psRangeDec, /* I/O Compressor data structure */
68 | opus_int *decode_only_mid /* O Flag that only mid channel has been coded */
69 | )
70 | {
71 | /* Decode flag that only mid channel is coded */
72 | *decode_only_mid = ec_dec_icdf( psRangeDec, silk_stereo_only_code_mid_iCDF, 8 );
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/c/opus/celt/entcode.c:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2001-2011 Timothy B. Terriberry
2 | */
3 | /*
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions
6 | are met:
7 |
8 | - Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | - Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "entcode.h"
33 | #include "arch.h"
34 |
35 | #if !defined(EC_CLZ)
36 | /*This is a fallback for systems where we don't know how to access
37 | a BSR or CLZ instruction (see ecintrin.h).
38 | If you are optimizing Opus on a new platform and it has a native CLZ or
39 | BZR (e.g. cell, MIPS, x86, etc) then making it available to Opus will be
40 | an easy performance win.*/
41 | int ec_ilog(opus_uint32 _v){
42 | /*On a Pentium M, this branchless version tested as the fastest on
43 | 1,000,000,000 random 32-bit integers, edging out a similar version with
44 | branches, and a 256-entry LUT version.*/
45 | int ret;
46 | int m;
47 | ret=!!_v;
48 | m=!!(_v&0xFFFF0000)<<4;
49 | _v>>=m;
50 | ret|=m;
51 | m=!!(_v&0xFF00)<<3;
52 | _v>>=m;
53 | ret|=m;
54 | m=!!(_v&0xF0)<<2;
55 | _v>>=m;
56 | ret|=m;
57 | m=!!(_v&0xC)<<1;
58 | _v>>=m;
59 | ret|=m;
60 | ret+=!!(_v&0x2);
61 | return ret;
62 | }
63 | #endif
64 |
65 | opus_uint32 ec_tell_frac(ec_ctx *_this){
66 | opus_uint32 nbits;
67 | opus_uint32 r;
68 | int l;
69 | int i;
70 | /*To handle the non-integral number of bits still left in the encoder/decoder
71 | state, we compute the worst-case number of bits of val that must be
72 | encoded to ensure that the value is inside the range for any possible
73 | subsequent bits.
74 | The computation here is independent of val itself (the decoder does not
75 | even track that value), even though the real number of bits used after
76 | ec_enc_done() may be 1 smaller if rng is a power of two and the
77 | corresponding trailing bits of val are all zeros.
78 | If we did try to track that special case, then coding a value with a
79 | probability of 1/(1<nbits_total<rng);
84 | r=_this->rng>>(l-16);
85 | for(i=BITRES;i-->0;){
86 | int b;
87 | r=r*r>>15;
88 | b=(int)(r>>16);
89 | l=l<<1|b;
90 | r>>=b;
91 | }
92 | return nbits-l;
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/typedef.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifndef SILK_TYPEDEF_H
29 | #define SILK_TYPEDEF_H
30 |
31 | #include "opus_types.h"
32 | #include "opus_defines.h"
33 |
34 | #ifndef FIXED_POINT
35 | # include
36 | # define silk_float float
37 | # define silk_float_MAX FLT_MAX
38 | #endif
39 |
40 | #define silk_int64_MAX ((opus_int64)0x7FFFFFFFFFFFFFFFLL) /* 2^63 - 1 */
41 | #define silk_int64_MIN ((opus_int64)0x8000000000000000LL) /* -2^63 */
42 | #define silk_int32_MAX 0x7FFFFFFF /* 2^31 - 1 = 2147483647 */
43 | #define silk_int32_MIN ((opus_int32)0x80000000) /* -2^31 = -2147483648 */
44 | #define silk_int16_MAX 0x7FFF /* 2^15 - 1 = 32767 */
45 | #define silk_int16_MIN ((opus_int16)0x8000) /* -2^15 = -32768 */
46 | #define silk_int8_MAX 0x7F /* 2^7 - 1 = 127 */
47 | #define silk_int8_MIN ((opus_int8)0x80) /* -2^7 = -128 */
48 | #define silk_uint8_MAX 0xFF /* 2^8 - 1 = 255 */
49 |
50 | #define silk_TRUE 1
51 | #define silk_FALSE 0
52 |
53 | /* assertions */
54 | #if (defined _WIN32 && !defined _WINCE && !defined(__GNUC__) && !defined(NO_ASSERTS))
55 | # ifndef silk_assert
56 | # include /* ASSERTE() */
57 | # define silk_assert(COND) _ASSERTE(COND)
58 | # endif
59 | #else
60 | # ifdef ENABLE_ASSERTIONS
61 | # include
62 | # include
63 | #define silk_fatal(str) _silk_fatal(str, __FILE__, __LINE__);
64 | #ifdef __GNUC__
65 | __attribute__((noreturn))
66 | #endif
67 | static OPUS_INLINE void _silk_fatal(const char *str, const char *file, int line)
68 | {
69 | fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
70 | abort();
71 | }
72 | # define silk_assert(COND) {if (!(COND)) {silk_fatal("assertion failed: " #COND);}}
73 | # else
74 | # define silk_assert(COND)
75 | # endif
76 | #endif
77 |
78 | #endif /* SILK_TYPEDEF_H */
79 |
--------------------------------------------------------------------------------
/src/main/c/opus/silk/NLSF_VQ.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 | - Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | - Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 | names of specific contributors, may be used to endorse or promote
13 | products derived from this software without specific prior written
14 | permission.
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | ***********************************************************************/
27 |
28 | #ifdef HAVE_CONFIG_H
29 | #include "config.h"
30 | #endif
31 |
32 | #include "main.h"
33 |
34 | /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
35 | void silk_NLSF_VQ(
36 | opus_int32 err_Q26[], /* O Quantization errors [K] */
37 | const opus_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */
38 | const opus_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */
39 | const opus_int K, /* I Number of codebook vectors */
40 | const opus_int LPC_order /* I Number of LPCs */
41 | )
42 | {
43 | opus_int i, m;
44 | opus_int32 diff_Q15, sum_error_Q30, sum_error_Q26;
45 |
46 | silk_assert( LPC_order <= 16 );
47 | silk_assert( ( LPC_order & 1 ) == 0 );
48 |
49 | /* Loop over codebook */
50 | for( i = 0; i < K; i++ ) {
51 | sum_error_Q26 = 0;
52 | for( m = 0; m < LPC_order; m += 2 ) {
53 | /* Compute weighted squared quantization error for index m */
54 | diff_Q15 = silk_SUB_LSHIFT32( in_Q15[ m ], (opus_int32)*pCB_Q8++, 7 ); /* range: [ -32767 : 32767 ]*/
55 | sum_error_Q30 = silk_SMULBB( diff_Q15, diff_Q15 );
56 |
57 | /* Compute weighted squared quantization error for index m + 1 */
58 | diff_Q15 = silk_SUB_LSHIFT32( in_Q15[m + 1], (opus_int32)*pCB_Q8++, 7 ); /* range: [ -32767 : 32767 ]*/
59 | sum_error_Q30 = silk_SMLABB( sum_error_Q30, diff_Q15, diff_Q15 );
60 |
61 | sum_error_Q26 = silk_ADD_RSHIFT32( sum_error_Q26, sum_error_Q30, 4 );
62 |
63 | silk_assert( sum_error_Q26 >= 0 );
64 | silk_assert( sum_error_Q30 >= 0 );
65 | }
66 | err_Q26[ i ] = sum_error_Q26;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------